[PATCH v2 0/3] environment: distro: Add SF distro support

This patch is based on Tom comments from previous version[1] for adding new distro support separately as in include/environment/distro/sf.h
This new sf distro command not touch the existing include/config_distro_bootcmd.h.
Used this new SF distro command in rk3399 platform.
[1] https://patchwork.ozlabs.org/patch/1232666/
Any inputs? Jagan.
Jagan Teki (3): environment: distro: Add SF distro command rk3399: Add boot flash script offset, size rockchip: Enable SF distro bootcmd
include/configs/rk3399_common.h | 3 +++ include/configs/rockchip-common.h | 9 ++++++- include/environment/distro/sf.h | 41 +++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 include/environment/distro/sf.h

Add distro boot command support for SPI flash (SF).
This distro boot will read the boot script at specific location at the flash and start sourcing the same.
This file need to include on required include/config file.
Cc: Tom Rini trini@konsulko.com Signed-off-by: Jagan Teki jagan@amarulasolutions.com --- Changes for v2: - new patch
include/environment/distro/sf.h | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/environment/distro/sf.h
diff --git a/include/environment/distro/sf.h b/include/environment/distro/sf.h new file mode 100644 index 0000000000..e793be06c6 --- /dev/null +++ b/include/environment/distro/sf.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2020 Amarula Solutions(India) + * + * SF distro configurations. + */ + +#ifndef __DISTRO_SF_CONFIG_H +#define __DISTRO_SF_CONFIG_H + +#if CONFIG_IS_ENABLED(CMD_SF) +#define BOOTENV_SHARED_SF(devtypel) \ + #devtypel "_boot=" \ + "if " #devtypel " probe ${busnum}; then " \ + "devtype=" #devtypel "; " \ + "run scan_sf_for_scripts; " \ + "fi\0" +#define BOOTENV_DEV_SF(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel #instance "=" \ + "busnum=" #instance "; " \ + "run " #devtypel "_boot\0" +#define BOOTENV_DEV_NAME_SF(devtypeu, devtypel, instance) \ + #devtypel #instance " " +#else +#define BOOTENV_SHARED_SF(devtypel) +#define BOOTENV_DEV_SF \ + BOOT_TARGET_DEVICES_references_SF_without_CONFIG_CMD_SF +#define BOOTENV_DEV_NAME_SF \ + BOOT_TARGET_DEVICES_references_SF_without_CONFIG_CMD_SF + +#endif /* CONFIG_CMD_SF */ + +#define BOOTENV_SF \ + BOOTENV_SHARED_SF(sf) \ + "scan_sf_for_scripts=" \ + "${devtype} read ${scriptaddr} " \ + "${script_offset_f} ${script_size_f}; " \ + "source ${scriptaddr}; " \ + "echo SCRIPT FAILED: continuing...\0" + +#endif /* __DISTRO_SF_CONFIG_H */

On Fri, Apr 10, 2020 at 11:56:29PM +0530, Jagan Teki wrote:
Add distro boot command support for SPI flash (SF).
This distro boot will read the boot script at specific location at the flash and start sourcing the same.
This file need to include on required include/config file.
Cc: Tom Rini trini@konsulko.com Signed-off-by: Jagan Teki jagan@amarulasolutions.com
Reviewed-by: Tom Rini trini@konsulko.com

Most of the SPI flash devices in rockchip (rk3399) are 16MiB size. So, let's use the script offset at the end of 8K.
This way it cannot overlap any offsets being used by software components in flash layout.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com Reviewed-by: Kever Yang kever.yang@rock-chips.com --- Changes for v2: - new patch
include/configs/rk3399_common.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h index 89a8a44bbe..01a9174bd2 100644 --- a/include/configs/rk3399_common.h +++ b/include/configs/rk3399_common.h @@ -48,6 +48,8 @@
#define ENV_MEM_LAYOUT_SETTINGS \ "scriptaddr=0x00500000\0" \ + "script_offset_f=0xffe000\0" \ + "script_size_f=0x2000\0" \ "pxefile_addr_r=0x00600000\0" \ "fdt_addr_r=0x01f00000\0" \ "kernel_addr_r=0x02080000\0" \

Most of the SPI flash devices in rockchip (rk3399) are 16MiB size. So, let's use the script offset at the end of 8K.
You wouldn't have the commands for writing the idbloader.img/u-boot.itb to these SPI flash on one of these devices by chance?
Peter
This way it cannot overlap any offsets being used by software components in flash layout.
Signed-off-by: Jagan Teki jagan@amarulasolutions.com Reviewed-by: Kever Yang kever.yang@rock-chips.com
Changes for v2:
- new patch
include/configs/rk3399_common.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h index 89a8a44bbe..01a9174bd2 100644 --- a/include/configs/rk3399_common.h +++ b/include/configs/rk3399_common.h @@ -48,6 +48,8 @@
#define ENV_MEM_LAYOUT_SETTINGS \ "scriptaddr=0x00500000\0" \
"script_offset_f=0xffe000\0" \
"script_size_f=0x2000\0" \ "pxefile_addr_r=0x00600000\0" \ "fdt_addr_r=0x01f00000\0" \ "kernel_addr_r=0x02080000\0" \
-- 2.17.1

On Mon, Apr 20, 2020 at 9:21 PM Peter Robinson pbrobinson@gmail.com wrote:
Most of the SPI flash devices in rockchip (rk3399) are 16MiB size. So, let's use the script offset at the end of 8K.
You wouldn't have the commands for writing the idbloader.img/u-boot.itb to these SPI flash on one of these devices by chance?
https://wiki.amarulasolutions.com/bsp/rockchip/rk3399/roc-rk3399-pc.html#boo...

Enable SPI flash(SF) distro boot command in Rockchip.
This distro boot will read the boot script at specific location at the flash and start sourcing the same.
Included the SF device at the last of the target devices list since all the rest of the devices on the list have more possibility to boot the distribution due to the size of the SPI flash is concern.
Cc: Tom Rini trini@konsulko.com Signed-off-by: Jagan Teki jagan@amarulasolutions.com --- Changes for v2: - update BOOT_TARGET_SF
include/configs/rk3399_common.h | 1 + include/configs/rockchip-common.h | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h index 01a9174bd2..f0ae6e67a7 100644 --- a/include/configs/rk3399_common.h +++ b/include/configs/rk3399_common.h @@ -60,6 +60,7 @@ #endif
#include <config_distro_bootcmd.h> +#include <environment/distro/sf.h> #define CONFIG_EXTRA_ENV_SETTINGS \ ENV_MEM_LAYOUT_SETTINGS \ "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \ diff --git a/include/configs/rockchip-common.h b/include/configs/rockchip-common.h index b55e09a9ca..d97395db90 100644 --- a/include/configs/rockchip-common.h +++ b/include/configs/rockchip-common.h @@ -41,11 +41,18 @@ #define BOOT_TARGET_DHCP(func) #endif
+#if CONFIG_IS_ENABLED(CMD_SF) + #define BOOT_TARGET_SF(func) func(SF, sf, 0) +#else + #define BOOT_TARGET_SF(func) +#endif + #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_MMC(func) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) + BOOT_TARGET_DHCP(func) \ + BOOT_TARGET_SF(func)
#ifdef CONFIG_ARM64 #define ROOT_UUID "B921B045-1DF0-41C3-AF44-4C6F280D3FAE;\0"

On Fri, Apr 10, 2020 at 11:57 PM Jagan Teki jagan@amarulasolutions.com wrote:
This patch is based on Tom comments from previous version[1] for adding new distro support separately as in include/environment/distro/sf.h
This new sf distro command not touch the existing include/config_distro_bootcmd.h.
Used this new SF distro command in rk3399 platform.
[1] https://patchwork.ozlabs.org/patch/1232666/
Any inputs? Jagan.
Jagan Teki (3): environment: distro: Add SF distro command rk3399: Add boot flash script offset, size rockchip: Enable SF distro bootcmd
Applied to u-boot-spi/master
participants (3)
-
Jagan Teki
-
Peter Robinson
-
Tom Rini