Skip to contentSkip to conversation

board: starqltechn: enable serial console

PATCH In review Dzmitry Sankouski 4 participants 7 messages Dec 27, 2022 – Jan 11, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board: starqltechn: enable serial console

It was temporary disabled due to problem with boot. Issue was fixed in
commit f5ed6c9ccf3e ("uart: sdm845: Fix debug UART pinmux")

---
 configs/starqltechn_defconfig | 4 ++--
 include/configs/sdm845.h      | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)
configs/starqltechn_defconfig +2 -2
index 7955076d61..7a64f2a7a0 100644
@@ -20,14 +20,14 @@ CONFIG_SYS_PBSIZE=532
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_BMP=y
 # CONFIG_NET is not set
-# CONFIG_DM_STDIO is not set
 CONFIG_CLK=y
 CONFIG_MSM_GPIO=y
 CONFIG_QCOM_PMIC_GPIO=y
 CONFIG_PINCTRL=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_QCOM=y
-# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
+CONFIG_REQUIRE_SERIAL_CONSOLE=y
+CONFIG_MSM_GENI_SERIAL=y
 CONFIG_SPMI_MSM=y
 CONFIG_VIDEO=y
 CONFIG_SYS_WHITE_ON_BLACK=y
include/configs/sdm845.h +3 -2
index af5fe27e68..ec6cb3a13c 100644
@@ -16,8 +16,9 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"bootm_size=0x4000000\0"	\
 	"bootm_low=0x80000000\0"	\
-	"stdout=vidconsole\0"	\
-	"stderr=vidconsole\0"	\
+	"stdin=serial\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"
 
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/1 SoC: sdm845: find and save KASLR to env variables

KASLR address is needed to boot fully functional Android. KASLR is set by primary bootloader, and since u-boot is used as a secondary bootloader(replacing kernel) on sdm845 platform, KASLR may be found by comparing memory chunks at relocaddr over supposed KASLR range.

---
 arch/arm/mach-snapdragon/init_sdm845.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/mach-snapdragon/init_sdm845.c +18 -0
index 5f53c21947..1f88502394 100644
@@ -78,5 +78,23 @@ __weak int misc_init_r(void)
 		env_set("key_power", "0");
 	}
 
+	/*
+	 * search for kaslr address, set by primary bootloader by searching first
+	 * 0x100 relocated bytes at u-boot's initial load address range
+	 */
+	uintptr_t start = gd->ram_base;
+	uintptr_t end = start + 0x800000;
+	u8 *addr = (u8 *)start;
+	phys_addr_t *relocaddr = (phys_addr_t *)gd->relocaddr;
+	u32 block_size = 0x1000;
+
+	while (memcmp(addr, relocaddr, 0x100) && (uintptr_t)addr < end)
+		addr += block_size;
+
+	if ((uintptr_t)addr >= end)
+		printf("KASLR not found in range 0x%lx - 0x%lx", start, end);
+	else
+		env_set_addr("KASLR", addr);
+
 	return 0;
 }
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] SoC: sdm845: find and save KASLR to env variables

Quoted 41 lines · Dzmitry Sankouski

KASLR address is needed to boot fully functional Android. KASLR is set by primary bootloader, and since u-boot is used as a secondary bootloader(replacing kernel) on sdm845 platform, KASLR may be found by comparing memory chunks at relocaddr over supposed KASLR range.

---
 arch/arm/mach-snapdragon/init_sdm845.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/mach-snapdragon/init_sdm845.c +18 -1
index 5f53c21947..1f88502394 100644
@@ -78,5 +78,23 @@ __weak int misc_init_r(void)
                env_set("key_power", "0");
        }
 
+       /*
+        * search for kaslr address, set by primary bootloader by searching first
+        * 0x100 relocated bytes at u-boot's initial load address range
+        */
+       uintptr_t start = gd->ram_base;
+       uintptr_t end = start + 0x800000;
+       u8 *addr = (u8 *)start;
+       phys_addr_t *relocaddr = (phys_addr_t *)gd->relocaddr;
+       u32 block_size = 0x1000;
+
+       while (memcmp(addr, relocaddr, 0x100) && (uintptr_t)addr < end)
+               addr += block_size;
+
+       if ((uintptr_t)addr >= end)
+               printf("KASLR not found in range 0x%lx - 0x%lx", start, end);
+       else
+               env_set_addr("KASLR", addr);
+
        return 0;
 }
--
Quoted 2 lines

2.30.2

#3 lore raw

Re: [PATCH] SoC: sdm845: find and save KASLR to env variables

In reply to Dzmitry Sankouski
Quoted 8 lines · Dzmitry Sankouski

KASLR address is needed to boot fully functional Android. KASLR is set by primary bootloader, and since u-boot is used as a secondary bootloader(replacing kernel) on sdm845 platform, KASLR may be found by comparing memory chunks at relocaddr over supposed KASLR range.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#4 lore raw

Re: [PATCH] SoC: sdm845: find and save KASLR to env variables

In reply to Dzmitry Sankouski
Quoted 6 lines · Dzmitry Sankouski

KASLR address is needed to boot fully functional Android. KASLR is set by primary bootloader, and since u-boot is used as a secondary bootloader(replacing kernel) on sdm845 platform, KASLR may be found by comparing memory chunks at relocaddr over supposed KASLR range.

By KASLR I presume you mean the random seed? KASLR is a technology used in the kernel, but it's actually a random seed that's passed to the kernel to generate the random layout.

Quoted 36 lines
---
 arch/arm/mach-snapdragon/init_sdm845.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/mach-snapdragon/init_sdm845.c +18 -1
index 5f53c21947..1f88502394 100644
@@ -78,5 +78,23 @@ __weak int misc_init_r(void)
                env_set("key_power", "0");
        }
 
+       /*
+        * search for kaslr address, set by primary bootloader by searching first
+        * 0x100 relocated bytes at u-boot's initial load address range
+        */
+       uintptr_t start = gd->ram_base;
+       uintptr_t end = start + 0x800000;
+       u8 *addr = (u8 *)start;
+       phys_addr_t *relocaddr = (phys_addr_t *)gd->relocaddr;
+       u32 block_size = 0x1000;
+
+       while (memcmp(addr, relocaddr, 0x100) && (uintptr_t)addr < end)
+               addr += block_size;
+
+       if ((uintptr_t)addr >= end)
+               printf("KASLR not found in range 0x%lx - 0x%lx", start, end);
+       else
+               env_set_addr("KASLR", addr);
+
        return 0;
 }
--

2.30.2

#5 lore raw

Re: [PATCH] SoC: sdm845: find and save KASLR to env variables

Right.

ср, 11 янв. 2023 г. в 05:36, Peter Robinson <[email protected]>:

Quoted 49 lines · Dzmitry Sankouski
Quoted 6 lines

KASLR address is needed to boot fully functional Android. KASLR is set by primary bootloader, and since u-boot is used as a secondary bootloader(replacing kernel) on sdm845 platform, KASLR may be found by comparing memory chunks at relocaddr over supposed KASLR range.

By KASLR I presume you mean the random seed? KASLR is a technology used in the kernel, but it's actually a random seed that's passed to the kernel to generate the random layout.

Quoted 36 lines
---
 arch/arm/mach-snapdragon/init_sdm845.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/mach-snapdragon/init_sdm845.c +18 -1
index 5f53c21947..1f88502394 100644
@@ -78,5 +78,23 @@ __weak int misc_init_r(void)
                env_set("key_power", "0");
        }
 
+       /*
+        * search for kaslr address, set by primary bootloader by searching first
+        * 0x100 relocated bytes at u-boot's initial load address range
+        */
+       uintptr_t start = gd->ram_base;
+       uintptr_t end = start + 0x800000;
+       u8 *addr = (u8 *)start;
+       phys_addr_t *relocaddr = (phys_addr_t *)gd->relocaddr;
+       u32 block_size = 0x1000;
+
+       while (memcmp(addr, relocaddr, 0x100) && (uintptr_t)addr < end)
+               addr += block_size;
+
+       if ((uintptr_t)addr >= end)
+               printf("KASLR not found in range 0x%lx - 0x%lx", start, end);
+       else
+               env_set_addr("KASLR", addr);
+
        return 0;
 }
--

2.30.2