1

Is there a way to upload applications to an STM32 board over the ethernet?

I need to be able to upload code to ~200 Nucleo F429ZI boards that are only connected together with a PC via a LAN.

mgmussi
  • 520
  • 1
  • 4
  • 19
Roger Hache
  • 405
  • 1
  • 5
  • 17
  • 1
    Certainly, basically you implement software functions to download new code into memory and then execute it. These MCUs are capable both of in-system FLASH programming for persistent storage of new firmwares and execution out of RAM for temporary execution, both memories of which are more than sufficient for complex programs and bootloaders. Depending on your specific requirements there may be more or less library code which you can draw on although and Ethernet protocols and dynamic code management can be complex it most certainly _possible_. – doynax Jul 03 '17 at 21:23

3 Answers3

2

I project I did in the past had the following setup.

  • One external flash
  • Boot-loader (first STM32 project in my IDE), doing the following each boot-up
    • Is there a new image in the external flash? I even added a RSA signature to this step
    • If image verifies OK, erase STM32-flash except the first 64K which has the boot-loader, and rewrite it using data from the external flash. And clear the first sector in the external flash when done to avoid reflashing the STM32 at every boot
    • Jump into the payload
  • Payload (second STM32 project in my IDE). I configured my IDE to place the image 64K into the flash of the STM32. My payload uses LwIP as its IP-stack (git latest, and grabbed the hardware glue-code needed from another STM32 example)
  • Made a small tool that can read the .hex file that my IDE generates, sign it with my RSA key, and output a file that my control-software understands and can transmit to my STM32 when it is operating in its normal mode.
Stian Skjelstad
  • 2,277
  • 1
  • 9
  • 19
1

You can find example codes for STM324xG_EVAL and STM324x9I_EVAL board on STMCubeF4 under LWIP_IAP folder and you can follow the documents UM1709 and AN3968. You should adapt example codes according to your board.

Gürtaç Kadem
  • 315
  • 4
  • 13
0

I have not used LwIP_IAP - as noted by Gürtaç Kadem - but it seems like the easiest solution.

Another way (also applicable to non-ST boards, in case someone else wanders to this question) would be to add the mbed bootloader to your project. Then run a TCP server on your board, let the PC connect to the board and write the new application to the board. Store the new binary in flash, and the bootloader can then load the new binary on reboot.

Requires a bit of coding though. Also you'd need to add a trust relationship between computer and board, perhaps by signing the new binary with a private key and holding the public key on the board. mbed TLS is capable of this (f.e. via X509).

Jan Jongboom
  • 26,598
  • 9
  • 83
  • 120