Files
qdl/Makefile

93 lines
2.9 KiB
Makefile
Raw Permalink Normal View History

QDL := qdl
RAMDUMP := qdl-ramdump
VERSION := $(or $(VERSION), $(shell git describe --dirty --always --tags 2>/dev/null), "unknown-version")
PKG_CONFIG ?= pkg-config
CFLAGS += -O2 -Wall -g `$(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
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)
RAMDUMP_SRCS := ramdump.c sahara.c io.c sim.c usb.c util.c ux.c oscompat.c
RAMDUMP_OBJS := $(RAMDUMP_SRCS:.c=.o)
Add ks utility ks (short for kickstart) is a utility which uses sahara to load images from the host to a device. This is intended for "flashless boot" devices like the Qualcomm Cloud AI 100 which rely on obtaining the runtime firmware from the host instead of storing it on device. While ks uses sahara, like qdl, it is different enough that a separate utility is justified. ks does not need USB support, instead opting for simple open()/read()/write() operations. ks does not need firehose. The set of program arguments that ks needs is vastly different than the set that qdl supports. This initial implementation of ks defines two arguments. Both are required, but the image specifier argument can be specified more than one. A sample invocation - ks -p /dev/mhi0_QAIC_SAHARA -s 1:/opt/qti-aic/firmware/fw1.bin -s 2:/opt/qti-aic/firmware/fw2.bin In this example, ks is instructed to use the /dev/mhi0_QAIC_SAHARA device node file as the "port" which the device is using for the sahara protocol. /opt/qti-aic/firmware/fw1.bin is mapped to id 1, and /opt/qti-aic/firmware/fw2.bin is mapped to id 2. If the device requests image id 1, ks will attempt to open and read /opt/qti-aic/firmware/fw1.bin to send to the device. Note that /opt/qti-aic/firmware/fw1.bin does not need to exist on the filesystem. If ks cannot access the file (perhaps because it does not exist), then the device will determine the next action. This is useful for setting up a single command in a udev rule that can handle multiple configurations, such as an optional DDR training process. Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
2023-01-24 17:00:10 +00:00
KS_OUT := ks
KS_SRCS := ks.c sahara.c util.c ux.c oscompat.c
Add ks utility ks (short for kickstart) is a utility which uses sahara to load images from the host to a device. This is intended for "flashless boot" devices like the Qualcomm Cloud AI 100 which rely on obtaining the runtime firmware from the host instead of storing it on device. While ks uses sahara, like qdl, it is different enough that a separate utility is justified. ks does not need USB support, instead opting for simple open()/read()/write() operations. ks does not need firehose. The set of program arguments that ks needs is vastly different than the set that qdl supports. This initial implementation of ks defines two arguments. Both are required, but the image specifier argument can be specified more than one. A sample invocation - ks -p /dev/mhi0_QAIC_SAHARA -s 1:/opt/qti-aic/firmware/fw1.bin -s 2:/opt/qti-aic/firmware/fw2.bin In this example, ks is instructed to use the /dev/mhi0_QAIC_SAHARA device node file as the "port" which the device is using for the sahara protocol. /opt/qti-aic/firmware/fw1.bin is mapped to id 1, and /opt/qti-aic/firmware/fw2.bin is mapped to id 2. If the device requests image id 1, ks will attempt to open and read /opt/qti-aic/firmware/fw1.bin to send to the device. Note that /opt/qti-aic/firmware/fw1.bin does not need to exist on the filesystem. If ks cannot access the file (perhaps because it does not exist), then the device will determine the next action. This is useful for setting up a single command in a udev rule that can handle multiple configurations, such as an optional DDR training process. Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
2023-01-24 17:00:10 +00:00
KS_OBJS := $(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
CHECKPATCH_URL := $(CHECKPATCH_ROOT)/checkpatch.pl
CHECKPATCH_SP_URL := $(CHECKPATCH_ROOT)/spelling.txt
CHECKPATCH := ./.scripts/checkpatch.pl
CHECKPATCH_SP := ./.scripts/spelling.txt
MANPAGES := ks.1 qdl-ramdump.1 qdl.1
default: $(QDL) $(RAMDUMP) $(KS_OUT)
Add ks utility ks (short for kickstart) is a utility which uses sahara to load images from the host to a device. This is intended for "flashless boot" devices like the Qualcomm Cloud AI 100 which rely on obtaining the runtime firmware from the host instead of storing it on device. While ks uses sahara, like qdl, it is different enough that a separate utility is justified. ks does not need USB support, instead opting for simple open()/read()/write() operations. ks does not need firehose. The set of program arguments that ks needs is vastly different than the set that qdl supports. This initial implementation of ks defines two arguments. Both are required, but the image specifier argument can be specified more than one. A sample invocation - ks -p /dev/mhi0_QAIC_SAHARA -s 1:/opt/qti-aic/firmware/fw1.bin -s 2:/opt/qti-aic/firmware/fw2.bin In this example, ks is instructed to use the /dev/mhi0_QAIC_SAHARA device node file as the "port" which the device is using for the sahara protocol. /opt/qti-aic/firmware/fw1.bin is mapped to id 1, and /opt/qti-aic/firmware/fw2.bin is mapped to id 2. If the device requests image id 1, ks will attempt to open and read /opt/qti-aic/firmware/fw1.bin to send to the device. Note that /opt/qti-aic/firmware/fw1.bin does not need to exist on the filesystem. If ks cannot access the file (perhaps because it does not exist), then the device will determine the next action. This is useful for setting up a single command in a udev rule that can handle multiple configurations, such as an optional DDR training process. Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
2023-01-24 17:00:10 +00:00
$(QDL): $(QDL_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
$(RAMDUMP): $(RAMDUMP_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
Add ks utility ks (short for kickstart) is a utility which uses sahara to load images from the host to a device. This is intended for "flashless boot" devices like the Qualcomm Cloud AI 100 which rely on obtaining the runtime firmware from the host instead of storing it on device. While ks uses sahara, like qdl, it is different enough that a separate utility is justified. ks does not need USB support, instead opting for simple open()/read()/write() operations. ks does not need firehose. The set of program arguments that ks needs is vastly different than the set that qdl supports. This initial implementation of ks defines two arguments. Both are required, but the image specifier argument can be specified more than one. A sample invocation - ks -p /dev/mhi0_QAIC_SAHARA -s 1:/opt/qti-aic/firmware/fw1.bin -s 2:/opt/qti-aic/firmware/fw2.bin In this example, ks is instructed to use the /dev/mhi0_QAIC_SAHARA device node file as the "port" which the device is using for the sahara protocol. /opt/qti-aic/firmware/fw1.bin is mapped to id 1, and /opt/qti-aic/firmware/fw2.bin is mapped to id 2. If the device requests image id 1, ks will attempt to open and read /opt/qti-aic/firmware/fw1.bin to send to the device. Note that /opt/qti-aic/firmware/fw1.bin does not need to exist on the filesystem. If ks cannot access the file (perhaps because it does not exist), then the device will determine the next action. This is useful for setting up a single command in a udev rule that can handle multiple configurations, such as an optional DDR training process. Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
2023-01-24 17:00:10 +00:00
$(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:.}]" > $@
manpages: $(KS_OUT) $(RAMDUMP) $(QDL)
help2man -N -n "KS" -o ks.1 ./ks
help2man -N -n "Qualcomm Download" -o qdl.1 ./qdl
help2man -N -n "Qualcomm Download Ramdump" -o qdl-ramdump.1 ./qdl-ramdump
version.h::
@echo "#define VERSION \"$(VERSION)\"" > .version.h
@cmp -s .version.h version.h || cp .version.h version.h
util.o: version.h
clean:
rm -f $(QDL) $(QDL_OBJS)
rm -f $(RAMDUMP) $(RAMDUMP_OBJS)
Add ks utility ks (short for kickstart) is a utility which uses sahara to load images from the host to a device. This is intended for "flashless boot" devices like the Qualcomm Cloud AI 100 which rely on obtaining the runtime firmware from the host instead of storing it on device. While ks uses sahara, like qdl, it is different enough that a separate utility is justified. ks does not need USB support, instead opting for simple open()/read()/write() operations. ks does not need firehose. The set of program arguments that ks needs is vastly different than the set that qdl supports. This initial implementation of ks defines two arguments. Both are required, but the image specifier argument can be specified more than one. A sample invocation - ks -p /dev/mhi0_QAIC_SAHARA -s 1:/opt/qti-aic/firmware/fw1.bin -s 2:/opt/qti-aic/firmware/fw2.bin In this example, ks is instructed to use the /dev/mhi0_QAIC_SAHARA device node file as the "port" which the device is using for the sahara protocol. /opt/qti-aic/firmware/fw1.bin is mapped to id 1, and /opt/qti-aic/firmware/fw2.bin is mapped to id 2. If the device requests image id 1, ks will attempt to open and read /opt/qti-aic/firmware/fw1.bin to send to the device. Note that /opt/qti-aic/firmware/fw1.bin does not need to exist on the filesystem. If ks cannot access the file (perhaps because it does not exist), then the device will determine the next action. This is useful for setting up a single command in a udev rule that can handle multiple configurations, such as an optional DDR training process. Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
2023-01-24 17:00:10 +00:00
rm -f $(KS_OUT) $(KS_OBJS)
rm -f $(MANPAGES)
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)
2023-02-21 04:55:09 +00:00
install -d $(DESTDIR)$(prefix)/bin
install -m 755 $^ $(DESTDIR)$(prefix)/bin
tests: default
tests:
@./tests/run_tests.sh
# Target to download checkpatch.pl if not present
$(CHECKPATCH):
@echo "Downloading checkpatch.pl..."
@mkdir -p $(dir $(CHECKPATCH))
@curl -sSfL $(CHECKPATCH_URL) -o $(CHECKPATCH)
@curl -sSfL $(CHECKPATCH_SP_URL) -o $(CHECKPATCH_SP)
@chmod +x $(CHECKPATCH)
check: $(CHECKPATCH)
@echo "Running checkpatch on source files (excluding sha2.c and sha2.h)..."
@for file in $(CHECKPATCH_SOURCES); do \
perl $(CHECKPATCH) --no-tree -f $$file || exit 1; \
done
check-cached: $(CHECKPATCH)
@echo "Running checkpatch on staged changes..."
@git diff --cached -- . | perl $(CHECKPATCH) --no-tree -