Skip to content
Snippets Groups Projects
Unverified Commit 67687636 authored by Gaëtan Harter's avatar Gaëtan Harter Committed by cladmi
Browse files

cortexm_common_ldscript: add test for linker FW_ROM_LEN

Compile an elf file with a length equals to half the rom length.
parent 7dad2e70
No related branches found
No related tags found
No related merge requests found
...@@ -20,12 +20,12 @@ BOARD_WHITELIST += stm32mindev ...@@ -20,12 +20,12 @@ BOARD_WHITELIST += stm32mindev
include $(RIOTBASE)/Makefile.include 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 = test-elffile-overflow test-elffile-fw_rom_length
COMPILE_TESTS += tests-offsets COMPILE_TESTS += tests-offsets tests-fw_rom_len
all: compile-tests all: compile-tests
...@@ -98,3 +98,26 @@ $(BINDIR)/$(APPLICATION)_offset_%.elf: ROM_OFFSET=$* ...@@ -98,3 +98,26 @@ $(BINDIR)/$(APPLICATION)_offset_%.elf: ROM_OFFSET=$*
$(BINDIR)/$(APPLICATION)_offset_%.elf: $(ELFFILES_DEPS) $(BINDIR)/$(APPLICATION)_offset_%.elf: $(ELFFILES_DEPS)
$(Q)$(_LINK) -o $@ $(Q)$(_LINK) -o $@
.PRECIOUS: $(BINDIR)/$(APPLICATION)_offset_%.elf .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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment