[U-Boot] [RFC PATCH] rockchip: tinker: Add boot from capability

Michael Nazzareno Trimarchi michael at amarulasolutions.com
Thu Nov 14 21:47:10 UTC 2019


Hi

Drop it

+int mmc_get_env_dev(void)
+{
+       u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
+
+       if (bootdevice_brom_id == BROM_BOOTSOURCE_EMMC)
+               return 0;
+
+       return 1;
+}

THis is enough for tinker

Michael

On Wed, Nov 13, 2019 at 8:50 AM Michael Nazzareno Trimarchi
<michael at amarulasolutions.com> wrote:
>
> Hi Kever
>
> On Wed, Nov 13, 2019 at 2:03 AM Kever Yang <kever.yang at rock-chips.com> wrote:
> >
> >
> > On 2019/11/12 下午6:02, Michael Nazzareno Trimarchi wrote:
> > > Hi Kever
> > >
> > > On Tue, Nov 12, 2019 at 10:57 AM Kever Yang <kever.yang at rock-chips.com> wrote:
> > >> Hi Michael,
> > >>
> > >> On 2019/11/12 下午4:14, Michael Trimarchi wrote:
> > >>> We need to know from what device we are booting
> > >> Please make sure board_spl_was_booted_from() works for rk3288, which
> > >>
> > >> already work for rk3399, after that, we can move those functions from rk3399
> > >>
> > >> only into common code to make everything work.
> > >>
> > >> We are not going to add "spl-boot-device".
> > > That implementation has no sense in my use case. You need fit image. I
> > > don't need any special change
> >
> >
> > I don't understand what you want to do.
> >
> > The implementation is to get boot device from bootRom and convert it to
> > the device in SPL dt,
> >
> > why it has no sense?
>
> commit 75014470aec60580978962071972f2962695938d
> Author: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
> Date:   Wed Sep 13 21:29:30 2017 +0200
>
>     spl: add a fdt_addr field to spl_image_info
>
>     When loading a full U-Boot with detached device-tree using the SPL FIT
>     backend, we should store the address of the FDT loaded as part of the
>     SPL image info: this allows us to fixup the FDT with additional info
>     we may want to propagate onward.
>
>     Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
>     Reviewed-by: Simon Glass <sjg at chromium.org>
>
> The change rk3399 use is a detached device-tree. This not cover all
> the use case. I'm using some place holder
> to pass the information to next stage without detach it
>
> Michael
> >
> >
> > Thanks,
> >
> > - Kever
> >
> > > Michael
> > >>
> > >> Thanks,
> > >>
> > >> - Kever
> > >>
> > >>> in order
> > >>> to save the enviroment in right place
> > >>>
> > >>> Signed-off-by: Michael Trimarchi <michael at amarulasolutions.com>
> > >>> ---
> > >>>    arch/arm/dts/rk3288-tinker-s-u-boot.dtsi     |  1 +
> > >>>    arch/arm/mach-rockchip/rk3288/rk3288.c       | 46 ++++++++++++++++++++
> > >>>    board/rockchip/tinker_rk3288/tinker-rk3288.c | 41 +++++++++++++++++
> > >>>    configs/tinker-rk3288_defconfig              |  2 +
> > >>>    configs/tinker-s-rk3288_defconfig            |  2 +
> > >>>    5 files changed, 92 insertions(+)
> > >>>
> > >>> diff --git a/arch/arm/dts/rk3288-tinker-s-u-boot.dtsi b/arch/arm/dts/rk3288-tinker-s-u-boot.dtsi
> > >>> index 538593359a..2193127514 100644
> > >>> --- a/arch/arm/dts/rk3288-tinker-s-u-boot.dtsi
> > >>> +++ b/arch/arm/dts/rk3288-tinker-s-u-boot.dtsi
> > >>> @@ -10,6 +10,7 @@
> > >>>        chosen {
> > >>>                u-boot,spl-boot-order = \
> > >>>                        "same-as-spl", &sdmmc, &emmc;
> > >>> +             u-boot,spl-boot-device = "/dwmmc at ff0f0000";
> > >>>        };
> > >>>    };
> > >>>
> > >>> diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c b/arch/arm/mach-rockchip/rk3288/rk3288.c
> > >>> index 987b4e0d58..002d1508e5 100644
> > >>> --- a/arch/arm/mach-rockchip/rk3288/rk3288.c
> > >>> +++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
> > >>> @@ -3,6 +3,8 @@
> > >>>     * Copyright (c) 2016 Rockchip Electronics Co., Ltd
> > >>>     */
> > >>>    #include <common.h>
> > >>> +#include <spl.h>
> > >>> +#include <fdt_support.h>
> > >>>    #include <dm.h>
> > >>>    #include <env.h>
> > >>>    #include <clk.h>
> > >>> @@ -26,6 +28,50 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
> > >>>        [BROM_BOOTSOURCE_SD] = "/dwmmc at ff0c0000",
> > >>>    };
> > >>>
> > >>> +#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
> > >>> +const char *spl_decode_boot_device(u32 boot_device)
> > >>> +{
> > >>> +     int i;
> > >>> +     static const struct {
> > >>> +             u32 boot_device;
> > >>> +             const char *ofpath;
> > >>> +     } spl_boot_devices_tbl[] = {
> > >>> +             { BOOT_DEVICE_MMC2, "/dwmmc at ff0f0000" },
> > >>> +             { BOOT_DEVICE_MMC1, "/dwmmc at ff0c0000" },
> > >>> +     };
> > >>> +
> > >>> +     for (i = 0; i < ARRAY_SIZE(spl_boot_devices_tbl); ++i)
> > >>> +             if (spl_boot_devices_tbl[i].boot_device == boot_device)
> > >>> +                     return spl_boot_devices_tbl[i].ofpath;
> > >>> +
> > >>> +     return NULL;
> > >>> +}
> > >>> +
> > >>> +void spl_perform_fixups(struct spl_image_info *spl_image)
> > >>> +{
> > >>> +     void *blob = (void *)gd->fdt_blob;
> > >>> +     const char *boot_ofpath;
> > >>> +     int chosen;
> > >>> +
> > >>> +     if (!blob)
> > >>> +             return;
> > >>> +
> > >>> +     boot_ofpath = spl_decode_boot_device(spl_image->boot_device);
> > >>> +     if (!boot_ofpath) {
> > >>> +             pr_err("%s: could not map boot_device to ofpath\n", __func__);
> > >>> +             return;
> > >>> +     }
> > >>> +
> > >>> +     chosen = fdt_find_or_add_subnode(blob, 0, "chosen");
> > >>> +     if (chosen < 0) {
> > >>> +             pr_err("%s: could not find/create '/chosen'\n", __func__);
> > >>> +             return;
> > >>> +     }
> > >>> +     fdt_setprop_string(blob, chosen,
> > >>> +                        "u-boot,spl-boot-device", boot_ofpath);
> > >>> +}
> > >>> +#endif
> > >>> +
> > >>>    #ifdef CONFIG_SPL_BUILD
> > >>>    static void configure_l2ctlr(void)
> > >>>    {
> > >>> diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c b/board/rockchip/tinker_rk3288/tinker-rk3288.c
> > >>> index 6c76c3c25c..66a7394d95 100644
> > >>> --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c
> > >>> +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c
> > >>> @@ -9,6 +9,34 @@
> > >>>    #include <i2c_eeprom.h>
> > >>>    #include <netdev.h>
> > >>>
> > >>> +static int tinker_boot_device = CONFIG_SYS_MMC_ENV_DEV;
> > >>> +
> > >>> +/*
> > >>> + * Select the boot device according to what was set in spl step
> > >>> + */
> > >>> +static int setup_boottargets(void)
> > >>> +{
> > >>> +     const char *boot_device =
> > >>> +             ofnode_get_chosen_prop("u-boot,spl-boot-device");
> > >>> +
> > >>> +     if (!boot_device) {
> > >>> +             debug("%s: /chosen/u-boot,spl-boot-device not set\n",
> > >>> +                   __func__);
> > >>> +             return -1;
> > >>> +     }
> > >>> +     debug("%s: booted from %s\n", __func__, boot_device);
> > >>> +
> > >>> +     if (!strcmp(boot_device, "/dwmmc at ff0f0000")) {
> > >>> +             /* eMMC boot device */
> > >>> +             tinker_boot_device = 1;
> > >>> +     } else {
> > >>> +             /* sdcard boot device */
> > >>> +             tinker_boot_device = 0;
> > >>> +     }
> > >>> +
> > >>> +     return 0;
> > >>> +}
> > >>> +
> > >>>    static int get_ethaddr_from_eeprom(u8 *addr)
> > >>>    {
> > >>>        int ret;
> > >>> @@ -33,3 +61,16 @@ int rk3288_board_late_init(void)
> > >>>
> > >>>        return 0;
> > >>>    }
> > >>> +
> > >>> +int misc_init_r(void)
> > >>> +{
> > >>> +     setup_boottargets();
> > >>> +
> > >>> +     return 0;
> > >>> +}
> > >>> +
> > >>> +int mmc_get_env_dev(void)
> > >>> +{
> > >>> +     debug("boot device %d\n", tinker_boot_device);
> > >>> +     return tinker_boot_device;
> > >>> +}
> > >>> diff --git a/configs/tinker-rk3288_defconfig b/configs/tinker-rk3288_defconfig
> > >>> index c851a93f31..106e24e8ca 100644
> > >>> --- a/configs/tinker-rk3288_defconfig
> > >>> +++ b/configs/tinker-rk3288_defconfig
> > >>> @@ -13,7 +13,9 @@ CONFIG_DEBUG_UART=y
> > >>>    CONFIG_TPL_SYS_MALLOC_F_LEN=0x4000
> > >>>    CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000
> > >>>    CONFIG_SYS_MALLOC_F_LEN=0x4000
> > >>> +CONFIG_SPL_OF_LIBFDT=y
> > >>>    # CONFIG_ANDROID_BOOT_IMAGE is not set
> > >>> +CONFIG_MISC_INIT_R=y
> > >>>    CONFIG_USE_PREBOOT=y
> > >>>    CONFIG_SILENT_CONSOLE=y
> > >>>    CONFIG_CONSOLE_MUX=y
> > >>> diff --git a/configs/tinker-s-rk3288_defconfig b/configs/tinker-s-rk3288_defconfig
> > >>> index c851a93f31..106e24e8ca 100644
> > >>> --- a/configs/tinker-s-rk3288_defconfig
> > >>> +++ b/configs/tinker-s-rk3288_defconfig
> > >>> @@ -13,7 +13,9 @@ CONFIG_DEBUG_UART=y
> > >>>    CONFIG_TPL_SYS_MALLOC_F_LEN=0x4000
> > >>>    CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000
> > >>>    CONFIG_SYS_MALLOC_F_LEN=0x4000
> > >>> +CONFIG_SPL_OF_LIBFDT=y
> > >>>    # CONFIG_ANDROID_BOOT_IMAGE is not set
> > >>> +CONFIG_MISC_INIT_R=y
> > >>>    CONFIG_USE_PREBOOT=y
> > >>>    CONFIG_SILENT_CONSOLE=y
> > >>>    CONFIG_CONSOLE_MUX=y
> > >>
> > >
> >
> >
>
>
> --
> | Michael Nazzareno Trimarchi                     Amarula Solutions BV |
> | COO  -  Founder                                      Cruquiuskade 47 |
> | +31(0)851119172                                 Amsterdam 1018 AM NL |
> |                  [`as] http://www.amarulasolutions.com               |



-- 
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |


More information about the U-Boot mailing list