u-boot: Simplify boot script
PATCH v2 1/1 u-boot: Simplify boot script
A patch is added to check if the firmware loaded a device tree blob into memory and set the fdt_addr_r 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.
---
Changes in v2:
- Instead of setting device_tree_address to 0x100 in config.txt, patch U-Boot to detect the device tree blob address if it was loaded.
recipes-bsp/rpi-u-boot-scr/files/boot.cmd | 3 + .../rpi-u-boot-scr/files/raspberrypi/boot.cmd | 6 -- .../rpi-u-boot-scr/files/raspberrypi0/boot.cmd | 6 -- .../rpi-u-boot-scr/files/raspberrypi2/boot.cmd | 6 -- .../rpi-u-boot-scr/files/raspberrypi3/boot.cmd | 6 -- recipes-bsp/u-boot/files/rpi-fdt-addr.patch | 80 ++++++++++++++++++++++ recipes-bsp/u-boot/u-boot_%.bbappend | 2 + 7 files changed, 85 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 create mode 100644 recipes-bsp/u-boot/files/rpi-fdt-addr.patch
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}
recipes-bsp/u-boot/files/rpi-fdt-addr.patch new file +80 -0
80 lines not on this page · raw message
recipes-bsp/u-boot/u-boot_%.bbappend +2 -0
@@ -1 +1,3 @@ +FILESEXTRAPATHS_prepend_rpi := "${THISDIR}/files:" RDEPENDS_${PN}_append_rpi = " rpi-u-boot-scr" +SRC_URI_append_rpi = " file://rpi-fdt-addr.patch"
Signature · 1 line
2.10.1
Quoted 6 lines · On Sat, 5 Nov 2016 00:47:34 +1100 Jonathan Liu <[email protected]> wrote:
A patch is added to check if the firmware loaded a device tree blob into memory and set the
fdt_addr_rvariable 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.
Quoted 9 lines
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]>---
Changes in v2:
- Instead of settingdevice_tree_addressto0x100in config.txt, patch U-Boot to detect the device tree blob address if it was loaded.
I've tested this on the HW I have access to but I'm still running into problems.
RaspberryPi B+: Fails with "Could not find a valid device tree" message. I need to debug this further.
RaspberryPi 3: Boots successfully. However "earlyprintk" is missing from the bootargs so we miss kernel messages which may be useful for debug.
Thanks,
Paul Barker
Hi Paul,
Quoted 22 lines · Paul Barker
Quoted 6 lines · On Sat, 5 Nov 2016 00:47:34 +1100 Jonathan Liu <[email protected]> wrote:
A patch is added to check if the firmware loaded a device tree blob into memory and set the
fdt_addr_rvariable 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.Quoted 9 lines
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]>---
Changes in v2:
- Instead of settingdevice_tree_addressto0x100in config.txt, patch U-Boot to detect the device tree blob address if it was loaded.I've tested this on the HW I have access to but I'm still running into problems.
Quoted 6 lines
RaspberryPi B+: Fails with "Could not find a valid device tree" message. I need to debug this further.
RaspberryPi 3: Boots successfully. However "earlyprintk" is missing from the bootargs so we miss kernel messages which may be useful for debug.
You can do one of the following:
- Add CMDLINE_append = " earlyprintk" to local.conf or distro conf
- Modify cmdline.txt on the SD card boot partition and add earlyprintk
I didn't want to make any assumptions.
Regards,
Jonathan
Quoted 27 lines · Jonathan Liu
Hi Paul,
Quoted 24 lines · Paul Barker
Quoted 6 lines · On Sat, 5 Nov 2016 00:47:34 +1100 Jonathan Liu <[email protected]> wrote:
A patch is added to check if the firmware loaded a device tree blob into memory and set the
fdt_addr_rvariable 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.Quoted 9 lines
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]>---
Changes in v2:
- Instead of settingdevice_tree_addressto0x100in config.txt, patch U-Boot to detect the device tree blob address if it was loaded.I've tested this on the HW I have access to but I'm still running into problems.
RaspberryPi B+: Fails with "Could not find a valid device tree" message. I need to debug this further.
To debug booting with device tree:
1. Build image without U-Boot (alternatively you can manually type in the U-Boot script commands you had previously for Raspberry Pi 1 at the U-Boot prompt after interrupting auto-boot)
2. Add dtdebug=on to config.txt
3. Boot
4. Copy vcdbg and libelftoolchain.so to Raspberry Pi 1 and run "LD_LIBRARY_PATH=. ./vcdbg log msg"
Quoted 10 lines
Quoted 4 lines
RaspberryPi 3: Boots successfully. However "earlyprintk" is missing from the bootargs so we miss kernel messages which may be useful for debug.
You can do one of the following:
- AddCMDLINE_append= " earlyprintk" to local.conf or distro conf
- Modify cmdline.txt on the SD card boot partition and add earlyprintkI didn't want to make any assumptions.