-
Notifications
You must be signed in to change notification settings - Fork 747
Update .apps section #4191
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
Update .apps section #4191
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't explain why this works but it seems like an improvement over what we have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have no explanation for why this should make a difference, but working code > not-working code.
Can you update the other boards Makefiles and READMEs that need it to include ,ALLOC
, i.e. these:
$ git grep '\.apps=LOAD'
esp32-c3-devkitM-1/Makefile: $(RISC_PREFIX)-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $^ $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM)-app.elf
imxrt1050-evkb/Makefile: arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $< \
imxrt1050-evkb/README.md: --set-section-flags .apps=LOAD \
nano_rp2040_connect/Makefile: arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $(KERNEL) $(KERNEL_WITH_APP)
nucleo_f429zi/README.md: --set-section-flags .apps=LOAD \
nucleo_f429zi/README.md: arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $(KERNEL) $(KERNEL_WITH_APP)
nucleo_f446re/README.md: --set-section-flags .apps=LOAD \
nucleo_f446re/README.md: arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $(KERNEL) $(KERNEL_WITH_APP)
opentitan/earlgrey-cw310/Makefile: $(RISC_PREFIX)-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $^ $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM)-app.elf
opentitan/earlgrey-cw310/Makefile: $(RISC_PREFIX)-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM)_verilator.elf $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM)_verilator.elf
pico_explorer_base/Makefile: arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $(KERNEL) $(KERNEL_WITH_APP)
raspberry_pi_pico/Makefile: arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $(KERNEL) $(KERNEL_WITH_APP)
teensy40/Makefile: $(Q)arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $< $(TOCK_ROOT_DIRECTORY)target/$(TARGET)/release/$(PLATFORM)-apps.elf
teensy40/README.md: --set-section-flags .apps=LOAD \
teensy40/README.md: arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $(KERNEL) $(KERNEL_WITH_APP)
weact_f401ccu6/Makefile: arm-none-eabi-objcopy --set-section-flags .apps=LOAD --update-section .apps=$(APP) $< $(KERNEL_WITH_APP)
weact_f401ccu6/README.md: --set-section-flags .apps=LOAD \
Done. |
@inesmaria08 can you verify this PR one more time with the Pico and the STM32 board? |
I tested the changes once more on both the Pico and the STM32, and it seems to work. |
@alexandruradovici I tried running the above commands on a QEMU rv32 virt kernel: On current upstream master:
With this PR:
Neither command manages to produce an output file. That being said, the LiteX checks still work on this PR and I don't think that this method has many applications on RISC-V. Loading more than one app requires careful placement for matching the flash load address of a given app, and making sure that no two apps conflict in their RAM addresses. Tockloader's flash-file backend is a great way to load apps into kernel binaries while maintaining these constraints. So, while this doesn't seem to change anything for RISC-V, I'm fine with merging this given it improves things over in the ARM world. |
Gotta love linkers. |
@lschuermann the command has to be split in two:
This should be updated in the commit that I sent yesterday. |
I am not sure why the size check fails. |
Gotcha, I missed that change -- will try that again. I'm wondering though whether it makes sense to guide users to this ELF hackery when we have the flash-file backend in Tockloader that can do all of this, and work well with multiple apps across both ARM and RISC-V. Independent of the fact that this is a good fix, should we update the READMEs to point to Tockloader instead? |
You are mostly right, the problem is that we have a couple of boards like the STM32s and the Raspberry Pi Pico (without debugger) where tockloader does not work:
|
This does seem like another good use of flash file, but we would need to add uf2 file support somehow. |
Are you referring to generating a uf2 output? That is simple to do. |
Pull Request Overview
This pull request fixes a the linker script to allow the writing of applications into kernel's elf file.
While rebasing #4099, @inesmaria08 got the following error while adding apps into the kernel's elf file errors with:
This seems to be a regression bug due the merge of #4169 which sets the
.apps
section toNOLOAD
.After further inquiry, it seems that the linker is not able to relocate the
.relocate
section. I am not an expert in liker files, and I think this should not happen as the 8000.relocate
section seems to be loaded in RAM.Putting
.apps
after.relocate
seems to fix the issue.Furthermore, it seems that
gdb
andprobe-rs
refuse to load sections which are not tagged asALLOC
.Testing Strategy
This pull request was tested by @inesmaria08 using a Pico Explorer Base.
TODO or Help Wanted
Feedback regarding the linker script.
Documentation Updated
/docs
, or no updates are required.Formatting
make prepush
.