Power & Source of Big Ideas

Using UART1 as default serial debug console

Moderators: chensy, FATechsupport


I recently acquired a Nano PI R1 and I have been using the debug console on UART0 (the 3 pins along the 1 Gb ethernet port). See picture below.

It works perfectly, I can see U-boot and even interrupt it.

I am wondering if it is possible to use UART1 as default debug console instead of UART0. Because I want to keep the Nanopi in a metal case it would be more convenient to use an external output.

I know I could use a serial console over USB but I would like to be able to see U-boot messages and even interrupt it before the Linux kernel is loaded.

My understanding is that U-boot needs to be tweaked, possibly recompiled.
My printenv is like this:

Code: Select all

=> printenv
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_scripts=boot.scr.uimg boot.scr
boot_targets=fel mmc_auto usb0 pxe dhcp
bootcmd=run distro_bootcmd
bootcmd_dhcp=run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00010:UNDI:003000;setenv bootp_arch 0xa;if dhcp ${kernel_addr_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;
bootcmd_fel=if test -n ${fel_booted} && test -n ${fel_scriptaddr}; then echo '(FEL boot)'; source ${fel_scriptaddr}; fi
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_mmc1=setenv devnum 1; run mmc_boot
bootcmd_mmc_auto=run bootcmd_mmc0
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootcmd_usb0=setenv devnum 0; run usb_boot
dfu_alt_info_ram=kernel ram 0x42000000 0x1000000;fdt ram 0x43000000 0x100000;ramdisk ram 0x43300000 0x4000000
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_part; fi
preboot=usb start
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootarm.efi; then echo Found EFI removable media binary efi/boot/bootarm.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot_part; fi

I see:

Code: Select all


I guess it should be changed to tty1 ?

Output of coninfo:

Code: Select all

=> coninfo 
List of available devices:
serial@01c28000 00000007 IO
serial   00000003 IO stdin stdout stderr
nulldev  00000003 IO

I tried this without success (U-boot prompt):

Code: Select all

setenv console tty1,115200

I also tried:

Code: Select all

cd /boot/
nano boot.cmd

I changed the line that reads

Code: Select all

setenv bootargs console=ttyS0,115200

to tty1

The screen (still on UART0) stops at "Starting kernel ...":

Code: Select all

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
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
1052 bytes read in 22 ms (45.9 KiB/s)
## Executing script at 43100000
reading zImage
5747872 bytes read in 289 ms (19 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 ...

If I plug the cables to UART1 there is no output though.

Is it possible to use the external UART as default debug console ?

The most direct way is to change the nanopi-r1.dtb
patch-sun8i-h3-nanopi.dtsi then recompile sun8i-h3-nanopi-r1.dts to sun8i-h3-nanopi-r1.dtb
if you only have the dtb in /boot , dtc -I dtb -O dts ..., edit the resulting dts, then dtc -I dts -O dtb ...

--- arch/arm/dts/sun8i-h3-nanopi.dtsi.orig Mon Jun 29 10:00:56 2020
+++ arch/arm/dts/sun8i-h3-nanopi.dtsi Mon Jun 29 10:06:38 2020
@@ -50,11 +50,11 @@

/ {
aliases {
- serial0 = &uart0;
+ serial1 = &uart1;

chosen {
- stdout-path = "serial0:115200n8";
+ stdout-path = "serial1:115200n8";

leds {
@@ -103,6 +103,12 @@
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pa_pins>;
status = "okay";
+&uart1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart1_pins>;
+ status = "okay";

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (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 1 guest