-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cortexm_common/ldscript: simplify generation of firmwares in section of the ROM #9351
cortexm_common/ldscript: simplify generation of firmwares in section of the ROM #9351
Conversation
I re-added the main I tried doing it in |
Murdock broken build:
Is caused by #8913 as the rule defining I did not see it before as I compile without parallel build in a clean environment. |
640ff18
to
74e7cc2
Compare
I rebased on commits that should handle I also added a debug test in Makefile.include to verify that BASELIBS is indeed stable in the file. |
74e7cc2
to
636d668
Compare
Yes, my bad I forgot to update it. |
636d668
to
54c2b6b
Compare
I'd like to ACK this PR but I don't have the hardware to test. Tests are needed for:
I'd say any of the tests on these boards should validate this PR. |
I will add them to the list of tested boards in |
I tested on the bluepill (using swd flasher), tests/leds make LED0 flash. I also ran the tests/cortem_common_ldscript and got
@kYc0o Let me know if you would like anything more extensive. |
Actually the goal is to keep the bootloader, this PR modifies a bit the way the offset is managed to move the code outside the space allowed for the bootloader, but I can imagine that if you flash with SWD you've already remove the bootloader. Did you change the |
Nope, I will reflash the bootloader (sometimes a pain) then attempt to vary the ROM_OFFSET using the tests/cortem_common_ldscript... After the RIOT meeting. |
The goal is not to modify it, but just test if RIOT flashed with the normal settings still works. |
Hmmm seems like my hardware isn't happy (I cannot use the USB bootloader to program the bluepill). I will try some other ones Monday. I was able to flash with the st-link from the nucleo board or the UART setting it BOOT0 pin to 1. |
So here are the things I found... Currently the bluepill, which uses the stm32f103c8 works with swd and RIOT. Using the bootloader to flash is very outdated and full of problems. The bootloader firmware generic_boot20_pc13.bin changed the bootmode pin to B2 (which means the boot1 jumper must be connected to 1). The dfu-util also seems to show 3 instances instead of 1, requiring a serial number to specify the bootloader.
Here are the instances with the most recent bootloader
The third thing is it appears to not produce a .bin file which the bootloader requires. Finally the last problems (though it is more likely my problem) requires it to be run with sudo or the udev rules updated. Note that I used the dfu-util 0.8 as this is the most recent version for Ubuntu 16.04 LTS |
If you do RIOT/boards/common/stm32f103c8/Makefile.include Lines 19 to 26 in 9f26d37
|
I had a arduino-mkr1000 on my drawer, so I could test. Everything works and the bootloader is kept. I'd say then it's safe to merge. |
However, discovered a bug specific of that target (sam0). It works just by chance but the Makefiles need to be adapted. Can you take a look @cladmi? |
Basically, the |
@bergzand I will add a README with the expected output. |
Thanks, I'm afraid that mainly the negative tests might confuse people |
I added a |
ACK! @cladmi Thank you for adding the readme. Please squash |
47e9355
to
599bcee
Compare
You were right to request having one in the first place :) I just tend to forget if it is not minor changes. I am re-running the test in our docker image for verification (but pushed before testing of course…) |
Compilation and compile tests works on docker image and arm-none-eabi-gcc 8.1.0. |
@cladmi Your commits show up as unverified in the github webinterface. Are you sure that those are your commits? Should we trust these changes? 😆 |
Oh it's because I am from my laptop and did not commit with my fu-berlin address. Will rebase. |
Oh just misconfiguration of the |
Inspired by kaspar030 version to removing the new _boot_offset variable. https://github.com/kaspar030/RIOT/blob/cbf324a66d0c925dd02eca290e17c350945e97b2/cpu/cortexm_common/ldscripts/cortexm.ld
Trigger an overflow by 1 byte to detect in ROM_LEN is indeed used.
It will help testing if it is taken into account and for defining for outside after.
Test that _rom_offfset is removed from the available _rom_length.
The variables should all always be defined.
Define _rom_offset with a conditional evaluated at execution time to allow setting it in compilation rules and generate in the same make instance different elf files with different configurations.
Compile two elf files with different offset and verify the linked file offset. I only enabled samr21-xpro and iotlab nodes for the moment.
Allow defining a specific rom length to use for linking the firmware, _fw_rom_length, instead of the default configuration to use the whole rom from _rom_offset to the end. * Add cortexm_common/Makefile.include FW_ROM_SIZE configuration * Add an assertion that _fw_rom_length still respects _rom_length
Compile an elf file with a length equals to half the rom length.
Verify that specifying a too big _fw_rom_length for the rom is detected and prevent compilation.
Explain the test and the output you should get.
599bcee
to
6abcf2e
Compare
Congrats! One step forward for easy OTA updates 😃 |
Contribution description
This adds/modifies two build system configuration variables for
cortexm_common/ldscript/cortexm.ld
.It is now possible to generate during a build, different elf files with different rom offset and firmware rom length by setting
ROM_OFFSET
andFW_ROM_LEN
variables.ROM_OFFSET
so it can be set as a target specific variable to be used during linking.FW_ROM_LEN
variable that can restrict the firmware length to use when linking instead of using the whole rom afterROM_OFFSET
.ROM_LEN
to beROM_LEN = ROM_OFFSET + FW_ROM_LEN
which was not as straightforward to use.Use cases
The goal is firmwares that do not use the whole ROM for the over the air update scenario with a ROM split in 3 parts "Boot Loader - Firmware 1 - Firmware 2".
Current state
In the test, I currently only set the supported board with a whitelist to
iotlab-xx
andsamr21-xpro
nodes. But it should be expandable to all boards usingcortexm_common/ldscript/cortexm.ld
as linking script.I can do it depending on your feedback.
There are compilation tests for:
FW_ROM_LEN
Issues/PRs references
Part of #9342
Depends on #9451This is a modified version of things inspired from both following branches:
kYc0o https://github.com/kYc0o/RIOT/tree/ota_firmware_updates
kaspar030 https://github.com/kaspar030/RIOT/tree/ota_firmware_updates
I did not re-use the existing commits as it is a different implementation.
Tell me if you want to be mentioned in a commit.