[yocto] [meta-raspberrypi][PATCH] u-boot: Simplify boot script

Paul Barker paul at paulbarker.me.uk
Thu Nov 3 15:14:16 PDT 2016


On Fri, 4 Nov 2016 08:55:05 +1100
Jonathan Liu <net147 at gmail.com> wrote:

> Hi Paul,
> 
> On 4 November 2016 at 07:57, Paul Barker <paul at paulbarker.me.uk> wrote:
> > On Wed,  2 Nov 2016 00:49:11 +1100
> > Jonathan Liu <net147 at gmail.com> wrote:
> >
> >> 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.
> >>
> >> Signed-off-by: Jonathan Liu <net147 at gmail.com>
> >> ---
> >>  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
> >>
> >> diff --git a/recipes-bsp/bootfiles/rpi-config_git.bb b/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
> >> @@ -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
> >> 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..3f7e3b6
> >> --- /dev/null
> >> +++ b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd
> >> @@ -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}
> >>
> >> <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.dtb
> >
> > So 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?
> 
> 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.
> 

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



More information about the yocto mailing list