Skip to contentSkip to conversation

Add defconfig for STM32MP157 Discovery Kit

PATCH New Thomas Petazzoni 3 participants 9 messages Apr 26, 2019 – Aug 3, 2019 Arm STM32

lore
Share & tools
lore
#0 lore raw

v2 cover Add defconfig for STM32MP157 Discovery Kit

Hello,

This set of patches add a defconfig for the STM32MP157 Discovery Kit platform. The first three patches are preparation patches and the last one adds the defconfig itself and its related files.

Changes since v1:

- Add missing BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y option in the defconfig

Thanks!

Thomas

Thomas Petazzoni (4):
package/genimage: bump version
package/genimage: add patch to support bootable flag in GPT tables boot/uboot: add option to pass custom variables to U-Boot build configs/stm32mp157_dk: new defconfig

 .gitlab-ci.yml                                |   1 +
 DEVELOPERS                                    |   2 +
 .../stm32mp157-dk/genimage.cfg                |  24 +++
 .../stm32mp157-dk/linux.config                | 182 ++++++++++++++++++
 .../overlay/boot/extlinux/extlinux.conf       |   4 +
 .../stm32mp157-dk/readme.txt                  |  38 ++++
 .../stm32mp157-dk/uboot-fragment.config       |   1 +
 boot/uboot/Config.in                          |   6 +
 boot/uboot/uboot.mk                           |   3 +-
 configs/stm32mp157_dk_defconfig               |  31 +++
 ...dd-support-for-bootable-flags-on-GPT.patch |  45 +++++
 package/genimage/genimage.hash                |   2 +-
 package/genimage/genimage.mk                  |   7 +-
 13 files changed, 341 insertions(+), 5 deletions(-)
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/genimage.cfg
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/linux.config
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/overlay/boot/extlinux/extlinux.conf
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/readme.txt
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/uboot-fragment.config
 create mode 100644 configs/stm32mp157_dk_defconfig
 create mode 100644 package/genimage/0001-image-hd-add-support-for-bootable-flags-on-GPT.patch
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/4 package/genimage: bump version

This commit bumps the genimage version to a not yet released commit, in order to benefit from the GPT support that was added in upstream genimage.

Indeed, we are about to add a defconfig for the STM32MP157 Discovery Kit platform and the STM32MP157 BootROM loads the first stage bootloader from the GPT partitions named fsbl*, which requires a GPT partition table.

We will of course be able to switch back to a released version once a release that includes GPT support will have been done upstream.

---
 package/genimage/genimage.hash | 2 +-
 package/genimage/genimage.mk   | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
package/genimage/genimage.hash +1 -1
index 095eb1413f..00af52486b 100644
@@ -1,2 +1,2 @@
 # Locally calculated
-sha256	5a36b2c1387007c2d6535a722ee257a387d0913bddcf8a94d460e6acd4d01859	genimage-10.tar.xz
+sha256	fd19ef94a82a014178255e181af91b403be6bebf217bae4c2541dbeeb1d4e1c9  genimage-abc1c32378debaccdfb63c711de56f3a1becb84b.tar.gz
package/genimage/genimage.mk +4 -3
index 393c3e9b94..35502532f9 100644
@@ -4,10 +4,11 @@
 #
 ################################################################################
 
-GENIMAGE_VERSION = 10
-GENIMAGE_SOURCE = genimage-$(GENIMAGE_VERSION).tar.xz
-GENIMAGE_SITE = https://github.com/pengutronix/genimage/releases/download/v$(GENIMAGE_VERSION)
+GENIMAGE_VERSION = abc1c32378debaccdfb63c711de56f3a1becb84b
+GENIMAGE_SITE = $(call github,pengutronix,genimage,$(GENIMAGE_VERSION))
 HOST_GENIMAGE_DEPENDENCIES = host-pkgconf host-libconfuse
+# fetching from git
+GENIMAGE_AUTORECONF = YES
 GENIMAGE_LICENSE = GPL-2.0
 GENIMAGE_LICENSE_FILES = COPYING
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 1/4 package/genimage: bump version

Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

This commit bumps the genimage version to a not yet released commit, in order to benefit from the GPT support that was added in upstream genimage.

Indeed, we are about to add a defconfig for the STM32MP157 Discovery Kit platform and the STM32MP157 BootROM loads the first stage bootloader from the GPT partitions named fsbl*, which requires a GPT partition table.

Quoted 4 lines

We will of course be able to switch back to a released version once a release that includes GPT support will have been done upstream.

Do you know when v11 is planned? genimage-10 was released more than 1 year ago by now (Mar 29 2018).

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v2 1/4 package/genimage: bump version

Hello Peter,

Quoted 2 lines · On Sat, 27 Apr 2019 14:23:36 +0200 Peter Korsgaard <[email protected]> wrote:

Do you know when v11 is planned? genimage-10 was released more than 1 year ago by now (Mar 29 2018).

As discussed on IRC, I have filled in an issue in genimage tracker, and the upstream developer said he would make a release in the near future:

https://github.com/pengutronix/genimage/issues/63

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH v2 1/4 package/genimage: bump version

Hi Thomas,

Le 16/05/2019 ? 19:45, Thomas Petazzoni a ?crit?:

Quoted 5 lines

Hello Peter,

On Sat, 27 Apr 2019 14:23:36 +0200
Peter Korsgaard <[email protected]> wrote:

Quoted 7 lines
Quoted 2 lines

Do you know when v11 is planned? genimage-10 was released more than 1 year ago by now (Mar 29 2018).

As discussed on IRC, I have filled in an issue in genimage tracker, and the upstream developer said he would make a release in the near future:

https://github.com/pengutronix/genimage/issues/63

The 2 first patches of this series are not needed anymore since genimage 11 was merged

https://git.buildroot.net/buildroot/commit/?id=b9ac298a027f3c71a3aaae12e63eba7df8ce7a14

I'm marking theses two patches superseded in patchwork.

Best regards,
Romain

Quoted 5 lines

Best regards,

Thomas

#5 lore raw

PATCH v2 2/4 package/genimage: add patch to support bootable flag in GPT tables

In reply to Thomas Petazzoni

This commit adds a patch, submitted upstream, to add support for setting the bootable flag in GPT partition tables. While we normally don't accept feature patches in Buildroot, this one is really minimal (two lines of code) and is in fact necessary for the STM32MP157 Discovery Kit defconfig.

Indeed, the STM32MP157 BootROM loads the first stage bootloader from the GPT partitions named fsbl*, which requires a GPT partition table. But then, the "U-Boot Generic Distro" mechanism identifies the GPT partition that contains the extlinux.conf file to use thanks to the "bootable" flag of GPT partitions.

---
 ...dd-support-for-bootable-flags-on-GPT.patch | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 package/genimage/0001-image-hd-add-support-for-bootable-flags-on-GPT.patch
package/genimage/0001-image-hd-add-support-for-bootable-flags-on-GPT.patch new file +45 -0
new file mode 100644
index 0000000000..03cc5dd39d
@@ -0,0 +1,45 @@
+From f23a09b177d9a55679fd3a57951313b8a34dc4d9 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Tue, 23 Apr 2019 14:09:42 +0200
+Subject: [PATCH] image-hd: add support for bootable flags on GPT
+
+Bit 2 of the GPT partition table entry "flags" attribute allows to
+mark the partition as bootable, so we add support for setting this
+flag, using the same bootable flag used for MBR partition tables.
+
+Setting this flag is useful to properly support the "Generic Distro"
+concept from U-Boot [1], which searches for boot scripts in the
+bootable partition.
+
+[1] http://git.denx.de/?p=u-boot.git;a=blob;f=doc/README.distro
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+Upstream: https://github.com/pengutronix/genimage/pull/58
+---
+ image-hd.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/image-hd.c b/image-hd.c
+index 2c2860c..1f80ae7 100644
+--- a/image-hd.c
++++ b/image-hd.c
+@@ -78,6 +78,8 @@ struct gpt_partition_entry {
+ #define GPT_SECTORS		(1 + GPT_ENTRIES * sizeof(struct gpt_partition_entry) / 512)
+ #define GPT_REVISION_1_0	0x00010000
+ 
++#define GPT_PE_FLAG_BOOTABLE	(1 << 2)
++
+ static void hdimage_setup_chs(unsigned int lba, unsigned char *chs)
+ {
+ 	const unsigned int hpc = 255;
+@@ -275,6 +277,7 @@ static int hdimage_insert_gpt(struct image *image, struct list_head *partitions)
+ 		uuid_parse(part->partition_uuid, table[i].uuid);
+ 		table[i].first_lba = htole64(part->offset/512);
+ 		table[i].last_lba = htole64((part->offset + part->size)/512 - 1);
++		table[i].flags = part->bootable ? GPT_PE_FLAG_BOOTABLE : 0;
+ 		for (j = 0; j < strlen(part->name) && j < 36; j++)
+ 			table[i].name[j] = htole16(part->name[j]);
+ 		i++;
+-- 
+2.20.1
+
Signature · 1 line
2.20.1
#6 lore raw

PATCH v2 3/4 boot/uboot: add option to pass custom variables to U-Boot build

In reply to Thomas Petazzoni

U-Boot supports a number of environment variables to pass specific information. The following patches were submitted in the past to one some specific Config.in option to pass some of these variables:

- http://patchwork.ozlabs.org/patch/881197/ proposed an option to pass a custom EXT_DTB= variable

- http://patchwork.ozlabs.org/patch/1018245/ proposed an option to pass a custom DEVICE_TREE= variable

Instead of adding one Config.in option for each of those variables, let's provide a generic mechanism to pass arbitrary variables during U-Boot build step.

Cc Konstantin Porotchkin <[email protected]>
Cc Clemens Gruber <[email protected]>
---
 boot/uboot/Config.in | 6 ++++++
 boot/uboot/uboot.mk  | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)
boot/uboot/Config.in +6 -0
index 33b7e67ff7..799c201259 100644
@@ -550,4 +550,10 @@ config BR2_TARGET_UBOOT_CUSTOM_DTS_PATH
 
 endif
 
+config BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS
+	string "Custom make options"
+	help
+	  List of custom make options passed at build time. Can be
+	  used for example to pass a DEVICE_TREE= value.
+
 endif # BR2_TARGET_UBOOT
boot/uboot/uboot.mk +2 -1
index ae09c37d84..aac5b96451 100644
@@ -133,7 +133,8 @@ UBOOT_MAKE_OPTS += \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
 	ARCH=$(UBOOT_ARCH) \
 	HOSTCC="$(HOSTCC) $(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS)))" \
-	HOSTLDFLAGS="$(HOST_LDFLAGS)"
+	HOSTLDFLAGS="$(HOST_LDFLAGS)" \
+	$(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS))
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31),y)
 UBOOT_DEPENDENCIES += arm-trusted-firmware
Signature · 1 line
2.20.1
#7 lore raw

PATCH v2 3/4 boot/uboot: add option to pass custom variables to U-Boot build

Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

U-Boot supports a number of environment variables to pass specific information. The following patches were submitted in the past to one some specific Config.in option to pass some of these variables:

- http://patchwork.ozlabs.org/patch/881197/ proposed an option to pass a custom EXT_DTB= variable

- http://patchwork.ozlabs.org/patch/1018245/ proposed an option to pass a custom DEVICE_TREE= variable

Quoted 7 lines

Instead of adding one Config.in option for each of those variables, let's provide a generic mechanism to pass arbitrary variables during U-Boot build step.

Cc Konstantin Porotchkin <[email protected]>
Cc Clemens Gruber <[email protected]>

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#8 lore raw

PATCH v2 4/4 configs/stm32mp157_dk: new defconfig

In reply to Thomas Petazzoni

This commit adds a minimal defconfig to build a Buildroot system for the STM32MP157 Discovery Kit, which is the low-cost evaluation platform for the new STM32MP157 system-on-chip from ST. This system-on-chip features a single or dual Cortex-A7, a single Cortex-M4, and a wide variety of peripherals.

This commit includes a custom linux configuration file, because there is no specific defconfig for this platform in the kernel, only multi_v7_defconfig supports it, which is really a massive defconfig. That's why a custom linux configuration file is added.

A small U-Boot config fragment allows to disable the watchdog, so that userspace by default doesn't need to have a watchdog daemon running.

The vendor U-Boot and Linux trees are used for the moment, but the platform support is being upstreamed, so switching to upstream versions will be possible in the relatively near future.

---
 .gitlab-ci.yml                                |   1 +
 DEVELOPERS                                    |   2 +
 .../stm32mp157-dk/genimage.cfg                |  24 +++
 .../stm32mp157-dk/linux.config                | 182 ++++++++++++++++++
 .../overlay/boot/extlinux/extlinux.conf       |   4 +
 .../stm32mp157-dk/readme.txt                  |  38 ++++
 .../stm32mp157-dk/uboot-fragment.config       |   1 +
 configs/stm32mp157_dk_defconfig               |  31 +++
 8 files changed, 283 insertions(+)
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/genimage.cfg
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/linux.config
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/overlay/boot/extlinux/extlinux.conf
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/readme.txt
 create mode 100644 board/stmicroelectronics/stm32mp157-dk/uboot-fragment.config
 create mode 100644 configs/stm32mp157_dk_defconfig
.gitlab-ci.yml +1 -0
index e9869be784..e1428c0037 100644
@@ -269,6 +269,7 @@ solidrun_macchiatobin_mainline_defconfig: { extends: .defconfig }
 solidrun_macchiatobin_marvell_defconfig: { extends: .defconfig }
 stm32f429_disco_defconfig: { extends: .defconfig }
 stm32f469_disco_defconfig: { extends: .defconfig }
+stm32mp157_dk_defconfig: { extends: .defconfig }
 toradex_apalis_imx6_defconfig: { extends: .defconfig }
 ts4800_defconfig: { extends: .defconfig }
 ts4900_defconfig: { extends: .defconfig }
DEVELOPERS +2 -0
index 56556413aa..3a16808341 100644
@@ -2170,9 +2170,11 @@ F:	toolchain/
 
 N:	Thomas Petazzoni <[email protected]>
 F:	arch/Config.in.arm
+F:	board/stmicroelectronics/stm32mp157-dk/
 F:	boot/boot-wrapper-aarch64/
 F:	boot/grub2/
 F:	boot/gummiboot/
+F:	configs/stm32mp157_dk_defconfig
 F:	package/android-tools/
 F:	package/b43-firmware/
 F:	package/b43-fwcutter/
board/stmicroelectronics/stm32mp157-dk/genimage.cfg new file +24 -0
new file mode 100644
index 0000000000..33c418b9a5
@@ -0,0 +1,24 @@
+image sdcard.img {
+	hdimage {
+		gpt = "true"
+	}
+
+	partition fsbl1 {
+		image = "u-boot-spl.stm32"
+	}
+
+	partition fsbl2 {
+		image = "u-boot-spl.stm32"
+	}
+
+	partition uboot {
+		image = "u-boot.img"
+	}
+
+	partition rootfs {
+		image = "rootfs.ext4"
+		partition-type = 0x83
+		bootable = "yes"
+		size = 256M
+	}
+}
board/stmicroelectronics/stm32mp157-dk/linux.config new file +182 -0

182 lines not on this page · raw message

board/stmicroelectronics/stm32mp157-dk/overlay/boot/extlinux/extlinux.conf new file +4 -0
new file mode 100644
index 0000000000..325f3fc30e
@@ -0,0 +1,4 @@
+label stm32mp15-buildroot
+  kernel /boot/zImage
+  devicetree /boot/stm32mp157c-dk2.dtb
+  append root=/dev/mmcblk0p4 rootwait
board/stmicroelectronics/stm32mp157-dk/readme.txt new file +38 -0
new file mode 100644
index 0000000000..ac2061a234
@@ -0,0 +1,38 @@
+STM32MP157 Discovery Kit
+
+Intro
+=====
+
+This configuration supports the STM32MP157 Discovery Kit 2 (DK2)
+platform:
+
+  https://www.st.com/en/evaluation-tools/stm32mp157c-dk2.html
+
+How to build
+============
+
+ $ make stm32mp157_dk_defconfig
+ $ make
+
+How to write the microSD card
+=============================
+
+Once the build process is finished you will have an image called
+"sdcard.img" in the output/images/ directory.
+
+Copy the bootable "sdcard.img" onto an microSD card with "dd":
+
+  $ sudo dd if=output/images/sdcard.img of=/dev/sdX
+
+Boot the board
+==============
+
+ (1) Insert the microSD card in connector CN15
+
+ (2) Plug a micro-USB cable in connector CN11 and run your serial
+     communication program on /dev/ttyACM0.
+
+ (3) Plug a USB-C cable in CN6 to power-up the board.
+
+ (4) The system will start, with the console on UART, but also visible
+     on the screen.
board/stmicroelectronics/stm32mp157-dk/uboot-fragment.config new file +1 -0
new file mode 100644
index 0000000000..a278ce9e23
@@ -0,0 +1 @@
+# CONFIG_STM32MP_WATCHDOG is not set
configs/stm32mp157_dk_defconfig new file +31 -0
new file mode 100644
index 0000000000..59a9101776
@@ -0,0 +1,31 @@
+BR2_arm=y
+BR2_cortex_a7=y
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
+BR2_ROOTFS_OVERLAY="board/stmicroelectronics/stm32mp157-dk/overlay/"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/stmicroelectronics/stm32mp157-dk/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
+BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,STMicroelectronics,linux,v4.19-stm32mp-r1.2)/linux-v4.19-stm32mp-r1.2.tar.gz"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/stmicroelectronics/stm32mp157-dk/linux.config"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="stm32mp157c-dk2"
+BR2_LINUX_KERNEL_INSTALL_TARGET=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
+BR2_TARGET_UBOOT_CUSTOM_GIT=y
+BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/STMicroelectronics/u-boot.git"
+BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="v2018.11-stm32mp-r2.1"
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="stm32mp15_basic"
+BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="board/stmicroelectronics/stm32mp157-dk/uboot-fragment.config"
+# BR2_TARGET_UBOOT_FORMAT_BIN is not set
+BR2_TARGET_UBOOT_FORMAT_IMG=y
+BR2_TARGET_UBOOT_SPL=y
+BR2_TARGET_UBOOT_SPL_NAME="spl/u-boot-spl.stm32"
+BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS="DEVICE_TREE=stm32mp157c-dk2"
+BR2_PACKAGE_HOST_GENIMAGE=y
Signature · 1 line
2.20.1