Power & Source of Big Ideas

[Q] How can I use the UART1 port via serial console at R1?

Moderators: chensy, FATechsupport

Hello!

The NanoPi R1 uses the internal DBG UART via serial console as default.
But it's a bit inconvenient because it's inaccessible when the case is put on.

So I want to use the external UART1 port via serial console.
How can I do it?
I had the same problem with Nano PI R1.
What I did is:

1) Buy http://wiki.friendlyarm.com/wiki/index. ... o_RS232/zh
2) Correct bootargs at /boot/boot.cmd to console=ttyS1,115200
3) Compile boot.cmd with mkimage
4) Use on my legacy Linux : chmod 777 /dev/ttyS1; cu -l /dev/ttyS1 ; ( Nothing in common with ttyS1 at point 2)
Indeed that works.

But the first output lines will still be displayed on the default console:

Code: Select all

U-Boot SPL 2017.11 (Jan 17 2019 - 16:29:28)
DRAM: 1024 MiB(408MHz)
CPU Freq: 408MHz
memory test: 1
Pattern 55aa  Writing...Reading...OK
Trying to boot from MMC1
Boot device: sd


U-Boot 2017.11 (Jan 17 2019 - 16:29:28 +0800) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: FriendlyElec NanoPi H3
DRAM:  1 GiB
CPU Freq: 1008MHz
MMC:   SUNXI SD/MMC: 0, SUNXI SD/MMC: 1
In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
BOARD: nanopi-r1
starting USB...
No controllers found
Hit any key to stop autoboot:  2  1  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
reading /boot.scr
969 bytes read in 22 ms (43 KiB/s)
## Executing script at 43100000
reading zImage
5747872 bytes read in 290 ms (18.9 MiB/s)
reading rootfs.cpio.gz
2845838 bytes read in 154 ms (17.6 MiB/s)
reading sun8i-h3-nanopi-r1.dtb
36688 bytes read in 30 ms (1.2 MiB/s)
## Flattened Device Tree blob at 48000000
   Booting using the fdt blob at 0x48000000
   Loading Ramdisk to 49b00000, end 4a000000 ... OK
   Loading Device Tree to 49af4000, end 49afff4f ... OK

Starting kernel ...

Then the rest of the output will be displayed on the external UART console:

Code: Select all

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.52 (root@wwd) (gcc version 4.9.3 (ctng-1.21.0-229g-FA)) #110 SMP Thu Jan 17 10:19:10 CST 2019
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=30c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: FriendlyElec NanoPi-R1
[    0.000000] Memory policy: Data cache writealloc
...


PS: I used the USB to TTL adapter:

Image

Link: https://www.friendlyarm.com/index.php?r ... uct_id=178
To further clarify my previous post: the instructions apply if your OS is FriendlyCore.

If you want to use Armbian the procedure is different.
The Armbian page for the R1 mentions that "Debug serial console is enabled on UART0, which is located near mUSB port,"
So apparently the second UART port has to be enabled manually.

Here is what I did:

First of all run the armbian-config utility:

Code: Select all

armbian-config

Go to: System and security settings
Then go to: Toggle hardware configuration: UART, I2C, etc.
Then enable UART2 (this is ttyS1)
Save.
Exit.

Next step:
Edit /boot/boot.cmd.

There is a section that reads:

Code: Select all

if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=ttyS0,115200 console=tty1"; fi
if test "${console}" = "serial"; then setenv consoleargs "console=ttyS0,115200"; fi

Change the second line as follows:

Code: Select all

if test "${console}" = "serial"; then setenv consoleargs "console=ttyS1,115200"; fi

(The default setting in /boot/armbianEnv.txt is: console=serial)

Reboot.
prima wrote:
If you want to use Armbian the procedure is different.


Now by default:
https://github.com/armbian/build/pull/1719

(will be present in next release)
Thanks Igor,

But that didn't work for me out of the box. I downloaded the latest image today.
I see that the /boot/boot.cmd file has been adapted to use ttyS1 as default.
But apparently the UART port itself is not enabled, so using the armbian-config utility I had to go to:
  • System and security settings
  • Then go to: Toggle hardware configuration: UART, I2C, etc.
  • Then enable UART2 (this is ttyS1)
  • Then reboot, and it works.
But I think I am missing the early output from U-boot (that lets you interrupt the process or change settings by pressing a key in the very first seconds of booting).
My screen log begins like this:

Code: Select all

Loading, please wait...
Starting version 241
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Scanning for Btrfs filesystems
done.
Begin: Will now check root file system ... fsck from util-linux 2.33.1
[/sbin/fsck.ext4 (1) -- /dev/mmcblk0p1] fsck.ext4 -a -C0 /dev/mmcblk0p1
/dev/mmcblk0p1: clean, 37416/441792 files, 292577/1910680 blocks
done.
 done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... done.

Welcome to Debian GNU/Linux 10 (buster)!


Thanks anyway.

Who is online

In total there are 8 users online :: 0 registered, 0 hidden and 8 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 8 guests