How to configure U-Boot for your board

Revision as of 17:20, 11 May 2020 by Registered User

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

1. introduction[edit source]

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:

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

2. device tree[edit source]

It is the minimal configuration needed to start your board.

See U-Boot_overview#Device_tree for details but the basic steps are:

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

At this point you can trying to boot with the generic ST defconfig and with the ST board directory with your board device tree, but the board-specific features are not yet correctly managed.

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

  make stm32mp15_trusted_defconfig
  make DEVICE_TREE=<board> all

3. 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 :

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

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


4. Kconfig[edit source]

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

1/ in arch/arm/mach-stm32mp/Kconfig :

  • 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

2/ add board/<vendor>/<board>/Kconfig file:

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 .

CONFIG_SYS_CONFIG_NAME = <config> is used to select the used #configuration file.

5. 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 .

6. configuration file[edit source]

The configuration file is the include file selected in Makefile.autoconf by CONFIG_SYS_CONFIG_NAME in include/configs The ST CONFIG_SYS_CONFIG_NAME is stm32mp1; the configuration file is include/configs/stm32mp1.h .

The ST configuration file can be

  • used in your project
  • or included in your board configuration file
  • or can be used a starting point for your configuration file.

7. References[edit source]