Search code examples
linux-kernelembedded-linuxu-bootttyrockchip

Enabling UART TTY for an RK3128 Embedded Linux Device


Background

I have an embedded Android device device that uses the U-Boot bootloader. The system also uses the Busybox suite.

I have access to the U-Boot shell through a UART port and can dump, modify, and upload a new filesystem but I have no terminal access to the OS. One limitation I have with U-Boot is that the saveenv command has been disabled however, the setenv command seems to work for the current boot session.

The bootargs U-Boot variable is currently set to storagemedia=nand (there is no console= setting).

So far I have tried using echo on various serial ports and modifying the inittab file to setup a TTY shell for the UART port.

My attempts to setup a TTY shell

::respawn:/sbin/getty -L serial 115200 -n -l /bin/autologin
::respawn:/sbin/getty -L serial0 115200 -n -l /bin/autologin
::respawn:/sbin/getty -L s0 115200 -n -l /bin/autologin
::respawn:/sbin/getty -L console 115200 -n -l /bin/autologin

The original Line in the inittab file (doesn't work)

# [THE ORIGINAL LINE]
ttyFIQ0::respawn:/sbin/getty -L  ttyFIQ0 0 vt100 #

Regardless of what I do, the last few lines I receive from the UART port are:

## Booting Android Image at 0x62ce3248 ...                                      
Kernel load addr 0x62ce3a48 size 4400 KiB                                       
## Flattened Device Tree blob at 61f00000                                       
   Booting using the fdt blob at 0x61f00000                                     
   XIP Kernel Image ... OK                                                      
CACHE: Misaligned operation at range [62ce3a48, 6312f888]                       
   Loading Device Tree to 60ff1000, end 60fff36c ... OK                         
Adding bank: 0x60000000 - 0x61000000 (size: 0x01000000)                         
Adding bank: 0x61200000 - 0x70000000 (size: 0x0ee00000)                         
                                                                                
Starting kernel ...

After the Starting kernel ... message, I receive nothing indicating that a TTY shell is running even though, the OS boots and runs perfectly. If I type anything into the terminal after the Starting kernel ... message has been received, the OS freezes.

Question

How do I setup a TTY shell for the Operating System that will use the UART port so that I can finally interact with the embedded device OS through a terminal?


Solution

  • The reason I couldn't establish a shell connection on the UART0 port was because the UART0 port was being used by the fiq-debugger which prevented me from starting a getty program on the UART0 port through device ttyFIQ0. After looking around the .dtb file (in the Flattened Device Tree blob at 61f00000), I noticed that serial devices (named something like serial@20060000) had their status set to status = disabled.

    I modified the .dtb file to enable all of the serial ports (set their status to status = okay. Then, I also had to modify the serial-id property of the fiq-debugger in the .dtb file to be a value other than 0x00 since 0x00 refers to UART0 which is the only accessible UART port on circuit board I was using.

    Finally, I modified the inittab file on the device to run a getty program on port ttyS0 (this device was originally disabled in the .dtb file). With that final change, the RK3128 allowed a serial terminal on UART0.