* [PATCH 0/2] get sdm845 boards u-boot usable as a secondary bootloader
@ 2022-01-11 16:01 Dzmitry Sankouski
2022-01-11 16:01 ` [PATCH 1/2] soc: sdm845: implement ABL info collecting, add bootcommand and usage doc Dzmitry Sankouski
2022-01-11 16:01 ` [PATCH 2/2] board: starqltechn: get board usable - fix defconfig and strip config options Dzmitry Sankouski
0 siblings, 2 replies; 5+ messages in thread
From: Dzmitry Sankouski @ 2022-01-11 16:01 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 `abl_fdt_addr` env variable
- u-boot reads `linux,initrd-start` property,
and stores it in `abl_initrd_start_addr`
In this way, u-boot bootcmd relies on `abl_initrd_start_addr` env variable,
and boils down to `bootm $abl_initrd_start_addr`. If more control on
boot process is desired, pack a boot script in FIT image, and put it to
default configuration
Dzmitry Sankouski (2):
soc: sdm845: implement ABL info collecting, add bootcommand and usage
doc
board: starqltechn: get board usable - fix defconfig and strip config
options
arch/arm/mach-snapdragon/init_sdm845.c | 60 ++++++++++++++++++++----
configs/starqltechn_defconfig | 12 +++--
doc/board/qualcomm/sdm845.rst | 63 +++++++++++++++++++++++++-
include/configs/sdm845.h | 5 ++
4 files changed, 124 insertions(+), 16 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] soc: sdm845: implement ABL info collecting, add bootcommand and usage doc
2022-01-11 16:01 [PATCH 0/2] get sdm845 boards u-boot usable as a secondary bootloader Dzmitry Sankouski
@ 2022-01-11 16:01 ` Dzmitry Sankouski
2022-01-11 16:01 ` [PATCH 2/2] board: starqltechn: get board usable - fix defconfig and strip config options Dzmitry Sankouski
1 sibling, 0 replies; 5+ messages in thread
From: Dzmitry Sankouski @ 2022-01-11 16:01 UTC (permalink / raw)
To: u-boot; +Cc: Dzmitry Sankouski, Ramon Fried, Tom Rini
U-boot is intended to replace linux kernel in android boot image, 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 `abl_fdt_addr` env variable
- u-boot reads `linux,initrd-start` property,
and stores it in `abl_initrd_start_addr`
In this way, u-boot bootcmd relies on `abl_initrd_start_addr` env variable,
and boils down to `bootm $abl_initrd_start_addr`. If more control on
boot process is desired, pack a boot script in FIT image, and put it to
default configuration
Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
---
arch/arm/mach-snapdragon/init_sdm845.c | 60 ++++++++++++++++++++----
doc/board/qualcomm/sdm845.rst | 63 +++++++++++++++++++++++++-
include/configs/sdm845.h | 5 ++
3 files changed, 116 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-snapdragon/init_sdm845.c b/arch/arm/mach-snapdragon/init_sdm845.c
index 5f53c21947..6aeaeeb53a 100644
--- a/arch/arm/mach-snapdragon/init_sdm845.c
+++ b/arch/arm/mach-snapdragon/init_sdm845.c
@@ -7,6 +7,7 @@
#include <init.h>
#include <env.h>
+#include <fdtdec.h>
#include <common.h>
#include <asm/system.h>
#include <asm/gpio.h>
@@ -14,6 +15,14 @@
DECLARE_GLOBAL_DATA_PTR;
+static ulong fdt_addr __section(".data");
+
+void save_boot_params(ulong r0)
+{
+ fdt_addr = r0;
+ save_boot_params_ret();
+}
+
int dram_init(void)
{
return fdtdec_setup_mem_size_base();
@@ -29,8 +38,33 @@ __weak int board_init(void)
return 0;
}
-/* Check for vol- and power buttons */
-__weak int misc_init_r(void)
+void set_abl_env(void)
+{
+ const void *fdt_blob;
+ int node, ret;
+ ulong initrd_start_prop;
+
+ ret = env_set_addr("abl_fdt_addr", fdt_addr);
+ if (ret < 0) {
+ printf("Failed to set abl device tree address\n");
+ return;
+ }
+
+ fdt_blob = (void *)fdt_addr;
+ node = fdt_path_offset(fdt_blob, "/chosen");
+ if (!node) {
+ printf("Chosen node not found in device tree at addr: 0x%ll\n", fdt_addr);
+ return;
+ }
+ initrd_start_prop = fdtdec_get_addr(fdt_blob, node, "linux,initrd-start");
+ if (!initrd_start_prop) {
+ printf("linux,initrd-start property is not set\n");
+ return;
+ }
+ env_set_addr("abl_initrd_start_addr", initrd_start_prop);
+}
+
+void read_pressed_keys(void)
{
struct udevice *pon;
struct gpio_desc resin;
@@ -39,19 +73,19 @@ __weak int misc_init_r(void)
ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8998_pon@800", &pon);
if (ret < 0) {
printf("Failed to find PMIC pon node. Check device tree\n");
- return 0;
+ return;
}
node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
- "key_vol_down");
+ "key_vol_down");
if (node < 0) {
printf("Failed to find key_vol_down node. Check device tree\n");
- return 0;
+ return;
}
if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
- &resin, 0)) {
+ &resin, 0)) {
printf("Failed to request key_vol_down button.\n");
- return 0;
+ return;
}
if (dm_gpio_get_value(&resin)) {
env_set("key_vol_down", "1");
@@ -64,12 +98,12 @@ __weak int misc_init_r(void)
"key_power");
if (node < 0) {
printf("Failed to find key_power node. Check device tree\n");
- return 0;
+ return;
}
if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
- &resin, 0)) {
+ &resin, 0)) {
printf("Failed to request key_power button.\n");
- return 0;
+ return;
}
if (dm_gpio_get_value(&resin)) {
env_set("key_power", "1");
@@ -77,6 +111,12 @@ __weak int misc_init_r(void)
} else {
env_set("key_power", "0");
}
+}
+
+__weak int misc_init_r(void)
+{
+ set_abl_env();
+ read_pressed_keys();
return 0;
}
diff --git a/doc/board/qualcomm/sdm845.rst b/doc/board/qualcomm/sdm845.rst
index cd46cbe9cf..e14fd05118 100644
--- a/doc/board/qualcomm/sdm845.rst
+++ b/doc/board/qualcomm/sdm845.rst
@@ -13,11 +13,27 @@ SDM845 - hi-end qualcomm chip, introduced in late 2017.
Mostly used in flagship phones and tablets of 2018.
U-Boot can be used as a replacement for Qualcomm's original ABL (UEFI) bootloader.
-It is loaded as an Android boot image through ABL
+It's replaces linux kernel in android boot image, and
+it's FIT payload replaces initramfs file. The boot process is similar to
+boot image with linux:
+
+- 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 `abl_fdt_addr` env variable
+- u-boot reads `linux,initrd-start` property,
+and stores it in `abl_initrd_start_addr`
+
+In this way, u-boot bootcmd relies on `abl_initrd_start_addr` env variable,
+and boils down to `bootm $abl_initrd_start_addr`. If more control on
+boot process is desired, pack a boot script in FIT image, and put it to
+default configuration
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 +41,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..cdf0f7e030 100644
--- a/include/configs/sdm845.h
+++ b/include/configs/sdm845.h
@@ -16,6 +16,11 @@
/* Generic Timer Definitions */
#define COUNTER_FREQUENCY 19000000
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "bootm_size=0x4000000\0" \
+ "bootcmd=bootm $abl_initrd_start_addr\0" \
+ "bootm_low=0x80000000\0"
+
/* Size of malloc() pool */
#define CONFIG_SYS_BOOTM_LEN SZ_64M
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] board: starqltechn: get board usable - fix defconfig and strip config options
2022-01-11 16:01 [PATCH 0/2] get sdm845 boards u-boot usable as a secondary bootloader Dzmitry Sankouski
2022-01-11 16:01 ` [PATCH 1/2] soc: sdm845: implement ABL info collecting, add bootcommand and usage doc Dzmitry Sankouski
@ 2022-01-11 16:01 ` Dzmitry Sankouski
2022-01-11 16:19 ` Tom Rini
1 sibling, 1 reply; 5+ messages in thread
From: Dzmitry Sankouski @ 2022-01-11 16:01 UTC (permalink / raw)
To: u-boot; +Cc: Dzmitry Sankouski, Ramon Fried, Tom Rini
- add FIT image support
- 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>
Cc: Tom Rini <trini@konsulko.com>
---
configs/starqltechn_defconfig | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/configs/starqltechn_defconfig b/configs/starqltechn_defconfig
index f57bb859cc..987ce93a36 100644
--- a/configs/starqltechn_defconfig
+++ b/configs/starqltechn_defconfig
@@ -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
@@ -20,5 +21,8 @@ CONFIG_PM8916_GPIO=y
CONFIG_PINCTRL=y
CONFIG_DM_PMIC=y
CONFIG_PMIC_PM8916=y
-CONFIG_MSM_GENI_SERIAL=y
+# todo: fix serial initialization hang, when assembled in android boot image.
+CONFIG_REQUIRE_SERIAL_CONSOLE=n
+CONFIG_MSM_GENI_SERIAL=n
CONFIG_SPMI_MSM=y
+CONFIG_LINUX_KERNEL_IMAGE_HEADER=y
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] board: starqltechn: get board usable - fix defconfig and strip config options
2022-01-11 16:01 ` [PATCH 2/2] board: starqltechn: get board usable - fix defconfig and strip config options Dzmitry Sankouski
@ 2022-01-11 16:19 ` Tom Rini
2022-01-30 10:43 ` Dzmitry Sankouski
0 siblings, 1 reply; 5+ messages in thread
From: Tom Rini @ 2022-01-11 16:19 UTC (permalink / raw)
To: Dzmitry Sankouski; +Cc: u-boot, Ramon Fried
[-- Attachment #1: Type: text/plain, Size: 1902 bytes --]
On Tue, Jan 11, 2022 at 07:01:59PM +0300, Dzmitry Sankouski wrote:
> - add FIT image support
> - 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>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> configs/starqltechn_defconfig | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/configs/starqltechn_defconfig b/configs/starqltechn_defconfig
> index f57bb859cc..987ce93a36 100644
> --- a/configs/starqltechn_defconfig
> +++ b/configs/starqltechn_defconfig
> @@ -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
> @@ -20,5 +21,8 @@ CONFIG_PM8916_GPIO=y
> CONFIG_PINCTRL=y
> CONFIG_DM_PMIC=y
> CONFIG_PMIC_PM8916=y
> -CONFIG_MSM_GENI_SERIAL=y
> +# todo: fix serial initialization hang, when assembled in android boot image.
> +CONFIG_REQUIRE_SERIAL_CONSOLE=n
> +CONFIG_MSM_GENI_SERIAL=n
> CONFIG_SPMI_MSM=y
> +CONFIG_LINUX_KERNEL_IMAGE_HEADER=y
As the defconfig files are (re)generated by 'savedefconfig' that comment
will be lost quickly. And it needs to be "# CONFIG_FOO is not set" as
well.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] board: starqltechn: get board usable - fix defconfig and strip config options
2022-01-11 16:19 ` Tom Rini
@ 2022-01-30 10:43 ` Dzmitry Sankouski
0 siblings, 0 replies; 5+ messages in thread
From: Dzmitry Sankouski @ 2022-01-30 10:43 UTC (permalink / raw)
To: Tom Rini; +Cc: U-Boot Mailing List, Ramon Fried
This patch series reimplemented in more generic way in
`save prev bootloader data, when u-boot chainloaded`
patch series
вт, 11 янв. 2022 г. в 19:19, Tom Rini <trini@konsulko.com>:
> On Tue, Jan 11, 2022 at 07:01:59PM +0300, Dzmitry Sankouski wrote:
>
> > - add FIT image support
> > - 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>
> > Cc: Tom Rini <trini@konsulko.com>
> > ---
> > configs/starqltechn_defconfig | 12 ++++++++----
> > 1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/configs/starqltechn_defconfig
> b/configs/starqltechn_defconfig
> > index f57bb859cc..987ce93a36 100644
> > --- a/configs/starqltechn_defconfig
> > +++ b/configs/starqltechn_defconfig
> > @@ -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
> > @@ -20,5 +21,8 @@ CONFIG_PM8916_GPIO=y
> > CONFIG_PINCTRL=y
> > CONFIG_DM_PMIC=y
> > CONFIG_PMIC_PM8916=y
> > -CONFIG_MSM_GENI_SERIAL=y
> > +# todo: fix serial initialization hang, when assembled in android boot
> image.
> > +CONFIG_REQUIRE_SERIAL_CONSOLE=n
> > +CONFIG_MSM_GENI_SERIAL=n
> > CONFIG_SPMI_MSM=y
> > +CONFIG_LINUX_KERNEL_IMAGE_HEADER=y
>
> As the defconfig files are (re)generated by 'savedefconfig' that comment
> will be lost quickly. And it needs to be "# CONFIG_FOO is not set" as
> well.
>
> --
> Tom
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-30 10:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 16:01 [PATCH 0/2] get sdm845 boards u-boot usable as a secondary bootloader Dzmitry Sankouski
2022-01-11 16:01 ` [PATCH 1/2] soc: sdm845: implement ABL info collecting, add bootcommand and usage doc Dzmitry Sankouski
2022-01-11 16:01 ` [PATCH 2/2] board: starqltechn: get board usable - fix defconfig and strip config options Dzmitry Sankouski
2022-01-11 16:19 ` Tom Rini
2022-01-30 10:43 ` Dzmitry Sankouski
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.