u-boot: Simplify boot script
PATCH 1/1 u-boot: Simplify boot script
device_tree_address=0x100 is set in config.txt so the firmware will load a patched device tree blob to 0x100 before passing control to U-Boot. 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.
--- recipes-bsp/bootfiles/rpi-config_git.bb | 5 +++++ recipes-bsp/rpi-u-boot-scr/files/boot.cmd | 3 +++ recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd | 6 ------ 6 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 recipes-bsp/rpi-u-boot-scr/files/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd
recipes-bsp/bootfiles/rpi-config_git.bb +5 -0
@@ -76,6 +76,11 @@ do_deploy() { echo "dispmanx_offline=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt fi + # U-Boot Device Tree support + if [ "${KERNEL_IMAGETYPE}" = "uImage" ]; then + sed -i '/#device_tree_address/ c\device_tree_address=0x100' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt + fi + # SPI bus support if [ -n "${ENABLE_SPI_BUS}" ] || [ "${PITFT}" = "1" ]; then echo "# Enable SPI bus" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
recipes-bsp/rpi-u-boot-scr/files/boot.cmd new file +3 -0
@@ -0,0 +1,3 @@ +fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs +fatload mmc 0:1 ${kernel_addr_r} uImage +bootm ${kernel_addr_r} - ${fdt_addr_r}
recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd deleted +0 -6
@@ -1,6 +0,0 @@ -setenv fdtfile bcm2708-rpi-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0 -fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}
recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd deleted +0 -6
@@ -1,6 +0,0 @@ -setenv fdtfile bcm2708-rpi-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0 -fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}
recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd deleted +0 -6
@@ -1,6 +0,0 @@ -setenv fdtfile bcm2709-rpi-2-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0 -fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}
recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd deleted +0 -6
@@ -1,6 +0,0 @@ -setenv fdtfile bcm2710-rpi-3-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0 -fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}
Signature · 1 line
2.10.1
Quoted 99 lines · On Wed, 2 Nov 2016 00:49:11 +1100 Jonathan Liu <[email protected]> wrote:
device_tree_address=0x100 is set in config.txt so the firmware will load a patched device tree blob to
0x100before passing control to U-Boot. 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.
Signed-off-by Jonathan Liu <[email protected]>--- recipes-bsp/bootfiles/rpi-config_git.bb | 5 +++++ recipes-bsp/rpi-u-boot-scr/files/boot.cmd | 3 +++ recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd | 6 ------ 6 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 recipes-bsp/rpi-u-boot-scr/files/boot.cmd delete mode 100644recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd
(quoted diff) +0
-0b/recipes-bsp/bootfiles/rpi-config_git.bb index f610718..2f4d25c 100644 --- a/recipes-bsp/bootfiles/rpi-config_git.bb +++ b/recipes-bsp/bootfiles/rpi-config_git.bb
(quoted diff) +0
-0@@ -76,6 +76,11 @@ do_deploy() { echo "dispmanx_offline=1"Quoted 1 line
Quoted 1 line
${DEPLOYDIR}/bcm2835-bootfiles/config.txtfirecipes-bsp/bootfiles/rpi-config_git.bb +3
-0+ # U-Boot Device Tree support + if [ "${KERNEL_IMAGETYPE}" = "uImage" ]; then + sed -i '/#device_tree_address/ c\device_tree_address=0x100'
${DEPLOYDIR}/bcm2835-bootfiles/config.txtrecipes-bsp/bootfiles/rpi-config_git.bb +2
-0+ fi + # SPI bus support if [ -n "${ENABLE_SPI_BUS}" ] || [ "${PITFT}" = "1" ]; then echo "# Enable SPI bus"Quoted 3 lines
Quoted 3 lines
${DEPLOYDIR}/bcm2835-bootfiles/config.txtdiff --git a/recipes-bsp/rpi-u-boot-scr/files/boot.cmd b/recipes-bsp/rpi-u-boot-scr/files/boot.cmdnew file mode 100644
index 0000000..3f7e3b6recipes-bsp/rpi-u-boot-scr/files/boot.cmd new file +3
-0@@ -0,0 +1,3 @@ +fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs +fatload mmc 0:1 ${kernel_addr_r} uImage +bootm ${kernel_addr_r} - ${fdt_addr_r}(quoted diff) +0
-0b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd deleted file mode 100644 index c86c758..0000000
recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd deleted +0
-2@@ -1,6 +0,0 @@ -setenv fdtfile bcm2708-rpi-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0
recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd deleted +0
-3-fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}(quoted diff) +0
-0b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd deleted file mode 100644 index c86c758..0000000
recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd deleted +0
-2@@ -1,6 +0,0 @@ -setenv fdtfile bcm2708-rpi-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0
recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd deleted +0
-3-fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}(quoted diff) +0
-0b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd deleted file mode 100644 index aa4ea64..0000000
recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd deleted +0
-2@@ -1,6 +0,0 @@ -setenv fdtfile bcm2709-rpi-2-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0
recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd deleted +0
-3-fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}(quoted diff) +0
-0b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd deleted file mode 100644 index 2950856..0000000
recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd deleted +0
-2@@ -1,6 +0,0 @@ -setenv fdtfile bcm2710-rpi-3-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0
recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd
Quoted 3 lines
recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd deleted +0
-3-fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}
Looks like I missed the RaspberryPi Device Tree documentation
(https://www.raspberrypi.org/documentation/configuration/device-tree.md)
when putting my patches together. I assumed that they use device trees in a pretty standard way but looks like I was wrong!
I'll give this a test this week.
Thanks,
Paul
Quoted 114 lines · Paul Barker
Quoted 99 lines · On Wed, 2 Nov 2016 00:49:11 +1100 Jonathan Liu <[email protected]> wrote:
device_tree_address=0x100 is set in config.txt so the firmware will load a patched device tree blob to
0x100before passing control to U-Boot. 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.
Signed-off-by Jonathan Liu <[email protected]>---
recipes-bsp/bootfiles/rpi-config_git.bb | 5 +++++ recipes-bsp/rpi-u-boot-scr/files/boot.cmd | 3 +++ recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd | 6 ------ 6 files changed, 8 insertions(+), 24 deletions(-)create mode 100644 recipes-bsp/rpi-u-boot-scr/files/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd
(quoted diff) +0
-0b/recipes-bsp/bootfiles/rpi-config_git.bb index f610718..2f4d25c 100644 --- a/recipes-bsp/bootfiles/rpi-config_git.bb +++ b/recipes-bsp/bootfiles/rpi-config_git.bb
(quoted diff) +0
-0@@ -76,6 +76,11 @@ do_deploy() { echo "dispmanx_offline=1"Quoted 1 line
Quoted 1 line
${DEPLOYDIR}/bcm2835-bootfiles/config.txtfirecipes-bsp/bootfiles/rpi-config_git.bb +3
-0+ # U-Boot Device Tree support + if [ "${KERNEL_IMAGETYPE}" = "uImage" ]; then + sed -i '/#device_tree_address/ c\device_tree_address=0x100'
${DEPLOYDIR}/bcm2835-bootfiles/config.txtrecipes-bsp/bootfiles/rpi-config_git.bb +2
-0+ fi + # SPI bus support if [ -n "${ENABLE_SPI_BUS}" ] || [ "${PITFT}" = "1" ]; then echo "# Enable SPI bus"Quoted 3 lines
Quoted 3 lines
${DEPLOYDIR}/bcm2835-bootfiles/config.txtdiff --git a/recipes-bsp/rpi-u-boot-scr/files/boot.cmd b/recipes-bsp/rpi-u-boot-scr/files/boot.cmdnew file mode 100644
index 0000000..3f7e3b6recipes-bsp/rpi-u-boot-scr/files/boot.cmd new file +3
-0@@ -0,0 +1,3 @@ +fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs +fatload mmc 0:1 ${kernel_addr_r} uImage +bootm ${kernel_addr_r} - ${fdt_addr_r}(quoted diff) +0
-0b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd deleted file mode 100644 index c86c758..0000000
recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd deleted +0
-2@@ -1,6 +0,0 @@ -setenv fdtfile bcm2708-rpi-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0
recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd deleted +0
-3-fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}(quoted diff) +0
-0b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd deleted file mode 100644 index c86c758..0000000
recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd deleted +0
-2@@ -1,6 +0,0 @@ -setenv fdtfile bcm2708-rpi-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0
recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd deleted +0
-3-fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}(quoted diff) +0
-0b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd deleted file mode 100644 index aa4ea64..0000000
recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd deleted +0
-2@@ -1,6 +0,0 @@ -setenv fdtfile bcm2709-rpi-2-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0
recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd deleted +0
-3-fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}(quoted diff) +0
-0b/recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd deleted file mode 100644 index 2950856..0000000
recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd deleted +0
-2@@ -1,6 +0,0 @@ -setenv fdtfile bcm2710-rpi-3-b.dtb -setenv bootargs 'earlyprintk console=tty0 console=ttyAMA0root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd' -mmc dev 0
recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd
Quoted 3 lines
recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd deleted +0
-3-fatload mmc 0:1 ${kernel_addr_r} uImage -fatload mmc 0:1 ${fdt_addr_r} ${fdtfile} -bootm ${kernel_addr_r} - ${fdt_addr_r}Looks like I missed the RaspberryPi Device Tree documentation
(https://www.raspberrypi.org/documentation/configuration/device-tree.md)
when putting my patches together. I assumed that they use device trees in a pretty standard way but looks like I was wrong!
Quoted 1 line
I'll give this a test this week.
Staged for testing
Quoted 8 lines
Thanks,
Paul
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto
Quoted 50 lines · On Wed, 2 Nov 2016 00:49:11 +1100 Jonathan Liu <[email protected]> wrote:
device_tree_address=0x100 is set in config.txt so the firmware will load a patched device tree blob to
0x100before passing control to U-Boot. 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.
Signed-off-by Jonathan Liu <[email protected]>--- recipes-bsp/bootfiles/rpi-config_git.bb | 5 +++++ recipes-bsp/rpi-u-boot-scr/files/boot.cmd | 3 +++ recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd | 6 ------ 6 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 recipes-bsp/rpi-u-boot-scr/files/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmdrecipes-bsp/bootfiles/rpi-config_git.bb +5
-0@@ -76,6 +76,11 @@ do_deploy() { echo "dispmanx_offline=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt fi + # U-Boot Device Tree support + if [ "${KERNEL_IMAGETYPE}" = "uImage" ]; then + sed -i '/#device_tree_address/ c\device_tree_address=0x100' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt + fi + # SPI bus support if [ -n "${ENABLE_SPI_BUS}" ] || [ "${PITFT}" = "1" ]; then echo "# Enable SPI bus" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txtrecipes-bsp/rpi-u-boot-scr/files/boot.cmd new file +3
-0@@ -0,0 +1,3 @@ +fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs +fatload mmc 0:1 ${kernel_addr_r} uImage +bootm ${kernel_addr_r} - ${fdt_addr_r}
Quoted 1 line
<snip deleted files>
This doesn't work for me.
On RaspberryPi B+ I get no kernel messages during the boot. I do get a login prompt though and the boot is successful.
On RaspberryPi 3 I don't get anything after "Starting kernel ...".
https://www.raspberrypi.org/documentation/configuration/device-tree.md
says:
The base Device Trees are located alongside start.elf in the FAT partition (/boot from Linux), named bcm2708-rpi-b.dtb, bcm2708-rpi-b-plus.dtb, bcm2708-rpi-cm.dtb, and bcm2709-rpi-2-b.dtb.
In /boot I have:
bcm2708-rpi-b.dtb
bcm2708-rpi-b-plus.dtb
bcm2709-rpi-2-b.dtb
bcm2710-rpi-3-b.dtbSo my guess is that the RaspberryPi 3 isn't loading the right device tree.
Is this a problem with start.elf (which we need to report upstream) or a problem with our DTB file names?
I'd also say we probably have a problem with bootargs as it doesn't print out kernel messages during boot.
What's the benefit of using the device tree cobbled together by start.elf instead of loading the DTB file ourselves?
Thanks,
Paul Barker
Hi Paul,
Quoted 80 lines · Paul Barker
Quoted 50 lines · On Wed, 2 Nov 2016 00:49:11 +1100 Jonathan Liu <[email protected]> wrote:
device_tree_address=0x100 is set in config.txt so the firmware will load a patched device tree blob to
0x100before passing control to U-Boot. 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.
Signed-off-by Jonathan Liu <[email protected]>--- recipes-bsp/bootfiles/rpi-config_git.bb | 5 +++++ recipes-bsp/rpi-u-boot-scr/files/boot.cmd | 3 +++ recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd | 6 ------ 6 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 recipes-bsp/rpi-u-boot-scr/files/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmdrecipes-bsp/bootfiles/rpi-config_git.bb +5
-0@@ -76,6 +76,11 @@ do_deploy() { echo "dispmanx_offline=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt fi + # U-Boot Device Tree support + if [ "${KERNEL_IMAGETYPE}" = "uImage" ]; then + sed -i '/#device_tree_address/ c\device_tree_address=0x100' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt + fi + # SPI bus support if [ -n "${ENABLE_SPI_BUS}" ] || [ "${PITFT}" = "1" ]; then echo "# Enable SPI bus" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txtrecipes-bsp/rpi-u-boot-scr/files/boot.cmd new file +3
-0@@ -0,0 +1,3 @@ +fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs +fatload mmc 0:1 ${kernel_addr_r} uImage +bootm ${kernel_addr_r} - ${fdt_addr_r}Quoted 1 line
<snip deleted files>
This doesn't work for me.
On RaspberryPi B+ I get no kernel messages during the boot. I do get a login prompt though and the boot is successful.
On RaspberryPi 3 I don't get anything after "Starting kernel ...".
https://www.raspberrypi.org/documentation/configuration/device-tree.md
says:The base Device Trees are located alongside start.elf in the FAT partition (/boot from Linux), named bcm2708-rpi-b.dtb, bcm2708-rpi-b-plus.dtb, bcm2708-rpi-cm.dtb, and bcm2709-rpi-2-b.dtb.
In /boot I have:
bcm2708-rpi-b.dtb bcm2708-rpi-b-plus.dtb bcm2709-rpi-2-b.dtb bcm2710-rpi-3-b.dtbSo my guess is that the RaspberryPi 3 isn't loading the right device tree.
Quoted 8 lines
Is this a problem with start.elf (which we need to report upstream) or a problem with our DTB file names?
I'd also say we probably have a problem with bootargs as it doesn't print out kernel messages during boot.
What's the benefit of using the device tree cobbled together by start.elf instead of loading the DTB file ourselves?
As I mentioned in the commit:
"This allows things like MAC address, board revision and serial number to be correctly configured and options in config.txt to be used."
So:
- MAC address of ethernet shown by ifconfig
- Output of cat /proc/cpuinfo
Looks like the config.txt option disables the board model auto detection so the device_tree= config.txt isn't automatically set properly. Probably the U-Boot binary needs to modified by mkknlimg --dtok instead of explicitly setting the device tree address in config.txt. Will look into this later if I have time.
Regards,
Jonathan
Quoted 100 lines · On Fri, 4 Nov 2016 08:55:05 +1100 Jonathan Liu <[email protected]> wrote:
Hi Paul,
Quoted 80 lines · Paul Barker
Quoted 50 lines · On Wed, 2 Nov 2016 00:49:11 +1100 Jonathan Liu <[email protected]> wrote:
device_tree_address=0x100 is set in config.txt so the firmware will load a patched device tree blob to
0x100before passing control to U-Boot. 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.
Signed-off-by Jonathan Liu <[email protected]>--- recipes-bsp/bootfiles/rpi-config_git.bb | 5 +++++ recipes-bsp/rpi-u-boot-scr/files/boot.cmd | 3 +++ recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd | 6 ------ 6 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 recipes-bsp/rpi-u-boot-scr/files/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmdrecipes-bsp/bootfiles/rpi-config_git.bb +5
-0@@ -76,6 +76,11 @@ do_deploy() { echo "dispmanx_offline=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt fi + # U-Boot Device Tree support + if [ "${KERNEL_IMAGETYPE}" = "uImage" ]; then + sed -i '/#device_tree_address/ c\device_tree_address=0x100' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt + fi + # SPI bus support if [ -n "${ENABLE_SPI_BUS}" ] || [ "${PITFT}" = "1" ]; then echo "# Enable SPI bus" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txtrecipes-bsp/rpi-u-boot-scr/files/boot.cmd new file +3
-0@@ -0,0 +1,3 @@ +fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs +fatload mmc 0:1 ${kernel_addr_r} uImage +bootm ${kernel_addr_r} - ${fdt_addr_r}Quoted 1 line
<snip deleted files>
This doesn't work for me.
On RaspberryPi B+ I get no kernel messages during the boot. I do get a login prompt though and the boot is successful.
On RaspberryPi 3 I don't get anything after "Starting kernel ...".
https://www.raspberrypi.org/documentation/configuration/device-tree.md
says:The base Device Trees are located alongside start.elf in the FAT partition (/boot from Linux), named bcm2708-rpi-b.dtb, bcm2708-rpi-b-plus.dtb, bcm2708-rpi-cm.dtb, and bcm2709-rpi-2-b.dtb.
In /boot I have:
bcm2708-rpi-b.dtb bcm2708-rpi-b-plus.dtb bcm2709-rpi-2-b.dtb bcm2710-rpi-3-b.dtbSo my guess is that the RaspberryPi 3 isn't loading the right device tree.
Quoted 8 lines
Is this a problem with start.elf (which we need to report upstream) or a problem with our DTB file names?
I'd also say we probably have a problem with bootargs as it doesn't print out kernel messages during boot.
What's the benefit of using the device tree cobbled together by start.elf instead of loading the DTB file ourselves?
As I mentioned in the commit:
"This allows things like MAC address, board revision and serial number to be correctly configured and options in config.txt to be used."So:
- MAC address of ethernet shown by ifconfig
- Output of cat/proc/cpuinfo
Quoted 6 lines
Looks like the config.txt option disables the board model auto detection so the device_tree= config.txt isn't automatically set properly. Probably the U-Boot binary needs to modified by mkknlimg --dtok instead of explicitly setting the device tree address in config.txt. Will look into this later if I have time.
Ah ok, that makes sense.
I'll have a look if there's any way to check which DTB file start.elf is picking up.
I thought mkknlimg wasn't required any more though
(https://github.com/raspberrypi/tools/issues/58). I'm probably just hitting up against the not-well-documented bits of the RaspberryPi boot process.
Thanks,
Paul
Hi Paul,
Quoted 112 lines · Paul Barker
Quoted 100 lines · On Fri, 4 Nov 2016 08:55:05 +1100 Jonathan Liu <[email protected]> wrote:
Hi Paul,
Quoted 80 lines · Paul Barker
Quoted 50 lines · On Wed, 2 Nov 2016 00:49:11 +1100 Jonathan Liu <[email protected]> wrote:
device_tree_address=0x100 is set in config.txt so the firmware will load a patched device tree blob to
0x100before passing control to U-Boot. 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.
Signed-off-by Jonathan Liu <[email protected]>--- recipes-bsp/bootfiles/rpi-config_git.bb | 5 +++++ recipes-bsp/rpi-u-boot-scr/files/boot.cmd | 3 +++ recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd | 6 ------ recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmd | 6 ------ 6 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 recipes-bsp/rpi-u-boot-scr/files/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi0/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi2/boot.cmd delete mode 100644 recipes-bsp/rpi-u-boot-scr/files/raspberrypi3/boot.cmdrecipes-bsp/bootfiles/rpi-config_git.bb +5
-0@@ -76,6 +76,11 @@ do_deploy() { echo "dispmanx_offline=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt fi + # U-Boot Device Tree support + if [ "${KERNEL_IMAGETYPE}" = "uImage" ]; then + sed -i '/#device_tree_address/ c\device_tree_address=0x100' ${DEPLOYDIR}/bcm2835-bootfiles/config.txt + fi + # SPI bus support if [ -n "${ENABLE_SPI_BUS}" ] || [ "${PITFT}" = "1" ]; then echo "# Enable SPI bus" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txtrecipes-bsp/rpi-u-boot-scr/files/boot.cmd new file +3
-0@@ -0,0 +1,3 @@ +fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs +fatload mmc 0:1 ${kernel_addr_r} uImage +bootm ${kernel_addr_r} - ${fdt_addr_r}Quoted 1 line
<snip deleted files>
This doesn't work for me.
On RaspberryPi B+ I get no kernel messages during the boot. I do get a login prompt though and the boot is successful.
On RaspberryPi 3 I don't get anything after "Starting kernel ...".
https://www.raspberrypi.org/documentation/configuration/device-tree.md
says:The base Device Trees are located alongside start.elf in the FAT partition (/boot from Linux), named bcm2708-rpi-b.dtb, bcm2708-rpi-b-plus.dtb, bcm2708-rpi-cm.dtb, and bcm2709-rpi-2-b.dtb.
In /boot I have:
bcm2708-rpi-b.dtb bcm2708-rpi-b-plus.dtb bcm2709-rpi-2-b.dtb bcm2710-rpi-3-b.dtbSo my guess is that the RaspberryPi 3 isn't loading the right device tree.
Quoted 8 lines
Is this a problem with start.elf (which we need to report upstream) or a problem with our DTB file names?
I'd also say we probably have a problem with bootargs as it doesn't print out kernel messages during boot.
What's the benefit of using the device tree cobbled together by start.elf instead of loading the DTB file ourselves?
As I mentioned in the commit:
"This allows things like MAC address, board revision and serial number to be correctly configured and options in config.txt to be used."So:
- MAC address of ethernet shown by ifconfig
- Output of cat/proc/cpuinfoQuoted 6 lines
Looks like the config.txt option disables the board model auto detection so the device_tree= config.txt isn't automatically set properly. Probably the U-Boot binary needs to modified by mkknlimg --dtok instead of explicitly setting the device tree address in config.txt. Will look into this later if I have time.
Ah ok, that makes sense.
Quoted 7 lines
I'll have a look if there's any way to check which DTB file start.elf is picking up.
I thought mkknlimg wasn't required any more though
(https://github.com/raspberrypi/tools/issues/58). I'm probably just hitting up against the not-well-documented bits of the RaspberryPi boot process.
You're right. It seems the firmware from 4.4 release onward will enable device tree by default if there is no trailer present.
Running "vcdbg log msg" shows:
002761.625: Read command line from file 'cmdline.txt' dwc_otg.lpm_enable=0 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
002785.056: Loading 'kernel7.img' to 0x8000 size 0x52690 002788.710: No kernel trailer (run mkknlimg to fix) - assuming DT-capable 002791.303: Loading 'bcm2709-rpi-2-b.dtb' to 0x5a690 size 0x3bfc 002869.679: dtparam: pwr_led_gpio=35
002879.048: dtparam: uart0_clkrate=48000000
002969.703: dtparam: arm_freq=900000000
003011.816: dtparam: core_freq=250000000
003022.927: dtparam: cache_line_size=64
003044.337: Device tree loaded to 0x2effbf00 (size 0x40f8) 003047.568: gpioman: gpioman_get_pin_num: pin SDCARD_CONTROL_POWER not defined 100942.791: vchiq_core: vchiq_init_state: slot_zero = 0xf6c80000, is_master = 1 100947.180: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
100952.267: TV service:host side not connected, dropping notification 0x00000002, 0x00000002, 0x00000027
I just copied downloaded
https://github.com/raspberrypi/firmware/blob/master/hardfp/opt/vc/bin/vcdbg
and https://github.com/raspberrypi/firmware/blob/master/hardfp/opt/vc/lib/libelftoolchain.so
to my Raspberry Pi and ran "LD_LIBRARY_PATH=. ./vcdbg log msg".
Note the line "002788.710: No kernel trailer (run mkknlimg to fix) - assuming DT-capable".
Sometime ago the firmware used to load the patched device tree blobs to 0x100 (which is the default value of fdt_addr_r in newer versions of U-Boot for Raspberry Pi). It seems to have changed though as can be seen by the line "003044.337: Device tree loaded to 0x2effbf00 (size 0x40f8)".
Something like this would fix it for Raspberry Pi 2:
(quoted diff) +0 -0
b/recipes-bsp/bootfiles/rpi-config_git.bb
index 2f4d25c..f610718 100644
recipes-bsp/bootfiles/rpi-config_git.bb +0 -3
@@ -76,11 +76,6 @@ do_deploy() { echo "dispmanx_offline=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt fi - # U-Boot Device Tree support - if [ "${KERNEL_IMAGETYPE}" = "uImage" ]; then - sed -i '/#device_tree_address/ c\device_tree_address=0x100'
${DEPLOYDIR}/bcm2835-bootfiles/config.txt
- fi
-
# SPI bus support
if [ -n "${ENABLE_SPI_BUS}" ] || [ "${PITFT}" = "1" ]; then
echo "# Enable SPI bus" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt(quoted diff) +0 -0
b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd
index 3f7e3b6..201272a 100644
recipes-bsp/rpi-u-boot-scr/files/boot.cmd +1 -0
@@ -1,3 +1,4 @@ +setenv fdt_addr_r 0x2effbf00 fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs fatload mmc 0:1 ${kernel_addr_r} uImage bootm ${kernel_addr_r} - ${fdt_addr_r}
But the device tree address may change in the future and might be different for each Raspberry Pi model.
I only have Raspberry Pi 2 for development.
Here are some ways to solve this:
- Find out the memory address the blob is loaded to for each model and use the fdt addr command to try each one until it can parse it successfully. Likely to break in the future.
- Modify U-Boot to save the device tree address from CPU register r2 in the entry point, then the U-Boot script can try reading the device tree from that address.
- Get upstream Raspberry Pi firmware to support auto-detection of board and loading of associated device tree, even when device_tree_address is set in config.txt
Regards,
Jonathan