buildroot.busybox.net archive mirror
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] configs/stm32f746g-disco: new defconfig
@ 2022-09-22  7:42 Waldemar Brodkorb
  2023-02-06 22:02 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Waldemar Brodkorb @ 2022-09-22  7:42 UTC (permalink / raw)
  To: buildroot

Add support for ST Microsystems STM32F746G-DISCO board.
See here for hardware details:
https://www.st.com/en/evaluation-tools/32f746gdiscovery.html

The LCD and Ethernet are _not_ yet supported by Linux upstream.
The RAM is very limited, so the init script is stolen from the
RISCV noMMU systems to support booting to a shell without crashing.

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
---
 DEVELOPERS                                    |  2 +
 .../stm32f746g-disco/extlinux.conf            |  4 ++
 .../stm32f746g-disco/flash.sh                 | 18 ++++++++
 .../stm32f746g-disco/genimage.cfg             | 27 ++++++++++++
 .../stm32f746g-disco/linux.fragment           |  6 +++
 .../stm32f746g-disco/post-build.sh            |  4 ++
 .../stm32f746g-disco/readme.txt               | 31 ++++++++++++++
 .../stm32f746g-disco/rootfs_overlay/init      |  1 +
 .../stm32f746g-disco/rootfs_overlay/sbin/init | 41 +++++++++++++++++++
 configs/stm32f746g_disco_sd_defconfig         | 32 +++++++++++++++
 10 files changed, 166 insertions(+)
 create mode 100644 board/stmicroelectronics/stm32f746g-disco/extlinux.conf
 create mode 100755 board/stmicroelectronics/stm32f746g-disco/flash.sh
 create mode 100644 board/stmicroelectronics/stm32f746g-disco/genimage.cfg
 create mode 100644 board/stmicroelectronics/stm32f746g-disco/linux.fragment
 create mode 100755 board/stmicroelectronics/stm32f746g-disco/post-build.sh
 create mode 100644 board/stmicroelectronics/stm32f746g-disco/readme.txt
 create mode 120000 board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/init
 create mode 100755 board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/sbin/init
 create mode 100644 configs/stm32f746g_disco_sd_defconfig

diff --git a/DEVELOPERS b/DEVELOPERS
index 14b91fca8d..484bb90bcf 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -3037,6 +3037,8 @@ F:	package/mksh/
 F:	package/ruby/
 F:	package/uclibc/
 F:	package/uclibc-ng-test/
+F:	board/stmicroelectronics/stm32f746g-disco/
+F:	configs/stm32f746g_disco_sd_defconfig
 
 N:	Will Newton <will.newton@gmail.com>
 F:	package/enchant/
diff --git a/board/stmicroelectronics/stm32f746g-disco/extlinux.conf b/board/stmicroelectronics/stm32f746g-disco/extlinux.conf
new file mode 100644
index 0000000000..bb79c0b412
--- /dev/null
+++ b/board/stmicroelectronics/stm32f746g-disco/extlinux.conf
@@ -0,0 +1,4 @@
+label stm32f746-disco-buildroot
+  kernel /zImage
+  devicetree /stm32f746-disco.dtb
+  append console=ttySTM0,115200 root=/dev/mmcblk0p2 rw rootwait consoleblank=0 ignore_loglevel
diff --git a/board/stmicroelectronics/stm32f746g-disco/flash.sh b/board/stmicroelectronics/stm32f746g-disco/flash.sh
new file mode 100755
index 0000000000..d4e98cc808
--- /dev/null
+++ b/board/stmicroelectronics/stm32f746g-disco/flash.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+OUTPUT_DIR=$1
+
+if ! test -d "${OUTPUT_DIR}" ; then
+    echo "ERROR: no output directory specified."
+    echo "Usage: $0 OUTPUT_DIR"
+    exit 1
+fi
+
+${OUTPUT_DIR}/host/bin/openocd -f board/stm32f7discovery.cfg \
+  -c "init" \
+  -c "reset init" \
+  -c "flash probe 0" \
+  -c "flash info 0" \
+  -c "flash write_image erase ${OUTPUT_DIR}/images/u-boot-dtb.bin 0x08000000" \
+  -c "reset run" \
+  -c "shutdown"
diff --git a/board/stmicroelectronics/stm32f746g-disco/genimage.cfg b/board/stmicroelectronics/stm32f746g-disco/genimage.cfg
new file mode 100644
index 0000000000..6743d41972
--- /dev/null
+++ b/board/stmicroelectronics/stm32f746g-disco/genimage.cfg
@@ -0,0 +1,27 @@
+image boot.vfat {
+	vfat {
+		files = {
+			"zImage",
+			"stm32f746-disco.dtb",
+			"extlinux"
+		}
+	}
+
+	size = 16M
+}
+
+image sdcard.img {
+	hdimage {
+	}
+
+	partition u-boot {
+		partition-type = 0xC
+		image = "boot.vfat"
+	}
+
+	partition rootfs {
+		partition-type = 0x83
+		image = "rootfs.ext2"
+		size = 32M
+	}
+}
diff --git a/board/stmicroelectronics/stm32f746g-disco/linux.fragment b/board/stmicroelectronics/stm32f746g-disco/linux.fragment
new file mode 100644
index 0000000000..de2e14be6f
--- /dev/null
+++ b/board/stmicroelectronics/stm32f746g-disco/linux.fragment
@@ -0,0 +1,6 @@
+CONFIG_SET_MEM_PARAM=y
+CONFIG_DRAM_BASE=0xC0000000
+CONFIG_DRAM_SIZE=0x01000000
+CONFIG_FLASH_MEM_BASE=0x08000000
+CONFIG_FLASH_SIZE=0x00200000
+# CONFIG_XIP_KERNEL is not set
diff --git a/board/stmicroelectronics/stm32f746g-disco/post-build.sh b/board/stmicroelectronics/stm32f746g-disco/post-build.sh
new file mode 100755
index 0000000000..ec20fca7d9
--- /dev/null
+++ b/board/stmicroelectronics/stm32f746g-disco/post-build.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+BOARD_DIR="$(dirname $0)"
+
+install -m 0644 -D $BOARD_DIR/extlinux.conf $BINARIES_DIR/extlinux/extlinux.conf
diff --git a/board/stmicroelectronics/stm32f746g-disco/readme.txt b/board/stmicroelectronics/stm32f746g-disco/readme.txt
new file mode 100644
index 0000000000..d312840ea3
--- /dev/null
+++ b/board/stmicroelectronics/stm32f746g-disco/readme.txt
@@ -0,0 +1,31 @@
+STM32F746G-DISCO
+===================
+
+This tutorial describes how to use the predefined Buildroot
+configuration for the STM32F746G-DISCO evaluation platform.
+
+Building
+--------
+
+  make stm32f746g_disco_sd_defconfig
+  make
+
+Flashing
+--------
+
+  ./board/stmicroelectronics/stm32f746-disco/flash.sh output/
+
+It will flash the U-boot bootloader.
+
+Creating SD card
+----------------
+
+Buildroot prepares an"sdcard.img" image in the output/images/ directory,
+ready to be dumped on a SD card. Launch the following command as root:
+
+  dd if=output/images/sdcard.img of=/dev/<your-sd-device>
+
+*** WARNING! This will destroy all the card content. Use with care! ***
+
+For details about the medium image layout and its content, see the
+definition in board/stmicroelectronics/stm32f746-disco/genimage.cfg.
diff --git a/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/init b/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/init
new file mode 120000
index 0000000000..a0b71977c0
--- /dev/null
+++ b/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/init
@@ -0,0 +1 @@
+/sbin/init
\ No newline at end of file
diff --git a/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/sbin/init b/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/sbin/init
new file mode 100755
index 0000000000..1285fd4420
--- /dev/null
+++ b/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/sbin/init
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# This script replaces the default busybox init process to avoid having that
+# process staying alive and sleeping in the background, (uselessly) consuming
+# precious memory.
+
+# Mount procfs and sysfs
+/bin/mount -t proc proc /proc
+/bin/mount -t sysfs sysfs /sys
+
+# When the kernel is directly booted, devtmpfs is not automatically mounted.
+# Manually mount it if needed.
+devmnt=$(mount | grep -c devtmpfs)
+if [ ${devmnt} -eq 0 ]; then
+    /bin/mount -t devtmpfs devtmpfs /dev
+fi
+
+# Use the /dev/console device node from devtmpfs if possible to not
+# confuse glibc's ttyname_r().
+# This may fail (E.G. booted with console=), and errors from exec will
+# terminate the shell, so use a subshell for the test
+if (exec 0</dev/console) 2>/dev/null; then
+    exec 0</dev/console
+    exec 1>/dev/console
+    exec 2>/dev/console
+fi
+
+# Clear memory to reduce page fragmentation
+echo 3 > /proc/sys/vm/drop_caches
+
+# Print a fun logo :)
+echo "          __  _"
+echo "         / / (_) ____   _   _ __  __"
+echo "        / /  | ||  _ \\ | | | |\\ \\/ /"
+echo "       / /___| || | | || |_| | >  < "
+echo "      /_____/|_||_| |_| \\____|/_/\\_\\"
+echo "    ST Microsystems STM32F746G-DISCO NOMMU"
+echo ""
+
+# Finally, let's start an interactive shell
+exec /bin/sh
diff --git a/configs/stm32f746g_disco_sd_defconfig b/configs/stm32f746g_disco_sd_defconfig
new file mode 100644
index 0000000000..7061a8a6ed
--- /dev/null
+++ b/configs/stm32f746g_disco_sd_defconfig
@@ -0,0 +1,32 @@
+BR2_arm=y
+BR2_cortex_m7=y
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_19=y
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/stm32f746g-disco/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/stmicroelectronics/stm32f746g-disco/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.19.9"
+BR2_LINUX_KERNEL_DEFCONFIG="stm32"
+BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/stmicroelectronics/stm32f746g-disco/linux.fragment"
+BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM=y
+BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="zImage"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="stm32f746-disco"
+BR2_PACKAGE_BUSYBOX_CONFIG="package/busybox/busybox-minimal.config"
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="32M"
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_CUSTOM_VERSION=y
+BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2022.10-rc5"
+BR2_TARGET_UBOOT_BOARDNAME="stm32f746-disco"
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="stm32f746-disco"
+BR2_TARGET_UBOOT_FORMAT_DTB_BIN=y
+BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
+BR2_PACKAGE_HOST_OPENOCD=y
+BR2_INIT_NONE=y
+BR2_ROOTFS_OVERLAY="board/stmicroelectronics/stm32f746g-disco/rootfs_overlay"
-- 
2.30.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH] configs/stm32f746g-disco: new defconfig
  2022-09-22  7:42 [Buildroot] [PATCH] configs/stm32f746g-disco: new defconfig Waldemar Brodkorb
@ 2023-02-06 22:02 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-02-06 22:02 UTC (permalink / raw)
  To: Waldemar Brodkorb; +Cc: buildroot

On Thu, 22 Sep 2022 09:42:51 +0200
Waldemar Brodkorb <wbx@openadk.org> wrote:

> Add support for ST Microsystems STM32F746G-DISCO board.
> See here for hardware details:
> https://www.st.com/en/evaluation-tools/32f746gdiscovery.html
> 
> The LCD and Ethernet are _not_ yet supported by Linux upstream.
> The RAM is very limited, so the init script is stolen from the
> RISCV noMMU systems to support booting to a shell without crashing.
> 
> Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

Sorry for the very very slow feedback. It mostly looks good of course,
but there are two things that bother me. One very small and easy to
address, another not so difficult, but I'm not entirely sure how to
address it.

See below.

> diff --git a/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/sbin/init b/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/sbin/init
> new file mode 100755
> index 0000000000..1285fd4420
> --- /dev/null
> +++ b/board/stmicroelectronics/stm32f746g-disco/rootfs_overlay/sbin/init
> @@ -0,0 +1,41 @@
> +#!/bin/sh
> +
> +# This script replaces the default busybox init process to avoid having that
> +# process staying alive and sleeping in the background, (uselessly) consuming
> +# precious memory.

[...]

What bothers me is that board/canaan/k210-soc/rootfs_overlay/sbin/init
is exactly the same script, so we're duplicating it. Can we do
something about it? I'm not exactly sure. A minimal "init" package for
noMMU systems maybe?

Also, do you really need this minimal init?
stm32f469_disco_sd_defconfig doesn't need it apparently.

> +BR2_TARGET_UBOOT=y
> +BR2_TARGET_UBOOT_CUSTOM_VERSION=y
> +BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2022.10-rc5"

Can we switch to a non-rc version?

Thanks a lot!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-06 22:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22  7:42 [Buildroot] [PATCH] configs/stm32f746g-disco: new defconfig Waldemar Brodkorb
2023-02-06 22:02 ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).