NTC CHIP: ubifs troubleshooting via UART/USB + a Raspberry Pi 3


This is just a quick jot-down style list of notes while trying to recover important data from my CHIP's ubifs.

Hardware Setup

You can use any CHIP-compatible UART device. I just happen to have a RPi 3 sitting here, so I'll use that:

CHIP    RPi3
----    ----
 RX <--> TX
 TX <--> RX

I'll be powering my CHIP from the USB port of my RPi3, so there is a common GND. If you don't have that, connect an extra GND wire between the GND connections of the two boards.

Software Setup: RPi 3

In the Raspberry Pi 3 settings (raspi-config), make sure "Serial port" communication is set up in such a way that the login terminal is disabled on the UART, but the serial port itself is enabled. Once rebooted, this should make /dev/serial0 available. The CHIP seems to use 115200 8N1, which should be the default on the Raspberry Pi 3, but if not, make sure to configure it later.

You also need minicom:

sudo apt install -y minicom

U-Boot prompt / serial console

On the Raspberry Pi 3, start minicom:

minicom -D /dev/serial0

Verify that the baud rate and serial port settings are correct (115200/8N1) and then use a MicroUSB to USB-A cable to connect the CHIP to the Raspberry Pi (and power it from there), which should also give a common GND connection.

This should eventually lead to a U-Boot prompt.

When U-Boot boots, press Enter to interrupt the boot process. You can view the environment variables using env print. We are interested in the kernel command-line arguments, which are in bootargs. Just replace the default command line's "rw" mount option with "ro", and set init=/bin/sh for a root shell.

In my case, something like this works:

setenv bootargs 'root=ubi0:rootfs rootfstype=ubifs ro earlyprintk ubi.mtd=4 init=/bin/sh'

Note that if your ubifs is damaged to the point where it's not mountable, you need to create a USB disk with e.g. busybox on it and use it as a rootfs to boot into a root shell.

After setting the boot env, just run:


After it has finish booting, the root shell is launched -- you're in!

First order of business is to mount /proc and /sys (/dev is populated by the kernel using devtmpfs):

mount -t proc none /proc
mount -t sysfs none /sys

Next, start sshd:

/etc/init.d/ssh start

You can also bring up the usb0 interface:

ifconfig usb0 up

Then, check with ifconfig what the assigned IPv6 address is. Also make sure to bring up the interface on the Raspberry Pi side of things. Then, using the IPv6 link-local address of the CHIP (you can copy'n'paste this from the minicom terminal output), you can ssh into the CHIP:

ssh chip@fe80:....%usb0

Since it's link-local, you have to specify %usb0 or whatever interface on your Raspberry Pi the CHIP is connected to.

Once you can connect from the Raspberry Pi 3 via SSH, you can do all sorts of recovery operations, like rsync'ing your files over, etc...

With all files recovered, the easiest way to bring back your CHIP from an unbootable state is to reflash it.

The JFPossibilities CHIP Mirror has all the necessary files and tools, you just need a jumper wire from GND to the FEL pin to enter "FEL" mode, which can be used for flashing.

Also of interest is the NTC CHIP page on linux-sunxi.org, which has some more useful information for low-level flashing and device-specific topics.

Thomas Perl · 2023-10-28