How to configure U-Boot for your board

Revision as of 16:53, 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 with:

  1. add your board #device tree
  2. create your own board support #board subdirectory
  3. add TARGET_<board> in #Kconfig
  4. create your board #defconfig
  5. add your #configuration file

2. device tree[edit source]

See U-Boot_overview#Device_tree for details.

  • 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 the generic ST defconfig with the ST board directory but the board-specific features are not 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 our source code and a Makefile file

You can compile the ST files (in board/st/stm32mp1 or in board/st/common) or just copy as staring 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

You can add any files needed for your board.

4. Kconfig[edit source]

You need to support your board in Kconfig with a new configuration flag .

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
 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/ 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 in #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
  • save the updated defconfig: make savedefconfig
  • verify and copy the file defconfig in configs/<vendor>_<board>_defconfig

See for example the file configs/dh_stm32mp1/stm32mp15_dhcom_basic_defconfig .

6. configuration file[edit source]

The configuration file is selected in Makefile.autoconf by CONFIG_SYS_CONFIG_NAME.

The ST <config>= stm32mp1; the configuration file is include/configs/stm32mp1.h .

The ST configuration file can be

  • used in your project
  • or included in your customed configuration file
  • or can be used a starting poitn for your configuration file.

7. References[edit source]