diff --git a/tests/cortexm_common_ldscript/Makefile b/tests/cortexm_common_ldscript/Makefile index 49973d3f29487ebb685bb558a27d3f600de62f2c..337462fdea5c8553ef209299935b29671ec88c01 100644 --- a/tests/cortexm_common_ldscript/Makefile +++ b/tests/cortexm_common_ldscript/Makefile @@ -20,12 +20,12 @@ BOARD_WHITELIST += stm32mindev include $(RIOTBASE)/Makefile.include -# # # # # # # # # # # # # # # # # # # -# Compile time tests for ROM_OFFSET # -# # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Compile time tests for ROM_OFFSET and FW_ROM_LENGTH # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # COMPILE_TESTS = test-elffile-overflow test-elffile-fw_rom_length -COMPILE_TESTS += tests-offsets +COMPILE_TESTS += tests-offsets tests-fw_rom_len all: compile-tests @@ -98,3 +98,26 @@ $(BINDIR)/$(APPLICATION)_offset_%.elf: ROM_OFFSET=$* $(BINDIR)/$(APPLICATION)_offset_%.elf: $(ELFFILES_DEPS) $(Q)$(_LINK) -o $@ .PRECIOUS: $(BINDIR)/$(APPLICATION)_offset_%.elf + + +# Compile elf files with FW_ROM_LEN and verify the length is taken into account +# I arbitrarily do 'half' size because I needed to take a value and +# that it is similar to what is required for doing dual firmware in rom ota + +tests-fw_rom_len: test-fw_len_half_rom + +.PHONY: test-fw_len_half_rom +test-fw_len_half_rom: $(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf + $(Q)echo -n "Test compilation with half ROM length: " + $(Q)\ + TEST_FW_LEN=$$($(PREFIX)readelf --symbols $^ 2>/dev/null | awk '/_fw_rom_length/{printf "0x%s\n", $$2}'); \ + EXPECT_FW_LEN=$$(printf "0x%08x" $$(( $(ROM_LEN_BYTES) / 2 ))); \ + if test $${TEST_FW_LEN} != $${EXPECT_FW_LEN}; then \ + echo "[ERROR] Linker firmware length not used $${TEST_FW_LEN} != $${EXPECT_FW_LEN}" >&2; \ + exit 1;\ + fi + $(Q)echo [OK] +$(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf: FW_ROM_LEN=$$(($(ROM_LEN_BYTES)/2)) +$(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf: $(ELFFILES_DEPS) + $(Q)$(_LINK) -o $@ +.PRECIOUS: $(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf