* [PATCH 0/3] save prev bootloader data, when u-boot chainloaded
@ 2022-02-22 18:49 Dzmitry Sankouski
2022-02-22 18:49 ` [PATCH 1/3 v3] arm: init: save previous bootloader data Dzmitry Sankouski
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Dzmitry Sankouski @ 2022-02-22 18:49 UTC (permalink / raw)
To: u-boot; +Cc: Dzmitry Sankouski
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
--
2.20.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3 v3] arm: init: save previous bootloader data
2022-02-22 18:49 [PATCH 0/3] save prev bootloader data, when u-boot chainloaded Dzmitry Sankouski
@ 2022-02-22 18:49 ` Dzmitry Sankouski
2022-04-05 18:00 ` Tom Rini
2022-02-22 18:49 ` [PATCH 2/3 v4] board: starqltechn: get board usable - add bootcmd and docs Dzmitry Sankouski
2022-02-22 18:49 ` [PATCH 3/3 v2] board: axy17lte: " Dzmitry Sankouski
2 siblings, 1 reply; 7+ messages in thread
From: Dzmitry Sankouski @ 2022-02-22 18:49 UTC (permalink / raw)
To: u-boot; +Cc: Dzmitry Sankouski, Tom Rini
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
Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
---
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
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index c48e1f622d..f3c31c05e5 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -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)
diff --git a/arch/arm/lib/save_prev_bl_data.c b/arch/arm/lib/save_prev_bl_data.c
new file mode 100644
index 0000000000..f4ee86a89c
--- /dev/null
+++ b/arch/arm/lib/save_prev_bl_data.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * save_prev_bl_data - saving previous bootloader data
+ * to environment variables.
+ *
+ * Copyright (c) 2022 Dzmitry Sankouski (dsankouski@gmail.com)
+ */
+#include <init.h>
+#include <env.h>
+#include <fdtdec.h>
+#include <fdt_support.h>
+#include <fdt.h>
+#include <common.h>
+#include <linux/errno.h>
+#include <asm/system.h>
+#include <asm/armv8/mmu.h>
+
+static ulong reg0 __section(".data");
+
+/**
+ * Save x0 register value, assuming previous bootloader set it to
+ * point on loaded fdt or (for older linux kernels)atags.
+ */
+void save_boot_params(ulong r0)
+{
+ reg0 = r0;
+ save_boot_params_ret();
+}
+
+bool is_addr_accessible(phys_addr_t addr)
+{
+ struct mm_region *mem = mem_map;
+ phys_addr_t bank_start;
+ phys_addr_t bank_end;
+
+ while (mem->size) {
+ bank_start = mem->phys;
+ bank_end = bank_start + mem->size;
+ debug("check if block %pap - %pap includes %pap\n", &bank_start, &bank_end, &addr);
+ if (addr > bank_start && addr < bank_end)
+ return true;
+ mem++;
+ }
+
+ return false;
+}
+
+int save_prev_bl_data(void)
+{
+ struct fdt_header *fdt_blob;
+ int node;
+ u64 initrd_start_prop;
+
+ if (!is_addr_accessible((phys_addr_t)reg0))
+ return -ENODATA;
+
+ fdt_blob = (struct fdt_header *)reg0;
+ if (!fdt_valid(&fdt_blob)) {
+ pr_warn("%s: address 0x%lx is not a valid fdt\n", __func__, reg0);
+ return -ENODATA;
+ }
+
+ if (CONFIG_IS_ENABLED(SAVE_PREV_BL_FDT_ADDR))
+ env_set_addr("prevbl_fdt_addr", (void *)reg0);
+ if (!CONFIG_IS_ENABLED(SAVE_PREV_BL_INITRAMFS_START_ADDR))
+ return 0;
+
+ node = fdt_path_offset(fdt_blob, "/chosen");
+ if (!node) {
+ pr_warn("%s: chosen node not found in device tree at addr: 0x%lx\n",
+ __func__, reg0);
+ return -ENODATA;
+ }
+ /*
+ * linux,initrd-start property might be either 64 or 32 bit,
+ * depending on primary bootloader implementation.
+ */
+ initrd_start_prop = fdtdec_get_uint64(fdt_blob, node, "linux,initrd-start", 0);
+ if (!initrd_start_prop) {
+ debug("%s: attempt to get uint64 linux,initrd-start property failed, trying uint\n",
+ __func__);
+ initrd_start_prop = fdtdec_get_uint(fdt_blob, node, "linux,initrd-start", 0);
+ if (!initrd_start_prop) {
+ debug("%s: attempt to get uint failed, too\n", __func__);
+ return -ENODATA;
+ }
+ }
+ env_set_addr("prevbl_initrd_start_addr", (void *)initrd_start_prop);
+
+ return 0;
+}
diff --git a/boot/Kconfig b/boot/Kconfig
index c8d5906cd3..da2f0797e0 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -135,10 +135,10 @@ config FIT_IMAGE_POST_PROCESS
processed before being added to the FIT image).
config FIT_PRINT
- bool "Support FIT printing"
- default y
- help
- Support printing the content of the fitImage in a verbose manner.
+ bool "Support FIT printing"
+ default y
+ help
+ Support printing the content of the fitImage in a verbose manner.
if SPL
@@ -207,12 +207,12 @@ config SPL_LOAD_FIT
This path has the following limitations:
1. "loadables" images, other than FDTs, which do not have a "load"
- property will not be loaded. This limitation also applies to FPGA
- images with the correct "compatible" string.
+ property will not be loaded. This limitation also applies to FPGA
+ images with the correct "compatible" string.
2. For FPGA images, only the "compatible" = "u-boot,fpga-legacy"
- loading method is supported.
+ loading method is supported.
3. FDTs are only loaded for images with an "os" property of "u-boot".
- "linux" images are also supported with Falcon boot mode.
+ "linux" images are also supported with Falcon boot mode.
config SPL_LOAD_FIT_ADDRESS
hex "load address of fit image"
@@ -345,8 +345,8 @@ config SYS_EXTRA_OPTIONS
The old configuration infrastructure (= mkconfig + boards.cfg)
provided the extra options field. If you have something like
"HAS_BAR,BAZ=64", the optional options
- #define CONFIG_HAS
- #define CONFIG_BAZ 64
+ #define CONFIG_HAS
+ #define CONFIG_BAZ 64
will be defined in include/config.h.
This option was prepared for the smooth migration from the old
configuration to Kconfig. Since this option will be removed sometime,
@@ -380,7 +380,7 @@ config SYS_CLK_FREQ
int "CPU clock frequency"
default 125000000 if ARCH_LS1012A
default 100000000 if ARCH_P2020 || ARCH_T1024 || ARCH_T1042 || \
- ARCH_LS1021A || FSL_LSCH2 || FSL_LSCH3
+ ARCH_LS1021A || FSL_LSCH2 || FSL_LSCH3
default 66666666 if ARCH_P1010 || ARCH_P1020 || ARCH_T4240
default 66660000 if ARCH_T2080
default 33333333 if RCAR_GEN3
@@ -485,15 +485,15 @@ config BOOTSTAGE_REPORT
boot process. The report looks something like this:
Timer summary in microseconds:
- Mark Elapsed Stage
- 0 0 reset
+ Mark Elapsed Stage
+ 0 0 reset
3,575,678 3,575,678 board_init_f start
- 3,575,695 17 arch_cpu_init A9
- 3,575,777 82 arch_cpu_init done
- 3,659,598 83,821 board_init_r start
- 3,910,375 250,777 main_loop
+ 3,575,695 17 arch_cpu_init A9
+ 3,575,777 82 arch_cpu_init done
+ 3,659,598 83,821 board_init_r start
+ 3,910,375 250,777 main_loop
29,916,167 26,005,792 bootm_start
- 30,361,327 445,160 start_kernel
+ 30,361,327 445,160 start_kernel
config BOOTSTAGE_RECORD_COUNT
int "Number of boot stage records to store"
@@ -580,24 +580,24 @@ config SHOW_BOOT_PROGRESS
Legacy uImage format:
Arg Where When
- 1 common/cmd_bootm.c before attempting to boot an image
+ 1 common/cmd_bootm.c before attempting to boot an image
-1 common/cmd_bootm.c Image header has bad magic number
- 2 common/cmd_bootm.c Image header has correct magic number
+ 2 common/cmd_bootm.c Image header has correct magic number
-2 common/cmd_bootm.c Image header has bad checksum
- 3 common/cmd_bootm.c Image header has correct checksum
+ 3 common/cmd_bootm.c Image header has correct checksum
-3 common/cmd_bootm.c Image data has bad checksum
- 4 common/cmd_bootm.c Image data has correct checksum
+ 4 common/cmd_bootm.c Image data has correct checksum
-4 common/cmd_bootm.c Image is for unsupported architecture
- 5 common/cmd_bootm.c Architecture check OK
+ 5 common/cmd_bootm.c Architecture check OK
-5 common/cmd_bootm.c Wrong Image Type (not kernel, multi)
- 6 common/cmd_bootm.c Image Type check OK
+ 6 common/cmd_bootm.c Image Type check OK
-6 common/cmd_bootm.c gunzip uncompression error
-7 common/cmd_bootm.c Unimplemented compression type
- 7 common/cmd_bootm.c Uncompression OK
- 8 common/cmd_bootm.c No uncompress/copy overwrite error
+ 7 common/cmd_bootm.c Uncompression OK
+ 8 common/cmd_bootm.c No uncompress/copy overwrite error
-9 common/cmd_bootm.c Unsupported OS (not Linux, BSD, VxWorks, QNX)
- 9 common/image.c Start initial ramdisk verification
+ 9 common/image.c Start initial ramdisk verification
-10 common/image.c Ramdisk header has bad magic number
-11 common/image.c Ramdisk header has bad checksum
10 common/image.c Ramdisk header is OK
@@ -1067,4 +1067,29 @@ config DEFAULT_FDT_FILE
help
This option is used to set the default fdt file to boot OS.
+config SAVE_PREV_BL_FDT_ADDR
+ depends on ARM
+ bool "Saves fdt address, passed by the previous bootloader, to env var"
+ default n
+ help
+ When u-boot is used as a chain-loaded bootloader (replacing OS kernel),
+ enable this option to save fdt address, passed by the
+ previous bootloader for future use.
+ Address is saved to `prevbl_fdt_addr` environment variable.
+
+ If no fdt was provided by previous bootloader, no env variables
+ will be created.
+
+config SAVE_PREV_BL_INITRAMFS_START_ADDR
+ depends on ARM
+ bool "Saves initramfs address, passed by the previous bootloader, to env var"
+ default n
+ help
+ When u-boot is used as a chain-loaded bootloader(replacing OS kernel),
+ enable this option to save initramfs address, passed by the
+ previous bootloader for future use.
+ Address is saved to `prevbl_initrd_start_addr` environment variable.
+
+ If no initramfs was provided by previous bootloader, no env variables
+ will be created.
endmenu # Booting
diff --git a/common/board_r.c b/common/board_r.c
index c24d9b4e22..5b717e2162 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -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);
diff --git a/include/init.h b/include/init.h
index 20c3976af0..1a55a0e2e4 100644
--- a/include/init.h
+++ b/include/init.h
@@ -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
*
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3 v4] board: starqltechn: get board usable - add bootcmd and docs
2022-02-22 18:49 [PATCH 0/3] save prev bootloader data, when u-boot chainloaded Dzmitry Sankouski
2022-02-22 18:49 ` [PATCH 1/3 v3] arm: init: save previous bootloader data Dzmitry Sankouski
@ 2022-02-22 18:49 ` Dzmitry Sankouski
2022-04-05 18:00 ` Tom Rini
2022-02-22 18:49 ` [PATCH 3/3 v2] board: axy17lte: " Dzmitry Sankouski
2 siblings, 1 reply; 7+ messages in thread
From: Dzmitry Sankouski @ 2022-02-22 18:49 UTC (permalink / raw)
To: u-boot; +Cc: Dzmitry Sankouski, Ramon Fried
U-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.
Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
---
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
Changes for v4:
- fix uart driver pinmux
- remove serial from stdout and stderr env
- disable serial driver, because it's crashes autoboot
arch/arm/dts/sdm845.dtsi | 6 ++--
arch/arm/dts/starqltechn-uboot.dtsi | 9 ++++--
arch/arm/dts/starqltechn.dts | 13 ++++++--
configs/starqltechn_defconfig | 21 ++++++++++---
doc/board/qualcomm/sdm845.rst | 47 ++++++++++++++++++++++++++++-
include/configs/sdm845.h | 8 +++++
6 files changed, 90 insertions(+), 14 deletions(-)
diff --git a/arch/arm/dts/sdm845.dtsi b/arch/arm/dts/sdm845.dtsi
index 1185b71216..6f2fb20d68 100644
--- a/arch/arm/dts/sdm845.dtsi
+++ b/arch/arm/dts/sdm845.dtsi
@@ -48,10 +48,8 @@
/* DEBUG UART */
qup_uart9: qup-uart9-default {
- pinmux {
- pins = "GPIO_4", "GPIO_5";
- function = "qup9";
- };
+ pins = "GPIO_4", "GPIO_5";
+ function = "gpio";
};
};
diff --git a/arch/arm/dts/starqltechn-uboot.dtsi b/arch/arm/dts/starqltechn-uboot.dtsi
index d8d75e018a..b55cccfe14 100644
--- a/arch/arm/dts/starqltechn-uboot.dtsi
+++ b/arch/arm/dts/starqltechn-uboot.dtsi
@@ -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;
};
diff --git a/arch/arm/dts/starqltechn.dts b/arch/arm/dts/starqltechn.dts
index 387420f30b..0261388319 100644
--- a/arch/arm/dts/starqltechn.dts
+++ b/arch/arm/dts/starqltechn.dts
@@ -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 {
diff --git a/configs/starqltechn_defconfig b/configs/starqltechn_defconfig
index f57bb859cc..75e8409c4d 100644
--- a/configs/starqltechn_defconfig
+++ b/configs/starqltechn_defconfig
@@ -2,16 +2,18 @@ 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
+# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
# CONFIG_NET is not set
# CONFIG_DM_STDIO is not set
CONFIG_CLK=y
@@ -20,5 +22,16 @@ CONFIG_PM8916_GPIO=y
CONFIG_PINCTRL=y
CONFIG_DM_PMIC=y
CONFIG_PMIC_PM8916=y
-CONFIG_MSM_GENI_SERIAL=y
+# CONFIG_MSM_GENI_SERIAL is not set
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
diff --git a/doc/board/qualcomm/sdm845.rst b/doc/board/qualcomm/sdm845.rst
index cd46cbe9cf..b00a30a313 100644
--- a/doc/board/qualcomm/sdm845.rst
+++ b/doc/board/qualcomm/sdm845.rst
@@ -17,7 +17,9 @@ It is loaded as an Android boot image through ABL
Installation
------------
-First, setup ``CROSS_COMPILE`` for aarch64. Then, build U-Boot for your board::
+Build
+^^^^^^^^^^^^^^^^^^^^^^^^
+Setup ``CROSS_COMPILE`` for aarch64 and build U-Boot for your board::
$ export CROSS_COMPILE=<aarch64 toolchain prefix>
$ make <your board name here, see Boards section>_defconfig
@@ -25,6 +27,49 @@ First, setup ``CROSS_COMPILE`` for aarch64. Then, build U-Boot for your board::
This will build ``u-boot.bin`` in the configured output directory.
+Generate FIT image
+^^^^^^^^^^^^^^^^^^^^^^^^
+See doc/uImage.FIT for more details
+
+Pack android boot image
+^^^^^^^^^^^^^^^^^^^^^^^^
+We'll assemble android boot image with ``u-boot.bin`` instead of linux kernel,
+and FIT image instead of ``initramfs``. Android bootloader expect gzipped kernel
+with appended dtb, so let's mimic linux to satisfy stock bootloader:
+
+- create dump dtb::
+
+ workdir=/tmp/prepare_payload
+ mkdir -p "$workdir"
+ cd "$workdir"
+ mock_dtb="$workdir"/payload_mock.dtb
+
+ dtc -I dts -O dtb -o "$mock_dtb" << EOF
+ /dts-v1/;
+ / {
+ memory {
+ /* We expect the bootloader to fill in the size */
+ reg = <0 0 0 0>;
+ };
+
+ chosen { };
+ };
+ EOF
+
+- gzip u-boot ``gzip u-boot.bin``
+- append dtb to gzipped u-boot: ``cat u-boot.bin.gz "$mock_dtb" > u-boot.bin.gz-dtb``
+
+Now we've got everything to build android boot image:::
+
+ mkbootimg --base 0x0 --kernel_offset 0x00008000 \
+ --ramdisk_offset 0x02000000 --tags_offset 0x01e00000 \
+ --pagesize 4096 --second_offset 0x00f00000 \
+ --ramdisk "$fit_image" \
+ --kernel u-boot.bin.gz-dtb \
+ -o boot.img
+
+Flash image with your phone's flashing method.
+
Boards
------------
starqlte
diff --git a/include/configs/sdm845.h b/include/configs/sdm845.h
index af9ba197d4..ba57323c74 100644
--- a/include/configs/sdm845.h
+++ b/include/configs/sdm845.h
@@ -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=vidconsole\0" \
+ "stderr=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
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3 v2] board: axy17lte: get board usable - add bootcmd and docs
2022-02-22 18:49 [PATCH 0/3] save prev bootloader data, when u-boot chainloaded Dzmitry Sankouski
2022-02-22 18:49 ` [PATCH 1/3 v3] arm: init: save previous bootloader data Dzmitry Sankouski
2022-02-22 18:49 ` [PATCH 2/3 v4] board: starqltechn: get board usable - add bootcmd and docs Dzmitry Sankouski
@ 2022-02-22 18:49 ` Dzmitry Sankouski
2022-04-05 18:00 ` Tom Rini
2 siblings, 1 reply; 7+ messages in thread
From: Dzmitry Sankouski @ 2022-02-22 18:49 UTC (permalink / raw)
To: u-boot; +Cc: Dzmitry Sankouski
U-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
Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
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(-)
diff --git a/configs/a3y17lte_defconfig b/configs/a3y17lte_defconfig
index ddc1801a59..e120263ec6 100644
--- a/configs/a3y17lte_defconfig
+++ b/configs/a3y17lte_defconfig
@@ -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
diff --git a/configs/a5y17lte_defconfig b/configs/a5y17lte_defconfig
index 2534ab0573..95fee179fd 100644
--- a/configs/a5y17lte_defconfig
+++ b/configs/a5y17lte_defconfig
@@ -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
diff --git a/configs/a7y17lte_defconfig b/configs/a7y17lte_defconfig
index a2d76377ab..5564ab51a2 100644
--- a/configs/a7y17lte_defconfig
+++ b/configs/a7y17lte_defconfig
@@ -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
diff --git a/doc/board/samsung/axy17lte.rst b/doc/board/samsung/axy17lte.rst
index e84fefec70..b7f299d1c7 100644
--- a/doc/board/samsung/axy17lte.rst
+++ b/doc/board/samsung/axy17lte.rst
@@ -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.
diff --git a/include/configs/exynos78x0-common.h b/include/configs/exynos78x0-common.h
index 8d3449f028..46efb16b65 100644
--- a/include/configs/exynos78x0-common.h
+++ b/include/configs/exynos78x0-common.h
@@ -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
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3 v3] arm: init: save previous bootloader data
2022-02-22 18:49 ` [PATCH 1/3 v3] arm: init: save previous bootloader data Dzmitry Sankouski
@ 2022-04-05 18:00 ` Tom Rini
0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2022-04-05 18:00 UTC (permalink / raw)
To: Dzmitry Sankouski; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 901 bytes --]
On Tue, Feb 22, 2022 at 09:49:52PM +0300, Dzmitry Sankouski wrote:
> 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
>
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> Cc: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3 v4] board: starqltechn: get board usable - add bootcmd and docs
2022-02-22 18:49 ` [PATCH 2/3 v4] board: starqltechn: get board usable - add bootcmd and docs Dzmitry Sankouski
@ 2022-04-05 18:00 ` Tom Rini
0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2022-04-05 18:00 UTC (permalink / raw)
To: Dzmitry Sankouski; +Cc: u-boot, Ramon Fried
[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]
On Tue, Feb 22, 2022 at 09:49:53PM +0300, Dzmitry Sankouski wrote:
> U-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.
>
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> Cc: Ramon Fried <rfried.dev@gmail.com>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3 v2] board: axy17lte: get board usable - add bootcmd and docs
2022-02-22 18:49 ` [PATCH 3/3 v2] board: axy17lte: " Dzmitry Sankouski
@ 2022-04-05 18:00 ` Tom Rini
0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2022-04-05 18:00 UTC (permalink / raw)
To: Dzmitry Sankouski; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]
On Tue, Feb 22, 2022 at 09:49:54PM +0300, Dzmitry Sankouski wrote:
> U-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
>
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-05 18:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 18:49 [PATCH 0/3] save prev bootloader data, when u-boot chainloaded Dzmitry Sankouski
2022-02-22 18:49 ` [PATCH 1/3 v3] arm: init: save previous bootloader data Dzmitry Sankouski
2022-04-05 18:00 ` Tom Rini
2022-02-22 18:49 ` [PATCH 2/3 v4] board: starqltechn: get board usable - add bootcmd and docs Dzmitry Sankouski
2022-04-05 18:00 ` Tom Rini
2022-02-22 18:49 ` [PATCH 3/3 v2] board: axy17lte: " Dzmitry Sankouski
2022-04-05 18:00 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.