Skip to contentSkip to conversation

board: dragonboard410c: Fix some minor issues

PATCH In review Stephan Gerhold 3 participants 11 messages Jul 14, 2021 – Jul 24, 2021

lore
Share & tools
lore
#0 lore raw

cover board: dragonboard410c: Fix some minor issues

I spent some more time testing the "U-Boot without LK" changes [1] on DB410c last week and noticed some minor issues that are fixed in this patch series.

Ideally they should be applied on top of [1]. However, actually PATCH 1/3 and PATCH 2/3 are completely unrelated to [1] and could be also applied independently. PATCH 3/3 is likely directly related to [1].

[1]: https://lore.kernel.org/u-boot/[email protected]/

Stephan Gerhold (3):
board: dragonboard410c: Fix PHYS_SDRAM_1_SIZE
board: dragonboard410c: Fix fastboot
serial: serial_msm: Delay initialization to let pins stabilize

 board/qualcomm/dragonboard410c/dragonboard410c.c | 3 +--
 configs/dragonboard410c_defconfig                | 1 +
 drivers/serial/serial_msm.c                      | 4 ++++
 include/configs/dragonboard410c.h                | 4 ++--
 4 files changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/3 board: dragonboard410c: Fix PHYS_SDRAM_1_SIZE

The DragonBoard 410c has proprietary firmware from Qualcomm that reserves 8 MiB of memory for tz/smem/hyp/rmtfs/rfsa from 0x86000000 to 0x86800000. I'm not aware of any ATF (ARM Trusted Firmware) port for DB410c that would reserve 30 MiB of memory at the end of RAM. I suspect the comment might have been copied from hikey.h which has a very similar comment (and which actually does have an ATF port).

Reducing the memory size just prevents U-Boot from using the end of the RAM, not the reserved region inbetween. Therefore we might as well display the correct DRAM size (1 GiB) instead of strange 986 MiB.

Fixes 626f048bbc14 ("board: Add Qualcomm Dragonboard 410C support")

---

 include/configs/dragonboard410c.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/configs/dragonboard410c.h +2 -2
index 1f08508c4d..6474e57b29 100644
@@ -16,8 +16,8 @@
 
 /* Physical Memory Map */
 #define PHYS_SDRAM_1			0x80000000
-/* 1008 MB (the last ~30Mb are secured for TrustZone by ATF*/
-#define PHYS_SDRAM_1_SIZE		0x3da00000
+/* Note: 8 MiB (0x86000000 - 0x86800000) are reserved for tz/smem/hyp/rmtfs/rfsa */
+#define PHYS_SDRAM_1_SIZE		SZ_1G
 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
 #define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x7fff0)
 #define CONFIG_SYS_LOAD_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x80000)
Signature · 1 line
2.32.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] board: dragonboard410c: Fix PHYS_SDRAM_1_SIZE

Quoted 35 lines · Stephan Gerhold

The DragonBoard 410c has proprietary firmware from Qualcomm that reserves 8 MiB of memory for tz/smem/hyp/rmtfs/rfsa from 0x86000000 to 0x86800000. I'm not aware of any ATF (ARM Trusted Firmware) port for DB410c that would reserve 30 MiB of memory at the end of RAM. I suspect the comment might have been copied from hikey.h which has a very similar comment (and which actually does have an ATF port).

Reducing the memory size just prevents U-Boot from using the end of the RAM, not the reserved region inbetween. Therefore we might as well display the correct DRAM size (1 GiB) instead of strange 986 MiB.

Fixes 626f048bbc14 ("board: Add Qualcomm Dragonboard 410C support")

---

 include/configs/dragonboard410c.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/configs/dragonboard410c.h +2 -3
index 1f08508c4d..6474e57b29 100644
@@ -16,8 +16,8 @@
 
 /* Physical Memory Map */
 #define PHYS_SDRAM_1                   0x80000000
-/* 1008 MB (the last ~30Mb are secured for TrustZone by ATF*/
-#define PHYS_SDRAM_1_SIZE              0x3da00000
+/* Note: 8 MiB (0x86000000 - 0x86800000) are reserved for tz/smem/hyp/rmtfs/rfsa */
+#define PHYS_SDRAM_1_SIZE              SZ_1G
 #define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM_1
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
 #define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x80000)
--
Quoted 2 lines

2.32.0

#3 lore raw

Re: [PATCH 1/3] board: dragonboard410c: Fix PHYS_SDRAM_1_SIZE

In reply to Stephan Gerhold
Quoted 7 lines · Stephan Gerhold

The DragonBoard 410c has proprietary firmware from Qualcomm that reserves 8 MiB of memory for tz/smem/hyp/rmtfs/rfsa from 0x86000000 to 0x86800000. I'm not aware of any ATF (ARM Trusted Firmware) port for DB410c that would reserve 30 MiB of memory at the end of RAM. I suspect the comment might have been copied from hikey.h which has a very similar comment (and which actually does have an ATF port).

Quoted 7 lines

Reducing the memory size just prevents U-Boot from using the end of the RAM, not the reserved region inbetween. Therefore we might as well display the correct DRAM size (1 GiB) instead of strange 986 MiB.

Fixes 626f048bbc14 ("board: Add Qualcomm Dragonboard 410C support")

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#4 lore raw

PATCH 2/3 board: dragonboard410c: Fix fastboot

In reply to Stephan Gerhold

At the moment pressing the volume down key does not actually launch fastboot. This is because setting "bootdelay" to "-1" actually disables autoboot and drops to the U-Boot console. It does not execute the "bootcmd".

The correct value for "bootdelay" here would be "-2", which disables the delay and key checking and would immediately execute the "bootcmd".

However, even better in this case is using "preboot" to trigger Fastboot. The advantage is that running "fastboot continue" will actually continue the autoboot process instead of ending up in the U-Boot shell.

Also make sure to unset "preboot" again immediately in case the user saves the environment after triggering fastboot.

Cc Ramon Fried <[email protected]>
Fixes aa043ee91a47 ("db410c: automatically launch fastboot")

---

 board/qualcomm/dragonboard410c/dragonboard410c.c | 3 +--
 configs/dragonboard410c_defconfig                | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)
board/qualcomm/dragonboard410c/dragonboard410c.c +1 -2
index 3b71881cac..371b3262f8 100644
@@ -132,8 +132,7 @@ int misc_init_r(void)
 	}
 
 	if (dm_gpio_get_value(&resin)) {
-		env_set("bootdelay", "-1");
-		env_set("bootcmd", "fastboot 0");
+		env_set("preboot", "setenv preboot; fastboot 0");
 		printf("key_vol_down pressed - Starting fastboot.\n");
 	}
 
configs/dragonboard410c_defconfig +1 -0
index dc9d0d893c..a46283f980 100644
@@ -10,6 +10,7 @@ CONFIG_DISTRO_DEFAULTS=y
 # CONFIG_ANDROID_BOOT_IMAGE is not set
 CONFIG_FIT=y
 CONFIG_OF_BOARD_SETUP=y
+CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_MISC_INIT_R=y
Signature · 1 line
2.32.0
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] board: dragonboard410c: Fix fastboot

Quoted 52 lines · Stephan Gerhold

At the moment pressing the volume down key does not actually launch fastboot. This is because setting "bootdelay" to "-1" actually disables autoboot and drops to the U-Boot console. It does not execute the "bootcmd".

The correct value for "bootdelay" here would be "-2", which disables the delay and key checking and would immediately execute the "bootcmd".

However, even better in this case is using "preboot" to trigger Fastboot. The advantage is that running "fastboot continue" will actually continue the autoboot process instead of ending up in the U-Boot shell.

Also make sure to unset "preboot" again immediately in case the user saves the environment after triggering fastboot.

Cc Ramon Fried <[email protected]>
Fixes aa043ee91a47 ("db410c: automatically launch fastboot")

---

 board/qualcomm/dragonboard410c/dragonboard410c.c | 3 +--
 configs/dragonboard410c_defconfig                | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)
board/qualcomm/dragonboard410c/dragonboard410c.c +1 -2
index 3b71881cac..371b3262f8 100644
@@ -132,8 +132,7 @@ int misc_init_r(void)
        }
 
        if (dm_gpio_get_value(&resin)) {
-               env_set("bootdelay", "-1");
-               env_set("bootcmd", "fastboot 0");
+               env_set("preboot", "setenv preboot; fastboot 0");
                printf("key_vol_down pressed - Starting fastboot.\n");
        }
 
configs/dragonboard410c_defconfig +1 -1
index dc9d0d893c..a46283f980 100644
@@ -10,6 +10,7 @@ CONFIG_DISTRO_DEFAULTS=y
 # CONFIG_ANDROID_BOOT_IMAGE is not set
 CONFIG_FIT=y
 CONFIG_OF_BOARD_SETUP=y
+CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_MISC_INIT_R=y
--
Quoted 2 lines

2.32.0

I also noticed that a few days ago, it's strange because it used to work, maybe something changed since I introduced the fastboot support.

#6 lore raw

Re: [PATCH 2/3] board: dragonboard410c: Fix fastboot

In reply to Stephan Gerhold
Quoted 12 lines · Stephan Gerhold

At the moment pressing the volume down key does not actually launch fastboot. This is because setting "bootdelay" to "-1" actually disables autoboot and drops to the U-Boot console. It does not execute the "bootcmd".

The correct value for "bootdelay" here would be "-2", which disables the delay and key checking and would immediately execute the "bootcmd".

However, even better in this case is using "preboot" to trigger Fastboot. The advantage is that running "fastboot continue" will actually continue the autoboot process instead of ending up in the U-Boot shell.

Quoted 7 lines

Also make sure to unset "preboot" again immediately in case the user saves the environment after triggering fastboot.

Cc Ramon Fried <[email protected]>
Fixes aa043ee91a47 ("db410c: automatically launch fastboot")

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#7 lore raw

PATCH 3/3 serial: serial_msm: Delay initialization to let pins stabilize

In reply to Stephan Gerhold

For some reason, the DragonBoard 410c aborts autoboot immediately if U-Boot is started without LK. It looks like it picks up a single broken character via serial and therefore believes a key was pressed to abort autoboot.

After some debugging, it seems like adding some delay after pinctrl setup but before UART initialization fixes the issue. It's also worth mentioning that unlike when booting from LK, the pinctrl setup is actually necessary when booting U-Boot without LK since UART is broken if the pinctrl line is removed.

I suspect that reconfiguring the pins might take some time to stabilize and if the UART controller is enabled too quickly it will pick up some random noise. Adding a few milliseconds of delay fixes the issue and shouldn't have any other negative side effects.

3ms seems to be the minimum delay required in my tests, use 5ms instead just to be sure.

---

 drivers/serial/serial_msm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/serial/serial_msm.c +4 -0
index d8dd5c1104..ac4d0824b9 100644
@@ -18,6 +18,7 @@
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <linux/compiler.h>
+#include <linux/delay.h>
 #include <dm/pinctrl.h>
 
 /* Serial registers - this driver works in uartdm mode*/
@@ -193,6 +194,9 @@ static int msm_uart_clk_init(struct udevice *dev)
 
 static void uart_dm_init(struct msm_serial_data *priv)
 {
+	/* Delay initialization for a bit to let pins stabilize if necessary */
+	mdelay(5);
+
 	writel(priv->clk_bit_rate, priv->base + UARTDM_CSR);
 	writel(0x0, priv->base + UARTDM_MR1);
 	writel(MSM_BOOT_UART_DM_8_N_1_MODE, priv->base + UARTDM_MR2);
Signature · 1 line
2.32.0
#8 lore raw

Re: [PATCH 3/3] serial: serial_msm: Delay initialization to let pins stabilize

Quoted 49 lines · Stephan Gerhold

For some reason, the DragonBoard 410c aborts autoboot immediately if U-Boot is started without LK. It looks like it picks up a single broken character via serial and therefore believes a key was pressed to abort autoboot.

After some debugging, it seems like adding some delay after pinctrl setup but before UART initialization fixes the issue. It's also worth mentioning that unlike when booting from LK, the pinctrl setup is actually necessary when booting U-Boot without LK since UART is broken if the pinctrl line is removed.

I suspect that reconfiguring the pins might take some time to stabilize and if the UART controller is enabled too quickly it will pick up some random noise. Adding a few milliseconds of delay fixes the issue and shouldn't have any other negative side effects.

3ms seems to be the minimum delay required in my tests, use 5ms instead just to be sure.

---

 drivers/serial/serial_msm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/serial/serial_msm.c +4 -1
index d8dd5c1104..ac4d0824b9 100644
@@ -18,6 +18,7 @@
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <linux/compiler.h>
+#include <linux/delay.h>
 #include <dm/pinctrl.h>
 
 /* Serial registers - this driver works in uartdm mode*/
@@ -193,6 +194,9 @@ static int msm_uart_clk_init(struct udevice *dev)
 
 static void uart_dm_init(struct msm_serial_data *priv)
 {
+       /* Delay initialization for a bit to let pins stabilize if necessary */
+       mdelay(5);
+
        writel(priv->clk_bit_rate, priv->base + UARTDM_CSR);
        writel(0x0, priv->base + UARTDM_MR1);
        writel(MSM_BOOT_UART_DM_8_N_1_MODE, priv->base + UARTDM_MR2);
--
Quoted 2 lines

2.32.0

Eh...this is not a nice fix, perhaps just clearing the RX buffer after initialization will work better ?

#9 lore raw

Re: [PATCH 3/3] serial: serial_msm: Delay initialization to let pins stabilize

Quoted 41 lines · Ramon Fried
Quoted 40 lines · Stephan Gerhold

For some reason, the DragonBoard 410c aborts autoboot immediately if U-Boot is started without LK. It looks like it picks up a single broken character via serial and therefore believes a key was pressed to abort autoboot.

After some debugging, it seems like adding some delay after pinctrl setup but before UART initialization fixes the issue. It's also worth mentioning that unlike when booting from LK, the pinctrl setup is actually necessary when booting U-Boot without LK since UART is broken if the pinctrl line is removed.

I suspect that reconfiguring the pins might take some time to stabilize and if the UART controller is enabled too quickly it will pick up some random noise. Adding a few milliseconds of delay fixes the issue and shouldn't have any other negative side effects.

3ms seems to be the minimum delay required in my tests, use 5ms instead just to be sure.

---

 drivers/serial/serial_msm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/serial/serial_msm.c +1 -0
index d8dd5c1104..ac4d0824b9 100644
@@ -18,6 +18,7 @@
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <linux/compiler.h>
+#include <linux/delay.h>
 #include <dm/pinctrl.h>
 
 /* Serial registers - this driver works in uartdm mode*/
@@ -193,6 +194,9 @@ static int msm_uart_clk_init(struct udevice *dev)
 
Quoted 13 lines
Quoted 11 lines
drivers/serial/serial_msm.c +3 -1
 static void uart_dm_init(struct msm_serial_data *priv)
 {
+       /* Delay initialization for a bit to let pins stabilize if necessary */
+       mdelay(5);
+
        writel(priv->clk_bit_rate, priv->base + UARTDM_CSR);
        writel(0x0, priv->base + UARTDM_MR1);
        writel(MSM_BOOT_UART_DM_8_N_1_MODE, priv->base + UARTDM_MR2);
--

2.32.0

Eh...this is not a nice fix, perhaps just clearing the RX buffer after initialization will work better ?

I don't like it much either but this is the best I came up with even after spending several hours trying to track down the problem. I also tried porting more register initialization from LK, probably even tried clearing the RX buffer again after initialization.

The problem is: In my tests there was no way to get rid of the delay, because the character doesn't show up until a few milliseconds after initialization. What you suggest would only work like this:

<initialize UART>
mdelay(5); // Wait for the weird character to show up <clear RX buffer>

Which is not much different (and in fact will take longer) than:

  mdelay(5);
  <initialize UART>

So unfortunately I can't think of a way to get rid of the delay. :(

I'm not sure if this is some strange problem of my DB410c, I'd actually be curious if the problem can also be reproduced on others.

Stephan

#10 lore raw

Re: [PATCH 3/3] serial: serial_msm: Delay initialization to let pins stabilize

In reply to Stephan Gerhold
Quoted 16 lines · Stephan Gerhold

For some reason, the DragonBoard 410c aborts autoboot immediately if U-Boot is started without LK. It looks like it picks up a single broken character via serial and therefore believes a key was pressed to abort autoboot.

After some debugging, it seems like adding some delay after pinctrl setup but before UART initialization fixes the issue. It's also worth mentioning that unlike when booting from LK, the pinctrl setup is actually necessary when booting U-Boot without LK since UART is broken if the pinctrl line is removed.

I suspect that reconfiguring the pins might take some time to stabilize and if the UART controller is enabled too quickly it will pick up some random noise. Adding a few milliseconds of delay fixes the issue and shouldn't have any other negative side effects.

Quoted 4 lines

3ms seems to be the minimum delay required in my tests, use 5ms instead just to be sure.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom