Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
sudo apt-get install -y libxml2-dev libusb-1.0-0-dev

- name: Build
run: make
run: make all

- name: Run tests
run: make tests
Expand All @@ -35,7 +35,7 @@ jobs:
mkdir dist
cp `pkg-config --variable=libdir libusb-1.0`/libusb-1.0.so.0 dist
chmod 0644 dist/*
cp qdl dist
cp ./build/release/bin/qdl dist
patchelf --set-rpath '$ORIGIN' dist/qdl

- name: Upload artifact
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
brew install libxml2

- name: Build
run: make
run: make all

- name: Run tests
run: make tests
Expand All @@ -75,7 +75,7 @@ jobs:
cp `pkg-config --variable=libdir libusb-1.0`/libusb-1.0.0.dylib dist
cp `pkg-config --variable=libdir liblzma`/liblzma.5.dylib dist
chmod 0644 dist/*
cp qdl dist
cp ./build/release/bin/qdl dist

if uname -a | grep -q arm64; then
LIBUSB_DIR=/opt/homebrew/opt/libusb/lib
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
mingw-w64-x86_64-libusb

- name: Build
run: make
run: make all
shell: msys2 {0}

- name: Run tests
Expand All @@ -145,7 +145,7 @@ jobs:
Copy-Item (Join-Path $BIN_DIR "liblzma-5.dll") $DistDir
Copy-Item (Join-Path $BIN_DIR "libiconv-2.dll") $DistDir

Copy-Item "qdl.exe" $DistDir
Copy-Item "./build/release/bin/qdl.exe" $DistDir

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/build/
/tests/data/*.elf
/tests/data/*.bin
/tests/data/*.img
*.o
qdl
qdl-ramdump
Expand All @@ -7,5 +11,5 @@ compile_commands.json
.cache
.version.h
version.h
scripts
.scripts
.checkpatch-camelcase.git.
61 changes: 41 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
QDL := qdl
RAMDUMP := qdl-ramdump
VERSION := $(or $(VERSION), $(shell git describe --dirty --always --tags 2>/dev/null), "unknown-version")

CFLAGS += -O2 -Wall -g `pkg-config --cflags libxml-2.0 libusb-1.0`
CFLAGS += -Wall `pkg-config --cflags libxml-2.0 libusb-1.0`
LDFLAGS += `pkg-config --libs libxml-2.0 libusb-1.0`
ifeq ($(OS),Windows_NT)
LDFLAGS += -lws2_32
endif
prefix := /usr/local

# Default build type
BUILD_TYPE ?= debug
BUILD_DIR = build/$(BUILD_TYPE)
OBJ_DIR = $(BUILD_DIR)/obj
BIN_DIR = $(BUILD_DIR)/bin
GEN_DIR = $(BUILD_DIR)/gen

QDL := qdl
QDL_SRCS := firehose.c io.c qdl.c sahara.c util.c patch.c program.c read.c sha2.c sim.c ufs.c usb.c ux.c oscompat.c vip.c sparse.c gpt.c
QDL_OBJS := $(QDL_SRCS:.c=.o)
QDL_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(QDL_SRCS:.c=.o)))

RAMDUMP := qdl-ramdump
RAMDUMP_SRCS := ramdump.c sahara.c io.c sim.c usb.c util.c ux.c oscompat.c
RAMDUMP_OBJS := $(RAMDUMP_SRCS:.c=.o)
RAMDUMP_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(RAMDUMP_SRCS:.c=.o)))

KS_OUT := ks
KS_SRCS := ks.c sahara.c util.c ux.c oscompat.c
KS_OBJS := $(KS_SRCS:.c=.o)
KS_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(KS_SRCS:.c=.o)))

CHECKPATCH_SOURCES := $(shell find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.sh" \) ! -name "sha2.c" ! -name "sha2.h" ! -name "*version.h" ! -name "list.h")
CHECKPATCH_ROOT := https://raw.githubusercontent.com/torvalds/linux/v6.15/scripts
Expand All @@ -26,41 +33,55 @@ CHECKPATCH_SP_URL := $(CHECKPATCH_ROOT)/spelling.txt
CHECKPATCH := ./.scripts/checkpatch.pl
CHECKPATCH_SP := ./.scripts/spelling.txt

default: $(QDL) $(RAMDUMP) $(KS_OUT)
default: debug
all: debug release

release:
$(MAKE) BUILD_TYPE=release CFLAGS='$(CFLAGS) -O2 -Ibuild/release/gen' _all_internal

debug:
$(MAKE) BUILD_TYPE=debug CFLAGS='$(CFLAGS) -O0 -g -Ibuild/debug/gen' _all_internal

# Inner target that actually builds things with the chosen BUILD_TYPE
_all_internal: dirs $(BIN_DIR)/$(QDL) $(BIN_DIR)/$(RAMDUMP) $(BIN_DIR)/$(KS_OUT)

dirs:
@mkdir -p $(OBJ_DIR) $(BIN_DIR) $(GEN_DIR)

$(OBJ_DIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

$(QDL): $(QDL_OBJS)
$(BIN_DIR)/$(QDL): $(QDL_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)

$(RAMDUMP): $(RAMDUMP_OBJS)
$(BIN_DIR)/$(RAMDUMP): $(RAMDUMP_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)

$(KS_OUT): $(KS_OBJS)
$(BIN_DIR)/$(KS_OUT): $(KS_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)

compile_commands.json: $(QDL_SRCS) $(KS_SRCS)
@echo -n $^ | jq -snR "[inputs|split(\" \")[]|{directory:\"$(PWD)\", command: \"$(CC) $(CFLAGS) -c \(.)\", file:.}]" > $@

version.h::
@echo "#define VERSION \"$(VERSION)\"" > .version.h
@cmp -s .version.h version.h || cp .version.h version.h
$(GEN_DIR)/version.h:
@echo "#define VERSION \"$(VERSION)\"" > $(GEN_DIR)/.version.h
@cmp -s $(GEN_DIR)/.version.h $(GEN_DIR)/version.h || cp $(GEN_DIR)/.version.h $(GEN_DIR)/version.h

util.o: version.h
$(OBJ_DIR)/util.o: $(GEN_DIR)/version.h

clean:
rm -f $(QDL) $(QDL_OBJS)
rm -f $(RAMDUMP) $(RAMDUMP_OBJS)
rm -f $(KS_OUT) $(KS_OBJS)
rm -rf build
rm -f compile_commands.json
rm -f version.h .version.h
rm -f $(CHECKPATCH)
rm -f $(CHECKPATCH_SP)
if [ -d .scripts ]; then rmdir .scripts; fi

install: $(QDL) $(RAMDUMP) $(KS_OUT)
install: release
install -d $(DESTDIR)$(prefix)/bin
install -m 755 $^ $(DESTDIR)$(prefix)/bin
install -m 755 $(BIN_DIR)/$(QDL) $(BIN_DIR)/$(RAMDUMP) $(BIN_DIR)/$(KS_OUT) $(DESTDIR)$(prefix)/bin

tests: default
tests: debug
tests:
@./tests/run_tests.sh

Expand Down
3 changes: 2 additions & 1 deletion tests/test_vip_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
FLAT_BUILD=${SCRIPT_PATH}/data

REP_ROOT=${SCRIPT_PATH}/..
QDL_PATH=${REP_ROOT}/build/debug/bin
VIP_PATH=${FLAT_BUILD}/vip
EXPECTED_DIGEST="a05e1124edbe34dc504a327544fb66572591353dc3fa25e6e7eafbe4803e63e0"
VIP_TABLE_FILE=${VIP_PATH}/DigestsToSign.bin

mkdir -p $VIP_PATH

cd $FLAT_BUILD
${REP_ROOT}/qdl --dry-run --create-digests=${VIP_PATH} \
${QDL_PATH}/qdl --dry-run --create-digests=${VIP_PATH} \
prog_firehose_ddr.elf rawprogram*.xml patch*.xml

if command -v sha256sum >/dev/null 2>&1; then
Expand Down
Loading