-
Notifications
You must be signed in to change notification settings - Fork 12
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
Target mcuboot-image does not upload the signed executable #18
Comments
Hi @cfoucher-laas, that's somewhat expected behavior. When you press the [env]
...
[env:upload_mcuboot_image]
extends = env:your_default_env_name
targets = mcuboot-image, upload |
@valeros: thank you for this quick answer. What I understood from this dive in pio scripts is that the Also, can you confirm me that I'm not breaking anything else by overriding the |
The
SCons documentation doesn't forbid it explicitly, so I believe you should be fine, although I'd recommend using the approach with a separate environment and default targets or a precise CLI command |
I didn't include the full
As you can see, we already define multiple targets, so we are fine working in command line. The issue arises when we use the VS Code buttons provided by pio, which are very handy for us as we work with people not familiar with command line. In that case, the "build" button correctly interprets the This is why I think it would be a pretty good feature to allow defining targets for the default upload process in pio configuration file. |
Your workaround is just fine for such cases, if it also won't work for any reason, you can always fall back to a standalone environment with two default targets
That's the goal the extra scripts were designed for, if the default behavior of PlatformIO doesn't suit your needs, you can fine tune it any way you like. |
Thank you for these precisions regarding the intended behavior, this is now more clear to me. I understand that this is not a bug, but the intended behavior as per the way the tool is built. However, let aside these VS Code related stuff, I cannot help to think that even in command line, a user would expect that using the target Hence, I had a few other ideas that may be more in line with the project guidelines. I apologize if I'm bothering you, but only see my insistence as aiming at improving things for other users that could fall in the same pitfall as me. Let me expose my ideas to you, then I promise I'll stop bothering you. Idea 1: Replace/rename the file in the processIn STSTM32 platform, the target_elf = env.BuildProgram()
target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf)
if "zephyr" in frameworks and "mcuboot-image" in COMMAND_LINE_TARGETS:
target_firm = env.MCUbootImage(
join("$BUILD_DIR", "${PROGNAME}.mcuboot.bin"), target_firm) We could simply target Idea 2: Use a way of detecting the file to uploadAnother approach would be to have a detection that the user has built a mcuboot firmware. Currently, the upload stage only knows the correct file by the fact that the above code overwrites This part has only one drawback I can think of: if building Idea 3: Remember the latest built firmwareAnother way of achieving the same result as the previous idea would be to "remember" the latest firmware image built. For example, the build process could leave a trace within the build directory in the form of a text file such as "latest_built_firmware". The upload process could then, when this file is present, use its content to define the I cannot see any drawbacks to this approach, except that the code of the python scripts would be slightly more complicated. Idea 4: Define another target such as
|
Describe the bug
On STSTM32 platform, we use the
mcuboot-image
target to sign the image after building. We had trouble making this target to work flawlessly, as while the firmware is correctly built, it is the pre-mcuboot firmware that gets uploaded to the board. We finally found some workarounds, but they all have drawbacks. Here are the different steps we took:First try
We started by using the following parameters in
platformio.ini
:In this case, the firmware is correctly built, but the upload phase will not upload the signed firmware (
firmware.mcuboot.bin
), only the pre-mcuboot filefirmware.bin
. At this stage, the workaround was to use an external tool to upload the firmware to the board.Second try
We identified the following code snippet in STSTM32's
main.py
:This lead us to a second try by ensuring the upload phase is done in a single step with the build/sign process. Here, we modified the targets in
platformio.ini
as follows:There, it works but this is an akward configuration because the "build" button in the bottom bar of VS Code will also upload the file (thus would result in an error when not connected to the board), while the "upload" button still uploads the wrong file.
Third try
Finally, we resorted in a trick consisting in forcing pio scripts use the
mcuboot-image
even with the single "upload" step, by altering theCOMMAND_LINE_TARGETS
variable. This uses a "pre" hook as follows:With the following content in
upload_signed_firmware.py
:To Reproduce
Steps to reproduce the behavior:
targets = mcuboot-image
toplatformio.ini
firmware.mcuboot.bin
firmware.bin
Expected behavior
When using the
mcuboot-image
target inplatformio.ini
, the "upload" phase should upload the final, signed, firmware, not the one produced at an earlier phase of the build process.Impact
The impact was a time-consuming process of going through the pio scripts and understanding Scons in order to find a workaround. Now that it works, the impact is minimal (only an additional script to ship in our repo).
Environment
framework-zephyr
version2.30400.230914
The text was updated successfully, but these errors were encountered: