Installing FreeRTOS to STM32H7 SOM via Ethernet

This application note explains how to install FreeRTOS to the STM32H7 System-On-Module using the Ethernet interface as the download channel.

Refer to https://voxelbotics.atlassian.net/wiki/spaces/DOC/pages/298909698 as a pre-requisite to understanding the installation procedure.

1. Hardware Set-Up

The following hardware set-up is required for installation of the software to the STM32H7 SOM:

  • STM32H7-SOM Rev 1A soldered onto the STM32H7-BSB Rev 1A or STM32H7-BSB Rev 2A baseboard.

  • The microUSB cable connected to the P1 connector on the baseboard (to provide the STM32H7 serial console to the development host).

  • The TST-LINK/V2 debugger/programmer connected to the 20-pin P3 ARM JTAG connector on the baseboard.

2. Connecting STM32H7-SOM Starter Kit to the Local Network

2.1. Connecting the Kit with the STM32H7-BSB Rev 1A

The Waveshare LAN8720 ETH board connected to the P2 header with a special cable. The pin-out is as follows:

STM32H7

Function

BSB

ETH

Name

LAN8720

Comment

 

3V3

P2.1

P2.1

VCC

 

 

 

3V3

P2.2

P2.2

VCC

 

 

 

GND

P2.3

P2.3

GND

 

 

 

GND

P2.4

P2.4

GND

 

 

PC1

ETH_MDC

P2.5

P2.5

MDC

MDC

 

PA2

ETH_MDIO

P2.6

P2.6

MDIO

MDIO

 

PA7

RMII_CRS_DV

P2.7

P2.7

CRS_DV

CRS_DV/MODE2

 

PA1

RMII_REF_CLK

P2.8

P2.8

R_RXCLK

 

50MHz from LAN8720

PC5

RMII_RXD1

P2.9

P2.9

RXD1

RXD1/MODE1

 

PC4

RMII_RXD0

P2.10

P2.10

RXD0

RXD0/MODE0

 

PG13

RMII_TXD0

P2.11

P2.11

TXD0

TXD0

 

PG11

RMII_TXEN

P2.12

P2.12

TX_EN

TXEN

 

PG10

-

P2.13

-

-

-

 

PG12

RMII_TXD1

P2.14

P2.14

TXD1

TXD1

 

The following picture illustrates the above hardware set-up:

2.2. Connecting the Kit with the STM32H7-BSB Rev 2A

Connect Ethernet cable to the J5 Ethernet connector on the baseboard.

The following picture illustrates the this hardware set-up:

3. Installing FreeRTOS to Flash

3.1. Installable Images

The images to be installed onto the STM32H7 SOM can be obtained using one of the two approaches, as follows:

  1. Build the images from the sources, as documented in https://voxelbotics.atlassian.net/wiki/spaces/DOC/pages/298385434 .

  2. Use the prebuilt images provided by Emcraft. The prebuilt images can be found in the location documented in Release Notes.

3.2. Installing U-Boot SPL to Internal Flash

Step through the following procedure to install the U-Boot SPL to the internal Flash of the STM32H750:

  1. Run the following command on the Linux development host:

    $ st-flash write u-boot-spl.bin 0x08000000 st-flash 1.7.0-120-gbeffed4 2023-10-03T14:41:17 INFO common.c: H74x/H75x: 128 KiB SRAM, 45069 KiB flash in at least 128 KiB pages. file u-boot-spl.bin md5 checksum: b262768ecdb3a41d7380ad9f3a3b1a6, stlink checksum: 0x005232a9 2023-10-03T14:41:17 INFO common.c: Attempting to write 62085 (0xf285) bytes to stm32 address: 134217728 (0x8000000) 2023-10-03T14:41:17 WARN common.c: unaligned len 0xf285 -- padding with zero 2023-10-03T14:41:18 INFO common.c: Flash page at addr: 0x08000000 erased 2023-10-03T14:41:18 INFO common.c: Finished erasing 1 pages of 131072 (0x20000) bytes 2023-10-03T14:41:18 INFO common.c: Starting Flash write for H7 62086/62086 bytes written 2023-10-03T14:41:19 INFO common.c: Starting verification of write complete 2023-10-03T14:41:19 INFO common.c: Flash written and verified! jolly good!
  2. Verify that the U-Boot SPL has been successfully installed. Reset the SOM by pressing the S3 button on the carrier board and confirm that the following output appears on the serial UART console:

    U-Boot SPL 2019.04-emcraft-h7-2.0.0-g5445b38714 (Apr 19 2023 - 14:03:32 +0400) Hit 's' key to enter spl shell: Trying to boot from SPI

3.3. Installing U-Boot "Proper" to QSPI Flash

Step through the following procedure to install the U-Boot "Proper" to the QSPI Flash:

  1. On the development host, make sure that your serial terminal utility (such as picocom) is not connected to the board serial console (/dev/ttyUSB1 in this example). Exit the utility or just kill it, for example:

    [sasha_d@workbench ~]$ killall picocom [sasha_d@workbench ~]$
  2. Run the following command on the Linux development host:

  3. Reset the board to start programming u-boot-upstream/u-boot.img via /dev/ttyUSB1.

  4. Reset the SOM by pressing the S3 button on the carrier board.

  5. Wait for the kermit utility to load the U-Boot image (observe the progress indicators).

  6. The script will exit successfully at the end of the installation procedure:

  7. Connect to the SOM console using a serial terminal utility, for example:

  8. Verify that the U-Boot "proper" has been successfully installed. Reset the SOM by pressing the S3 button on the carrier board and confirm that the following output appears on the serial UART console:

3.4. Configuring Network in U-Boot

Step through the following procedure to configure the network parameters in U-Boot:

  1. Set the MAC address of the Ethernet interface (you can choose an arbitrary address for development purposes but make sure that it is unique within your LAN):

  2. Set the IP address of the board to a value that makes sense for your LAN, for example:

  3. Set the TFTP server IP address, for example:

  4. Save the network parameters in the QSPI Flash:

  5. Try to download a non-existent file from the TFTP server and confirm that the File not found error is reported:

3.5. Installing FreeRTOS to QSPI Flash

Step through the following procedure to install the FreeRTOS to the QSPI Flash:

  1. Create the pair of the redundant 4 MB UBI volumes for the FreeRTOS images (this step can be skipped if the volumes have been already created earlier):

  2. Initialize and save the boot variables:

  3. Download the FreeRTOS image from the TFTP server:

  4. Install the FreeRTOS image to the QSPI Flash:

  5. Verify that the FreeRTOS has been successfully installed. Reset the SOM by pressing the S3 button on the carrier board and confirm that the following output appears on the serial UART console:

3.6. Enabling LCD and Splash Screen on Starter Kit with LCD

If your starter kit includes the LCD, it can be enabled in software by installing the U-Boot splash screen image to the QSPI Flash. Step through the following procedure to install the stm32h7-splash-24bpp.bmp picture as the splash screen:

  1. Create the 2 MB UBI volume for the splash screen image (this step can be skipped if the volume has been already created earlier):

  2. Download the splash screen image from the TFTP server:

  3. Install the splash screen image to the QSPI Flash:

4. Upgrading U-Boot "Proper" via Ethernet

Step through the following procedure to upgrade the U-Boot "Proper" via Ethernet using the previously installed U-Boot:

  1. Download the U-Boot image from the TFTP server:

  2. Install the U-Boot image to the QSPI Flash:

5. Troubleshooting Ethernet

Here are some troubleshooting tips, in case tftpboot does not work for you from U-Boot:

  • As trivial as it sounds make sure that the board is connected to the LAN with an Ethernet cable.

  • Suppose you are still not getting your file from the TFTP server. It is possible that the problem is on the host side - you must set up a TFTP server correctly. Just google for "how to set up a tftp server" and follow the advice from some top articles.

  • Make sure you have copied a file you are trying to download to the TFTP server directory on the host.

  • Disable the firewall on the host since get enabled, it will block TFTP requests from the target.

  • On the target, make sure that you have set ipaddr and serverip correctly. Check ethaddr and make sure that you don't have another embedded board (eg. another STM32H7 SOM) configured for the same MAC address.