All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] configs/stm32f429_disco: fix kernel bootup
@ 2021-11-01 18:24 Dario Binacchi via buildroot
  2021-11-08 12:25 ` Christophe Priouzeau
  2021-11-09 22:00 ` Arnout Vandecappelle
  0 siblings, 2 replies; 5+ messages in thread
From: Dario Binacchi via buildroot @ 2021-11-01 18:24 UTC (permalink / raw)
  To: buildroot; +Cc: Christophe Priouzeau, Dario Binacchi

The kernel generated by the configuration for the STM32f429-discovery
board is buggy:

 Unhandled exception: IPSR = 00000006 LR = fffffff1
 CPU: 0 PID: 1 Comm: init Not tainted 4.11.0 #2
 Hardware name: STM32 (Device Tree Support)
 task: 9041a000 task.stack: 907c0000
 PC is at ret_fast_syscall+0x2/0x4a
 LR is at tty_ioctl+0x1ad/0x75c
 pc : [<0800d942>]    lr : [<080c2e05>]    psr: 4000000b
 sp : 907c1fa8  ip : 0000001c  fp : 905961a2
 r10: 00000000  r9 : 907c0000  r8 : 0800dae0
 r7 : 00000036  r6 : 905e7e60  r5 : 00000000  r4 : 905e7ebc
 r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 00000000
 xPSR: 4000000b
 CPU: 0 PID: 1 Comm: init Not tainted 4.11.0 #2
 Hardware name: STM32 (Device Tree Support)
 [<0800fbf9>] (unwind_backtrace) from [<0800f05b>] (show_stack+0xb/0xc)
 [<0800f05b>] (show_stack) from [<0800f553>] (__invalid_entry+0x4b/0x4c)

Inspired by commit a3e3d9c198 ("configs/stm32f469_disco_xip_defconfig:
alternative defconfig for XIP") I updated the stm32f429_disco_defconfig
configuration to use a newer kernel. Current setup kernel + rootfs fits
in 1.6MB on-chip flash memory.

Fixes:
 - Move kernel to new flash bank due to growth of dtb size.
 - Fix kernel start address in afboot-stm32 bootloader.

For better binary size optimization gcc LTO is turned on.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
---
 .../stm32f429-disco/flash.sh                  |   2 +-
 .../stm32f429-disco/linux.config              | 120 ++++++++++++++++++
 ...9i-disco-update-kernel-start-address.patch |  30 +++++
 ...sco-don-t-force-init-in-chosen-boota.patch |  32 -----
 configs/stm32f429_disco_defconfig             |   9 +-
 5 files changed, 156 insertions(+), 37 deletions(-)
 create mode 100644 board/stmicroelectronics/stm32f429-disco/linux.config
 create mode 100644 board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
 delete mode 100644 board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch

diff --git a/board/stmicroelectronics/stm32f429-disco/flash.sh b/board/stmicroelectronics/stm32f429-disco/flash.sh
index b19e0a6019..3e2bf121d3 100755
--- a/board/stmicroelectronics/stm32f429-disco/flash.sh
+++ b/board/stmicroelectronics/stm32f429-disco/flash.sh
@@ -21,6 +21,6 @@ ${OUTPUT_DIR}/host/bin/openocd -f board/${BOARD_NAME}.cfg \
   -c "flash info 0" \
   -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f429i-disco.bin 0x08000000" \
   -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f429-disco.dtb 0x08004000" \
-  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x08008000" \
+  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x0800C000" \
   -c "reset run" \
   -c "shutdown"
diff --git a/board/stmicroelectronics/stm32f429-disco/linux.config b/board/stmicroelectronics/stm32f429-disco/linux.config
new file mode 100644
index 0000000000..7b5c60f180
--- /dev/null
+++ b/board/stmicroelectronics/stm32f429-disco/linux.config
@@ -0,0 +1,120 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_KERNEL_XZ=y
+CONFIG_NO_HZ_IDLE=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_PREEMPT=y
+CONFIG_LOG_BUF_SHIFT=12
+CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=10
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE="${BR_BINARIES_DIR}/rootfs.cpio"
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+# CONFIG_RD_ZSTD is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_MULTIUSER is not set
+# CONFIG_SYSFS_SYSCALL is not set
+# CONFIG_FHANDLE is not set
+CONFIG_POSIX_TIMERS=y
+CONFIG_BUG=y
+# CONFIG_BASE_FULL is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_AIO is not set
+# CONFIG_IO_URING is not set
+# CONFIG_ADVISE_SYSCALLS is not set
+# CONFIG_MEMBARRIER is not set
+# CONFIG_KALLSYMS is not set
+CONFIG_KCMP=y
+# CONFIG_RSEQ is not set
+CONFIG_EMBEDDED=y
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_SLOB=y
+# CONFIG_SLAB_MERGE_DEFAULT is not set
+# CONFIG_MMU is not set
+CONFIG_ARCH_STM32=y
+# CONFIG_MACH_STM32F469 is not set
+# CONFIG_MACH_STM32F746 is not set
+# CONFIG_MACH_STM32F769 is not set
+# CONFIG_MACH_STM32H743 is not set
+CONFIG_CPU_V7M_NUM_IRQ=240
+# CONFIG_ARM_DMA_MEM_BUFFERABLE is not set
+CONFIG_SET_MEM_PARAM=y
+CONFIG_DRAM_BASE=0x90000000
+CONFIG_DRAM_SIZE=0x00800000
+CONFIG_HZ_1000=y
+# CONFIG_ATAGS is not set
+CONFIG_XIP_KERNEL=y
+CONFIG_XIP_PHYS_ADDR=0x0800C000
+CONFIG_XIP_DEFLATED_DATA=y
+# CONFIG_SUSPEND is not set
+# CONFIG_STACKPROTECTOR is not set
+# CONFIG_COMPAT_32BIT_TIME is not set
+# CONFIG_GCC_PLUGINS is not set
+# CONFIG_BLOCK is not set
+CONFIG_BINFMT_FLAT=y
+CONFIG_BINFMT_SHARED_FLAT=y
+# CONFIG_COREDUMP is not set
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_ALLOW_DEV_COREDUMP is not set
+CONFIG_EEPROM_93CX6=y
+# CONFIG_INPUT is not set
+# CONFIG_VT is not set
+# CONFIG_UNIX98_PTYS is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_LDISC_AUTOLOAD is not set
+CONFIG_SERIAL_STM32=y
+CONFIG_SERIAL_STM32_CONSOLE=y
+# CONFIG_DEVMEM is not set
+# CONFIG_HWMON is not set
+CONFIG_WATCHDOG=y
+CONFIG_MFD_STM32_TIMERS=y
+# CONFIG_USB_SUPPORT is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_STM32=y
+CONFIG_DMADEVICES=y
+CONFIG_STM32_DMA=y
+CONFIG_STM32_DMAMUX=y
+CONFIG_STM32_MDMA=y
+CONFIG_SYNC_FILE=y
+# CONFIG_VIRTIO_MENU is not set
+# CONFIG_VHOST_MENU is not set
+CONFIG_IIO=y
+CONFIG_IIO_BUFFER=y
+CONFIG_IIO_TRIGGERED_BUFFER=y
+CONFIG_IIO_STM32_TIMER_TRIGGER=y
+# CONFIG_FILE_LOCKING is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+# CONFIG_PROC_SYSCTL is not set
+CONFIG_CONFIGFS_FS=y
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_NLS=y
+CONFIG_PRINTK_TIME=y
+CONFIG_CONSOLE_LOGLEVEL_DEFAULT=15
+CONFIG_CONSOLE_LOGLEVEL_QUIET=15
+CONFIG_MESSAGE_LOGLEVEL_DEFAULT=7
+# CONFIG_SYMBOLIC_ERRNAME is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_DEBUG_MISC is not set
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_RCU_TRACE is not set
+# CONFIG_RUNTIME_TESTING_MENU is not set
diff --git a/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch b/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
new file mode 100644
index 0000000000..715ade694d
--- /dev/null
+++ b/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
@@ -0,0 +1,30 @@
+From 9cdee858b36e2de7d6717e56fd3d08ad9ad25cde Mon Sep 17 00:00:00 2001
+From: Dario Binacchi <dariobin@libero.it>
+Date: Sun, 31 Oct 2021 08:52:52 +0100
+Subject: [PATCH] stm32f429i-disco: update kernel start address
+
+As of GNU/Linux v5.14 kernel device tree binary grows above 0x08008000
+and overwrites kernel binary.
+Therefore this commit moves kernel to the next flash bank.
+
+Signed-off-by: Dario Binacchi <dariobin@libero.it>
+---
+ stm32f429i-disco.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/stm32f429i-disco.c b/stm32f429i-disco.c
+index 8b27641..14a6f1e 100644
+--- a/stm32f429i-disco.c
++++ b/stm32f429i-disco.c
+@@ -88,7 +88,7 @@ static void fmc_wait_busy(void)
+ 
+ void start_kernel(void)
+ {
+-	void (*kernel)(uint32_t reserved, uint32_t mach, uint32_t dt) = (void (*)(uint32_t, uint32_t, uint32_t))(0x08008000 | 1);
++	void (*kernel)(uint32_t reserved, uint32_t mach, uint32_t dt) = (void (*)(uint32_t, uint32_t, uint32_t))(0x0800C000 | 1);
+ 
+ 	kernel(0, ~0UL, 0x08004000);
+ }
+-- 
+2.17.1
+
diff --git a/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch b/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
deleted file mode 100644
index d6d5c61aae..0000000000
--- a/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From ded9afa688184b3240a92c2b8f114c545a09bc3f Mon Sep 17 00:00:00 2001
-From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Date: Sat, 12 Mar 2016 23:14:41 +0100
-Subject: [PATCH] ARM: stm32f249-disco: don't force init= in /chosen/bootargs
-
-There is no reason to override the kernel's default init= value, as
-this breaks userspace that assumes the kernel default of /init is
-used. Since stm32 is often used with a minimal bootloader
-(afboot-stm32) that doesn't provide any mechanism to override the DTB,
-we need to adjust the kernel command line in the Device Tree source.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
----
- arch/arm/boot/dts/stm32f429-disco.dts | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/arch/arm/boot/dts/stm32f429-disco.dts b/arch/arm/boot/dts/stm32f429-disco.dts
-index f0b731d..2bae81c 100644
---- a/arch/arm/boot/dts/stm32f429-disco.dts
-+++ b/arch/arm/boot/dts/stm32f429-disco.dts
-@@ -53,7 +53,7 @@
- 	compatible = "st,stm32f429i-disco", "st,stm32f429";
- 
- 	chosen {
--		bootargs = "root=/dev/ram rdinit=/linuxrc";
-+		bootargs = "root=/dev/ram";
- 		stdout-path = "serial0:115200n8";
- 	};
- 
--- 
-2.6.4
-
diff --git a/configs/stm32f429_disco_defconfig b/configs/stm32f429_disco_defconfig
index 2c0641a6c5..58367fca0b 100644
--- a/configs/stm32f429_disco_defconfig
+++ b/configs/stm32f429_disco_defconfig
@@ -1,13 +1,14 @@
 BR2_arm=y
 BR2_cortex_m4=y
 BR2_GLOBAL_PATCH_DIR="board/stmicroelectronics/stm32f429-disco/patches"
-BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_11=y
+# BR2_UCLIBC_INSTALL_UTILS is not set
+BR2_GCC_ENABLE_LTO=y
 BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/common/stm32f4xx/stm32-post-build.sh"
 BR2_LINUX_KERNEL=y
-BR2_LINUX_KERNEL_CUSTOM_VERSION=y
-BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11"
-BR2_LINUX_KERNEL_DEFCONFIG="stm32"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/stmicroelectronics/stm32f429-disco/linux.config"
 BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM=y
+BR2_LINUX_KERNEL_XZ=y
 BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="xipImage"
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="stm32f429-disco"
-- 
2.17.1

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

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

* Re: [Buildroot] [PATCH 1/1] configs/stm32f429_disco: fix kernel bootup
  2021-11-01 18:24 [Buildroot] [PATCH 1/1] configs/stm32f429_disco: fix kernel bootup Dario Binacchi via buildroot
@ 2021-11-08 12:25 ` Christophe Priouzeau
  2021-11-09 22:00 ` Arnout Vandecappelle
  1 sibling, 0 replies; 5+ messages in thread
From: Christophe Priouzeau @ 2021-11-08 12:25 UTC (permalink / raw)
  To: Dario Binacchi, buildroot

On 11/1/21 7:24 PM, Dario Binacchi wrote:
> The kernel generated by the configuration for the STM32f429-discovery
> board is buggy:
> 
>   Unhandled exception: IPSR = 00000006 LR = fffffff1
>   CPU: 0 PID: 1 Comm: init Not tainted 4.11.0 #2
>   Hardware name: STM32 (Device Tree Support)
>   task: 9041a000 task.stack: 907c0000
>   PC is at ret_fast_syscall+0x2/0x4a
>   LR is at tty_ioctl+0x1ad/0x75c
>   pc : [<0800d942>]    lr : [<080c2e05>]    psr: 4000000b
>   sp : 907c1fa8  ip : 0000001c  fp : 905961a2
>   r10: 00000000  r9 : 907c0000  r8 : 0800dae0
>   r7 : 00000036  r6 : 905e7e60  r5 : 00000000  r4 : 905e7ebc
>   r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 00000000
>   xPSR: 4000000b
>   CPU: 0 PID: 1 Comm: init Not tainted 4.11.0 #2
>   Hardware name: STM32 (Device Tree Support)
>   [<0800fbf9>] (unwind_backtrace) from [<0800f05b>] (show_stack+0xb/0xc)
>   [<0800f05b>] (show_stack) from [<0800f553>] (__invalid_entry+0x4b/0x4c)
> 
> Inspired by commit a3e3d9c198 ("configs/stm32f469_disco_xip_defconfig:
> alternative defconfig for XIP") I updated the stm32f429_disco_defconfig
> configuration to use a newer kernel. Current setup kernel + rootfs fits
> in 1.6MB on-chip flash memory.
> 
> Fixes:
>   - Move kernel to new flash bank due to growth of dtb size.
>   - Fix kernel start address in afboot-stm32 bootloader.
> 
> For better binary size optimization gcc LTO is turned on.
> 
> Signed-off-by: Dario Binacchi <dariobin@libero.it>
Acked-by: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
> ---
>   .../stm32f429-disco/flash.sh                  |   2 +-
>   .../stm32f429-disco/linux.config              | 120 ++++++++++++++++++
>   ...9i-disco-update-kernel-start-address.patch |  30 +++++
>   ...sco-don-t-force-init-in-chosen-boota.patch |  32 -----
>   configs/stm32f429_disco_defconfig             |   9 +-
>   5 files changed, 156 insertions(+), 37 deletions(-)
>   create mode 100644 board/stmicroelectronics/stm32f429-disco/linux.config
>   create mode 100644 board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
>   delete mode 100644 board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> 
> diff --git a/board/stmicroelectronics/stm32f429-disco/flash.sh b/board/stmicroelectronics/stm32f429-disco/flash.sh
> index b19e0a6019..3e2bf121d3 100755
> --- a/board/stmicroelectronics/stm32f429-disco/flash.sh
> +++ b/board/stmicroelectronics/stm32f429-disco/flash.sh
> @@ -21,6 +21,6 @@ ${OUTPUT_DIR}/host/bin/openocd -f board/${BOARD_NAME}.cfg \
>     -c "flash info 0" \
>     -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f429i-disco.bin 0x08000000" \
>     -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f429-disco.dtb 0x08004000" \
> -  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x08008000" \
> +  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x0800C000" \
>     -c "reset run" \
>     -c "shutdown"
> diff --git a/board/stmicroelectronics/stm32f429-disco/linux.config b/board/stmicroelectronics/stm32f429-disco/linux.config
> new file mode 100644
> index 0000000000..7b5c60f180
> --- /dev/null
> +++ b/board/stmicroelectronics/stm32f429-disco/linux.config
> @@ -0,0 +1,120 @@
> +# CONFIG_LOCALVERSION_AUTO is not set
> +CONFIG_KERNEL_XZ=y
> +CONFIG_NO_HZ_IDLE=y
> +CONFIG_HIGH_RES_TIMERS=y
> +CONFIG_PREEMPT=y
> +CONFIG_LOG_BUF_SHIFT=12
> +CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=10
> +CONFIG_BLK_DEV_INITRD=y
> +CONFIG_INITRAMFS_SOURCE="${BR_BINARIES_DIR}/rootfs.cpio"
> +# CONFIG_RD_GZIP is not set
> +# CONFIG_RD_BZIP2 is not set
> +# CONFIG_RD_LZMA is not set
> +# CONFIG_RD_XZ is not set
> +# CONFIG_RD_LZO is not set
> +# CONFIG_RD_LZ4 is not set
> +# CONFIG_RD_ZSTD is not set
> +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
> +# CONFIG_MULTIUSER is not set
> +# CONFIG_SYSFS_SYSCALL is not set
> +# CONFIG_FHANDLE is not set
> +CONFIG_POSIX_TIMERS=y
> +CONFIG_BUG=y
> +# CONFIG_BASE_FULL is not set
> +# CONFIG_FUTEX is not set
> +# CONFIG_EPOLL is not set
> +# CONFIG_SIGNALFD is not set
> +# CONFIG_TIMERFD is not set
> +# CONFIG_EVENTFD is not set
> +# CONFIG_AIO is not set
> +# CONFIG_IO_URING is not set
> +# CONFIG_ADVISE_SYSCALLS is not set
> +# CONFIG_MEMBARRIER is not set
> +# CONFIG_KALLSYMS is not set
> +CONFIG_KCMP=y
> +# CONFIG_RSEQ is not set
> +CONFIG_EMBEDDED=y
> +# CONFIG_VM_EVENT_COUNTERS is not set
> +# CONFIG_COMPAT_BRK is not set
> +CONFIG_SLOB=y
> +# CONFIG_SLAB_MERGE_DEFAULT is not set
> +# CONFIG_MMU is not set
> +CONFIG_ARCH_STM32=y
> +# CONFIG_MACH_STM32F469 is not set
> +# CONFIG_MACH_STM32F746 is not set
> +# CONFIG_MACH_STM32F769 is not set
> +# CONFIG_MACH_STM32H743 is not set
> +CONFIG_CPU_V7M_NUM_IRQ=240
> +# CONFIG_ARM_DMA_MEM_BUFFERABLE is not set
> +CONFIG_SET_MEM_PARAM=y
> +CONFIG_DRAM_BASE=0x90000000
> +CONFIG_DRAM_SIZE=0x00800000
> +CONFIG_HZ_1000=y
> +# CONFIG_ATAGS is not set
> +CONFIG_XIP_KERNEL=y
> +CONFIG_XIP_PHYS_ADDR=0x0800C000
> +CONFIG_XIP_DEFLATED_DATA=y
> +# CONFIG_SUSPEND is not set
> +# CONFIG_STACKPROTECTOR is not set
> +# CONFIG_COMPAT_32BIT_TIME is not set
> +# CONFIG_GCC_PLUGINS is not set
> +# CONFIG_BLOCK is not set
> +CONFIG_BINFMT_FLAT=y
> +CONFIG_BINFMT_SHARED_FLAT=y
> +# CONFIG_COREDUMP is not set
> +CONFIG_DEVTMPFS=y
> +CONFIG_DEVTMPFS_MOUNT=y
> +# CONFIG_STANDALONE is not set
> +# CONFIG_PREVENT_FIRMWARE_BUILD is not set
> +# CONFIG_FW_LOADER is not set
> +# CONFIG_ALLOW_DEV_COREDUMP is not set
> +CONFIG_EEPROM_93CX6=y
> +# CONFIG_INPUT is not set
> +# CONFIG_VT is not set
> +# CONFIG_UNIX98_PTYS is not set
> +# CONFIG_LEGACY_PTYS is not set
> +# CONFIG_LDISC_AUTOLOAD is not set
> +CONFIG_SERIAL_STM32=y
> +CONFIG_SERIAL_STM32_CONSOLE=y
> +# CONFIG_DEVMEM is not set
> +# CONFIG_HWMON is not set
> +CONFIG_WATCHDOG=y
> +CONFIG_MFD_STM32_TIMERS=y
> +# CONFIG_USB_SUPPORT is not set
> +CONFIG_NEW_LEDS=y
> +CONFIG_LEDS_CLASS=y
> +CONFIG_LEDS_GPIO=y
> +CONFIG_LEDS_TRIGGERS=y
> +CONFIG_LEDS_TRIGGER_HEARTBEAT=y
> +CONFIG_RTC_CLASS=y
> +CONFIG_RTC_DRV_STM32=y
> +CONFIG_DMADEVICES=y
> +CONFIG_STM32_DMA=y
> +CONFIG_STM32_DMAMUX=y
> +CONFIG_STM32_MDMA=y
> +CONFIG_SYNC_FILE=y
> +# CONFIG_VIRTIO_MENU is not set
> +# CONFIG_VHOST_MENU is not set
> +CONFIG_IIO=y
> +CONFIG_IIO_BUFFER=y
> +CONFIG_IIO_TRIGGERED_BUFFER=y
> +CONFIG_IIO_STM32_TIMER_TRIGGER=y
> +# CONFIG_FILE_LOCKING is not set
> +# CONFIG_DNOTIFY is not set
> +# CONFIG_INOTIFY_USER is not set
> +# CONFIG_PROC_SYSCTL is not set
> +CONFIG_CONFIGFS_FS=y
> +# CONFIG_MISC_FILESYSTEMS is not set
> +CONFIG_NLS=y
> +CONFIG_PRINTK_TIME=y
> +CONFIG_CONSOLE_LOGLEVEL_DEFAULT=15
> +CONFIG_CONSOLE_LOGLEVEL_QUIET=15
> +CONFIG_MESSAGE_LOGLEVEL_DEFAULT=7
> +# CONFIG_SYMBOLIC_ERRNAME is not set
> +CONFIG_DEBUG_INFO=y
> +# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set
> +CONFIG_DEBUG_FS=y
> +# CONFIG_DEBUG_MISC is not set
> +# CONFIG_SCHED_DEBUG is not set
> +# CONFIG_RCU_TRACE is not set
> +# CONFIG_RUNTIME_TESTING_MENU is not set
> diff --git a/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch b/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
> new file mode 100644
> index 0000000000..715ade694d
> --- /dev/null
> +++ b/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
> @@ -0,0 +1,30 @@
> +From 9cdee858b36e2de7d6717e56fd3d08ad9ad25cde Mon Sep 17 00:00:00 2001
> +From: Dario Binacchi <dariobin@libero.it>
> +Date: Sun, 31 Oct 2021 08:52:52 +0100
> +Subject: [PATCH] stm32f429i-disco: update kernel start address
> +
> +As of GNU/Linux v5.14 kernel device tree binary grows above 0x08008000
> +and overwrites kernel binary.
> +Therefore this commit moves kernel to the next flash bank.
> +
> +Signed-off-by: Dario Binacchi <dariobin@libero.it>
> +---
> + stm32f429i-disco.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/stm32f429i-disco.c b/stm32f429i-disco.c
> +index 8b27641..14a6f1e 100644
> +--- a/stm32f429i-disco.c
> ++++ b/stm32f429i-disco.c
> +@@ -88,7 +88,7 @@ static void fmc_wait_busy(void)
> +
> + void start_kernel(void)
> + {
> +-	void (*kernel)(uint32_t reserved, uint32_t mach, uint32_t dt) = (void (*)(uint32_t, uint32_t, uint32_t))(0x08008000 | 1);
> ++	void (*kernel)(uint32_t reserved, uint32_t mach, uint32_t dt) = (void (*)(uint32_t, uint32_t, uint32_t))(0x0800C000 | 1);
> +
> + 	kernel(0, ~0UL, 0x08004000);
> + }
> +--
> +2.17.1
> +
> diff --git a/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch b/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> deleted file mode 100644
> index d6d5c61aae..0000000000
> --- a/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -From ded9afa688184b3240a92c2b8f114c545a09bc3f Mon Sep 17 00:00:00 2001
> -From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> -Date: Sat, 12 Mar 2016 23:14:41 +0100
> -Subject: [PATCH] ARM: stm32f249-disco: don't force init= in /chosen/bootargs
> -
> -There is no reason to override the kernel's default init= value, as
> -this breaks userspace that assumes the kernel default of /init is
> -used. Since stm32 is often used with a minimal bootloader
> -(afboot-stm32) that doesn't provide any mechanism to override the DTB,
> -we need to adjust the kernel command line in the Device Tree source.
> -
> -Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ----
> - arch/arm/boot/dts/stm32f429-disco.dts | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/arch/arm/boot/dts/stm32f429-disco.dts b/arch/arm/boot/dts/stm32f429-disco.dts
> -index f0b731d..2bae81c 100644
> ---- a/arch/arm/boot/dts/stm32f429-disco.dts
> -+++ b/arch/arm/boot/dts/stm32f429-disco.dts
> -@@ -53,7 +53,7 @@
> - 	compatible = "st,stm32f429i-disco", "st,stm32f429";
> -
> - 	chosen {
> --		bootargs = "root=/dev/ram rdinit=/linuxrc";
> -+		bootargs = "root=/dev/ram";
> - 		stdout-path = "serial0:115200n8";
> - 	};
> -
> ---
> -2.6.4
> -
> diff --git a/configs/stm32f429_disco_defconfig b/configs/stm32f429_disco_defconfig
> index 2c0641a6c5..58367fca0b 100644
> --- a/configs/stm32f429_disco_defconfig
> +++ b/configs/stm32f429_disco_defconfig
> @@ -1,13 +1,14 @@
>   BR2_arm=y
>   BR2_cortex_m4=y
>   BR2_GLOBAL_PATCH_DIR="board/stmicroelectronics/stm32f429-disco/patches"
> -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_11=y
> +# BR2_UCLIBC_INSTALL_UTILS is not set
> +BR2_GCC_ENABLE_LTO=y
>   BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/common/stm32f4xx/stm32-post-build.sh"
>   BR2_LINUX_KERNEL=y
> -BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> -BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11"
> -BR2_LINUX_KERNEL_DEFCONFIG="stm32"
> +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
> +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/stmicroelectronics/stm32f429-disco/linux.config"
>   BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM=y
> +BR2_LINUX_KERNEL_XZ=y
>   BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="xipImage"
>   BR2_LINUX_KERNEL_DTS_SUPPORT=y
>   BR2_LINUX_KERNEL_INTREE_DTS_NAME="stm32f429-disco"
> 


-- 
Best regards / Cordialement,

Christophe Priouzeau | Tel: +33 244027320
STMicroelectronics
ST online: www.st.com<http://www.st.com/>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] configs/stm32f429_disco: fix kernel bootup
  2021-11-01 18:24 [Buildroot] [PATCH 1/1] configs/stm32f429_disco: fix kernel bootup Dario Binacchi via buildroot
  2021-11-08 12:25 ` Christophe Priouzeau
@ 2021-11-09 22:00 ` Arnout Vandecappelle
  2021-11-14 16:47   ` Dario Binacchi via buildroot
  1 sibling, 1 reply; 5+ messages in thread
From: Arnout Vandecappelle @ 2021-11-09 22:00 UTC (permalink / raw)
  To: Dario Binacchi, buildroot; +Cc: Christophe Priouzeau



On 01/11/2021 19:24, Dario Binacchi wrote:
> The kernel generated by the configuration for the STM32f429-discovery
> board is buggy:
> 
>   Unhandled exception: IPSR = 00000006 LR = fffffff1
>   CPU: 0 PID: 1 Comm: init Not tainted 4.11.0 #2
>   Hardware name: STM32 (Device Tree Support)
>   task: 9041a000 task.stack: 907c0000
>   PC is at ret_fast_syscall+0x2/0x4a
>   LR is at tty_ioctl+0x1ad/0x75c
>   pc : [<0800d942>]    lr : [<080c2e05>]    psr: 4000000b
>   sp : 907c1fa8  ip : 0000001c  fp : 905961a2
>   r10: 00000000  r9 : 907c0000  r8 : 0800dae0
>   r7 : 00000036  r6 : 905e7e60  r5 : 00000000  r4 : 905e7ebc
>   r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 00000000
>   xPSR: 4000000b
>   CPU: 0 PID: 1 Comm: init Not tainted 4.11.0 #2
>   Hardware name: STM32 (Device Tree Support)
>   [<0800fbf9>] (unwind_backtrace) from [<0800f05b>] (show_stack+0xb/0xc)
>   [<0800f05b>] (show_stack) from [<0800f553>] (__invalid_entry+0x4b/0x4c)
> 
> Inspired by commit a3e3d9c198 ("configs/stm32f469_disco_xip_defconfig:
> alternative defconfig for XIP") I updated the stm32f429_disco_defconfig
> configuration to use a newer kernel. Current setup kernel + rootfs fits
> in 1.6MB on-chip flash memory.
> 
> Fixes:

  (nitpick) you normally put the fixes tag before the thing that gets fixed, not 
before the changes you made to fix them. So in this case, it would become before 
the Unhandled exception above.

>   - Move kernel to new flash bank due to growth of dtb size.
>   - Fix kernel start address in afboot-stm32 bootloader.
> 
> For better binary size optimization gcc LTO is turned on.
> 
> Signed-off-by: Dario Binacchi <dariobin@libero.it>
> ---
>   .../stm32f429-disco/flash.sh                  |   2 +-
>   .../stm32f429-disco/linux.config              | 120 ++++++++++++++++++
>   ...9i-disco-update-kernel-start-address.patch |  30 +++++
>   ...sco-don-t-force-init-in-chosen-boota.patch |  32 -----
>   configs/stm32f429_disco_defconfig             |   9 +-
>   5 files changed, 156 insertions(+), 37 deletions(-)
>   create mode 100644 board/stmicroelectronics/stm32f429-disco/linux.config
>   create mode 100644 board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
>   delete mode 100644 board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> 
> diff --git a/board/stmicroelectronics/stm32f429-disco/flash.sh b/board/stmicroelectronics/stm32f429-disco/flash.sh
> index b19e0a6019..3e2bf121d3 100755
> --- a/board/stmicroelectronics/stm32f429-disco/flash.sh
> +++ b/board/stmicroelectronics/stm32f429-disco/flash.sh
> @@ -21,6 +21,6 @@ ${OUTPUT_DIR}/host/bin/openocd -f board/${BOARD_NAME}.cfg \
>     -c "flash info 0" \
>     -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f429i-disco.bin 0x08000000" \
>     -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f429-disco.dtb 0x08004000" \
> -  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x08008000" \
> +  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x0800C000" \

  I'm a bit confused, but I think I get it now... We have 3 disco configs:

- stm32f429_disco_defconfig is XIP
- stm32f469_disco_defconfig is in spiflash
- stm32f469_disco_xip_defconfig is XIP

  So, perhaps, to make things clearer, we should rename this defconfig to 
stm32f429_disco_xip_defconfig?

[snip]
> diff --git a/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch b/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
> new file mode 100644
> index 0000000000..715ade694d
> --- /dev/null
> +++ b/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
> @@ -0,0 +1,30 @@
> +From 9cdee858b36e2de7d6717e56fd3d08ad9ad25cde Mon Sep 17 00:00:00 2001
> +From: Dario Binacchi <dariobin@libero.it>
> +Date: Sun, 31 Oct 2021 08:52:52 +0100
> +Subject: [PATCH] stm32f429i-disco: update kernel start address
> +
> +As of GNU/Linux v5.14 kernel device tree binary grows above 0x08008000
> +and overwrites kernel binary.
> +Therefore this commit moves kernel to the next flash bank.
> +
> +Signed-off-by: Dario Binacchi <dariobin@libero.it>

  Since the DTS comes from the upstream kernel AFAICS, it would seem that this 
patch should be sent upstream as well. Have you done that? If so, please add an 
Upstream: <URL>.

> +---
> + stm32f429i-disco.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/stm32f429i-disco.c b/stm32f429i-disco.c
> +index 8b27641..14a6f1e 100644
> +--- a/stm32f429i-disco.c
> ++++ b/stm32f429i-disco.c
> +@@ -88,7 +88,7 @@ static void fmc_wait_busy(void)
> +
> + void start_kernel(void)
> + {
> +-	void (*kernel)(uint32_t reserved, uint32_t mach, uint32_t dt) = (void (*)(uint32_t, uint32_t, uint32_t))(0x08008000 | 1);
> ++	void (*kernel)(uint32_t reserved, uint32_t mach, uint32_t dt) = (void (*)(uint32_t, uint32_t, uint32_t))(0x0800C000 | 1);
> +
> + 	kernel(0, ~0UL, 0x08004000);
> + }
> +--
> +2.17.1
> +
> diff --git a/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch b/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> deleted file mode 100644
> index d6d5c61aae..0000000000
> --- a/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -From ded9afa688184b3240a92c2b8f114c545a09bc3f Mon Sep 17 00:00:00 2001
> -From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> -Date: Sat, 12 Mar 2016 23:14:41 +0100
> -Subject: [PATCH] ARM: stm32f249-disco: don't force init= in /chosen/bootargs
> -
> -There is no reason to override the kernel's default init= value, as
> -this breaks userspace that assumes the kernel default of /init is
> -used. Since stm32 is often used with a minimal bootloader
> -(afboot-stm32) that doesn't provide any mechanism to override the DTB,
> -we need to adjust the kernel command line in the Device Tree source.
> -
> -Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ----
> - arch/arm/boot/dts/stm32f429-disco.dts | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/arch/arm/boot/dts/stm32f429-disco.dts b/arch/arm/boot/dts/stm32f429-disco.dts
> -index f0b731d..2bae81c 100644
> ---- a/arch/arm/boot/dts/stm32f429-disco.dts
> -+++ b/arch/arm/boot/dts/stm32f429-disco.dts
> -@@ -53,7 +53,7 @@
> - 	compatible = "st,stm32f429i-disco", "st,stm32f429";
> -
> - 	chosen {
> --		bootargs = "root=/dev/ram rdinit=/linuxrc";
> -+		bootargs = "root=/dev/ram";
> - 		stdout-path = "serial0:115200n8";
> - 	};
> -
> ---
> -2.6.4
> -
> diff --git a/configs/stm32f429_disco_defconfig b/configs/stm32f429_disco_defconfig
> index 2c0641a6c5..58367fca0b 100644
> --- a/configs/stm32f429_disco_defconfig
> +++ b/configs/stm32f429_disco_defconfig
> @@ -1,13 +1,14 @@
>   BR2_arm=y
>   BR2_cortex_m4=y
>   BR2_GLOBAL_PATCH_DIR="board/stmicroelectronics/stm32f429-disco/patches"
> -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_11=y
> +# BR2_UCLIBC_INSTALL_UTILS is not set
> +BR2_GCC_ENABLE_LTO=y
>   BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/common/stm32f4xx/stm32-post-build.sh"
>   BR2_LINUX_KERNEL=y
> -BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> -BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11"

  You *must* keep this (and the linux-headers version) explicitly, relying on 
the default is not OK. Indeed, if the default kernel is update in Buildroot 
(which happens every couple of weeks), then it's possible it will grow again and 
doesn't fit any more.


> -BR2_LINUX_KERNEL_DEFCONFIG="stm32"
> +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
> +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/stmicroelectronics/stm32f429-disco/linux.config"
>   BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM=y
> +BR2_LINUX_KERNEL_XZ=y

  Err, now I'm really confused, this is a XIP kernel right, so it shouldn't be 
compressed?

  Regards,
  Arnout

>   BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="xipImage"
>   BR2_LINUX_KERNEL_DTS_SUPPORT=y
>   BR2_LINUX_KERNEL_INTREE_DTS_NAME="stm32f429-disco"
> 
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] configs/stm32f429_disco: fix kernel bootup
  2021-11-09 22:00 ` Arnout Vandecappelle
@ 2021-11-14 16:47   ` Dario Binacchi via buildroot
  0 siblings, 0 replies; 5+ messages in thread
From: Dario Binacchi via buildroot @ 2021-11-14 16:47 UTC (permalink / raw)
  To: Arnout Vandecappelle, buildroot; +Cc: Christophe Priouzeau

Hi Arnout,

> Il 09/11/2021 23:00 Arnout Vandecappelle <arnout@mind.be> ha scritto:
> 
>  
> On 01/11/2021 19:24, Dario Binacchi wrote:
> > The kernel generated by the configuration for the STM32f429-discovery
> > board is buggy:
> > 
> >   Unhandled exception: IPSR = 00000006 LR = fffffff1
> >   CPU: 0 PID: 1 Comm: init Not tainted 4.11.0 #2
> >   Hardware name: STM32 (Device Tree Support)
> >   task: 9041a000 task.stack: 907c0000
> >   PC is at ret_fast_syscall+0x2/0x4a
> >   LR is at tty_ioctl+0x1ad/0x75c
> >   pc : [<0800d942>]    lr : [<080c2e05>]    psr: 4000000b
> >   sp : 907c1fa8  ip : 0000001c  fp : 905961a2
> >   r10: 00000000  r9 : 907c0000  r8 : 0800dae0
> >   r7 : 00000036  r6 : 905e7e60  r5 : 00000000  r4 : 905e7ebc
> >   r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 00000000
> >   xPSR: 4000000b
> >   CPU: 0 PID: 1 Comm: init Not tainted 4.11.0 #2
> >   Hardware name: STM32 (Device Tree Support)
> >   [<0800fbf9>] (unwind_backtrace) from [<0800f05b>] (show_stack+0xb/0xc)
> >   [<0800f05b>] (show_stack) from [<0800f553>] (__invalid_entry+0x4b/0x4c)
> > 
> > Inspired by commit a3e3d9c198 ("configs/stm32f469_disco_xip_defconfig:
> > alternative defconfig for XIP") I updated the stm32f429_disco_defconfig
> > configuration to use a newer kernel. Current setup kernel + rootfs fits
> > in 1.6MB on-chip flash memory.
> > 
> > Fixes:
> 
>   (nitpick) you normally put the fixes tag before the thing that gets fixed, not 
> before the changes you made to fix them. So in this case, it would become before 
> the Unhandled exception above.

Ok, I will do it.

> 
> >   - Move kernel to new flash bank due to growth of dtb size.
> >   - Fix kernel start address in afboot-stm32 bootloader.
> > 
> > For better binary size optimization gcc LTO is turned on.
> > 
> > Signed-off-by: Dario Binacchi <dariobin@libero.it>
> > ---
> >   .../stm32f429-disco/flash.sh                  |   2 +-
> >   .../stm32f429-disco/linux.config              | 120 ++++++++++++++++++
> >   ...9i-disco-update-kernel-start-address.patch |  30 +++++
> >   ...sco-don-t-force-init-in-chosen-boota.patch |  32 -----
> >   configs/stm32f429_disco_defconfig             |   9 +-
> >   5 files changed, 156 insertions(+), 37 deletions(-)
> >   create mode 100644 board/stmicroelectronics/stm32f429-disco/linux.config
> >   create mode 100644 board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
> >   delete mode 100644 board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> > 
> > diff --git a/board/stmicroelectronics/stm32f429-disco/flash.sh b/board/stmicroelectronics/stm32f429-disco/flash.sh
> > index b19e0a6019..3e2bf121d3 100755
> > --- a/board/stmicroelectronics/stm32f429-disco/flash.sh
> > +++ b/board/stmicroelectronics/stm32f429-disco/flash.sh
> > @@ -21,6 +21,6 @@ ${OUTPUT_DIR}/host/bin/openocd -f board/${BOARD_NAME}.cfg \
> >     -c "flash info 0" \
> >     -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f429i-disco.bin 0x08000000" \
> >     -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f429-disco.dtb 0x08004000" \
> > -  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x08008000" \
> > +  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x0800C000" \
> 
>   I'm a bit confused, but I think I get it now... We have 3 disco configs:
> 
> - stm32f429_disco_defconfig is XIP
> - stm32f469_disco_defconfig is in spiflash
> - stm32f469_disco_xip_defconfig is XIP
> 
>   So, perhaps, to make things clearer, we should rename this defconfig to 
> stm32f429_disco_xip_defconfig?

Yes, I agree with you, and I would rename stm32f469_disco_defconfig to stm32f469_disco_sd_defconfig too. 

> 
> [snip]
> > diff --git a/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch b/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
> > new file mode 100644
> > index 0000000000..715ade694d
> > --- /dev/null
> > +++ b/board/stmicroelectronics/stm32f429-disco/patches/afboot-stm32/0001-stm32f429i-disco-update-kernel-start-address.patch
> > @@ -0,0 +1,30 @@
> > +From 9cdee858b36e2de7d6717e56fd3d08ad9ad25cde Mon Sep 17 00:00:00 2001
> > +From: Dario Binacchi <dariobin@libero.it>
> > +Date: Sun, 31 Oct 2021 08:52:52 +0100
> > +Subject: [PATCH] stm32f429i-disco: update kernel start address
> > +
> > +As of GNU/Linux v5.14 kernel device tree binary grows above 0x08008000
> > +and overwrites kernel binary.
> > +Therefore this commit moves kernel to the next flash bank.
> > +
> > +Signed-off-by: Dario Binacchi <dariobin@libero.it>
> 
>   Since the DTS comes from the upstream kernel AFAICS, it would seem that this 
> patch should be sent upstream as well. Have you done that? If so, please add an 
> Upstream: <URL>.

I have not sent any patches, which probably would be rejected as I only see now 
that the commit 2e499dcff3ef8 ("Add possibility to use custom kernel load address") 
allows you to override the the default kernel load address. So, I thinks it's better
to patch the afboot package in buildroot. 
 
> 
> > +---
> > + stm32f429i-disco.c | 2 +-
> > + 1 file changed, 1 insertion(+), 1 deletion(-)
> > +
> > +diff --git a/stm32f429i-disco.c b/stm32f429i-disco.c
> > +index 8b27641..14a6f1e 100644
> > +--- a/stm32f429i-disco.c
> > ++++ b/stm32f429i-disco.c
> > +@@ -88,7 +88,7 @@ static void fmc_wait_busy(void)
> > +
> > + void start_kernel(void)
> > + {
> > +-	void (*kernel)(uint32_t reserved, uint32_t mach, uint32_t dt) = (void (*)(uint32_t, uint32_t, uint32_t))(0x08008000 | 1);
> > ++	void (*kernel)(uint32_t reserved, uint32_t mach, uint32_t dt) = (void (*)(uint32_t, uint32_t, uint32_t))(0x0800C000 | 1);
> > +
> > + 	kernel(0, ~0UL, 0x08004000);
> > + }
> > +--
> > +2.17.1
> > +
> > diff --git a/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch b/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> > deleted file mode 100644
> > index d6d5c61aae..0000000000
> > --- a/board/stmicroelectronics/stm32f429-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
> > +++ /dev/null
> > @@ -1,32 +0,0 @@
> > -From ded9afa688184b3240a92c2b8f114c545a09bc3f Mon Sep 17 00:00:00 2001
> > -From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> > -Date: Sat, 12 Mar 2016 23:14:41 +0100
> > -Subject: [PATCH] ARM: stm32f249-disco: don't force init= in /chosen/bootargs
> > -
> > -There is no reason to override the kernel's default init= value, as
> > -this breaks userspace that assumes the kernel default of /init is
> > -used. Since stm32 is often used with a minimal bootloader
> > -(afboot-stm32) that doesn't provide any mechanism to override the DTB,
> > -we need to adjust the kernel command line in the Device Tree source.
> > -
> > -Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> > ----
> > - arch/arm/boot/dts/stm32f429-disco.dts | 2 +-
> > - 1 file changed, 1 insertion(+), 1 deletion(-)
> > -
> > -diff --git a/arch/arm/boot/dts/stm32f429-disco.dts b/arch/arm/boot/dts/stm32f429-disco.dts
> > -index f0b731d..2bae81c 100644
> > ---- a/arch/arm/boot/dts/stm32f429-disco.dts
> > -+++ b/arch/arm/boot/dts/stm32f429-disco.dts
> > -@@ -53,7 +53,7 @@
> > - 	compatible = "st,stm32f429i-disco", "st,stm32f429";
> > -
> > - 	chosen {
> > --		bootargs = "root=/dev/ram rdinit=/linuxrc";
> > -+		bootargs = "root=/dev/ram";
> > - 		stdout-path = "serial0:115200n8";
> > - 	};
> > -
> > ---
> > -2.6.4
> > -
> > diff --git a/configs/stm32f429_disco_defconfig b/configs/stm32f429_disco_defconfig
> > index 2c0641a6c5..58367fca0b 100644
> > --- a/configs/stm32f429_disco_defconfig
> > +++ b/configs/stm32f429_disco_defconfig
> > @@ -1,13 +1,14 @@
> >   BR2_arm=y
> >   BR2_cortex_m4=y
> >   BR2_GLOBAL_PATCH_DIR="board/stmicroelectronics/stm32f429-disco/patches"
> > -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_11=y
> > +# BR2_UCLIBC_INSTALL_UTILS is not set
> > +BR2_GCC_ENABLE_LTO=y
> >   BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/common/stm32f4xx/stm32-post-build.sh"
> >   BR2_LINUX_KERNEL=y
> > -BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> > -BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11"
> 
>   You *must* keep this (and the linux-headers version) explicitly, relying on 
> the default is not OK. Indeed, if the default kernel is update in Buildroot 
> (which happens every couple of weeks), then it's possible it will grow again and 
> doesn't fit any more.

OK

> 
> 
> > -BR2_LINUX_KERNEL_DEFCONFIG="stm32"
> > +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
> > +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/stmicroelectronics/stm32f429-disco/linux.config"
> >   BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM=y
> > +BR2_LINUX_KERNEL_XZ=y
> 
>   Err, now I'm really confused, this is a XIP kernel right, so it shouldn't be 
> compressed?

Yes, you are right.
> 
>   Regards,
>   Arnout

Thanks and regards,
Dario

> 
> >   BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="xipImage"
> >   BR2_LINUX_KERNEL_DTS_SUPPORT=y
> >   BR2_LINUX_KERNEL_INTREE_DTS_NAME="stm32f429-disco"
> >
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* [Buildroot] [PATCH 1/1] configs/stm32f429_disco: fix kernel bootup
@ 2021-06-06 20:13 Dario Binacchi
  0 siblings, 0 replies; 5+ messages in thread
From: Dario Binacchi @ 2021-06-06 20:13 UTC (permalink / raw)
  To: buildroot

As described by [1], the kernel generated by the configuration for the
STM32f469 Discovery board is buggy. Using a newer kernel, as suggested
by [1], increases the dtb and Kernel image size. In particular, the
5.12 version of the kernel generates a dtb and a kernel image whose sum
exceeds the 2 MByte of the flash module.

So I decided to replace the afboot-stm32 bootloader in the flash with
U-boot to easily boot the system from sdcard without having to worry
about the size of dtb, kernel and rootfs generated by the configuration.

This solution allows you to fix the kernel boot issue and makes it
possible to use its future versions.

[1] http://buildroot-busybox.2317881.n4.nabble.com/Bug-11746-New-stm32f469-didn-t-work-correctly-td219644.html

Signed-off-by: Dario Binacchi <dariobin@libero.it>
---
 .../stm32f469-disco/extlinux.conf             |  4 +++
 .../stm32f469-disco/flash.sh                  |  4 +--
 .../stm32f469-disco/genimage.cfg              | 27 +++++++++++++++
 .../stm32f469-disco/linux.fragment            |  1 +
 ...sco-don-t-force-init-in-chosen-boota.patch | 33 -------------------
 .../stm32f469-disco/post-build.sh             |  4 +++
 .../stm32f469-disco/readme.txt                | 16 +++++++--
 configs/stm32f469_disco_defconfig             | 19 ++++++-----
 8 files changed, 62 insertions(+), 46 deletions(-)
 create mode 100644 board/stmicroelectronics/stm32f469-disco/extlinux.conf
 create mode 100644 board/stmicroelectronics/stm32f469-disco/genimage.cfg
 create mode 100644 board/stmicroelectronics/stm32f469-disco/linux.fragment
 delete mode 100644 board/stmicroelectronics/stm32f469-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
 create mode 100755 board/stmicroelectronics/stm32f469-disco/post-build.sh

diff --git a/board/stmicroelectronics/stm32f469-disco/extlinux.conf b/board/stmicroelectronics/stm32f469-disco/extlinux.conf
new file mode 100644
index 0000000000..1c2db4383b
--- /dev/null
+++ b/board/stmicroelectronics/stm32f469-disco/extlinux.conf
@@ -0,0 +1,4 @@
+label stm32f469-disco-buildroot
+  kernel /zImage
+  devicetree /stm32f469-disco.dtb
+  append console=ttySTM0,115200 root=/dev/mmcblk0p2 rw rootfstype=ext2 rootwait earlyprintk consoleblank=0 ignore_loglevel
diff --git a/board/stmicroelectronics/stm32f469-disco/flash.sh b/board/stmicroelectronics/stm32f469-disco/flash.sh
index 0ec0beb2de..984d2b2599 100755
--- a/board/stmicroelectronics/stm32f469-disco/flash.sh
+++ b/board/stmicroelectronics/stm32f469-disco/flash.sh
@@ -13,8 +13,6 @@ ${OUTPUT_DIR}/host/bin/openocd -f board/stm32f469discovery.cfg \
   -c "reset init" \
   -c "flash probe 0" \
   -c "flash info 0" \
-  -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f469i-disco.bin 0x08000000" \
-  -c "flash write_image erase ${OUTPUT_DIR}/images/stm32f469-disco.dtb 0x08004000" \
-  -c "flash write_image erase ${OUTPUT_DIR}/images/xipImage 0x08008000" \
+  -c "flash write_image erase ${OUTPUT_DIR}/images/u-boot.bin 0x08000000" \
   -c "reset run" \
   -c "shutdown"
diff --git a/board/stmicroelectronics/stm32f469-disco/genimage.cfg b/board/stmicroelectronics/stm32f469-disco/genimage.cfg
new file mode 100644
index 0000000000..bc945955fa
--- /dev/null
+++ b/board/stmicroelectronics/stm32f469-disco/genimage.cfg
@@ -0,0 +1,27 @@
+image boot.vfat {
+	vfat {
+		files = {
+			"zImage",
+			"stm32f469-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/stm32f469-disco/linux.fragment b/board/stmicroelectronics/stm32f469-disco/linux.fragment
new file mode 100644
index 0000000000..90f5e8a8ff
--- /dev/null
+++ b/board/stmicroelectronics/stm32f469-disco/linux.fragment
@@ -0,0 +1 @@
+# CONFIG_XIP_KERNEL is not set
\ No newline at end of file
diff --git a/board/stmicroelectronics/stm32f469-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch b/board/stmicroelectronics/stm32f469-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
deleted file mode 100644
index 750e477dfc..0000000000
--- a/board/stmicroelectronics/stm32f469-disco/patches/linux/0001-ARM-stm32f249-disco-don-t-force-init-in-chosen-boota.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From c8f8f33c2f0460a34c9545b01a7972a7ed2df0e9 Mon Sep 17 00:00:00 2001
-From: Christophe Priouzeau <christophe.priouzeau@st.com>
-Date: Mon, 29 May 2017 13:38:16 +0200
-Subject: [PATCH] ARM: stm32f249-disco: don't force init= in /chosen/bootargs
-
-There is no reason to override the kernel's default init= value, as
-this breaks userspace that assumes the kernel default of /init is
-used. Since stm32 is often used with a minimal bootloader
-(afboot-stm32) that doesn't provide any mechanism to override the DTB,
-we need to adjust the kernel command line in the Device Tree source.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
----
- arch/arm/boot/dts/stm32f469-disco.dts | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/arch/arm/boot/dts/stm32f469-disco.dts b/arch/arm/boot/dts/stm32f469-disco.dts
-index 0dd56ef..93ee1b2 100644
---- a/arch/arm/boot/dts/stm32f469-disco.dts
-+++ b/arch/arm/boot/dts/stm32f469-disco.dts
-@@ -53,7 +53,7 @@
- 	compatible = "st,stm32f469i-disco", "st,stm32f469";
- 
- 	chosen {
--		bootargs = "root=/dev/ram rdinit=/linuxrc";
-+		bootargs = "root=/dev/ram";
- 		stdout-path = "serial0:115200n8";
- 	};
- 
--- 
-2.7.4
-
diff --git a/board/stmicroelectronics/stm32f469-disco/post-build.sh b/board/stmicroelectronics/stm32f469-disco/post-build.sh
new file mode 100755
index 0000000000..ec20fca7d9
--- /dev/null
+++ b/board/stmicroelectronics/stm32f469-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/stm32f469-disco/readme.txt b/board/stmicroelectronics/stm32f469-disco/readme.txt
index 888bff08a1..c1e1d30e69 100644
--- a/board/stmicroelectronics/stm32f469-disco/readme.txt
+++ b/board/stmicroelectronics/stm32f469-disco/readme.txt
@@ -15,5 +15,17 @@ Flashing
 
   ./board/stmicroelectronics/stm32f469-disco/flash.sh output/
 
-It will flash the minimal bootloader, the Device Tree Blob, and the
-kernel image which includes the root filesystem as initramfs.
+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/stm32f469-disco/genimage.cfg.
diff --git a/configs/stm32f469_disco_defconfig b/configs/stm32f469_disco_defconfig
index 9760d51878..8701ccbc02 100644
--- a/configs/stm32f469_disco_defconfig
+++ b/configs/stm32f469_disco_defconfig
@@ -1,19 +1,22 @@
 BR2_arm=y
 BR2_cortex_m4=y
-BR2_GLOBAL_PATCH_DIR="board/stmicroelectronics/stm32f469-disco/patches"
-BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_11=y
-BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/common/stm32f4xx/stm32-post-build.sh"
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/common/stm32f4xx/stm32-post-build.sh board/stmicroelectronics/stm32f469-disco/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/stmicroelectronics/stm32f469-disco/genimage.cfg"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION=y
-BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11"
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.12"
 BR2_LINUX_KERNEL_DEFCONFIG="stm32"
-BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(LINUX_DIR)/arch/arm/configs/dram_0x00000000.config"
+BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(LINUX_DIR)/arch/arm/configs/dram_0x00000000.config board/stmicroelectronics/stm32f469-disco/linux.fragment"
 BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM=y
-BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="xipImage"
+BR2_LINUX_KERNEL_IMAGE_TARGET_NAME="zImage"
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="stm32f469-disco"
 BR2_PACKAGE_BUSYBOX_CONFIG="package/busybox/busybox-minimal.config"
-BR2_TARGET_ROOTFS_INITRAMFS=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_SIZE="32M"
 # BR2_TARGET_ROOTFS_TAR is not set
-BR2_TARGET_AFBOOT_STM32=y
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="stm32f469-discovery"
+BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_OPENOCD=y
-- 
2.17.1

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

end of thread, other threads:[~2021-11-14 16:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01 18:24 [Buildroot] [PATCH 1/1] configs/stm32f429_disco: fix kernel bootup Dario Binacchi via buildroot
2021-11-08 12:25 ` Christophe Priouzeau
2021-11-09 22:00 ` Arnout Vandecappelle
2021-11-14 16:47   ` Dario Binacchi via buildroot
  -- strict thread matches above, loose matches on Subject: below --
2021-06-06 20:13 Dario Binacchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.