Jump to content

Recommended Posts

Posted (edited)

Hi,

 

i'm currently trying to disable the serial console on port 2 on my Rockchip based Rockpi 4B (based on rk3399). I already found the following forum thread, that describes in brief, that i basically have to recompile my own armbian image. But still I'm missing some information. I have read the docs in docs.armbian.com and watched the YouTube video on how to build an armbian image.

So far, i was able to setup a VM for building an image on my workstation. I also had a successful compile run yesterday, that created some output in my output folder. Now, I'd like to apply a patch, that changes the serial debugging console during boot from port 2 to port 4. I have created a patchfile using the source code files from the mainline linux repository with the following command:

 

```

diff -Naur rk3399-rock-pi-4.dtsi rk3399-rock-pi-4.dtsi.1 > rk3399-rock-pi-4.dtsi.patch

```

 

My patch file looks like this now:

--- rk3399-rock-pi-4.dtsi       2022-08-29 12:33:21.534325708 +0000
+++ rk3399-rock-pi-4.dtsi.1     2022-08-29 12:36:59.535513608 +0000
@@ -17,7 +17,7 @@
        };

        chosen {
-               stdout-path = "serial2:1500000n8";
+               stdout-path = "serial4:1500000n8";
        };

        clkin_gmac: external-gmac-clock {

 

The original file is from here.

 

My question(s) would be:

- is this the correct way to create the patch file?

- Where do i put the patch file (and how do i name it)?

 

I have the following folder structure in my userpatches/u-boot directory:

 

drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-clearfog/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-helios4/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-imx6/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-imx7d-current/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-imx7d-legacy/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-media/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-meson/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-meson64/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-mt7623/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-mvebu64/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-mvebu-edge/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-odroid/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-odroidxu4/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-rk322x/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-rk35xx/
drwxrwsr-x  2 root    sudo     4096 Aug 30 08:08 u-boot-rockchip/     //    <---- i would place the patch file here. Is that correct?
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-rockchip64/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-rockchip-rk3588/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-rockpis/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-s5p6818/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-sun50iw9/
drwxrwsr-x  2 root    sudo     4096 Aug 29 12:45 u-boot-sunxi/

 

I'd appreciate any help and input!

 

Thanks in advance,

 

Michael

Edited by mfreudenberg
Inserted code formatted block
Posted

Hi,

 

i was able to create a seemingly correct patch file, by following this small tutorial:

https://medium.com/coinmonks/make-linux-kernel-better-beginners-guide-to-writing-your-first-linux-patch-1125e4891e0d.

 

What i did, was cloning the git mainline kernel repo and i updated the file

arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi

to my needs, which was just the change of line 17:

 stdout-path = "serial4:1500000n8";

 

afterwards i created the patch file by committing my change to my local repo and this command:

 

git format-patch master..name-of-my-branch

 

This gave my this file:

 

From af079115d70a778d457d0067375dde81928fb4db Mon Sep 17 00:00:00 2001
From: = <...>
Date: Tue, 30 Aug 2022 12:34:14 +0000
Subject: [PATCH] changed serial console port from 2 to 4 to omit issues with
 gpio sensors

---
 arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
index 401e1ae9d944..b4c7ea9a93a1 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
@@ -17,7 +17,7 @@ aliases {
        };

        chosen {
-               stdout-path = "serial2:1500000n8";
+               stdout-path = "serial4:1500000n8";
        };

        clkin_gmac: external-gmac-clock {
--
2.34.1

 

I have placed this file in the following folder

 

userpatches/u-boot/u-boot-rockchip64/rk3399-change-serial-console-port.patch

 

In addition to that i modified my config-default.conf and added the following build options:

# additions to compile for the rock-pi4
CREATE_PATCHES="yes"
BOARD="rockpi-4b"
BRANCH="current"
RELEASE="bullseye"
PROGRESS_LOG_TO_FILE="yes"
OFFLINE_WORK="no"
USE_MAINLINE_GOOGLE_MIRROR="yes" 	# i had issues to pull from the original repo
USE_GITHUB_UBOOT_MIRROR="yes"		# same as above

After running the compile.sh script i get the following  message:

 

[ o.k. ] Started patching process for [ u-boot rockchip64-rockpi-4b-current ]
[ o.k. ] Looking for user patches in [ userpatches/u-boot/u-boot-rockchip64 ]
[ o.k. ] * [l][c] add-board-clockworkpi-a06.patch
...
[ o.k. ] * [l][c] rk3399-always-init-rkclk.patch
[ warn ] * [u][c] rk3399-change-serial-console-port.patch [ failed ]			# <- why is this failed?
[ o.k. ] * [l][c] rk3399-disable-hdmi-roc-pc.patch
[ o.k. ] * [l][c] rk3399-disable-hdmi.patch
[ o.k. ] * [l][c] rk3399-enable-stable-mac.patch
[ o.k. ] * [l][c] rk3399-populate-child-node-of-syscon.patch

 

When i check the patching.log file i see a message, that says the "no file to patch". I don't get why this is shown, how can i fix my patch?

 

Processing file /home/michael/ws/build/userpatches/u-boot/u-boot-rockchip64/rk3399-change-serial-console-port.patch
The text leading up to this was:
--------------------------
|From af079115d70a778d457d0067375dde81928fb4db Mon Sep 17 00:00:00 2001
|From: = <...>
|Date: Tue, 30 Aug 2022 12:34:14 +0000
|Subject: [PATCH] changed serial console port from 2 to 4 to omit issues with
| gpio sensors
|
|---
| arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 2 +-
| 1 file changed, 1 insertion(+), 1 deletion(-)
|
|diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
|index 401e1ae9d944..b4c7ea9a93a1 100644
|--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
|+++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored

 

Anyone has an idea, what could be wrong?

 

 

Posted

It looks like you are using the dts name from the kernel rather than  u-boot.  I believe for u-boot the dts name is  something like

arch/arm/dts/rk3399-rock-pi-4.dtsi -- it looks like there are a couple that might be the one you want--. 

 

 The kernel dts files and u-boot dts files don't use the same paths ....    You created a patch for the kernel, not u-boot.....     

 

Posted (edited)

Small update from my side. I was able to successfully compile the kernel and u-boot, but i wasn't able to resolve my initial issue. Although, i was able to change the serial port from

 

stdout-path = "serial2:1500000n8";

to

stdout-path = "serial4:1500000n8";

 

I am still able to interrupt the boot process using an RS485 hat with an USB-to-Serial adapter. I just open a serial terminal (PyTTY) and spam the keyboard, while the board is rebooting. I can see, that the hat is receiving data (as the RX LED is flashing). I am also receiving some data (that i cannot interpret with PuTTY), when i "do the spamming":

 

grafik.png.1def89da472ab6a33929827797eaf6f1.png

 

I maybe should add some background story to my thread.

We are using the Rock-PI 4B to read out this weather sensor. The sensor is connected through an RS485-hat from zihatec. The hat uses serial port 2 via GPIO, which is hardwired so we cannot change it. Sometimes when we have to reboot the Rock-PI from remote, it doesn't reappear again. After checking the Board we can see, that it is stuck in the U-Boot. We assume, that the sensor is sending some data through the RS485 hat, just at the moment, when the Rock-PI reboots, thus interrupting the boot process.

 

While looking for a solution, i stumbled upon this thread in this forum. Here OP is seemingly able to change the serial port of the u-boot, by doing almost the same as i do. In addition OP is setting the UART status to "okay". I'm wondering, why the uart is still enabled on my board, as the file "./arch/arm64/boot/dts/rockchip/rk3399.dtsi" clearly shows that the uart status for port 2, 3 and 4 is "disabled".

 

 

 

Edited by mfreudenberg
Refinement of wording
Posted

Update on that thread:

 

I was playing around with make menuconfig as advised in this thread. I have created several u-boot patches, that should have disabled the serial console during boot. But none of them succeeded. I'm still able to stop the boot process by "spamming random characters" through a serial console, during boot. I'm wondering, if i'm following the correct approach. My last patch for u-boot is as follows:

 

--- a/.config   2022-09-08 13:11:36.338776585 +0000
+++ b/.config   2022-09-09 07:57:35.991434703 +0000
@@ -407,7 +409,7 @@
 #
 CONFIG_MENU=y
 # CONFIG_CONSOLE_RECORD is not set
-# CONFIG_DISABLE_CONSOLE is not set
+CONFIG_DISABLE_CONSOLE=y
 CONFIG_LOGLEVEL=4
 CONFIG_SPL_LOGLEVEL=4
 CONFIG_TPL_LOGLEVEL=4

 

This patch should just disable the console, but apparently it doesn't.

Posted

 

Should someone still be interested in how to get the uart2 interface running with an RS485 on a rockpi 4b (plus in my case), I was able to do so by making sure the serial port is active (which it should be by default) by following this post:

Decompile the necessery dtb file, make sure serial@ff1a0000 status is "okay" and recompile it again.

Deactivate console in the /boot/armbianEnv.txt and /boot/boot.cmd by setting it to "none" and recompile boot.cmd as show in this article:

https://docs.armbian.com/User-Guide_Fine-Tuning/#how-to-toggle-boot-output

And now final part, which took me a whole day to figure out, because deactivating the console wasn't enough since you need also to deactivate the getty service which occupies the ttys2 for the boot console.

Simply move it as root out of the systemd directory, reload systemd daemon and restart your device:

mv /etc/systemd/system/getty.target.wants/serial-getty@ttyS2.service ~ && systemctl daemon-reload && shutdown -r now

 

Some of the above mentioned steps may be unnecessery, but the result is more important for me at this point :D

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines