Integrating wolfBoot into PlatformIO

Hi all,

I was trying to add wolfboot library ( which uses as a secure bootloader and for OTA firmware upgrades written in C) to my project which is based on Arduino platform , and then I got the following error ,

I used C calling syntax for all the header files in wolfboot library which is ,

#ifdef __cplusplus
 extern "C" {
#endif

After all function declarations, add:

#ifdef __cplusplus
}
#endif

Still the same error ,appreciate if anyone has a clue on why this compile error pops up .

my .ini is
[env:nucleo_f767zi]
platform = ststm32
board = nucleo_f767zi
framework = arduino

Thanks.

The library wants you to implement hal_flash_write(). In which file did you create that function?

Well actually no. The WolfSSL library should provide these functions when they’re properly compiled in. See

and it will also want you to use this linker file

Which then ends up conflicting with Arduino though, so you’ll have to reconcile both parts.

Yes it is provided by wolfssl library . So do i need to add those linker files to a specific location ?

You should solve the undefined reference error first. Do you see that stm32f7.c file going into the build? Does it exist in your project?

No it doesn’t .I deleted that folder which comes in with the wolfboot assuming that the those hal functions will use stm32f7.c from arduinio stm core. May be i should add those file back and compile .

1 Like

I just copied stm32f7.c file from hal folder which provided by the wolfssl to the src directory and compiled, now there’s no more compile error.
Should I also need to update the linker file which provided by them with the stm arduino core linker file ?

Look like everything fine now ,thanks @maxgerhardt !

1 Like

Actually, are you sure? I took one more look at it and it looks to me like there should be two binaries involved. Once, you build + upload the bootloader (“wolfBoot.bin”) from the repo. The bootloader is only linked with that special linker file, it restricts it to the start at the start of flash ( 0x08000000) and the value of BOOTLOADER_PARTITION_SIZE. Only source codes from wolfBoot go into the wolfBoot.bin, none of your firmware or the Arduino stuff.

Then you have to adapt your (Arduino) firmware to start at a different offset, aka after the bootloader, which is when I read this correctly is 0x08020000. However, there is a 0x100 big firmware image header before the actual entry point that is generated “somehow”.

With this, the Arduino linker script should be unmodified, but you still have to tell it the offset (doable via this) and probably do a special post-processing step to correctly append the header.

Correct ,that I modified the existing linker script when building the my build+the bootloader for the give start address by the wolfboot .That I have done in a separate task. Currently i’m working on with the OTA update process and try to add the wolfboot library to the firmware and use their API’s.