How to configure U-Boot for your board

Revision as of 19:05, 11 May 2020 by Registered User

This page explains how to configure the U-Boot source for your board.

Many existing ressources [1] [2] explain the porting of U-Boot on a new board, this page is only a basic guideline for STM32MP1 series.

To summarize, you need to configure U-Boot for your <VENDOR> <BOARD> with the following steps:

  1. add your board #device tree: arch/arm/dts/<board>.dts and <board>-u-boot.dtsi
  2. create your own board support #board subdirectory: board/<vendor>/<board>
  3. add TARGET_<VENDOR> _<BOARD> in #Kconfig
  4. create your board #defconfig: defconfig/<board>_defconfig
  5. add your #configuration file : include/configs/<board>.h

1. device tree[edit source]

To add the board device tree in arch/arm/dts : <board>.dts and <board>-u-boot.dtsi

  • copy the kernel device tree in directory arch/arm/dts : <board>.dts
 dtb-$(CONFIG_STM32MP15x) += \
 	<board>.dtb 
  • add a U-Boot addon device tree for your board in arch/arm/dts directory: <board>-u-boot.dtsi
    This file is automatically include during <board>.dts processing,
    it includes the <soc>-u-boot.dtsi file provided by STMicroelectronics (arch/arm/dts/stm32mp15-u-boot.dtsi for example) and add all the properties on nodes needed by U-Boot (node /config, attibute u-boot,dm-pre-reloc / u-boot,dm-pre-proper).

At this point you can use the generic ST defconfig with the ST board directory but with your board device tree.

The board-specific features are not correctly managed but that can be enought for simple board, derivated from ST designs.

For example, on STM32MP15x lines More info.png, to use the ST stm32mp1 board with your device tree:

  make stm32mp15_trusted_defconfig
  make DEVICE_TREE=<board> all

The next step are required if the ST generic board has not the all behaviors expected for you board (MAC address not located in OTP, specific PMIC, specific boot command).

1.1. config node[edit source]

Some properties in node 'config' are also used to configure dynamically the U-Boot behavior in the board device tree:

  • Generic U-Boot configuration, managed in generic code:
    • u-boot,mmc-env-partition = name of partition used to save U-Boot environment
  • Some st properties only managed in ST board code; they can be used only if your board reuse this ST board code
    • u-boot,boot-led = name of LED used to indicate BOOT
    • u-boot,error-led = name of LED used to indicate error
    • st,adc_usb_pd = ADC channels used to check USB power supply
    • st,stm32prog-gpios = GPIO used to force STM32CubeProgrammer mode
    • st,fastboot-gpios = GPIO used to force FASTBOOT mode

For example in arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi

   	config {
   		u-boot,boot-led = "heartbeat";
   		u-boot,error-led = "error";
   		u-boot,mmc-env-partition = "ssbl";
   		st,adc_usb_pd = <&adc1 18>, <&adc1 19>;
   		st,fastboot-gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
   		st,stm32prog-gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
   	};

2. board subdirectory[edit source]

Create your own board support subdirectory = board/<vendor>/<board> and add a Makefile file.

You can add any source files needed for your board.

In this Makefile, you can compile the ST files (in board/st/stm32mp1 or in board/st/common) or just copy them as starting point and modify them.

For example in board/dhelectronics/dh_stm32mp1/Makefile , use ST files in ../../st/stm32mp1 and local file "board.c"

 ifdef CONFIG_SPL_BUILD
 obj-y += ../../st/stm32mp1/spl.o
 endif

 obj-y += ../../st/stm32mp1/board.o board.o

3. Kconfig[edit source]

You need to support your board in Kconfig with a new configuration flag: TARGET_<VENDOR>_<BOARD>

3.1. arch Kconfig: arch/arm/mach-stm32mp/Kconfig [edit source]

  • Add new CONFIG_TARGET_<VENDOR>_<BOARD>
  • Select the required option (soc for example : CONFIG_STM32MP15x)
  • Include your board Kconfig in arch one (source "board/<vendor>/<board>/Kconfig")
 choice
 	prompt "STM32MP15x board select"
 	optional
   
   [...]
   
   config TARGET_<VENDOR>_<BOARD>
   	bool "<vendor> <board> board"
   	select STM32MP15x
   	help
 		target the <vendor> <board> board with SOC STM32MP15x
 		managed by board/<vendor>/<board>
 
   endchoice
 
  [...]
  source "board/st/stm32mp1/Kconfig"
  source "board/dhelectronics/dh_stm32mp1/Kconfig"
  source "board/<vendor>/<board>/Kconfig"
  
  endif

3.2. board Kconfig: board/<vendor>/<board>/Kconfig[edit source]

The mininimal content of this file is:

 if TARGET_<VENDOR>_<BOARD>
 
 config SYS_BOARD
 	default "<board>"
 
 config SYS_VENDOR
 	default "<vendor>"
 
 config SYS_CONFIG_NAME
 	default "<config>"
 endif

See for example board/dhelectronics/dh_stm32mp1/Kconfig .

SYS_CONFIG_NAME is used to select the used #configuration file: include/configs/SYS_CONFIG_NAME.h

4. defconfig[edit source]

Add a new defconfig for your board in configs .

  • copy configs/stm32mp15_trusted_defconfig to your "<vendor>_<board>_defconfig"
  • select your new defconfig: make <vendor>_<board>_defconfig"
  • use make menuconfig to change your defconfig
    • remove CONFIG_TARGET_ST_STM32MP15x
    • add CONFIG_TARGET_<VENDOR>_<BOARD>
    • change CONFIG_DEFAULT_DEVICE_TREE from "stm32mp157c-ev1" to the name of the board device tree: "<board>"
  • save the updated defconfig: make savedefconfig
  • verify and copy the file defconfig in configs/<board>_defconfig

See for example the file configs/dh_stm32mp1/stm32mp15_dhcom_basic_defconfig .

5. configuration file[edit source]

The configuration file is the include file selected in Makefile.autoconf by CONFIG_SYS_CONFIG_NAME in include/configs .

This file define CONFIG_ flags of board which are not using Kconfig.

For example, in this configuration file, you can choose the initial U-Boot environment with CONFIG_EXTRA_ENV_SETTINGS, including the boot command.

For ST boards, CONFIG_SYS_CONFIG_NAME = stm32mp1; the configuration file is include/configs/stm32mp1.h .

This ST configuration file can be

  • used in your project (with CONFIG_SYS_CONFIG_NAME="stm32mp1")
  • or included in your board configuration file (#include "stm32mp1")
  • or can be used a starting point for your configuration file (copy and update it)

6. References[edit source]