2023-08-14 01:53 PM
Hi,
I have an stm32mp157d-dk1 board, for which I am building the core-image-minimal image within the poky (Dunfell) distribution. Other than adding the "meta-st-stm32mp" layer I have not made any ST related customisations.
I am trying to launch a custom elf file from the bootloader, following section 3.2.1 of the guide: How to start the coprocessor from the bootloader
I am running into a few issues:
That is, if I modify CONFIG_EXTRA_ENV_SETTINGS so that it becomes (I added some additional print-out, that I do not believe is causing my situation):
#define CONFIG_EXTRA_ENV_SETTINGS \
"stdin=serial\0" \
"stdout=serial\0" \
"stderr=serial\0" \
"kernel_addr_r=0xc2000000\0" \
"fdt_addr_r=0xc4000000\0" \
"fdtoverlay_addr_r=0xc4100000\0" \
"scriptaddr=0xc4100000\0" \
"pxefile_addr_r=0xc4200000\0" \
"splashimage=0xc4300000\0" \
"ramdisk_addr_r=0xc4400000\0" \
"altbootcmd=run bootcmd\0" \
"env_check=if env info -p -d -q; then env save; fi\0" \
STM32MP_BOOTCMD \
BOOTENV \
"boot_net_usb_start=true\0" \
"m4fw_name=my-m4-fw.elf\0" \
"m4fw_addr=${kernel_addr_r}\0" \
"boot_m4fw=rproc init; rproc load 0 ${kernel_addr_r} ${filesize}; rproc start 0\0" \
"boot_m4_mmc0=if load mmc 0#bootfs ${m4fw_addr} ${m4fw_name} ; then run boot_m4fw; fi;\0" \
"bootcmd=echo \"Loading the firmware!\"; echo \"ELF files is: ${m4fw_name}\"; run boot_m4_mmc0; echo \"Running boot command!\"; run bootcmd_mmc0\0"
Then CubeProgrammer fails as shown in the image:
In this case, the serial output from cubeprogrammer is as shown below:
Can someone explain what I am doing wrong or what I might be lacking in terms of missing packages, configuration, etc.? My configuration is pretty "vanilla" so other than adding "meta-st-stm32mp" straight from Dunfell, I have not done much wrt. ST setup.
I have found a work-around that allows me to flash the sdcard, by instead defining CONFIG_EXTRA_ENV_SETTINGS as follows:
#define CONFIG_EXTRA_ENV_SETTINGS \
"stdin=serial\0" \
"stdout=serial\0" \
"stderr=serial\0" \
"kernel_addr_r=0xc2000000\0" \
"fdt_addr_r=0xc4000000\0" \
"fdtoverlay_addr_r=0xc4100000\0" \
"scriptaddr=0xc4100000\0" \
"pxefile_addr_r=0xc4200000\0" \
"splashimage=0xc4300000\0" \
"ramdisk_addr_r=0xc4400000\0" \
"altbootcmd=run bootcmd\0" \
"env_check=if env info -p -d -q; then env save; fi\0" \
STM32MP_BOOTCMD \
BOOTENV \
"boot_net_usb_start=true\0" \
"m4fw_name=my-m4-fw.elf\0" \
"m4fw_addr=${kernel_addr_r}\0" \
"boot_m4fw=rproc init; rproc load 0 ${kernel_addr_r} ${filesize}; rproc start 0\0" \
"boot_m4_mmc0=if ext4load mmc 0:4 ${kernel_addr_r} ${m4fw_name} ; then run boot_m4fw; fi;\0" \
"bootcmd=echo \"Loading the firmware!\"; echo \"ELF files is: ${m4fw_name}\"; run boot_m4_mmc0; echo \"Running boot command!\"; run bootcmd_stm32mp\0"
In this case I am able to flash the sdcard, but I run into a new issue
That is, the firmware name in my case is "my-m4-fw.elf" as oppose to the default firmware name "rproc-m4-fw.elf". Part of my image is a package that copies my my-m4-fw.elf file into the bootfs - see image below:
The "my-m4-fw.elf" is there as it should be. I have verified the elf separately, so I know that it behaves as intended when loaded correctly.
On the very first boot after I flash the SD card, the firmware name is loaded correctly as shown in the image below, and the firmware launches as expected.
However, on every subsequent reset and reboot of the board, the elf file name is incorrectly loaded as the default "rproc-m4-fw.elf" as demonstrated below:
In this situation, the m4 obviously fails to load the firmware.
Again, can anyone explain to me what I am doing wrong, and why this happens?