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:
- add your board #device tree: arch/arm/dts/<board>.dts and <board>-u-boot.dtsi
- create your own board support #board subdirectory: board/<vendor>/<board>
- add TARGET_<VENDOR> _<BOARD> in #Kconfig
- create your board #defconfig: defconfig/<board>_defconfig
- add your #configuration file : include/configs/<board>.h
1. device tree[edit source]
First step it to add the board device tree in arch/arm/dts : <board>.dts and <board>-u-boot.dtsi
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
- update arch/arm/dts/Makefile to compile your device tree, for example:
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 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 , to use the ST stm32mp1 board with your device tree:
make stm32mp15_trusted_defconfig make DEVICE_TREE=<board> all
Some properties is used in ST board code to configure dynamically the board with the config node:
- Generic U-Boot configuration
- u-boot,mmc-env-partition = name of partition used to save U-Boot environment
- Some properties are managed in ST board code (they can be used only if your board reuse the 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>
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 .
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.
The ST CONFIG_SYS_CONFIG_NAME is stm32mp1; the configuration file is include/configs/stm32mp1.h .
This ST configuration file can be
- used in your project (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)