save prev bootloader data, when u-boot chainloaded
Subsystems (2)
cover save prev bootloader data, when u-boot chainloaded
When u-boot is used as a chain-loaded bootloader (replacing OS kernel), previous bootloader leaves data in RAM, that can be reused.
For example, on recent arm linux system, when chainloading u-boot, there are initramfs and fdt in RAM prepared for OS booting. Initramfs may be modified to store u-boot's payload, thus providing the ability to use chainloaded u-boot to boot OS without any storage support.
Two config options added:
- SAVE_PREV_BL_INITRAMFS_START_ADDR
saves initramfs start address to 'prevbl_initrd_start_addr' environment variable
- SAVE_PREV_BL_FDT_ADDR
saves fdt address to 'prevbl_fdt_addr' environment variable
This feature will be used for axy17lte and starqltechn boards for now, and more phones in future.
Dzmitry Sankouski (3):
arm: init: save previous bootloader data
board: starqltechn: get board usable - add bootcmd and docs
board: axy17lte: get board usable - add bootcmd and docs
arch/arm/dts/starqltechn-uboot.dtsi | 9 ++- arch/arm/dts/starqltechn.dts | 13 ++++- arch/arm/lib/Makefile | 5 ++ arch/arm/lib/save_prev_bl_data.c | 91 +++++++++++++++++++++++++++++ boot/Kconfig | 79 ++++++++++++++++--------- common/board_r.c | 5 ++ configs/a3y17lte_defconfig | 12 ++-- configs/a5y17lte_defconfig | 13 +++-- configs/a7y17lte_defconfig | 13 +++-- configs/starqltechn_defconfig | 18 +++++- doc/board/qualcomm/sdm845.rst | 47 ++++++++++++++- doc/board/samsung/axy17lte.rst | 15 +---- include/configs/exynos78x0-common.h | 4 ++ include/configs/sdm845.h | 8 +++ include/init.h | 13 +++++ 15 files changed, 282 insertions(+), 63 deletions(-) create mode 100644 arch/arm/lib/save_prev_bl_data.c
Signature · 1 line
2.20.1
PATCH v3 1/3 arm: init: save previous bootloader data
When u-boot is used as a chain-loaded bootloader (replacing OS kernel), previous bootloader leaves data in RAM, that can be reused.
For example, on recent arm linux system, when chainloading u-boot, there are initramfs and fdt in RAM prepared for OS booting. Initramfs may be modified to store u-boot's payload, thus providing the ability to use chainloaded u-boot to boot OS without any storage support.
Two config options added:
- SAVE_PREV_BL_INITRAMFS_START_ADDR
saves initramfs start address to 'prevbl_initrd_start_addr' environment variable
- SAVE_PREV_BL_FDT_ADDR
saves fdt address to 'prevbl_fdt_addr' environment variable
---
Changes for v2:
- change signed off line
Changes for v3:
- use if (CONFIG_IS_ENABLED... instead of #if defined
- fix save_prev_bl_data.o in Makefile
- add save_prev_bl_data call to env initialization
arch/arm/lib/Makefile | 5 ++ arch/arm/lib/save_prev_bl_data.c | 91 ++++++++++++++++++++++++++++++++ boot/Kconfig | 79 +++++++++++++++++---------- common/board_r.c | 5 ++ include/init.h | 13 +++++ 5 files changed, 166 insertions(+), 27 deletions(-) create mode 100644 arch/arm/lib/save_prev_bl_data.c
arch/arm/lib/Makefile +5 -0
@@ -48,6 +48,11 @@ obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o endif obj-$(CONFIG_SEMIHOSTING) += semihosting.o +ifneq ($(filter y,$(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) $(CONFIG_SAVE_PREV_BL_FDT_ADDR)),) +obj-y += save_prev_bl_data.o +endif + +# obj-$(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) += save_prev_bl_data.o obj-y += bdinfo.o obj-y += sections.o CFLAGS_REMOVE_sections.o := $(LTO_CFLAGS)
arch/arm/lib/save_prev_bl_data.c new file +91 -0
91 lines not on this page · raw message
boot/Kconfig +52 -27
132 lines not on this page · raw message
common/board_r.c +5 -0
@@ -445,6 +445,11 @@ static int initr_env(void)env_set_hex ("fdtcontroladdr" , (unsigned long )map_to_sysmem (gd->fdt_blob)); +#if (CONFIG_IS_ENABLED (SAVE_PREV_BL_INITRAMFS_START_ADDR ) || \ +CONFIG_IS_ENABLED (SAVE_PREV_BL_FDT_ADDR )) +save_prev_bl_data (); +#endif +/* Initialize from environment */ image_load_addr =env_get_ulong ("loadaddr" ,16 , image_load_addr);
include/init.h +13 -0
@@ -166,6 +166,19 @@ int arch_setup_bdinfo(void);*/ int setup_bdinfo (void ); +#if defined(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR ) || \ +defined(CONFIG_SAVE_PREV_BL_FDT_ADDR ) +/** +* save_prev_bl_data - Save prev bl data in env vars. +* +* When u-boot is chain-loaded, save previous bootloader data, +* like initramfs address to environment variables. +* +* Return: 0 if ok; -ENODATA on error +*/ +int save_prev_bl_data (void ); +#endif +/** * cpu_secondary_init_r() - CPU-specific secondary initialization *
Signature · 1 line
2.20.1
PATCH v3 2/3 board: starqltechn: get board usable - add bootcmd and docs
In reply to Dzmitry SankouskiU-boot is intended to replace linux kernel in android boot image(ABL), and it's FIT payload to replace initramfs file. The boot process is similar to boot image with linux:
- android bootloader (ABL) unpacks android boot image
- ABL sets linux,initrd-start property in chosen node in unpacked FDT
- ABL sets x0 register to FDT address, and passes control to u-boot
- u-boot reads x0 register, and stores it in prevbl_fdt_addr env variable
- u-boot reads linux,initrd-start property,
and stores it in prevbl_initrd_start_addr
In this way, u-boot bootcmd relies on prevbl_initrd_start_addr env variable, and boils down to bootm $prevbl_initrd_start_addr. If more control on boot process is desired, pack a boot script in FIT image, and put it to default configuration
What done:
- strip unneeded config options
- add FIT image support
- add framebuffer node, u-boot logo and video console
- increase LMB_MAX_REGIONS, to store all linux dtb reserved memory regions
- add linux kernel image header
Uart driver causes hang, when u-boot is used in android boot image instead of linux. Temporary disable console driver, until investigated and fixed.
---
Changes for v2:
- change signed off line
- add CONFIG_SAVE_PREV_BL_FDT_ADDR. It's needed to boot android stock kernel
- change bootcmd to source bootscript from FIT image for more flexibility
Changes for v3:
- enable simple framebuffer
- enable video console
- add preboot variable
- remove 0x prefix in name in device tree
arch/arm/dts/starqltechn-uboot.dtsi | 9 ++++-- arch/arm/dts/starqltechn.dts | 13 ++++++-- configs/starqltechn_defconfig | 18 +++++++++-- doc/board/qualcomm/sdm845.rst | 47 ++++++++++++++++++++++++++++- include/configs/sdm845.h | 8 +++++ 5 files changed, 86 insertions(+), 9 deletions(-)
arch/arm/dts/starqltechn-uboot.dtsi +6 -3
@@ -8,15 +8,18 @@ / { + framebuffer@9D400000 { + u-boot,dm-pre-reloc; + }; soc { u-boot,dm-pre-reloc; + serial@a84000 { + u-boot,dm-pre-reloc; + }; gcc { clock-controller@100000 { u-boot,dm-pre-reloc; }; - serial@0xa84000 { - u-boot,dm-pre-reloc; - }; gpio_north@3900000 { u-boot,dm-pre-reloc; };
arch/arm/dts/starqltechn.dts +11 -2
@@ -34,9 +34,18 @@ method = "smc"; }; + framebuffer: framebuffer@9D400000 { + compatible = "simple-framebuffer"; + reg = <0 0x9D400000 0 (2960 * 1440 * 4)>;//2400000 + width = <1440>; + height = <2960>; + stride = <(1440 * 4)>; + format = "a8r8g8b8"; + }; + soc: soc { - serial@0xa84000 { - status = "ok"; + serial@a84000 { + status = "okay"; }; pinctrl@3900000 {
configs/starqltechn_defconfig +15 -3
@@ -2,13 +2,14 @@ CONFIG_ARM=y CONFIG_SKIP_LOWLEVEL_INIT=y CONFIG_POSITION_INDEPENDENT=y CONFIG_ARCH_SNAPDRAGON=y -CONFIG_SYS_TEXT_BASE=0x80000000 -CONFIG_SYS_MALLOC_LEN=0x81f000 CONFIG_DEFAULT_DEVICE_TREE="starqltechn" +CONFIG_BOOTDELAY=0 +CONFIG_FIT=y +CONFIG_FIT_VERBOSE=y CONFIG_TARGET_STARQLTECHN=y CONFIG_IDENT_STRING="\nSamsung S9 SM-G9600" CONFIG_SYS_LOAD_ADDR=0x80000000 -CONFIG_USE_PREBOOT=y +CONFIG_LMB_MAX_REGIONS=64 # CONFIG_DISPLAY_CPUINFO is not set CONFIG_HUSH_PARSER=y CONFIG_CMD_GPIO=y
@@ -22,3 +23,14 @@ CONFIG_DM_PMIC=y CONFIG_PMIC_PM8916=y CONFIG_MSM_GENI_SERIAL=y CONFIG_SPMI_MSM=y +CONFIG_LINUX_KERNEL_IMAGE_HEADER=y +CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR=y +CONFIG_SAVE_PREV_BL_FDT_ADDR=y +CONFIG_DM_VIDEO=y +CONFIG_VIDEO_LOGO=y +CONFIG_CMD_VIDCONSOLE=y +CONFIG_CONSOLE_NORMAL=y +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_VIDEO_DT_SIMPLEFB=y +CONFIG_VIDEO_SIMPLE=y +CONFIG_CMD_BMP=y
doc/board/qualcomm/sdm845.rst +46 -1
59 lines not on this page · raw message
include/configs/sdm845.h +8 -0
@@ -16,6 +16,14 @@/* Generic Timer Definitions */ #define COUNTER_FREQUENCY 19000000 +#define CONFIG_EXTRA_ENV_SETTINGS \ + "bootm_size=0x4000000\0" \ + "bootm_low=0x80000000\0" \ + "stdout=serial,vidconsole\0" \ + "stderr=serial,vidconsole\0" \ + "preboot=source $prevbl_initrd_start_addr:prebootscript\0" \ + "bootcmd=source $prevbl_initrd_start_addr:bootscript\0" +/* Size of malloc() pool */ #define CONFIG_SYS_BOOTM_LEN SZ_64M
Signature · 1 line
2.20.1
PATCH v2 3/3 board: axy17lte: get board usable - add bootcmd and docs
In reply to Dzmitry SankouskiU-boot is intended to replace linux kernel in android boot image(ABL), and it's FIT payload to replace initramfs file. The boot process is similar to boot image with linux:
- android bootloader (ABL) unpacks android boot image
- ABL sets linux,initrd-start property in chosen node in unpacked FDT
- ABL sets x0 register to FDT address, and passes control to u-boot
- u-boot reads x0 register, and stores it in prevbl_fdt_addr env variable
- u-boot reads linux,initrd-start property,
and stores it in prevbl_initrd_start_addr
In this way, u-boot bootcmd relies on prevbl_initrd_start_addr env variable, and boils down to bootm $prevbl_initrd_start_addr. If more control on boot process is desired, pack a boot script in FIT image, and put it to default configuration
What done:
- Rearrange defconfig option order
- Add CONFIG_SAVE_PREV_BL_* options
- Doc updates:
- remove wrong SBOOT memory corruption note, because memory is changed during u-boot bringup process, not by SBOOT
- put payload on ramdisk place in abl boot image creation step
---
Changes for v2:
- increase CONFIG_LMB_MAX_REGIONS and CONFIG_SYS_BOOTM_LEN
- change signed off line
- add CONFIG_SAVE_PREV_BL_FDT_ADDR. It's needed to boot android
- change bootcmd to source bootscript from FIT image for more flexibility
configs/a3y17lte_defconfig | 12 +++++++----- configs/a5y17lte_defconfig | 13 ++++++++----- configs/a7y17lte_defconfig | 13 ++++++++----- doc/board/samsung/axy17lte.rst | 15 +++------------ include/configs/exynos78x0-common.h | 4 ++++ 5 files changed, 30 insertions(+), 27 deletions(-)
configs/a3y17lte_defconfig +7 -5
@@ -1,13 +1,13 @@ CONFIG_ARM=y -CONFIG_SYS_CONFIG_NAME="exynos78x0-common" -CONFIG_SKIP_LOWLEVEL_INIT=y CONFIG_ARCH_EXYNOS=y -CONFIG_SYS_TEXT_BASE=0x40001000 CONFIG_ARCH_EXYNOS7=y CONFIG_TARGET_A3Y17LTE=y +CONFIG_SYS_CONFIG_NAME="exynos78x0-common" +CONFIG_SYS_TEXT_BASE=0x40001000 +CONFIG_SYS_LOAD_ADDR=0x40001000 +CONFIG_SKIP_LOWLEVEL_INIT=y CONFIG_NR_DRAM_BANKS=8 CONFIG_DEFAULT_DEVICE_TREE="exynos78x0-axy17lte" -CONFIG_SYS_LOAD_ADDR=0x40001000 CONFIG_FIT=y CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo Read pressed buttons status;KEY_VOLUMEUP=gpa20;KEY_HOME=gpa17;KEY_VOLUMEDOWN=gpa21;KEY_POWER=gpa00;PRESSED=0;RELEASED=1;if gpio input $KEY_VOLUMEUP; then setenv VOLUME_UP $PRESSED; else setenv VOLUME_UP $RELEASED; fi;if gpio input $KEY_VOLUMEDOWN; then setenv VOLUME_DOWN $PRESSED; else setenv VOLUME_DOWN $RELEASED; fi;if gpio input $KEY_HOME; then setenv HOME $PRESSED; else setenv HOME $RELEASED; fi;if gpio input $KEY_POWER; then setenv POWER $PRESSED; else setenv POWER $RELEASED; fi;"
@@ -16,4 +16,6 @@ CONFIG_HUSH_PARSER=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_DM_I2C_GPIO=y -CONFIG_PINCTRL_EXYNOS78x0=y +CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR=y +CONFIG_SAVE_PREV_BL_FDT_ADDR=y +CONFIG_LMB_MAX_REGIONS=64
configs/a5y17lte_defconfig +8 -5
@@ -1,18 +1,21 @@ CONFIG_ARM=y -CONFIG_SYS_CONFIG_NAME="exynos78x0-common" -CONFIG_SKIP_LOWLEVEL_INIT=y CONFIG_ARCH_EXYNOS=y -CONFIG_SYS_TEXT_BASE=0x40001000 CONFIG_ARCH_EXYNOS7=y CONFIG_TARGET_A5Y17LTE=y +CONFIG_SYS_CONFIG_NAME="exynos78x0-common" +CONFIG_SYS_TEXT_BASE=0x40001000 +CONFIG_SYS_LOAD_ADDR=0x40001000 +CONFIG_SKIP_LOWLEVEL_INIT=y CONFIG_NR_DRAM_BANKS=12 CONFIG_DEFAULT_DEVICE_TREE="exynos78x0-axy17lte" -CONFIG_SYS_LOAD_ADDR=0x40001000 +CONFIG_HUSH_PARSER=y CONFIG_FIT=y CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo Read pressed buttons status;KEY_VOLUMEUP=gpa20;KEY_HOME=gpa17;KEY_VOLUMEDOWN=gpa21;KEY_POWER=gpa00;PRESSED=0;RELEASED=1;if gpio input $KEY_VOLUMEUP; then setenv VOLUME_UP $PRESSED; else setenv VOLUME_UP $RELEASED; fi;if gpio input $KEY_VOLUMEDOWN; then setenv VOLUME_DOWN $PRESSED; else setenv VOLUME_DOWN $RELEASED; fi;if gpio input $KEY_HOME; then setenv HOME $PRESSED; else setenv HOME $RELEASED; fi;if gpio input $KEY_POWER; then setenv POWER $PRESSED; else setenv POWER $RELEASED; fi;" # CONFIG_DISPLAY_CPUINFO is not set -CONFIG_HUSH_PARSER=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_DM_I2C_GPIO=y +CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR=y +CONFIG_SAVE_PREV_BL_FDT_ADDR=y +CONFIG_LMB_MAX_REGIONS=64
configs/a7y17lte_defconfig +8 -5
@@ -1,18 +1,21 @@ CONFIG_ARM=y -CONFIG_SYS_CONFIG_NAME="exynos78x0-common" -CONFIG_SKIP_LOWLEVEL_INIT=y CONFIG_ARCH_EXYNOS=y -CONFIG_SYS_TEXT_BASE=0x40001000 CONFIG_ARCH_EXYNOS7=y CONFIG_TARGET_A7Y17LTE=y +CONFIG_SYS_CONFIG_NAME="exynos78x0-common" +CONFIG_SYS_TEXT_BASE=0x40001000 +CONFIG_SYS_LOAD_ADDR=0x40001000 +CONFIG_SKIP_LOWLEVEL_INIT=y CONFIG_NR_DRAM_BANKS=12 CONFIG_DEFAULT_DEVICE_TREE="exynos78x0-axy17lte" -CONFIG_SYS_LOAD_ADDR=0x40001000 +CONFIG_HUSH_PARSER=y CONFIG_FIT=y CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo Read pressed buttons status;KEY_VOLUMEUP=gpa20;KEY_HOME=gpa17;KEY_VOLUMEDOWN=gpa21;KEY_POWER=gpa00;PRESSED=0;RELEASED=1;if gpio input $KEY_VOLUMEUP; then setenv VOLUME_UP $PRESSED; else setenv VOLUME_UP $RELEASED; fi;if gpio input $KEY_VOLUMEDOWN; then setenv VOLUME_DOWN $PRESSED; else setenv VOLUME_DOWN $RELEASED; fi;if gpio input $KEY_HOME; then setenv HOME $PRESSED; else setenv HOME $RELEASED; fi;if gpio input $KEY_POWER; then setenv POWER $PRESSED; else setenv POWER $RELEASED; fi;" # CONFIG_DISPLAY_CPUINFO is not set -CONFIG_HUSH_PARSER=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_DM_I2C_GPIO=y +CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR=y +CONFIG_SAVE_PREV_BL_FDT_ADDR=y +CONFIG_LMB_MAX_REGIONS=64
doc/board/samsung/axy17lte.rst +3 -12
@@ -66,26 +66,17 @@ and is therefore SBOOT's payload. It may be pure u-boot (with loading u-boot's payload from flash in mind), or u-boot + u-boot's payload. -It should be kept in mind, that SBOOT binary patches it's payload after loading -in address range 0x401f8550-0x401f9280. Given SBOOT loads payload to 0x40001000, -a range of 0x1f7550-0x1f8280 (2061648-2065024) in a payload file -will be corrupted after loading to RAM. - Creating payload file """"""""""""""""""""" - Assemble FIT image for your kernel -- Create a file for u-boot payload ``touch sboot-payload`` -- Write zeroes till 0x200000 address to be sure SBOOT won't corrupt your info - ``dd if=/dev/zero of=sboot-payload bs=$((0x200000)) count=1`` -- Write u-boot to the start of the payload ``dd if=<u-boot.bin path> of=sboot-payload`` -- Write FIT image to payload from 0x200000 address - ``dd if=<FIT image path> of=sboot-payload seek=1 bs=2M`` Creating android boot image """"""""""""""""""""""""""" Once payload created, it's time for android image:: - mkbootimg --base 0x40000000 --kernel_offset 0x00000000 --ramdisk_offset 0x01000000 --tags_offset 0x00000100 --pagesize 2048 --second_offset 0x00f00000 --kernel <sboot-payload path> -o uboot.img + uboot=<path to u-boot.bin file> + ramdisk=<path to FIT payload file> + mkbootimg --base 0x40000000 --kernel_offset 0x00000000 --ramdisk_offset 0x01000000 --tags_offset 0x00000100 --pagesize 2048 --second_offset 0x00f00000 --kernel "$uboot" --ramdisk "$ramdisk" -o uboot.img Note, that stock Samsung bootloader ignores offsets, set in mkbootimg.
include/configs/exynos78x0-common.h +4 -0
@@ -40,6 +40,7 @@#define CONFIG_SYS_SDRAM_BASE 0x40000000#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE + SZ_2M - GENERATED_GBL_DATA_SIZE) +#define CONFIG_SYS_BOOTM_LEN SZ_32M/* DRAM Memory Banks */ #define SDRAM_BANK_SIZE (256UL << 20UL)/* 256 MB */ #define PHYS_SDRAM_1 CONFIG_SYS_SDRAM_BASE
@@ -85,6 +86,9 @@#endif #define EXTRA_ENV_SETTINGS \ +/* Cannot use bootdelay > 0, because timer is not working */ +"bootdelay=0\0" \ +"bootcmd=source $prevbl_initrd_start_addr:bootscript\0" \EXYNOS_DEVICE_SETTINGS \EXYNOS_FDTFILE_SETTING \MEM_LAYOUT_ENV_SETTINGS
Signature · 1 line
2.20.1