makefiles: FIX boards generating a binary '.hex' file#8840
makefiles: FIX boards generating a binary '.hex' file#8840kaspar030 merged 2 commits intoRIOT-OS:masterfrom
Conversation
* Use the existing variable when possible * Remove duplicate definition * Remove unused BINFILE variable
| export RESET = # dfu-util has no support for resetting the device | ||
|
|
||
| export OFLAGS = -O binary | ||
| HEXFILE = $(ELFFILE:.elf=.bin) |
There was a problem hiding this comment.
I don't understand the improvement here.
There was a problem hiding this comment.
When I see hello-world.elf, I expect it to be an elf executable.
When I see hello-world.hex, I expect it to bean ihex file, not a binary file.
Without this, for the boards I changed, you get a binary file called hello-world.hex.
The fix makes it generate a file named with .bin instead of .hex.
In master:
$ make BOARD=bluepill PROGRAMMER=dfu-util
$ file bin/bluepill/hello-world.hex
bin/bluepill/hello-world.hex: data
# which is different from an `ihex` file.
$ file bin/iotlab-m3/hello-world.hex
bin/iotlab-m3/hello-world.hex: ASCII text, with CRLF line terminators
Also, having the wrong format for the output is problematic for me, because in #8838 I plan to add the following rules which would break if you do the opposite.
%.hex: %elf
$(Q)$(OBJCOPY) $(OFLAGS) -Oihex $< $@
%.bin: %.elf
$(Q)$(OBJCOPY) $(OFLAGS) -Obinary $< $@
For fixing it, I used what is done in other files in RIOT
git grep 'ELFFILE:.elf=.bin'
boards/cc2538dk/Makefile.include:export HEXFILE = $(ELFFILE:.elf=.bin)
boards/common/remote/Makefile.include:export HEXFILE = $(ELFFILE:.elf=.bin)
boards/mbed_lpc1768/Makefile.include:export HEXFILE = $(ELFFILE:.elf=.bin)
boards/nrf6310/Makefile.include:export HEXFILE = $(ELFFILE:.elf=.bin)
boards/opencm904/Makefile.include:export HEXFILE = $(ELFFILE:.elf=.bin)
boards/openmote-cc2538/Makefile.include: export HEXFILE = $(ELFFILE:.elf=.bin)
makefiles/tools/bossa.inc.mk:export HEXFILE = $(ELFFILE:.elf=.bin)
makefiles/tools/edbg.inc.mk:HEXFILE = $(ELFFILE:.elf=.bin)
makefiles/tools/jlink.inc.mk:export HEXFILE = $(ELFFILE:.elf=.bin)
Using HEXFILE variable for the output of objcopy is bad if it is not an ihex file but its what is currently done in RIOT. Changing this is addressed in the global PR by introducing FLASHFILE and this line will be replaced by FLASHFILE = $(BINFILE).
|
Do we need to test flashing for all affected boards? |
No. |
Contribution description
Some boards generate a '.hex' file that is a created with '-Obinary' which is wrong and is problematic to create rules by extension used in #8838
I also include some cleanup for HEXFILE/ELFFILE/BINFILE variables in the boards Makefile. To use them and remove unused BINFILE.
Issues/PRs references
Used in #8838