RW612 MCUBoot + TF-M Not Booting Hello, I am having issues with flashing my custom board set up very similar to the FRDM-RW612 with the TF-M + MCUBoot example. It seems that the newest version of the nxp-zephyr repo (v4.3.0) has changed some of the files in the tutorial. I have tried to follow it the best I can but my board still does not boot correctly. When I flash just the MCUBoot bootloader, I do see the expected output error Unable to find bootable image. When I follow the guide's instructions to flash the psa crypto sample I don't see any output on the terminal at all, not even the MCUBoot text anymore. I also tested it with the blinky sample in case it was just a terminal issue, but in that case the board LED does not blink either. Both of these samples do boot and run when i flash just TF-M without MCUBoot (west build -b frdm_rw612//ns samples/basic/blinky --pristine && west flash). In this case I also noticed an odd quirk. Since I need to use flexcomm3 for a peripheral, I wanted to switch the zephyr console to another output. When I edit the device tree I get different problems: 1. Switching zephyr console to Flexcomm2 instead of Flexcomm3 Made the following edits to boards/nxp/frdm_rw612/frdm_rw612_common.dtsi: Removed i2c-0 alias Removed ambient-temp0 alias Replaced chosen/zephyr,console with &flexcomm2 Added flexcomm2 node: &flexcomm2 {
compatible = "nxp,lpc-usart";
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&pinmux_flexcomm2_usart>;
pinctrl-names = "default";
wakeup-source;
}; Removed nxp_pmod_touch_panel_i2c, arduino_i2c, and mikrobus_i2c nodes And added a flexcomm2 pinctrl to boards/nxp/frdm_rw612/frdm_rw612-pinctrl.dtsi: &pinctrl {
pinmux_flexcomm2_usart: pinmux_flexcomm2_usart {
group0 {
pinmux = ;
slew-rate = "normal";
bias-pull-up;
};
};
}; And after this, when I flash the exact same blinky code that worked with FC3 as console, I see the bootloader output on FC3 (below) but nothing is ever outputted on FC2 and the LED does not blink. [INF] Starting bootloader
[WRN] This device was provisioned with dummy keys. This device is NOT SECURE
[INF] PSA Crypto init done, sig_type: EC-P256, using builtin keys
[INF] Image index: 1, Swap type: none
[INF] Image index: 0, Swap type: none
[INF] Bootloader chainload address offset: 0x20000
[INF] Image version: v0.0.0
[INF] Jumping to the first image slot
Booting TF-M v2.2.0+g3b3595f16
[WRN] This device was provisioned with dummy keys. This device is NOT SECURE
[Sec Thread] Secure image initializing!
[INF][PS] Encryption alg: 0x5500100
[INF][Crypto] Provision entropy seed...
[INF][Crypto] Provision entropy seed... complete. 2. Switching zephyr console to Flexcomm14 instead of Flexcomm3 Replaced chosen/zephyr,console with &flexcomm14 Added flexcomm14 node: &flexcomm14 {
compatible = "nxp,lpc-usart";
status = "disabled";
current-speed = <115200>;
pinctrl-0 = <&pinmux_flexcomm14_usart>;
pinctrl-names = "default";
wakeup-source;
}; And added a flexcomm14 pinctrl to boards/nxp/frdm_rw612/frdm_rw612-pinctrl.dtsi: &pinctrl {
pinmux_flexcomm14_usart: pinmux_flexcomm14_usart {
group0 {
pinmux = ;
slew-rate = "normal";
};
};
}; With these edits, I don't see any output on FC3 or FC14, and the LED does not blink at all. I don't know if the issue I am having with TF-M + MCUBoot is related to the TF-M-only console output problem, but I thought I'd include that just in case. My end goal is to have MCUBoot and TF-M so that I can perform firmware updates after booting, and I need to use Flexcomm3 for a peripheral so I need a different console output than the FRDM-RW612 uses. I'd also like to note that I can flash my board and print to console with FC14 when using neither TF-M nor MCUBoot, I only encountered issues with flashing/booting once enabling these subsystems. Any help is very appreciated, thank you! Re: RW612 MCUBoot + TF-M Not Booting I've played around with the proj.conf and found out that the issue is something related to the flash subsystem. I am currently testing MCUBoot with no TF-M, and the difference between an app that runs and an app that stalls at the line I: Jumping to the first image slot is one or more of the following KConfig options: CONFIG_FLASH_FILL_BUFFER_SIZE=32
CONFIG_FLASH=y
CONFIG_FLASH_MCUX_FLEXSPI_XIP_MEM="RAM"
CONFIG_FLASH_INIT_PRIORITY=50
CONFIG_FLASH_HAS_DRIVER_ENABLED=y
CONFIG_FLASH_HAS_EXPLICIT_ERASE=y
CONFIG_FLASH_HAS_PAGE_LAYOUT=y
CONFIG_FLASH_JESD216=y
CONFIG_FLASH_MCUX_FLEXSPI_NOR=y
CONFIG_MEMC_MCUX_FLEXSPI=y I've been digging around MCUBoot and NXP's flash files but I'm not sure if I'm on the right track or not. It looks like the line: ((void (*)(void))vt->reset)(); in the do_boot() function of MCUBoot's zephyr main.c is the last place I can debug to in GDB. After that reset "function" is called, the PC is at 0x20005840 and continuing/stepping does nothing, the program just hangs. Again any help or tips where to look to debug this issue are appreciated, thank you! Re: RW612 MCUBoot + TF-M Not Booting Hello,
Hope you are doing well. Could you please give us more details about your setup?
Are you using MCUXpresso for VSCode?
Before trying to implement all the changes related flexcomms, could you please clarify if you could follow the post? (with the respective version changes)
Best Regards,
Ricardo Re: RW612 MCUBoot + TF-M Not Booting Hi Ricardo, sorry if my original posts were scattered. I just started completely from scratch with the TF-M + MCUBoot guide so I could list what I had issues with. I do use MCUXpresso for VSCode for normal development, but since the guide is using the west command line tools, that's what I've used here. Issues with the TF-M + MCUBoot guide (on nxp_zephyr tag nxp-v4.3.0) - Under "Build and Flash TF-M from Downstream" in step 6 of "Modify secure image", it says that M_BOOT_FLASH_CONF_START should be the same as BOOT_FLASH_ACT_APP. I couldn't find BOOT_FLASH_ACT_APP anywhere in the repo, I'm not sure how to find what it is set to. I used #define M_BOOT_FLASH_CONF_START (0x18020000) - In step 8 of "Modify secure image", the guide instructs to add a VTOR configuration to SystemInitHook in hardware_init.c, but it looks like that code already exists. I left it alone. - In the "Modify non-secure image" section, the guide instructs to edit files in the folder nxp_zephyr\zephyr\build\tfm\api_ns\platform\partition, but nxp_zephyr\zephyr\build does not exist by default. The guide hasn't instructed to build anything by this point. After I had (later) built the app, the files in steps 2-6 were already modified to the correct values. - In step 7 of "Modify non-secure image", there is no nxp_zephyr/zsdk/boards directory. I am assuming it's supposed to be nxp_zephyr/zephyr/boards, so I followed step 8 with that path. - After making the edit to nxp_zephyr/zephyr/boards/nxp/frdm_rw612/frdm_rw612_rw612_ns.dts like the guide says, I get the following build error: required nodelabel not found: slot0_partition. If instead of making that edit, I build with the default device tree file, the sample builds almost all the way but at the last step I get the error: Traceback (most recent call last): ... intelhex.AddressOverlapError: Data overlapped at address 0x18020000 During handling of the above exception, another exception occurred: ... intelhex.AddressOverlapError: /nxp_zephyr/zephyr/build/zephyr/tfm_s_signed.hex has merge issues I just ignored this error and continued with the guide. - The last problem I had was in the "Merge Binaries" section on step 3, I get the error Error: No such command 'merge'. I used the command "export" instead of merge since it looked to have a similar function to me. After making these adjustments and flashing like the guide instructs, I still get the following terminal output: *** Booting MCUboot v2.2.0-192-g96576b341ee1 ***
*** Using Zephyr OS build nxp-v4.3.0 ***
I: Starting bootloader
I: Image index: 0, Swap type: perm
I: Image index: 0, Swap type: perm
I: Primary image: magic=bad, swap_type=0x0, copy_done=0x2, image_ok=0x2
I: Secondary image: magic=good, swap_type=0x1, copy_done=0x3, image_ok=0x1
I: Boot source: none
I: Image index: 0, Swap type: perm
I: Image index: 0, Swap type: perm
I: Image index: 0, Swap type: perm
I: Image index: 0, Swap type: perm
E: Image in the primary slot is not valid!
E: Unable to find bootable image I don't know if any of the adjustments I've made to the guide's instructions are what cause my problems, or if it's some other difference in the updated zephyr repo. Thank you for responding. Re: RW612 MCUBoot + TF-M Not Booting Hello @jm-streametric, hope you are doing well.
The guide that you are referring to (Zephyr MCUboot + TFM Demo using RW612) applies only to Zephyr versions lower than 4.2.0, in this case for Zephyr v4.3.0 (NXP's downstream repository) the procedure to build and flash the example is simpler for the FRDM-RW612 please see the steps below to build and flash the psa_crypto example:
Click on Import Example from Repository.
Select the NXP's downstream repository V4.3.0, this is important since the TF-M support for FRDM-RW612 has not been fully added to main Zephyr repository. Then select the non-secure version of the FRDM-RW612.
Select the psa_crypto example and click on the Import button.
Finally, build the example and flash it to the board (you can also open a debug session if needed). The log on a serial terminal should look like the following image if everything went correctly.
Please notice that this steps apply just for the FRDM-RW612 board as per now, since you are using the RW612 with a custom board, you will require to check for and make the necessary changes to add TF-M support to your board. The main point to take into consideration is the flash device that you are using, therefore if there is any difference in this regard you may need to make a larger port work.
Regarding the issues you had with the changes of the Flexcomm instance used for the Zephyr console, do not make the changes directly on the boards/nxp/frdm_rw612/frdm_rw612_common.dtsi file, as this changes are re-written to default at build time, instead try to add your modifications with a frdm_rw612.overlay file, this overlay takes precedence into Zephyr default device tree files and your changes will maintain.
Please let me know if the information is useful. Re: RW612 MCUBoot + TF-M Not Booting Hi Roman, Thank you for the reply! I was able to follow your instructions and got things working on my board :). The flash layout on my custom board is the same as the FRDM-RW612 so luckily I don't need to make changes there. Adding an overlay is a good point, I didn't think to try that before. As a follow up, is it possible to change the FlexComm output of the TF-M secure + BL2 systems? I can't use the default Flexcomm3 interface as I have a peripheral on there. Right now I am silencing debug output, but is there somewhere I can modify the BL2+S builds to output to, say, FC14 USART instead of FC3? Thank you! Re: RW612 MCUBoot + TF-M Not Booting Hi @jm-streametric.
Regarding your Flexcomm question: in the current implementation, TF‑M is “hard‑coded” to use USART3. If you need to switch to a different USART instance, you can do so by reviewing and modifying the TF‑M platform files located at:
/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nxp/frdmrw612
As a starting point, I recommend checking the platform_base_address.h file under:
frdmrw612/Device/Include
This file defines the platform-level base addresses, including the USART instances used by TF‑M.
Additionally, in the project_template folder within the same TF‑M target directory, you will find initial configuration code for the USART. These initializations should give you a clear reference for how USART3 is currently set up and where to apply changes to switch to a different USART instance
Hope this information helps! Re: RW612 MCUBoot + TF-M Not Booting Hi Roman, I have tried to switch the USART used by the TF-M system. When I switch all of the definitions the target/nxp/frdmrw612/project_template/* board.h and pin_mux.c from FC3/USART3 -> FC2/USART2 the change works. However, when I follow the same steps but change it to FC14/USART14 instead, the BL2 program hangs. I ran the address it hangs at through addr2line with bl2.elf, and it looks like the program is forever stuck looping in target/nxp/frdmrw612/Native_Driver/drivers/fsl_reset.c line 51. This doesn't seem right to me as I think the FC14 peripheral reset should be using the switch case on line 67 but that might be something wrong with addr2line? Either way, when I switch the TF-M system to print to USART14 the BL2 program hangs and my zephyr app never starts. Have you ever seen this problem before and do you have any clues why this happens? Re: RW612 MCUBoot + TF-M Not Booting Hello @jm-streametric, hope you are doing well.
Could you please check if in your device tree the node referring to the Flexcomm14 has been correctly configured and activated? Make sure that the status property is set to "okay" such as in the following example:
flexcomm14: flexcomm@126000 {
status = "okay";
};
Hope this helps! Re: RW612 MCUBoot + TF-M Not Booting Hi Roman, Yes I had the flexcomm14 node set to "okay" status. Although my question is for the BL2/Secure Environment logging. I would think the zephyr devicetree doesn't apply since those two binaries are built separately?
View full article