diff mbox series

[U-Boot] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register

Message ID 20181025011839.22273-1-uboot@andestech.com
State Accepted
Delegated to: Andes
Headers show
Series [U-Boot] riscv: ax25-ae350: Pass dtb address to u-boot with a1 register | expand

Commit Message

Andes Oct. 25, 2018, 1:18 a.m. UTC
From: Rick Chen <rick@andestech.com>

ax25-ae350 use CONFIG_OF_BOARD which allow the board to
override the fdt address. And prior_stage_fdt_address offer
a temporary memory address to keep the dtb address which was
passed from loader(gdb) to u-boot with a1.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: Greentime Hu <greentime@andestech.com>
---
 board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Bin Meng Oct. 25, 2018, 2:33 a.m. UTC | #1
Hi Rick,

On Thu, Oct 25, 2018 at 9:20 AM Andes <uboot@andestech.com> wrote:
>
> From: Rick Chen <rick@andestech.com>
>
> ax25-ae350 use CONFIG_OF_BOARD which allow the board to
> override the fdt address. And prior_stage_fdt_address offer
> a temporary memory address to keep the dtb address which was
> passed from loader(gdb) to u-boot with a1.

nits: U-Boot

>
> Signed-off-by: Rick Chen <rick@andestech.com>
> Cc: Greentime Hu <greentime@andestech.com>
> ---
>  board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
> index 5f4ca0f..d343453 100644
> --- a/board/AndesTech/ax25-ae350/ax25-ae350.c
> +++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
> @@ -14,6 +14,7 @@
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> +extern phys_addr_t prior_stage_fdt_address;
>  /*
>   * Miscellaneous platform dependent initializations
>   */
> @@ -66,7 +67,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
>
>  void *board_fdt_blob_setup(void)
>  {
> -       void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
> +       void **ptr = (void *)&prior_stage_fdt_address;
>         if (fdt_magic(*ptr) == FDT_MAGIC)
>                         return (void *)*ptr;
>
> --

board_fdt_blob_setup() should be completely removed. Instead the
simple fix should be add CONFIG_OF_PRIOR_STAGE to your board defconfig
files.

Regards,
Bin
Rick Chen Oct. 25, 2018, 3:12 a.m. UTC | #2
Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午10:33寫道:
>
> Hi Rick,
>
> On Thu, Oct 25, 2018 at 9:20 AM Andes <uboot@andestech.com> wrote:
> >
> > From: Rick Chen <rick@andestech.com>
> >
> > ax25-ae350 use CONFIG_OF_BOARD which allow the board to
> > override the fdt address. And prior_stage_fdt_address offer
> > a temporary memory address to keep the dtb address which was
> > passed from loader(gdb) to u-boot with a1.
>
> nits: U-Boot
>
> >
> > Signed-off-by: Rick Chen <rick@andestech.com>
> > Cc: Greentime Hu <greentime@andestech.com>
> > ---
> >  board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > index 5f4ca0f..d343453 100644
> > --- a/board/AndesTech/ax25-ae350/ax25-ae350.c
> > +++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > @@ -14,6 +14,7 @@
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > +extern phys_addr_t prior_stage_fdt_address;
> >  /*
> >   * Miscellaneous platform dependent initializations
> >   */
> > @@ -66,7 +67,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
> >
> >  void *board_fdt_blob_setup(void)
> >  {
> > -       void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
> > +       void **ptr = (void *)&prior_stage_fdt_address;
> >         if (fdt_magic(*ptr) == FDT_MAGIC)
> >                         return (void *)*ptr;
> >
> > --
>
> board_fdt_blob_setup() should be completely removed. Instead the
> simple fix should be add CONFIG_OF_PRIOR_STAGE to your board defconfig
> files.
>

Hi Bin

I have tried to switch from CONFIG_OF_BOARD to CONFIG_OF_PRIOR_STAGE.

But it will lost the function
that dtb will be pre-burned into designated flash location,
when U-Boot was booting from flash.

How can I achieve that with CONFIG_OF_PRIOR_STAGE ?

Rick

> Regards,
> Bin
Bin Meng Oct. 25, 2018, 3:15 a.m. UTC | #3
Hi Rick,

On Thu, Oct 25, 2018 at 11:11 AM Rick Chen <rickchen36@gmail.com> wrote:
>
> Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午10:33寫道:
> >
> > Hi Rick,
> >
> > On Thu, Oct 25, 2018 at 9:20 AM Andes <uboot@andestech.com> wrote:
> > >
> > > From: Rick Chen <rick@andestech.com>
> > >
> > > ax25-ae350 use CONFIG_OF_BOARD which allow the board to
> > > override the fdt address. And prior_stage_fdt_address offer
> > > a temporary memory address to keep the dtb address which was
> > > passed from loader(gdb) to u-boot with a1.
> >
> > nits: U-Boot
> >
> > >
> > > Signed-off-by: Rick Chen <rick@andestech.com>
> > > Cc: Greentime Hu <greentime@andestech.com>
> > > ---
> > >  board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > index 5f4ca0f..d343453 100644
> > > --- a/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > +++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > @@ -14,6 +14,7 @@
> > >
> > >  DECLARE_GLOBAL_DATA_PTR;
> > >
> > > +extern phys_addr_t prior_stage_fdt_address;
> > >  /*
> > >   * Miscellaneous platform dependent initializations
> > >   */
> > > @@ -66,7 +67,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
> > >
> > >  void *board_fdt_blob_setup(void)
> > >  {
> > > -       void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
> > > +       void **ptr = (void *)&prior_stage_fdt_address;
> > >         if (fdt_magic(*ptr) == FDT_MAGIC)
> > >                         return (void *)*ptr;
> > >
> > > --
> >
> > board_fdt_blob_setup() should be completely removed. Instead the
> > simple fix should be add CONFIG_OF_PRIOR_STAGE to your board defconfig
> > files.
> >
>
> Hi Bin
>
> I have tried to switch from CONFIG_OF_BOARD to CONFIG_OF_PRIOR_STAGE.
>
> But it will lost the function
> that dtb will be pre-burned into designated flash location,
> when U-Boot was booting from flash.
>

I don't get it. Do you mean on ae350 board, the DTB is pre-flashed on the flash?

> How can I achieve that with CONFIG_OF_PRIOR_STAGE ?

Regards,
Bin
Rick Chen Oct. 25, 2018, 3:28 a.m. UTC | #4
Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午11:16寫道:
>
> Hi Rick,
>
> On Thu, Oct 25, 2018 at 11:11 AM Rick Chen <rickchen36@gmail.com> wrote:
> >
> > Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午10:33寫道:
> > >
> > > Hi Rick,
> > >
> > > On Thu, Oct 25, 2018 at 9:20 AM Andes <uboot@andestech.com> wrote:
> > > >
> > > > From: Rick Chen <rick@andestech.com>
> > > >
> > > > ax25-ae350 use CONFIG_OF_BOARD which allow the board to
> > > > override the fdt address. And prior_stage_fdt_address offer
> > > > a temporary memory address to keep the dtb address which was
> > > > passed from loader(gdb) to u-boot with a1.
> > >
> > > nits: U-Boot
> > >
> > > >
> > > > Signed-off-by: Rick Chen <rick@andestech.com>
> > > > Cc: Greentime Hu <greentime@andestech.com>
> > > > ---
> > > >  board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > index 5f4ca0f..d343453 100644
> > > > --- a/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > +++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > @@ -14,6 +14,7 @@
> > > >
> > > >  DECLARE_GLOBAL_DATA_PTR;
> > > >
> > > > +extern phys_addr_t prior_stage_fdt_address;
> > > >  /*
> > > >   * Miscellaneous platform dependent initializations
> > > >   */
> > > > @@ -66,7 +67,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
> > > >
> > > >  void *board_fdt_blob_setup(void)
> > > >  {
> > > > -       void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
> > > > +       void **ptr = (void *)&prior_stage_fdt_address;
> > > >         if (fdt_magic(*ptr) == FDT_MAGIC)
> > > >                         return (void *)*ptr;
> > > >
> > > > --
> > >
> > > board_fdt_blob_setup() should be completely removed. Instead the
> > > simple fix should be add CONFIG_OF_PRIOR_STAGE to your board defconfig
> > > files.
> > >
> >
> > Hi Bin
> >
> > I have tried to switch from CONFIG_OF_BOARD to CONFIG_OF_PRIOR_STAGE.
> >
> > But it will lost the function
> > that dtb will be pre-burned into designated flash location,
> > when U-Boot was booting from flash.
> >
>
> I don't get it. Do you mean on ae350 board, the DTB is pre-flashed on the flash?
>

Yes
On ae350 board, the DTB is pre-flashed on the flash in booting from rom case.

u-boot boot from ram case:
CONFIG_OF_PRIOR_STAGE can achieve u-boot boot from ram and dtb was
passed by loader with a1(0xf0000).

u-boot boot from rom case:
If DTB is pre-flashed on the flash 0x800f0000 (This address can be
dynamically changed)
But no one assign a1=0x800f000, how can be gd->fdt_blob changed to 0x800f000.
I am wondering about that ?

0xf0000 is ram space
0x800f0000 is flash rom space

Rick


> > How can I achieve that with CONFIG_OF_PRIOR_STAGE ?
>
> Regards,
> Bin
Lukas Auer Oct. 25, 2018, 11:22 a.m. UTC | #5
Hi Rick,

On Thu, 2018-10-25 at 11:28 +0800, Rick Chen wrote:
> Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午11:16寫道:
> > 
> > Hi Rick,
> > 
> > On Thu, Oct 25, 2018 at 11:11 AM Rick Chen <rickchen36@gmail.com>
> > wrote:
> > > 
> > > Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午10:33寫道:
> > > > 
> > > > Hi Rick,
> > > > 
> > > > On Thu, Oct 25, 2018 at 9:20 AM Andes <uboot@andestech.com>
> > > > wrote:
> > > > > 
> > > > > From: Rick Chen <rick@andestech.com>
> > > > > 
> > > > > ax25-ae350 use CONFIG_OF_BOARD which allow the board to
> > > > > override the fdt address. And prior_stage_fdt_address offer
> > > > > a temporary memory address to keep the dtb address which was
> > > > > passed from loader(gdb) to u-boot with a1.
> > > > 
> > > > nits: U-Boot
> > > > 
> > > > > 
> > > > > Signed-off-by: Rick Chen <rick@andestech.com>
> > > > > Cc: Greentime Hu <greentime@andestech.com>
> > > > > ---
> > > > >  board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
> > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > index 5f4ca0f..d343453 100644
> > > > > --- a/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > +++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > @@ -14,6 +14,7 @@
> > > > > 
> > > > >  DECLARE_GLOBAL_DATA_PTR;
> > > > > 
> > > > > +extern phys_addr_t prior_stage_fdt_address;
> > > > >  /*
> > > > >   * Miscellaneous platform dependent initializations
> > > > >   */
> > > > > @@ -66,7 +67,7 @@ ulong board_flash_get_legacy(ulong base,
> > > > > int banknum, flash_info_t *info)
> > > > > 
> > > > >  void *board_fdt_blob_setup(void)
> > > > >  {
> > > > > -       void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
> > > > > +       void **ptr = (void *)&prior_stage_fdt_address;
> > > > >         if (fdt_magic(*ptr) == FDT_MAGIC)
> > > > >                         return (void *)*ptr;
> > > > > 
> > > > > --
> > > > 
> > > > board_fdt_blob_setup() should be completely removed. Instead
> > > > the
> > > > simple fix should be add CONFIG_OF_PRIOR_STAGE to your board
> > > > defconfig
> > > > files.
> > > > 
> > > 
> > > Hi Bin
> > > 
> > > I have tried to switch from CONFIG_OF_BOARD to
> > > CONFIG_OF_PRIOR_STAGE.
> > > 
> > > But it will lost the function
> > > that dtb will be pre-burned into designated flash location,
> > > when U-Boot was booting from flash.
> > > 
> > 
> > I don't get it. Do you mean on ae350 board, the DTB is pre-flashed
> > on the flash?
> > 
> 
> Yes
> On ae350 board, the DTB is pre-flashed on the flash in booting from
> rom case.
> 
> u-boot boot from ram case:
> CONFIG_OF_PRIOR_STAGE can achieve u-boot boot from ram and dtb was
> passed by loader with a1(0xf0000).
> 
> u-boot boot from rom case:
> If DTB is pre-flashed on the flash 0x800f0000 (This address can be
> dynamically changed)
> But no one assign a1=0x800f000, how can be gd->fdt_blob changed to
> 0x800f000.
> I am wondering about that ?
> 
> 0xf0000 is ram space
> 0x800f0000 is flash rom space
> 
> Rick
> 

If I understood it correctly and looking at the documentation in U-Boot 
you have two boot methods. The ae350 can either boot from the e-bios or
from external SPI ROM. The e-bios loads U-Boot into RAM, starts it, and
passes the build-in device tree to it. If the ae350 boots from SPI ROM,
the software stored in it will be the first thing to run. There is
therefore nothing, which can pass the built-in device tree to software.
Is this correct?

Would it makes sense to use CONFIG_OF_PRIOR_STAGE and boot using the 
e-bios by default? The SPI ROM could then be documented in the README
with instructions on how to use the built-in device tree.
Another option would be to only use the device tree from U-Boot.

Thanks,
Lukas
Bin Meng Oct. 25, 2018, 1:36 p.m. UTC | #6
Hi Rick,

On Thu, Oct 25, 2018 at 11:27 AM Rick Chen <rickchen36@gmail.com> wrote:
>
> Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午11:16寫道:
> >
> > Hi Rick,
> >
> > On Thu, Oct 25, 2018 at 11:11 AM Rick Chen <rickchen36@gmail.com> wrote:
> > >
> > > Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午10:33寫道:
> > > >
> > > > Hi Rick,
> > > >
> > > > On Thu, Oct 25, 2018 at 9:20 AM Andes <uboot@andestech.com> wrote:
> > > > >
> > > > > From: Rick Chen <rick@andestech.com>
> > > > >
> > > > > ax25-ae350 use CONFIG_OF_BOARD which allow the board to
> > > > > override the fdt address. And prior_stage_fdt_address offer
> > > > > a temporary memory address to keep the dtb address which was
> > > > > passed from loader(gdb) to u-boot with a1.
> > > >
> > > > nits: U-Boot
> > > >
> > > > >
> > > > > Signed-off-by: Rick Chen <rick@andestech.com>
> > > > > Cc: Greentime Hu <greentime@andestech.com>
> > > > > ---
> > > > >  board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
> > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > index 5f4ca0f..d343453 100644
> > > > > --- a/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > +++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > @@ -14,6 +14,7 @@
> > > > >
> > > > >  DECLARE_GLOBAL_DATA_PTR;
> > > > >
> > > > > +extern phys_addr_t prior_stage_fdt_address;
> > > > >  /*
> > > > >   * Miscellaneous platform dependent initializations
> > > > >   */
> > > > > @@ -66,7 +67,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
> > > > >
> > > > >  void *board_fdt_blob_setup(void)
> > > > >  {
> > > > > -       void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
> > > > > +       void **ptr = (void *)&prior_stage_fdt_address;
> > > > >         if (fdt_magic(*ptr) == FDT_MAGIC)
> > > > >                         return (void *)*ptr;
> > > > >
> > > > > --
> > > >
> > > > board_fdt_blob_setup() should be completely removed. Instead the
> > > > simple fix should be add CONFIG_OF_PRIOR_STAGE to your board defconfig
> > > > files.
> > > >
> > >
> > > Hi Bin
> > >
> > > I have tried to switch from CONFIG_OF_BOARD to CONFIG_OF_PRIOR_STAGE.
> > >
> > > But it will lost the function
> > > that dtb will be pre-burned into designated flash location,
> > > when U-Boot was booting from flash.
> > >
> >
> > I don't get it. Do you mean on ae350 board, the DTB is pre-flashed on the flash?
> >
>
> Yes
> On ae350 board, the DTB is pre-flashed on the flash in booting from rom case.
>
> u-boot boot from ram case:
> CONFIG_OF_PRIOR_STAGE can achieve u-boot boot from ram and dtb was
> passed by loader with a1(0xf0000).
>
> u-boot boot from rom case:
> If DTB is pre-flashed on the flash 0x800f0000 (This address can be
> dynamically changed)
> But no one assign a1=0x800f000, how can be gd->fdt_blob changed to 0x800f000.
> I am wondering about that ?
>

In the ROM case, U-Boot does not boot from reset vector, right? So the
first stage bootloader can pass DTB to U-Boot via a1 register, no?

> 0xf0000 is ram space
> 0x800f0000 is flash rom space
>

Regards,
Bin
Rick Chen Oct. 29, 2018, 3:22 a.m. UTC | #7
Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 下午9:36寫道:
>
> Hi Rick,
>
> On Thu, Oct 25, 2018 at 11:27 AM Rick Chen <rickchen36@gmail.com> wrote:
> >
> > Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午11:16寫道:
> > >
> > > Hi Rick,
> > >
> > > On Thu, Oct 25, 2018 at 11:11 AM Rick Chen <rickchen36@gmail.com> wrote:
> > > >
> > > > Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午10:33寫道:
> > > > >
> > > > > Hi Rick,
> > > > >
> > > > > On Thu, Oct 25, 2018 at 9:20 AM Andes <uboot@andestech.com> wrote:
> > > > > >
> > > > > > From: Rick Chen <rick@andestech.com>
> > > > > >
> > > > > > ax25-ae350 use CONFIG_OF_BOARD which allow the board to
> > > > > > override the fdt address. And prior_stage_fdt_address offer
> > > > > > a temporary memory address to keep the dtb address which was
> > > > > > passed from loader(gdb) to u-boot with a1.
> > > > >
> > > > > nits: U-Boot
> > > > >
> > > > > >
> > > > > > Signed-off-by: Rick Chen <rick@andestech.com>
> > > > > > Cc: Greentime Hu <greentime@andestech.com>
> > > > > > ---
> > > > > >  board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
> > > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > > index 5f4ca0f..d343453 100644
> > > > > > --- a/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > > +++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > > @@ -14,6 +14,7 @@
> > > > > >
> > > > > >  DECLARE_GLOBAL_DATA_PTR;
> > > > > >
> > > > > > +extern phys_addr_t prior_stage_fdt_address;
> > > > > >  /*
> > > > > >   * Miscellaneous platform dependent initializations
> > > > > >   */
> > > > > > @@ -66,7 +67,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
> > > > > >
> > > > > >  void *board_fdt_blob_setup(void)
> > > > > >  {
> > > > > > -       void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
> > > > > > +       void **ptr = (void *)&prior_stage_fdt_address;
> > > > > >         if (fdt_magic(*ptr) == FDT_MAGIC)
> > > > > >                         return (void *)*ptr;
> > > > > >
> > > > > > --
> > > > >
> > > > > board_fdt_blob_setup() should be completely removed. Instead the
> > > > > simple fix should be add CONFIG_OF_PRIOR_STAGE to your board defconfig
> > > > > files.
> > > > >
> > > >
> > > > Hi Bin
> > > >
> > > > I have tried to switch from CONFIG_OF_BOARD to CONFIG_OF_PRIOR_STAGE.
> > > >
> > > > But it will lost the function
> > > > that dtb will be pre-burned into designated flash location,
> > > > when U-Boot was booting from flash.
> > > >
> > >
> > > I don't get it. Do you mean on ae350 board, the DTB is pre-flashed on the flash?
> > >
> >
> > Yes
> > On ae350 board, the DTB is pre-flashed on the flash in booting from rom case.
> >
> > u-boot boot from ram case:
> > CONFIG_OF_PRIOR_STAGE can achieve u-boot boot from ram and dtb was
> > passed by loader with a1(0xf0000).
> >
> > u-boot boot from rom case:
> > If DTB is pre-flashed on the flash 0x800f0000 (This address can be
> > dynamically changed)
> > But no one assign a1=0x800f000, how can be gd->fdt_blob changed to 0x800f000.
> > I am wondering about that ?
> >
>
> In the ROM case, U-Boot does not boot from reset vector, right? So the
> first stage bootloader can pass DTB to U-Boot via a1 register, no?
>

In the ROM case, u-Boot will boot itself without first stage
bootloader from reset vector.
So there is no bootloader can pass pass DTB to U-Boot via a1.

> > 0xf0000 is ram space
> > 0x800f0000 is flash rom space
> >
>
> Regards,
> Bin
Bin Meng Oct. 29, 2018, 8:23 a.m. UTC | #8
Hi Rick,

On Mon, Oct 29, 2018 at 11:22 AM Rick Chen <rickchen36@gmail.com> wrote:
>
> Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 下午9:36寫道:
> >
> > Hi Rick,
> >
> > On Thu, Oct 25, 2018 at 11:27 AM Rick Chen <rickchen36@gmail.com> wrote:
> > >
> > > Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午11:16寫道:
> > > >
> > > > Hi Rick,
> > > >
> > > > On Thu, Oct 25, 2018 at 11:11 AM Rick Chen <rickchen36@gmail.com> wrote:
> > > > >
> > > > > Bin Meng <bmeng.cn@gmail.com> 於 2018年10月25日 週四 上午10:33寫道:
> > > > > >
> > > > > > Hi Rick,
> > > > > >
> > > > > > On Thu, Oct 25, 2018 at 9:20 AM Andes <uboot@andestech.com> wrote:
> > > > > > >
> > > > > > > From: Rick Chen <rick@andestech.com>
> > > > > > >
> > > > > > > ax25-ae350 use CONFIG_OF_BOARD which allow the board to
> > > > > > > override the fdt address. And prior_stage_fdt_address offer
> > > > > > > a temporary memory address to keep the dtb address which was
> > > > > > > passed from loader(gdb) to u-boot with a1.
> > > > > >
> > > > > > nits: U-Boot
> > > > > >
> > > > > > >
> > > > > > > Signed-off-by: Rick Chen <rick@andestech.com>
> > > > > > > Cc: Greentime Hu <greentime@andestech.com>
> > > > > > > ---
> > > > > > >  board/AndesTech/ax25-ae350/ax25-ae350.c | 3 ++-
> > > > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > > > >
> > > > > > > diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > > > index 5f4ca0f..d343453 100644
> > > > > > > --- a/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > > > +++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
> > > > > > > @@ -14,6 +14,7 @@
> > > > > > >
> > > > > > >  DECLARE_GLOBAL_DATA_PTR;
> > > > > > >
> > > > > > > +extern phys_addr_t prior_stage_fdt_address;
> > > > > > >  /*
> > > > > > >   * Miscellaneous platform dependent initializations
> > > > > > >   */
> > > > > > > @@ -66,7 +67,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
> > > > > > >
> > > > > > >  void *board_fdt_blob_setup(void)
> > > > > > >  {
> > > > > > > -       void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
> > > > > > > +       void **ptr = (void *)&prior_stage_fdt_address;
> > > > > > >         if (fdt_magic(*ptr) == FDT_MAGIC)
> > > > > > >                         return (void *)*ptr;
> > > > > > >
> > > > > > > --
> > > > > >
> > > > > > board_fdt_blob_setup() should be completely removed. Instead the
> > > > > > simple fix should be add CONFIG_OF_PRIOR_STAGE to your board defconfig
> > > > > > files.
> > > > > >
> > > > >
> > > > > Hi Bin
> > > > >
> > > > > I have tried to switch from CONFIG_OF_BOARD to CONFIG_OF_PRIOR_STAGE.
> > > > >
> > > > > But it will lost the function
> > > > > that dtb will be pre-burned into designated flash location,
> > > > > when U-Boot was booting from flash.
> > > > >
> > > >
> > > > I don't get it. Do you mean on ae350 board, the DTB is pre-flashed on the flash?
> > > >
> > >
> > > Yes
> > > On ae350 board, the DTB is pre-flashed on the flash in booting from rom case.
> > >
> > > u-boot boot from ram case:
> > > CONFIG_OF_PRIOR_STAGE can achieve u-boot boot from ram and dtb was
> > > passed by loader with a1(0xf0000).
> > >
> > > u-boot boot from rom case:
> > > If DTB is pre-flashed on the flash 0x800f0000 (This address can be
> > > dynamically changed)
> > > But no one assign a1=0x800f000, how can be gd->fdt_blob changed to 0x800f000.
> > > I am wondering about that ?
> > >
> >
> > In the ROM case, U-Boot does not boot from reset vector, right? So the
> > first stage bootloader can pass DTB to U-Boot via a1 register, no?
> >
>
> In the ROM case, u-Boot will boot itself without first stage
> bootloader from reset vector.
> So there is no bootloader can pass pass DTB to U-Boot via a1.
>

In this case, we need support OF_CONTROL like other arch, eg:
CONFIG_OF_EMBED and CONFIG_OF_SEPARATE.

Regards,
Bin
diff mbox series

Patch

diff --git a/board/AndesTech/ax25-ae350/ax25-ae350.c b/board/AndesTech/ax25-ae350/ax25-ae350.c
index 5f4ca0f..d343453 100644
--- a/board/AndesTech/ax25-ae350/ax25-ae350.c
+++ b/board/AndesTech/ax25-ae350/ax25-ae350.c
@@ -14,6 +14,7 @@ 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+extern phys_addr_t prior_stage_fdt_address;
 /*
  * Miscellaneous platform dependent initializations
  */
@@ -66,7 +67,7 @@  ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
 
 void *board_fdt_blob_setup(void)
 {
-	void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
+	void **ptr = (void *)&prior_stage_fdt_address;
 	if (fdt_magic(*ptr) == FDT_MAGIC)
 			return (void *)*ptr;