summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Liu <net147@gmail.com>2016-11-30 21:02:39 +0000
committerAndrei Gherzan <andrei@gherzan.ro>2016-12-06 19:16:11 +0100
commit064aa0a3884d4ef2cd7e9fdfebec19167b52b2e7 (patch)
treea5458d96f91b14e5f81b1467504d3eac7455c934
parent0e66d6953cee13a56428d5511838f898dc9da3b7 (diff)
downloadmeta-raspberrypi-064aa0a3884d4ef2cd7e9fdfebec19167b52b2e7.tar.gz
u-boot: Simplify boot script
A patch is backported to check if the firmware loaded a device tree blob into memory and set the fdt_addr variable if it is found. The U-Boot script will then read the command line arguments generated by the firmware from the device tree and boot the kernel with the command line arguments and the loaded device tree. This allows things like MAC address, board revision and serial number to be correctly configured and options in config.txt to be used. An additional patch is backported and further changes are made to support this. Signed-off-by: Jonathan Liu <net147@gmail.com> Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
-rw-r--r--recipes-bsp/rpi-u-boot-scr/files/boot.cmd3
-rw-r--r--recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd6
-rw-r--r--recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd6
-rw-r--r--recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd6
-rw-r--r--recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd6
-rw-r--r--recipes-bsp/u-boot/files/0001-arm-add-save_boot_params-for-ARM1176.patch56
-rw-r--r--recipes-bsp/u-boot/files/0002-rpi-passthrough-of-the-firmware-provided-FDT-blob.patch156
-rw-r--r--recipes-bsp/u-boot/files/0003-Include-lowlevel_init.o-for-rpi2.patch25
-rw-r--r--recipes-bsp/u-boot/u-boot_%.bbappend6
9 files changed, 246 insertions, 24 deletions
diff --git a/recipes-bsp/rpi-u-boot-scr/files/boot.cmd b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd
new file mode 100644
index 0000000..2e8452e
--- /dev/null
+++ b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd
@@ -0,0 +1,3 @@
1fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs
2fatload mmc 0:1 ${kernel_addr_r} uImage
3bootm ${kernel_addr_r} - ${fdt_addr}
diff --git a/recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd
deleted file mode 100644
index c86c758..0000000
--- a/recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd
+++ /dev/null
@@ -1,6 +0,0 @@
1setenv fdtfile bcm2708-rpi-b.dtb
2setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd'
3mmc dev 0
4fatload mmc 0:1 ${kernel_addr_r} uImage
5fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
6bootm ${kernel_addr_r} - ${fdt_addr_r}
diff --git a/recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd
deleted file mode 100644
index c86c758..0000000
--- a/recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd
+++ /dev/null
@@ -1,6 +0,0 @@
1setenv fdtfile bcm2708-rpi-b.dtb
2setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd'
3mmc dev 0
4fatload mmc 0:1 ${kernel_addr_r} uImage
5fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
6bootm ${kernel_addr_r} - ${fdt_addr_r}
diff --git a/recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd
deleted file mode 100644
index aa4ea64..0000000
--- a/recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd
+++ /dev/null
@@ -1,6 +0,0 @@
1setenv fdtfile bcm2709-rpi-2-b.dtb
2setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd'
3mmc dev 0
4fatload mmc 0:1 ${kernel_addr_r} uImage
5fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
6bootm ${kernel_addr_r} - ${fdt_addr_r}
diff --git a/recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd
deleted file mode 100644
index 2950856..0000000
--- a/recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd
+++ /dev/null
@@ -1,6 +0,0 @@
1setenv fdtfile bcm2710-rpi-3-b.dtb
2setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd'
3mmc dev 0
4fatload mmc 0:1 ${kernel_addr_r} uImage
5fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
6bootm ${kernel_addr_r} - ${fdt_addr_r}
diff --git a/recipes-bsp/u-boot/files/0001-arm-add-save_boot_params-for-ARM1176.patch b/recipes-bsp/u-boot/files/0001-arm-add-save_boot_params-for-ARM1176.patch
new file mode 100644
index 0000000..a5ebff5
--- /dev/null
+++ b/recipes-bsp/u-boot/files/0001-arm-add-save_boot_params-for-ARM1176.patch
@@ -0,0 +1,56 @@
1From 3e10fcde3f3c24a488866dd33fa3f5d46ff3d7a3 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?C=C3=A9dric=20Schieli?= <cschieli@gmail.com>
3Date: Fri, 11 Nov 2016 11:59:06 +0100
4Subject: [PATCH] arm: add save_boot_params for ARM1176
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Implement a hook to allow boards to save boot-time CPU state for later
10use. When U-Boot is chain-loaded by another bootloader, CPU registers may
11contain useful information such as system configuration information. This
12feature mirrors the equivalent ARMv7 feature.
13
14Signed-off-by: Cédric Schieli <cschieli@gmail.com>
15Acked-by: Stephen Warren <swarren@nvidia.com>
16Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
17Upstream-status: Backport
18---
19 arch/arm/cpu/arm1176/start.S | 10 ++++++++++
20 1 file changed, 10 insertions(+)
21
22diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S
23index a602d4e..7c00201 100644
24--- a/arch/arm/cpu/arm1176/start.S
25+++ b/arch/arm/cpu/arm1176/start.S
26@@ -16,6 +16,7 @@
27
28 #include <asm-offsets.h>
29 #include <config.h>
30+#include <linux/linkage.h>
31
32 #ifndef CONFIG_SYS_PHY_UBOOT_BASE
33 #define CONFIG_SYS_PHY_UBOOT_BASE CONFIG_SYS_UBOOT_BASE
34@@ -37,6 +38,11 @@
35 .globl reset
36
37 reset:
38+ /* Allow the board to save important registers */
39+ b save_boot_params
40+.globl save_boot_params_ret
41+save_boot_params_ret:
42+
43 /*
44 * set the cpu to SVC32 mode
45 */
46@@ -110,3 +116,7 @@ mmu_disable_phys:
47 c_runtime_cpu_setup:
48
49 mov pc, lr
50+
51+WEAK(save_boot_params)
52+ b save_boot_params_ret /* back to my caller */
53+ENDPROC(save_boot_params)
54--
552.1.4
56
diff --git a/recipes-bsp/u-boot/files/0002-rpi-passthrough-of-the-firmware-provided-FDT-blob.patch b/recipes-bsp/u-boot/files/0002-rpi-passthrough-of-the-firmware-provided-FDT-blob.patch
new file mode 100644
index 0000000..323b7ab
--- /dev/null
+++ b/recipes-bsp/u-boot/files/0002-rpi-passthrough-of-the-firmware-provided-FDT-blob.patch
@@ -0,0 +1,156 @@
1From ade243a211d62327e9ebadce27bbbff7981e37f0 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?C=C3=A9dric=20Schieli?= <cschieli@gmail.com>
3Date: Fri, 11 Nov 2016 11:59:07 +0100
4Subject: [PATCH] rpi: passthrough of the firmware provided FDT blob
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Raspberry firmware used to pass a FDT blob at a fixed address (0x100),
10but this is not true anymore. The address now depends on both the
11memory size and the blob size [1].
12
13If one wants to passthrough this FDT blob to the kernel, the most
14reliable way is to save its address from the r2/x0 register in the
15U-Boot entry point and expose it in a environment variable for
16further processing.
17
18This patch just does this:
19- save the provided address in the global variable fw_dtb_pointer
20- expose it in ${fdt_addr} if it points to a a valid FDT blob
21
22There are many different ways to use it. One can, for example, use
23the following script which will extract from the tree the command
24line built by the firmware, then hand over the blob to a previously
25loaded kernel:
26
27fdt addr ${fdt_addr}
28fdt get value bootargs /chosen bootargs
29bootz ${kernel_addr_r} - ${fdt_addr}
30
31Alternatively, users relying on sysboot/pxe can simply omit any FDT
32statement in their extlinux.conf file, U-Boot will automagically pick
33${fdt_addr} and pass it to the kernel.
34
35[1] https://www.raspberrypi.org/forums//viewtopic.php?f=107&t=134018
36
37Upstream-Status: Backport
38
39Signed-off-by: Cédric Schieli <cschieli@gmail.com>
40Acked-by: Stephen Warren <swarren@nvidia.com>
41Signed-off-by: Jonathan Liu <net147@gmail.com>
42---
43 board/raspberrypi/rpi/Makefile | 1 +
44 board/raspberrypi/rpi/lowlevel_init.S | 36 +++++++++++++++++++++++++++++++++++
45 board/raspberrypi/rpi/rpi.c | 29 ++++++++++++++++++++++++++++
46 3 files changed, 66 insertions(+)
47 create mode 100644 board/raspberrypi/rpi/lowlevel_init.S
48
49diff --git a/board/raspberrypi/rpi/Makefile b/board/raspberrypi/rpi/Makefile
50index 4ce2c98..dcb25ac 100644
51--- a/board/raspberrypi/rpi/Makefile
52+++ b/board/raspberrypi/rpi/Makefile
53@@ -5,3 +5,4 @@
54 #
55
56 obj-y := rpi.o
57+obj-y += lowlevel_init.o
58diff --git a/board/raspberrypi/rpi/lowlevel_init.S b/board/raspberrypi/rpi/lowlevel_init.S
59new file mode 100644
60index 0000000..cdbd8e1
61--- /dev/null
62+++ b/board/raspberrypi/rpi/lowlevel_init.S
63@@ -0,0 +1,36 @@
64+/*
65+ * (C) Copyright 2016
66+ * Cédric Schieli <cschieli@gmail.com>
67+ *
68+ * SPDX-License-Identifier: GPL-2.0+
69+ */
70+
71+#include <config.h>
72+
73+.align 8
74+.global fw_dtb_pointer
75+fw_dtb_pointer:
76+#ifdef CONFIG_ARM64
77+ .dword 0x0
78+#else
79+ .word 0x0
80+#endif
81+
82+/*
83+ * Routine: save_boot_params (called after reset from start.S)
84+ * Description: save ATAG/FDT address provided by the firmware at boot time
85+ */
86+
87+.global save_boot_params
88+save_boot_params:
89+
90+ /* The firmware provided ATAG/FDT address can be found in r2/x0 */
91+#ifdef CONFIG_ARM64
92+ adr x8, fw_dtb_pointer
93+ str x0, [x8]
94+#else
95+ str r2, fw_dtb_pointer
96+#endif
97+
98+ /* Returns */
99+ b save_boot_params_ret
100diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
101index 6245b36..ffd6d31 100644
102--- a/board/raspberrypi/rpi/rpi.c
103+++ b/board/raspberrypi/rpi/rpi.c
104@@ -25,6 +25,9 @@
105
106 DECLARE_GLOBAL_DATA_PTR;
107
108+/* From lowlevel_init.S */
109+extern unsigned long fw_dtb_pointer;
110+
111 static const struct bcm2835_gpio_platdata gpio_platdata = {
112 .base = BCM2835_GPIO_BASE,
113 };
114@@ -285,6 +288,31 @@ static void set_fdtfile(void)
115 setenv("fdtfile", fdtfile);
116 }
117
118+/*
119+ * If the firmware provided a valid FDT at boot time, let's expose it in
120+ * ${fdt_addr} so it may be passed unmodified to the kernel.
121+ */
122+static void set_fdt_addr(void)
123+{
124+ if (getenv("fdt_addr"))
125+ return;
126+
127+ if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
128+ return;
129+
130+ setenv_hex("fdt_addr", fw_dtb_pointer);
131+}
132+
133+/*
134+ * Prevent relocation from stomping on a firmware provided FDT blob.
135+ */
136+unsigned long board_get_usable_ram_top(unsigned long total_size)
137+{
138+ if ((gd->ram_top - fw_dtb_pointer) > SZ_64M)
139+ return gd->ram_top;
140+ return fw_dtb_pointer & ~0xffff;
141+}
142+
143 static void set_usbethaddr(void)
144 {
145 ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1);
146@@ -356,6 +384,7 @@ static void set_serial_number(void)
147
148 int misc_init_r(void)
149 {
150+ set_fdt_addr();
151 set_fdtfile();
152 set_usbethaddr();
153 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
154--
1552.10.2
156
diff --git a/recipes-bsp/u-boot/files/0003-Include-lowlevel_init.o-for-rpi2.patch b/recipes-bsp/u-boot/files/0003-Include-lowlevel_init.o-for-rpi2.patch
new file mode 100644
index 0000000..ce0273f
--- /dev/null
+++ b/recipes-bsp/u-boot/files/0003-Include-lowlevel_init.o-for-rpi2.patch
@@ -0,0 +1,25 @@
1From 1eb01436bc57ad32519a4567a1c9ec82d52d60a1 Mon Sep 17 00:00:00 2001
2From: Paul Barker <paul@paulbarker.me.uk>
3Date: Tue, 29 Nov 2016 19:47:49 +0000
4Subject: [PATCH] Include lowlevel_init.o for rpi2
5
6Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
7Upstream-status: Inappropriate
8 (not needed upstream as rpi_2 board directory is removed in latest
9 version)
10---
11 board/raspberrypi/rpi_2/Makefile | 1 +
12 1 file changed, 1 insertion(+)
13
14diff --git a/board/raspberrypi/rpi_2/Makefile b/board/raspberrypi/rpi_2/Makefile
15index d82cd21..9f865c5 100644
16--- a/board/raspberrypi/rpi_2/Makefile
17+++ b/board/raspberrypi/rpi_2/Makefile
18@@ -5,3 +5,4 @@
19 #
20
21 obj-y := ../rpi/rpi.o
22+obj-y += ../rpi/lowlevel_init.o
23--
242.1.4
25
diff --git a/recipes-bsp/u-boot/u-boot_%.bbappend b/recipes-bsp/u-boot/u-boot_%.bbappend
index 3781666..a4545f0 100644
--- a/recipes-bsp/u-boot/u-boot_%.bbappend
+++ b/recipes-bsp/u-boot/u-boot_%.bbappend
@@ -1 +1,7 @@
1FILESEXTRAPATHS_prepend_rpi := "${THISDIR}/files:"
1RDEPENDS_${PN}_append_rpi = " rpi-u-boot-scr" 2RDEPENDS_${PN}_append_rpi = " rpi-u-boot-scr"
3SRC_URI_append_rpi = " \
4 file://0001-arm-add-save_boot_params-for-ARM1176.patch \
5 file://0002-rpi-passthrough-of-the-firmware-provided-FDT-blob.patch \
6 file://0003-Include-lowlevel_init.o-for-rpi2.patch \
7 "