See original article by Thomas Petazzoni at bootlin.com
...
Important - Preparing Buildroot
For this tutorial to work as outlined in the text below we need to set up a new copy of buildroot and switch to a specific earlier version buildroot it. There's
a strong dependence between buildroot, the linux kernel and kernel additions and modifications by ST Microelectronics. On top there's also
a dependency regarding the build tools involved (gcc in particular) on the build host. In case of the current version of Lab Assignment 3 we need
a gcc version not newer than nine (gcc-9). Otherwise we'll run into problems when buildroot tries to compile the device tree parser.
- make sure your on a host with gcc-9 compiler (eda1, zaphod)
- consider using multiple host / spreading across servers - the build process will take a lot of time
- zaphod is faster than eda1 and has more memory
Create a new directory and clone the buildroot repository and switch to version 2020.05.3:
Codeblock | ||
---|---|---|
| ||
mkdir lab3
cd lab3
git clone git://git.buildroot.net/buildroot
cd buildroot
git checkout -b bme280 2020.05.3
make stm32mp157c_dk2_defconfig
make menuconfig
make |
Enabling the I2C bus
An introduction to the Device Tree
...
This stm32mp157c-dk2.dts
describes the hardware of our Discovery Kit 2 platform. In fact, it only describes what is specific to the Discovery Kit 2: the display panel, the touchscreen, the WiFi and Bluetooth chip. Everything else is common with the Discovery Kit 1 platform, which is why the stm32mp157c-dk2.dts
file includes the arm/boot/dts/stm32mp157a-dk1.dts file. Indeed, stm32mp157a-dk1.dts
describes the hardware on the Discovery Kit 1, which is the same as the Discovery Kit 2, without the display, touchscreen and WiFi/Bluetooth chip.
Codeblock | ||||
---|---|---|---|---|
| ||||
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* * Copyright (C) STMicroelectronics 2019 - All Rights Reserved * Author: Alexandre Torgue <alexandre.torgue@st.com> for STMicroelectronics. */ /dts-v1/; #include "stm32mp157.dtsi" #include "stm32mp15-pinctrl.dtsi" #include "stm32mp15xxac-pinctrl.dtsi" #include "stm32mp15xx-dkx.dtsi" / { model = "STMicroelectronics STM32MP157A-DK1 Discovery Board"; compatible = "st,stm32mp157a-dk1", "st,stm32mp157"; aliases { ethernet0 = ðernet0; serial0 = &uart4; serial1 = &usart3; serial2 = &uart7; }; chosen { stdout-path = "serial0:115200n8"; }; }; |
...
- arm/boot/dts/stm32mp157c.dtsi, which describes all the devices inside the STM32MP157 system-on-chip. It will be used by all Device Tree files describing boards based on the STM32MP157 processor.
- arm/boot/dts/stm32mp157c-m4-srm.dtsi, which describes the Cortex-M4 resources, which we are not going to discuss further for the moment
- arm/boot/dts/stm32mp157cac-pinctrl.dtsi, which provides some pin-muxing related details, which are specific to the SoC package being used.
...
- .
...
I2C controllers in the Device Tree
...
At this point, our linux/
folder contains the exact same source code as what Buildroot has retrieved. It is time to make our Device Tree change by editing arch/arm/boot/dts/stm32mp157c-dk2.dtsdts
and at the end of it, add:
...
If you look closely at what Buildroot will do, it will do a rsync of the Linux kernel source code from your linux/
Git repository to output/build/linux-custom
in Buildroot, and then do the build. You can check make sure that your I2C5 change is there!output/build/linux-custom/arch/arm/boot/dts/stm32mp157c-dk2.dts
to
...