-
Notifications
You must be signed in to change notification settings - Fork 8.4k
mcuboot: enable use on RISC-V with ram load mode #81276
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
mcuboot: enable use on RISC-V with ram load mode #81276
Conversation
nordicjm
left a comment
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.
Changes look OK, one nit.
ef3de17 to
0c63fa1
Compare
|
We have some problems in ci, now that |
|
The CI issues will have to be addressed. |
0c63fa1 to
5abdbed
Compare
5abdbed to
3c89775
Compare
arch/common/CMakeLists.txt
Outdated
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.
why is CONFIG_ROM_START_OFFSET > 0 needed here but only for risc?
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 don't wanted to change it for the other archs
- there are some riscv soc, that don't work, so the part to add a offset is only used, if that offset is needed
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.
If the others are failing, they should be fixed, this is adding a hack (would suggest getting build logs from CI then pinging the maintainers of those platforms since they would be broken)
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.
the problem was mainly opentitan, which needs to put a other rom header in front. maybe @snematbakhsh can help
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.
@nordicjm the opentitan one is not compatible with having a CONFIG_ROM_START_OFFSET, because it has to put something soc specific in front in the linker.
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.
@tkng-rivos @snematbakhsh as submitters of that board, can you take a look/fix?
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.
@maass-hamburg Once we turn on CONFIG_ROM_START_OFFSET for risc-v, I think we need to account for the manifest (similar to what is done here for another SOC). So I think we want to change soc/lowrisc/opentitan/Kconfig.defconfig as follows:
# The OpenTitan SoC requires a manifest in front of the
# application binary.
config ROM_START_OFFSET
default 0x404
.. and subsequently we no longer need the "GREATER 0" special case.
Why 0x404 and not 0x400 for 1024 byte manifest, you ask? It's this bug, I will take care of it after you land your PR (so just use 0x404).
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.
@snematbakhsh the CONFIG_ROM_START_OFFSET will result in everything before the offset being filled with zeros. But you need to write the start address in the manifest see here:
zephyr/soc/lowrisc/opentitan/rom_header.S
Line 25 in 90ff9c0
| .word(__start - __rom_header) |
We would also have to remove the part for creating the manifest, because it would conflict with the CONFIG_ROM_START_OFFSET code.
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.
the CONFIG_ROM_START_OFFSET will result in everything before the offset being filled with zeros.
It seems to work fine on my side, did I miss something?
Applying patches 1d65a59 (to generate .bin) and 387478c (my proposed change as previously discussed).
$ west build -b opentitan_earlgrey samples/hello_world/
$ hexdump build/zephyr/zephyr.bin | more
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000380 0000 0000 0404 0000 0000 0000 0000 0000
0000390 0000 0000 0000 0000 0000 0000 0000 0000
*
0000400 0000 0000 1197 f000 8193 4541 0297 0000
I think this works because the SORT_KEY for the OpenTitan manifest ("000...") precedes the SORT_KEY for rom_start_offset.ld ("0x0").
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.
seems like its working
|
@tkng-rivos @snematbakhsh ping ?? |
c431a2f to
ca918e0
Compare
nordicjm
left a comment
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.
minor nit.
ca918e0 to
a10dd22
Compare
|
fixed nit. |
tests/kernel/smp/testcase.yaml
Outdated
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.
This seems completely unrelated to the PR. Please revert.
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.
@cfriedt these tests are now failing, and I don't know why. You may want to take a look.
add flash_img_get_upload_slot() to get current upload slot. when CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD is enabled, it is not based on the DT. Signed-off-by: Fin Maaß <[email protected]>
don't assume, that the slot to upload is the second. Signed-off-by: Fin Maaß <[email protected]>
don't select USE_DT_CODE_PARTITION, when MCUBOOT_BOOTLOADER_MODE_RAM_LOAD Signed-off-by: Fin Maaß <[email protected]>
489d6f2 to
7d89f50
Compare
be able to use ROM_START_OFFSET on RISCV. Signed-off-by: Fin Maaß <[email protected]>
7d89f50 to
fc22d71
Compare
|
qemu_riscv64 and qemu_riscv32 do not support a different a ROM offset. The start has to be at |
this enables the use of mcuboot on riscv with ram load mode.
for that a function to get the flash_img_get_upload_slot() is needed.
Fixes: #83941