use make for creating dfu

This commit is contained in:
David Holdeman 2024-02-01 07:33:16 -06:00 committed by rusefillc
parent aff0592cc5
commit 66d3768c69
5 changed files with 56 additions and 59 deletions

View File

@ -385,6 +385,8 @@ include $(RULESFILE)
# Enable precompiled header
include rusefi_pch.mk
include bundle.mk
POST_MAKE_ALL_RULE_HOOK: $(BUILDDIR)/$(PROJECT).elf
@java -jar ../java_tools/gcc_map_reader.jar $(BUILDDIR)/$(PROJECT).map | grep Total || echo Unable to run gcc_map_reader
@$(TRGT)objdump -h $(BUILDDIR)/$(PROJECT).elf | grep -w ram4

42
firmware/bundle.mk Normal file
View File

@ -0,0 +1,42 @@
ifneq (,$(findstring NT,$(UNAME_S)))
H2D = ../misc/encedo_hex2dfu/hex2dfu.exe
else
H2D = ../misc/encedo_hex2dfu/hex2dfu.bin
endif
DFUS = deliver/$(PROJECT).dfu
BUNDLEFILES = \
$(DFUS) \
$(OUTS) \
$(BOUTS)
ifeq ($(USE_OPENBLT),yes)
BOOTLOADER_HEX = bootloader/blbuild/openblt_$(PROJECT_BOARD).hex
BOUTS = deliver/openblt.bin
else
OUTS = deliver/$(PROJECT).bin deliver/$(PROJECT).hex
ifeq ($(INCLUDE_ELF),yes)
OUTS += deliver/$(PROJECT).elf deliver/$(PROJECT).map deliver/$(PROJECT).list
endif
endif
$(BUILDDIR)/$(PROJECT).map: $(BUILDDIR)/$(PROJECT).elf
$(OUTS): deliver/%: $(BUILDDIR)/%
cp $< $@
$(BOUTS): deliver/openblt%: bootloader/blbuild/openblt_$(PROJECT_BOARD)%
cp $< $@
$(DFUS): deliver/%.dfu: $(BUILDDIR)/%.hex $(BOOTLOADER_HEX) deliver
ifeq ($(USE_OPENBLT),yes)
$(H2D) -i $(BOOTLOADER_HEX) -i $< -C 0x1C -o $@ -b deliver/$(PROJECT).bin
else
$(H2D) -i $< -C 0x1C -o $@
endif
deliver:
mkdir -p deliver
bundle: $(BUNDLEFILES) all

View File

@ -19,8 +19,19 @@ fi
echo "Entering $SCRIPT_NAME with board [$PROJECT_BOARD] and CPU [$PROJECT_CPU] at [$BOARD_DIR]"
mkdir -p .dep
if [ "$USE_OPENBLT" = "yes" ]; then
# TODO: why is this rm necessary?
# TODO: probably make/gcc do not like two separate projects (primary firmware and bootloader) co-existing in same folder structure?
cd bootloader
make -j$(nproc)
cd ..
[ -e bootloader/blbuild/openblt_$PROJECT_BOARD.hex ] || { echo "FAILED to compile OpenBLT by $SCRIPT_NAME with $PROJECT_BOARD"; exit 1; }
fi
rm -f pch/pch.h.gch/*
# todo: start using env variable for number of threads or for '-r'
make -j$(nproc) -r
make bundle -j$(nproc) -r
[ -e build/rusefi.hex ] || { echo "FAILED to compile by $SCRIPT_NAME with $PROJECT_BOARD $DEBUG_LEVEL_OPT and $EXTRA_PARAMS"; exit 1; }
@ -29,42 +40,6 @@ if [ ! -z $POST_BUILD_SCRIPT ]; then
source $POST_BUILD_SCRIPT
fi
if [ "$USE_OPENBLT" = "yes" ]; then
# TODO: why is this rm necessary?
# TODO: probably make/gcc do not like two separate projects (primary firmware and bootloader) co-existing in same folder structure?
rm -f pch/pch.h.gch/*
cd bootloader
make -j12
cd ..
[ -e bootloader/blbuild/openblt_$PROJECT_BOARD.hex ] || { echo "FAILED to compile OpenBLT by $SCRIPT_NAME with $PROJECT_BOARD"; exit 1; }
fi
. config/boards/common_script_hex2dfu_init.inc
if [ "$USE_OPENBLT" = "yes" ]; then
# this image is suitable for update through bootloader only
# do not deliver update images in any format that can confuse users
#cp build/rusefi.bin deliver/rusefi_update.bin
#cp build/rusefi.dfu deliver/rusefi_update.dfu
#cp build/rusefi.hex deliver/rusefi_update.hex
# bootloader and composite image
# echo "$SCRIPT_NAME: invoking hex2dfu for OpenBLT"
# $HEX2DFU -i bootloader/blbuild/openblt_$PROJECT_BOARD.hex -o bootloader/blbuild/openblt_$PROJECT_BOARD.dfu
# todo: no need for complex `PROJECT = openblt_$(PROJECT_BOARD)` and complex binary name if we copy into static file name anyway!
# do we need all these formats?
cp bootloader/blbuild/openblt_$PROJECT_BOARD.bin deliver/openblt.bin
# cp bootloader/blbuild/openblt_$PROJECT_BOARD.dfu deliver/openblt.dfu
#cp bootloader/blbuild/openblt_$PROJECT_BOARD.hex deliver/openblt.hex
echo "$SCRIPT_NAME: invoking hex2dfu for composite rusEFI+OpenBLT image"
$HEX2DFU -i bootloader/blbuild/openblt_$PROJECT_BOARD.hex -i build/rusefi.hex $CONTROL_SUM_OPTION -o deliver/rusefi.dfu -b deliver/rusefi.bin
else
. config/boards/common_script_post_build_without_blt.inc
fi
echo "$SCRIPT_NAME: build folder content:"
ls -l build

View File

@ -1,11 +0,0 @@
if uname | grep "NT"; then
HEX2DFU=../misc/encedo_hex2dfu/hex2dfu.exe
else
HEX2DFU=../misc/encedo_hex2dfu/hex2dfu.bin
fi
chmod u+x $HEX2DFU
CONTROL_SUM_OPTION="-C 0x1C"
mkdir -p deliver
rm -f deliver/*

View File

@ -1,11 +0,0 @@
echo "$SCRIPT_NAME: invoking hex2dfu for no-blt rusEFI image"
$HEX2DFU -i build/rusefi.hex $CONTROL_SUM_OPTION -o build/rusefi.dfu
# standalone images (for use with no bootloader)
cp build/rusefi.bin deliver/
cp build/rusefi.dfu deliver/
cp build/rusefi.hex deliver/
if [ "$INCLUDE_ELF" = "yes" ]; then
# we definitely need .elf .map .list
cp build/rusefi.* deliver/
fi