board: starqltechn: get board usable - add bootcmd and docs
authorDzmitry Sankouski <dsankouski@gmail.com>
Tue, 22 Feb 2022 18:49:53 +0000 (21:49 +0300)
committerTom Rini <trini@konsulko.com>
Mon, 4 Apr 2022 19:06:11 +0000 (15:06 -0400)
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>
arch/arm/dts/sdm845.dtsi
arch/arm/dts/starqltechn-uboot.dtsi
arch/arm/dts/starqltechn.dts
configs/starqltechn_defconfig
doc/board/qualcomm/sdm845.rst
include/configs/sdm845.h

index 1185b71..6f2fb20 100644 (file)
 
                        /* DEBUG UART */
                        qup_uart9: qup-uart9-default {
-                               pinmux {
-                                       pins = "GPIO_4", "GPIO_5";
-                                       function = "qup9";
-                               };
+                               pins = "GPIO_4", "GPIO_5";
+                               function = "gpio";
                        };
                };
 
index d8d75e0..b55cccf 100644 (file)
@@ -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;
                        };
index 387420f..0261388 100644 (file)
                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 {
index f57bb85..75e8409 100644 (file)
@@ -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
index cd46cbe..b6642c9 100644 (file)
@@ -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
index af9ba19..ba57323 100644 (file)
 /* 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