Reflashing the Pocket CHIP in 2023

In the event you need to reflash a CHIP computer in 2023 or later, this post contains a walkthrough of a successful reflash using Ubuntu 14.04 on a Live USB.

The C.H.I.P (and by extension, the Pocket C.H.I.P) was a short-lived single-board computer released in 2016. You can read more about it at the C.H.I.P Wikipedia Entry.

For simplicity, I will refer to this computer as the “CHIP” throughout the rest of this post.

The CHIP can be reflashed, and there are a variety of images available for it, but reflashing can be a complicated and frustrating process since the company that made it is long since gone and the flashing tools and software repositories are now hosted only on archive sites.

I successfully reflashed one of my CHIPs yesterday (after fighting with it for about a week) and this post is a description of what worked for me, here in 2023.

Downloads

I used three downloaded archives from the CHIP Flash Collection at the Internet Archive.

  • CHIP-SDK.zip
  • CHIP-tools.zip
  • flash-collection.zip

I also used the sunxi-tools repository at Github, though you should be able to git clone it, and don’t need to download it with the zip archives.

I used a Live USB flash drive loaded with Ubuntu 14.04 and a spare computer capable of running it as a live (read: not installed) system. I used a second USB flash drive to hold the downloaded files. You may be able to keep the extracted archives on the 2nd flash drive or you may need to copy the relevant directories to the live operating system. The CHIP-tools directory should be placed within the CHIP-SDK directory, and one directory from the flash-collection archive should also be placed within the CHIP-SDK directory (each directory in flash-collection is a separate CHIP image – you’ll need to select which one you want).

Make sure you reserve a USB 2.0 port for the CHIP on the computer you’ll use to run the Live USB. It doesn’t seem to play nice with USB 3.0 ports, so if you only have one of each, you’ll need to plug the Live USB into the 3.0 port and use the 2.0 first to transfer the tools directories and flash image to the live OS, then remove the file-transfer USB and use the 2.0 port to connect the CHIP.

1
2
3
4
5
6
7
# File structure
CHIP-SDK
|- CHIP-tools (directory)
|- [flash image dir] (directory)
|- README.md
|- setup_ubuntu1404.sh
|- Vagrantfile

Preparation

Upon loading up Ubuntu 14.04, I added universe repositories to the apt list so I’d have access to two applications the flasher needs.

1
2
3
4
5
6
7
# file: /etc/apt/sources.list

..
deb http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe

Most of the commands that come after here are taken from the setup_ubuntu1404.sh script. I’m not going to direct you to use the actual script because we need to build a different version of sunxi-tools than what’s most recent.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# update apt and install prerequisite applications
apt update
apt install -y \
build-essential \
 git \
 mercurial \
 cmake \
 curl \
 screen \
 unzip \
 device-tree-compiler \
 libncurses-dev \
 ppp \
 cu \
 linux-image-extra-virtual \
 u-boot-tools \
 android-tools-fastboot \
 android-tools-fsutils \
 python-dev \
 python-pip \
 libfdt-dev \
 libusb-1.0-0-dev \
 libz-dev \
 g++-arm-linux-gnueabihf \
 pkg-config \
 libacl1-dev \
 zlib1g-dev \
 liblzo2-dev \
 uuid-dev

If (and only if) you’re running 32-bit, also install:

1
apt install -y libc6-i386 lib32stdc++6 lib32z1

Make sure the user is permitted to communicate via USB serial connections:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
sudo usermod -a -G dialout $(logname)
sudo usermod -a -G plugdev $(logname)

echo -e 'SUBSYSTEM=="usb", ATTRS{idVendor}=="1f3a", ATTRS{idProduct}=="efe8", GROUP="plugdev", MODE="0660" SYMLINK+="usb-chip"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="1010", GROUP="plugdev", MODE="0660" SYMLINK+="usb-chip-fastboot"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1f3a", ATTRS{idProduct}=="1010", GROUP="plugdev", MODE="0660" SYMLINK+="usb-chip-fastboot"
SUBSYSTEM=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="plugdev", MODE="0660" SYMLINK+="usb-serial-adapter"
' | sudo tee /etc/udev/rules.d/99-allwinner.rules

sudo udevadm control --reload-rules

Build the sunxi-tools

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Clone the sunxi-tools repository
git clone https://github.com/linux-sunxi/sunxi-tools.git

# checkout v1.3 of sunxi-tools
cd sunxi-tools
git checkout tags/v1.3

# make the tools. Note that it may throw some warnings.
# If these commands throw errors about missing libraries, 
# you'll need to find them and install them, 
# then try these next two commands again
make
make misc

# add the sunxi-tools directory to PATH
# modify the path to the sunxi-tools directory if it's different
# from what is listed here
PATH=/home/ubuntu/sunxi-tools:$PATH

Now is the time to insert a jumper wire between the FEL and GND pins, and connect the CHIP to the USB 2.0 port. Make sure you’re using a USB cable that is capable of data transfer.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# If you want to make sure the CHIP is connected, it should appear
# in the output list when you do
lsusb

# enter the CHIP-tools directory
cd CHIP-tools

# run the flashing script
# note that the final path should point to the flash image directory
# which in this example is the one named "stable-pocketchip-b126"
FEL='sudo sunxi-fel' FASTBOOT='sudo fastboot' SNIB=false ./chip-update-firmware.sh -L ../stable-pocketchip-b126

If everything goes smoothly, what you’ll see is a series of tests followed by a few minutes’ worth of terminal output that reports progress of writing UBI data. Once it’s successfully done, it will say, “CHIP is ready to roll!”

At that point you can disconnect the CHIP and remove the jumper. If your CHIP has a Pocket, you can re-seat it into the Pocket and turn it on. You’ll still need to do some setup (keyboard, etc) but the OS should boot for you. Note that jessie has been retired to the archive.debian.org repository server, so that will matter when you go to update /etc/apt/sources.list on your CHIP.

You can let me know how it went for you by leaving a comment here, posting a pingback reply, or by mentioning me @cordelya on any ActivityPub-capable server that can federate with toots.cordelya.net.