Skip to contentSkip to conversation

trusted-firmware-a: replace baudrate with the one specified in machine conf

PATCH Trevor Woerner 1 participant 3 messages Dec 10, 2021 – Dec 13, 2021 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 66 lines · Quentin Schulz

Not all Rockchip boards have their console running at 1500000 baud in U-Boot and the kernel. Such is the case for puma-haikou RK3399-based SoM+Carrierboard.

In order to prepare for the addition of puma-haikou to meta-rockchip, let's replace the baudrate in TF-A by the one defined in the machine conf file in the RK_CONSOLE_BAUD variable.

---
 .../files/serial-console-baudrate.patch       | 36 -------------------
 .../trusted-firmware-a_%.bbappend             |  7 +++-
 2 files changed, 6 insertions(+), 37 deletions(-)
 delete mode 100644 recipes-bsp/trusted-firmware-a/files/serial-console-baudrate.patch
recipes-bsp/trusted-firmware-a/files/serial-console-baudrate.patch deleted +0 -36
deleted file mode 100644
index 2d6e9bf..0000000
@@ -1,36 +0,0 @@
-From 840d6b6420e1fd8cdf6e4de7fa58a6f8de151622 Mon Sep 17 00:00:00 2001
-From: Yann Dirson <[email protected]>
-Date: Tue, 6 Apr 2021 17:28:45 +0200
-Subject: [PATCH] Set serial console baudrate back to 1500000.
-Upstream-Status: Inappropriate[other]
-
-TF-A runs between two u-boot stages which both uses 1500000 baud, it
-just makes no sense to use the same UART at a different rate.
-
-This effectively reverts part of 0c05748bdebfad9fa43a80962186438bb8fbce62.
-Main reason for that change stated in https://developer.trustedfirmware.org/T762
-is ChromeOS compatibility.
-
-Looks like this patch may become unnecessary in the future, when
-u-boot and TF-A get to communicate this value.
-
----
- plat/rockchip/rk3399/rk3399_def.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/plat/rockchip/rk3399/rk3399_def.h b/plat/rockchip/rk3399/rk3399_def.h
-index ba83242eb..8d6ecfbe6 100644
---- a/plat/rockchip/rk3399/rk3399_def.h
-+++ b/plat/rockchip/rk3399/rk3399_def.h
-@@ -17,7 +17,7 @@
- /**************************************************************************
-  * UART related constants
-  **************************************************************************/
--#define RK3399_BAUDRATE			115200
-+#define RK3399_BAUDRATE			1500000
- #define RK3399_UART_CLOCK		24000000
- 
- /******************************************************************************
--- 
-2.30.2
-
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +0 -0
index f7777a7..0d06c44 100644
@@ -7,9 +7,14 @@ COMPATIBLE_MACHINE:append:rk3328 = "|rk3328"
 
 FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
 SRC_URI += "\

recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend COMPATIBLE_MACHINE:append:rk3328 = "|rk3328" · line 18

Quoted 10 lines
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +4 -1
-    file://serial-console-baudrate.patch \
     file://0001-Fix-build-with-gcc-11.patch \
     file://0001-dram-Fix-build-with-gcc-11.patch \
     file://0001-plat_macros.S-Use-compatible-.asciz-asm-directive.patch \
     file://0001-pmu-Do-not-mark-already-defined-functions-as-weak.patch \
 "
+
+fixup_rk3399_baudrate() {
+	sed -i "s/#define RK3399_BAUDRATE			115200/#define RK3399_BAUDRATE ${RK_CONSOLE_BAUD}/" ${S}/plat/rockchip/rk3399/rk3399_def.h
+}

This looks fragile to me, any change in the number of spaces/tabs and this line will stop working. Thankfully the symbol RK3399_BAUDRATE only appears once in this file! That will allow us to do something like the following instead:

	sed '/RK3399_BAUDRATE.*/RK3399_BAUDRATE ${RK_CONSOLE_BAUD}/d'

Can you test and submit a v2 please?

Quoted 5 lines
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +2 -0
+
+do_patch[postfuncs] += "fixup_rk3399_baudrate"
Signature · 1 line
2.30.2

A message that is not in the archive (sent off-list or not yet received): 20211210145019.uoqk2f2zhexdibha@fedora

#3 lore raw
Quoted 89 lines · Quentin Schulz

Hi Trevor,

Quoted 83 lines · Trevor Woerner
Quoted 66 lines · Quentin Schulz

Not all Rockchip boards have their console running at 1500000 baud in U-Boot and the kernel. Such is the case for puma-haikou RK3399-based SoM+Carrierboard.

In order to prepare for the addition of puma-haikou to meta-rockchip, let's replace the baudrate in TF-A by the one defined in the machine conf file in the RK_CONSOLE_BAUD variable.

---
 .../files/serial-console-baudrate.patch       | 36 -------------------
 .../trusted-firmware-a_%.bbappend             |  7 +++-
 2 files changed, 6 insertions(+), 37 deletions(-)
 delete mode 100644 recipes-bsp/trusted-firmware-a/files/serial-console-baudrate.patch
recipes-bsp/trusted-firmware-a/files/serial-console-baudrate.patch deleted +0 -36
deleted file mode 100644
index 2d6e9bf..0000000
@@ -1,36 +0,0 @@
-From 840d6b6420e1fd8cdf6e4de7fa58a6f8de151622 Mon Sep 17 00:00:00 2001
-From: Yann Dirson <[email protected]>
-Date: Tue, 6 Apr 2021 17:28:45 +0200
-Subject: [PATCH] Set serial console baudrate back to 1500000.
-Upstream-Status: Inappropriate[other]
-
-TF-A runs between two u-boot stages which both uses 1500000 baud, it
-just makes no sense to use the same UART at a different rate.
-
-This effectively reverts part of 0c05748bdebfad9fa43a80962186438bb8fbce62.
-Main reason for that change stated in https://urldefense.proofpoint.com/v2/url?u=https-3A__developer.trustedfirmware.org_T762&d=DwIBaQ&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=TULURVxAXuoOr1qm-lWPJ4RyXC82jen1-RFqhySvz2ZLazQ8DA84GQ7T4MccEcQp&s=7WhFJXuPJAZq8RxczqF3HrMD5JqRZdJ8MyMU9iEnq44&e= 
-is ChromeOS compatibility.
-
-Looks like this patch may become unnecessary in the future, when
-u-boot and TF-A get to communicate this value.
-
----
- plat/rockchip/rk3399/rk3399_def.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/plat/rockchip/rk3399/rk3399_def.h b/plat/rockchip/rk3399/rk3399_def.h
-index ba83242eb..8d6ecfbe6 100644
---- a/plat/rockchip/rk3399/rk3399_def.h
-+++ b/plat/rockchip/rk3399/rk3399_def.h
-@@ -17,7 +17,7 @@
- /**************************************************************************
-  * UART related constants
-  **************************************************************************/
--#define RK3399_BAUDRATE			115200
-+#define RK3399_BAUDRATE			1500000
- #define RK3399_UART_CLOCK		24000000
- 
- /******************************************************************************
--- 
-2.30.2
-
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +0 -0
index f7777a7..0d06c44 100644
@@ -7,9 +7,14 @@ COMPATIBLE_MACHINE:append:rk3328 = "|rk3328"
 
 FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
 SRC_URI += "\

recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend COMPATIBLE_MACHINE:append:rk3328 = "|rk3328" · line 18

Quoted 10 lines
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +4 -1
-    file://serial-console-baudrate.patch \
     file://0001-Fix-build-with-gcc-11.patch \
     file://0001-dram-Fix-build-with-gcc-11.patch \
     file://0001-plat_macros.S-Use-compatible-.asciz-asm-directive.patch \
     file://0001-pmu-Do-not-mark-already-defined-functions-as-weak.patch \
 "
+
+fixup_rk3399_baudrate() {
+	sed -i "s/#define RK3399_BAUDRATE			115200/#define RK3399_BAUDRATE ${RK_CONSOLE_BAUD}/" ${S}/plat/rockchip/rk3399/rk3399_def.h
+}

This looks fragile to me, any change in the number of spaces/tabs and this line will stop working. Thankfully the symbol RK3399_BAUDRATE only appears once in this file! That will allow us to do something like the following instead:

Quoted 2 lines
	sed '/RK3399_BAUDRATE.*/RK3399_BAUDRATE ${RK_CONSOLE_BAUD}/d'
Quoted 7 lines

Would
sed -i "s/#define RK3399_BAUDRATE\s\+.*/#define RK3399_BAUDRATE plep/" ${S}/plat/rockchip/rk3399/rk3399_def.h

work for you?
This makes sure that only RK3399_BAUDRATE definition will be changed, no comment, no RK3399_BAUDRATE_OTHER_VAR or RK3399_BAUDRATE being used in code/other constant in this file.

Sounds good.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 93 lines · Trevor Woerner via lists.yoctoproject.org
Quoted 92 lines · Quentin Schulz

Hi Trevor,

Quoted 83 lines · Trevor Woerner
Quoted 66 lines · Quentin Schulz

Not all Rockchip boards have their console running at 1500000 baud in U-Boot and the kernel. Such is the case for puma-haikou RK3399-based SoM+Carrierboard.

In order to prepare for the addition of puma-haikou to meta-rockchip, let's replace the baudrate in TF-A by the one defined in the machine conf file in the RK_CONSOLE_BAUD variable.

---
 .../files/serial-console-baudrate.patch       | 36 -------------------
 .../trusted-firmware-a_%.bbappend             |  7 +++-
 2 files changed, 6 insertions(+), 37 deletions(-)
 delete mode 100644 recipes-bsp/trusted-firmware-a/files/serial-console-baudrate.patch
recipes-bsp/trusted-firmware-a/files/serial-console-baudrate.patch deleted +0 -36
deleted file mode 100644
index 2d6e9bf..0000000
@@ -1,36 +0,0 @@
-From 840d6b6420e1fd8cdf6e4de7fa58a6f8de151622 Mon Sep 17 00:00:00 2001
-From: Yann Dirson <[email protected]>
-Date: Tue, 6 Apr 2021 17:28:45 +0200
-Subject: [PATCH] Set serial console baudrate back to 1500000.
-Upstream-Status: Inappropriate[other]
-
-TF-A runs between two u-boot stages which both uses 1500000 baud, it
-just makes no sense to use the same UART at a different rate.
-
-This effectively reverts part of 0c05748bdebfad9fa43a80962186438bb8fbce62.
-Main reason for that change stated in https://urldefense.proofpoint.com/v2/url?u=https-3A__developer.trustedfirmware.org_T762&d=DwIBaQ&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=TULURVxAXuoOr1qm-lWPJ4RyXC82jen1-RFqhySvz2ZLazQ8DA84GQ7T4MccEcQp&s=7WhFJXuPJAZq8RxczqF3HrMD5JqRZdJ8MyMU9iEnq44&e= 
-is ChromeOS compatibility.
-
-Looks like this patch may become unnecessary in the future, when
-u-boot and TF-A get to communicate this value.
-
----
- plat/rockchip/rk3399/rk3399_def.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/plat/rockchip/rk3399/rk3399_def.h b/plat/rockchip/rk3399/rk3399_def.h
-index ba83242eb..8d6ecfbe6 100644
---- a/plat/rockchip/rk3399/rk3399_def.h
-+++ b/plat/rockchip/rk3399/rk3399_def.h
-@@ -17,7 +17,7 @@
- /**************************************************************************
-  * UART related constants
-  **************************************************************************/
--#define RK3399_BAUDRATE			115200
-+#define RK3399_BAUDRATE			1500000
- #define RK3399_UART_CLOCK		24000000
- 
- /******************************************************************************
--- 
-2.30.2
-
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +0 -0
index f7777a7..0d06c44 100644
@@ -7,9 +7,14 @@ COMPATIBLE_MACHINE:append:rk3328 = "|rk3328"
 
 FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
 SRC_URI += "\

recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend COMPATIBLE_MACHINE:append:rk3328 = "|rk3328" · line 18

Quoted 10 lines
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +4 -1
-    file://serial-console-baudrate.patch \
     file://0001-Fix-build-with-gcc-11.patch \
     file://0001-dram-Fix-build-with-gcc-11.patch \
     file://0001-plat_macros.S-Use-compatible-.asciz-asm-directive.patch \
     file://0001-pmu-Do-not-mark-already-defined-functions-as-weak.patch \
 "
+
+fixup_rk3399_baudrate() {
+	sed -i "s/#define RK3399_BAUDRATE			115200/#define RK3399_BAUDRATE ${RK_CONSOLE_BAUD}/" ${S}/plat/rockchip/rk3399/rk3399_def.h
+}

This looks fragile to me, any change in the number of spaces/tabs and this line will stop working. Thankfully the symbol RK3399_BAUDRATE only appears once in this file! That will allow us to do something like the following instead:

Quoted 2 lines
	sed '/RK3399_BAUDRATE.*/RK3399_BAUDRATE ${RK_CONSOLE_BAUD}/d'

Would
sed -i "s/#define RK3399_BAUDRATE\s\+.*/#define RK3399_BAUDRATE plep/" ${S}/plat/rockchip/rk3399/rk3399_def.h

Quoted 6 lines
Quoted 4 lines

work for you?
This makes sure that only RK3399_BAUDRATE definition will be changed, no comment, no RK3399_BAUDRATE_OTHER_VAR or RK3399_BAUDRATE being used in code/other constant in this file.

Sounds good.

Am I correct in thinking a v2 is coming (or did it get swallowed up by my mail client)?

Otherwise, I can just fixup your v2 and apply it if you wish?

Quoted 8 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#55548): https://lists.yoctoproject.org/g/yocto/message/55548
Mute This Topic: https://lists.yoctoproject.org/mt/86986964/900817
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-