diff mbox series

[U-Boot,2/4] am335x_evm: scan more partitions and use uname_r

Message ID 20180307104044.4739-3-jdk@ti.com
State Rejected
Delegated to: Tom Rini
Headers show
Series Add support for BeagleBoard.org PocketBeagle | expand

Commit Message

Jason Kridner March 7, 2018, 10:40 a.m. UTC
This enables mainline u-boot to boot the BeagleBoard.org Debian
distribution builds without extensive environment modifications.

Some boot layouts only have a single partition on the
MMC/eMMC. This will scan those partitions after the second
partition that was already being scanned.

Some layouts use uname_r to define the kernel being used for the boot to
support multiple kernels stored within the boot file system without
using symlinks.

See http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0 for
more details on the BeagleBoard.org Debian image layout.

Signed-off-by: Jason Kridner <jdk@ti.com>
Cc: Robert Nelson <robertcnelson@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
---
 include/configs/am335x_evm.h |  5 ++++-
 include/environment/ti/mmc.h | 13 +++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)

Comments

Tom Rini March 7, 2018, 2:27 p.m. UTC | #1
On Wed, Mar 07, 2018 at 05:40:42AM -0500, Jason Kridner wrote:

> This enables mainline u-boot to boot the BeagleBoard.org Debian
> distribution builds without extensive environment modifications.
> 
> Some boot layouts only have a single partition on the
> MMC/eMMC. This will scan those partitions after the second
> partition that was already being scanned.
> 
> Some layouts use uname_r to define the kernel being used for the boot to
> support multiple kernels stored within the boot file system without
> using symlinks.
> 
> See http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0 for
> more details on the BeagleBoard.org Debian image layout.
> 
> Signed-off-by: Jason Kridner <jdk@ti.com>
> Cc: Robert Nelson <robertcnelson@gmail.com>
> Cc: Tom Rini <trini@konsulko.com>
> ---
>  include/configs/am335x_evm.h |  5 ++++-
>  include/environment/ti/mmc.h | 13 +++++++++----
>  2 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
> index 8d45b6fade..32fe0e0cd5 100644
> --- a/include/configs/am335x_evm.h
> +++ b/include/configs/am335x_evm.h
> @@ -61,7 +61,10 @@
>  #define BOOTENV_DEV_LEGACY_MMC(devtypeu, devtypel, instance) \
>  	"bootcmd_" #devtypel #instance "=" \
>  	"setenv mmcdev " #instance"; "\
> -	"setenv bootpart " #instance":2 ; "\
> +	"setenv bootpart " #instance":2; "\
> +	"run mmcboot;"\
> +	"setenv mmcdev " #instance"; "\
> +	"setenv bootpart " #instance":1; "\
>  	"run mmcboot\0"
>  
>  #define BOOTENV_DEV_NAME_LEGACY_MMC(devtypeu, devtypel, instance) \
> diff --git a/include/environment/ti/mmc.h b/include/environment/ti/mmc.h
> index 4305ebdaaf..b803ecccb7 100644
> --- a/include/environment/ti/mmc.h
> +++ b/include/environment/ti/mmc.h
> @@ -23,9 +23,10 @@
>  	"bootenvfile=uEnv.txt\0" \
>  	"importbootenv=echo Importing environment from mmc${mmcdev} ...; " \
>  		"env import -t ${loadaddr} ${filesize}\0" \
> -	"loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}\0" \
> -	"loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \
> -	"loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
> +	"loadbootenv=if fatload mmc ${mmcdev} ${loadaddr} ${bootdir}/${bootenvfile}; then echo Found ${bootdir}/${bootenvfile} in FAT partition; else load mmc ${mmcdev} ${loadaddr} ${bootdir}/${bootenvfile}; fi\0" \
> +	"loadimage=if test -n ${uname_r}; then load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/vmlinuz-${uname_r}; run loadrd; else load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}; fi\0" \
> +	"loadrd=load ${devtype} ${bootpart} ${rdaddr} ${bootdir}/initrd.img-${uname_r}; setenv rdsize ${filesize}\0" \
> +	"loadfdt=if test -n ${uname_r}; then load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/dtbs/${uname_r}/${fdtfile}; else load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}; fi;\0" \
>  	"envboot=mmc dev ${mmcdev}; " \
>  		"if mmc rescan; then " \
>  			"echo SD/MMC found on device ${mmcdev};" \
> @@ -45,7 +46,11 @@
>  	"mmcloados=run args_mmc; " \
>  		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
>  			"if run loadfdt; then " \
> -				"bootz ${loadaddr} - ${fdtaddr}; " \
> +				"if test -n ${uname_r}; then " \
> +					"bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}; " \
> +				"else " \
> +					"bootz ${loadaddr} - ${fdtaddr}; " \
> +				"fi; " \
>  			"else " \
>  				"if test ${boot_fdt} = try; then " \
>  					"bootz; " \

Why does this all differ from the usual Debian case?  Thanks!
Jason Kridner March 10, 2018, 4:34 p.m. UTC | #2
On Wed, Mar 7, 2018 at 9:27 AM Tom Rini <trini@konsulko.com> wrote:

> On Wed, Mar 07, 2018 at 05:40:42AM -0500, Jason Kridner wrote:
>
> > This enables mainline u-boot to boot the BeagleBoard.org Debian
> > distribution builds without extensive environment modifications.
> >
> > Some boot layouts only have a single partition on the
> > MMC/eMMC. This will scan those partitions after the second
> > partition that was already being scanned.
> >
> > Some layouts use uname_r to define the kernel being used for the boot to
> > support multiple kernels stored within the boot file system without
> > using symlinks.
> >
> > See http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0 for
> > more details on the BeagleBoard.org Debian image layout.
> >
> > Signed-off-by: Jason Kridner <jdk@ti.com>
> > Cc: Robert Nelson <robertcnelson@gmail.com>
> > Cc: Tom Rini <trini@konsulko.com>
> > ---
> >  include/configs/am335x_evm.h |  5 ++++-
> >  include/environment/ti/mmc.h | 13 +++++++++----
> >  2 files changed, 13 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
> > index 8d45b6fade..32fe0e0cd5 100644
> > --- a/include/configs/am335x_evm.h
> > +++ b/include/configs/am335x_evm.h
> > @@ -61,7 +61,10 @@
> >  #define BOOTENV_DEV_LEGACY_MMC(devtypeu, devtypel, instance) \
> >       "bootcmd_" #devtypel #instance "=" \
> >       "setenv mmcdev " #instance"; "\
> > -     "setenv bootpart " #instance":2 ; "\
> > +     "setenv bootpart " #instance":2; "\
> > +     "run mmcboot;"\
> > +     "setenv mmcdev " #instance"; "\
> > +     "setenv bootpart " #instance":1; "\
> >       "run mmcboot\0"
> >
> >  #define BOOTENV_DEV_NAME_LEGACY_MMC(devtypeu, devtypel, instance) \
> > diff --git a/include/environment/ti/mmc.h b/include/environment/ti/mmc.h
> > index 4305ebdaaf..b803ecccb7 100644
> > --- a/include/environment/ti/mmc.h
> > +++ b/include/environment/ti/mmc.h
> > @@ -23,9 +23,10 @@
> >       "bootenvfile=uEnv.txt\0" \
> >       "importbootenv=echo Importing environment from mmc${mmcdev} ...; "
> \
> >               "env import -t ${loadaddr} ${filesize}\0" \
> > -     "loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}\0" \
> > -     "loadimage=load ${devtype} ${bootpart} ${loadaddr}
> ${bootdir}/${bootfile}\0" \
> > -     "loadfdt=load ${devtype} ${bootpart} ${fdtaddr}
> ${bootdir}/${fdtfile}\0" \
> > +     "loadbootenv=if fatload mmc ${mmcdev} ${loadaddr}
> ${bootdir}/${bootenvfile}; then echo Found ${bootdir}/${bootenvfile} in FAT
> partition; else load mmc ${mmcdev} ${loadaddr} ${bootdir}/${bootenvfile};
> fi\0" \
> > +     "loadimage=if test -n ${uname_r}; then load ${devtype} ${bootpart}
> ${loadaddr} ${bootdir}/vmlinuz-${uname_r}; run loadrd; else load ${devtype}
> ${bootpart} ${loadaddr} ${bootdir}/${bootfile}; fi\0" \
> > +     "loadrd=load ${devtype} ${bootpart} ${rdaddr}
> ${bootdir}/initrd.img-${uname_r}; setenv rdsize ${filesize}\0" \
> > +     "loadfdt=if test -n ${uname_r}; then load ${devtype} ${bootpart}
> ${fdtaddr} ${bootdir}/dtbs/${uname_r}/${fdtfile}; else load ${devtype}
> ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}; fi;\0" \
> >       "envboot=mmc dev ${mmcdev}; " \
> >               "if mmc rescan; then " \
> >                       "echo SD/MMC found on device ${mmcdev};" \
> > @@ -45,7 +46,11 @@
> >       "mmcloados=run args_mmc; " \
> >               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then
> " \
> >                       "if run loadfdt; then " \
> > -                             "bootz ${loadaddr} - ${fdtaddr}; " \
> > +                             "if test -n ${uname_r}; then " \
> > +                                     "bootz ${loadaddr}
> ${rdaddr}:${rdsize} ${fdtaddr}; " \
> > +                             "else " \
> > +                                     "bootz ${loadaddr} - ${fdtaddr}; "
> \
> > +                             "fi; " \
> >                       "else " \
> >                               "if test ${boot_fdt} = try; then " \
> >                                       "bootz; " \
>
> Why does this all differ from the usual Debian case?  Thanks!
>

I believe the distros typically use /boot/extlinux/extlinux.conf. We need
some way to specify a number of other environment variables we use
elsewhere in our u-boot scripts for applying device-tree overlays and such.
This patch doesn't comprehend that. It does at least get our images to boot
without applying any overlays in u-boot.

I believe Robert is preparing a subsequent series to add the application of
overlays.

Do you have something else in mind with regards to envboot's future?


>
> --
> Tom
>
Vagrant Cascadian March 10, 2018, 11:13 p.m. UTC | #3
On 2018-03-10, Jason Kridner wrote:
> On Wed, Mar 7, 2018 at 9:27 AM Tom Rini <trini@konsulko.com> wrote:
>> On Wed, Mar 07, 2018 at 05:40:42AM -0500, Jason Kridner wrote:
>> > This enables mainline u-boot to boot the BeagleBoard.org Debian
>> > distribution builds without extensive environment modifications.
>> >
>> > Some boot layouts only have a single partition on the
>> > MMC/eMMC. This will scan those partitions after the second
>> > partition that was already being scanned.
>> >
>> > Some layouts use uname_r to define the kernel being used for the boot to
>> > support multiple kernels stored within the boot file system without
>> > using symlinks.
>> >
>> > See http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0 for
>> > more details on the BeagleBoard.org Debian image layout.
...
>> Why does this all differ from the usual Debian case?  Thanks!
>>
>
> I believe the distros typically use /boot/extlinux/extlinux.conf.

Debian typically uses a boot script, at least when installing from
debian-installer. There's a package called u-boot-menu which generates
the extlinux.conf file. There are some ideas floating around to try to
use u-boot's EFI emulation to boot grub-efi for platforms that don't
support EFI natively, as well.

But the majority of officially supported platforms in Debian still just
use boot scripts, for better or worse.


> We need some way to specify a number of other environment variables we
> use elsewhere in our u-boot scripts for applying device-tree overlays
> and such.

Could this functionality can't be implemented as a boot script, rather
than hard-coding it into the u-boot binary?

I know the official BeagleBoard.org images have been using a patched
u-boot for quite some time, and so there is something to be said for
pushing that upstream. Though there is a lot of duplication of
functionality supporting distro_bootcmd, legacy boot, and the patchsets
that BeagleBoard.org images use.


live well,
  vagrant
diff mbox series

Patch

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 8d45b6fade..32fe0e0cd5 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -61,7 +61,10 @@ 
 #define BOOTENV_DEV_LEGACY_MMC(devtypeu, devtypel, instance) \
 	"bootcmd_" #devtypel #instance "=" \
 	"setenv mmcdev " #instance"; "\
-	"setenv bootpart " #instance":2 ; "\
+	"setenv bootpart " #instance":2; "\
+	"run mmcboot;"\
+	"setenv mmcdev " #instance"; "\
+	"setenv bootpart " #instance":1; "\
 	"run mmcboot\0"
 
 #define BOOTENV_DEV_NAME_LEGACY_MMC(devtypeu, devtypel, instance) \
diff --git a/include/environment/ti/mmc.h b/include/environment/ti/mmc.h
index 4305ebdaaf..b803ecccb7 100644
--- a/include/environment/ti/mmc.h
+++ b/include/environment/ti/mmc.h
@@ -23,9 +23,10 @@ 
 	"bootenvfile=uEnv.txt\0" \
 	"importbootenv=echo Importing environment from mmc${mmcdev} ...; " \
 		"env import -t ${loadaddr} ${filesize}\0" \
-	"loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}\0" \
-	"loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \
-	"loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
+	"loadbootenv=if fatload mmc ${mmcdev} ${loadaddr} ${bootdir}/${bootenvfile}; then echo Found ${bootdir}/${bootenvfile} in FAT partition; else load mmc ${mmcdev} ${loadaddr} ${bootdir}/${bootenvfile}; fi\0" \
+	"loadimage=if test -n ${uname_r}; then load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/vmlinuz-${uname_r}; run loadrd; else load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}; fi\0" \
+	"loadrd=load ${devtype} ${bootpart} ${rdaddr} ${bootdir}/initrd.img-${uname_r}; setenv rdsize ${filesize}\0" \
+	"loadfdt=if test -n ${uname_r}; then load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/dtbs/${uname_r}/${fdtfile}; else load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}; fi;\0" \
 	"envboot=mmc dev ${mmcdev}; " \
 		"if mmc rescan; then " \
 			"echo SD/MMC found on device ${mmcdev};" \
@@ -45,7 +46,11 @@ 
 	"mmcloados=run args_mmc; " \
 		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
 			"if run loadfdt; then " \
-				"bootz ${loadaddr} - ${fdtaddr}; " \
+				"if test -n ${uname_r}; then " \
+					"bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}; " \
+				"else " \
+					"bootz ${loadaddr} - ${fdtaddr}; " \
+				"fi; " \
 			"else " \
 				"if test ${boot_fdt} = try; then " \
 					"bootz; " \