NextThingCo Pocket C.H.I.P. Flashing Guide

0x1231
10 min readJan 31, 2019

--

Flashing your C.H.I.P. without the web flasher

Note: Flashing must be done on Linux [Ubuntu Flavor]. Tested on Linux Mint.

Notes for non-Ubuntu users:

Now if you’re on Windows, you may find it easiest to boot into a Ubuntu live environment (cd/dvd/memstick, non-permanent. I.e. ‘try it out’ and never actually install, just run the commands in a terminal.) OSX is possibly more painful as booting a Ubuntu live setup on the newer machines tends to be a pain in the rear.

apt-get update && apt-get -y upgrade

apt-get -y install git android-tools-fastboot sunxi-tools u-boot-tools

Download and unpack the CHIP-SDK.zip from one of the following:

Download and unpack CHIP-tools.zip from one of the following:

Move the CHIP-tools directory inside CHIP-SDK directory (CHIP-SDK/CHIP-tools).

Download the a CHIP image from one of the following:

Unzip it (if necessary) and move the desired image into the CHIP-SDK directory. In my case since I’m flashing the Pocketchip I used the testing-gui-b543.zip image and I put it at CHIP-SDK/testing-gui-b543 because i like have desktop instead of pockethome.

Navigate to the CHIP-SDK directory in terminal and run the build script: ./setup_ubuntu1404.sh The build script should run. Multiple errors will be shown, including a fatal error when the script tries to get the CHIP-tools from a non-existant repo. This can be ignored since we already downloaded the CHIP-tools directory.

Put your CHIP in FEL mode by putting a jumper wire between GND and FEL. Connect the CHIP to your computer with USB (using the microUSB port on the CHIP, not the fullsize USB port).

Navigate to the CHIP-tools directory in terminal at CHIP-SDK/CHIP-tools and run the update firmware script. Use the -L option to explicitly specify the firmware versions from the flash-collection directory: ./chip-update-firmware.sh -L ../testing-gui-b543/

FLASH VERIFICATION COMPLETE.
# # #
#########
### ###
# {#} #
### '%######
# #
### ###
########
# # #
CHIP is ready to roll!

Pug in your C.H.I.P on to the PocketCHIP and power it up.

Note: We will have to install keyboard layouts, touchscreen needs to be calibrated and the sources.list needs to be edited (remove next thingco repos) also add long-press right-click. and you will require a usb mouse and a keyboard connect it to the fullzise USB port using a hub.

Connect your external keyboary, mouse and open terminal. or use serial connection.

sudo su

Note: password is “chip” change it using command passwd

nano /etc/sources.list

comment out nextthing co repo

FYI: The PocketCHIP uses both the CHIP and PocketCHIP repositories listed above. The PocketCHIP specific software is in its own repository.

To use these repositories all you need to do is update the applicable lines in your “/etc/apt/sources.list” files with my domain name. Example:

Original:

deb http://opensource.nextthing.co/chip/debian/repo jessie main
deb http://opensource.nextthing.co/chip/debian/pocketchip jessie main

Change it to:

deb http://chip.jfpossibilities.com/chip/debian/repo jessie main
deb http://chip.jfpossibilities.com/chip/debian/pocketchip jessie main

deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

deb http://http.debian.net/debian stretch-backports main contrib non-free
deb-src http://http.debian.net/debian stretch-backports main contrib non-free

deb http://chip.jfpossibilities.com/chip/debian/repo jessie main
deb http://chip.jfpossibilities.com/chip/debian/pocketchip jessie main

deb http://archive.raspbian.org/raspbian jessie main contrib non-free

#deb http://opensource.nextthing.co/chip/debian/repo jessie main
#deb http://opensource.nextthing.co/chip/debian/pocketchip jessie main
#deb http://opensource.nextthing.co/chip/debian/testing-repo testing main

I made sure to use the same paths for file locations to make it easier on lesser experienced users. Remember the “pocketchip” line above will only be on PocketCHIP installs.

apt-get update && apt-get -y upgrade

apt-get -y install git vala-terminal xfce4-genmon-plugin xinput-calibrator software-properties-common apt-transport-https

wget https://raw.githubusercontent.com/ALLGray/PocketDesk/master/Scripts/keyboard.sh && chmod +x keyboard.sh && ./keyboard.sh

keyboard.sh

#!/bin/bash

# Keyboard
wget -O /home/chip/.Xmodmap https://raw.githubusercontent.com/AllGray/PocketDesk/master/files/.Xmodmap
wget -O /home/chip/.xinitrc https://raw.githubusercontent.com/AllGray/PocketDesk/master/files/.xinitrc

.Xmodmap

keycode 10 = 1 exclam F1 exclam
keycode 11 = 2 at F2 at
keycode 12 = 3 numbersign F3 numbersign
keycode 13 = 4 dollar F4 dollar
keycode 14 = 5 percent F5 percent
keycode 15 = 6 asciicircum F6 asciicircum
keycode 16 = 7 ampersand F7 ampersand
keycode 17 = 8 asterisk F8 asterisk
keycode 18 = 9 parenleft F9 parenleft
keycode 19 = 0 parenright F10 parenright
keycode 22 = BackSpace BackSpace KP_Delete BackSpace
keycode 29 = y Y braceleft Y
keycode 30 = u U braceright U
keycode 31 = i I bracketleft I
keycode 32 = o O bracketright O
keycode 33 = p P bar P
keycode 36 = Return NoSymbol KP_Enter
keycode 43 = h H less H
keycode 44 = j J greater J
keycode 45 = k K apostrophe K
keycode 46 = l L quotedbl L
keycode 56 = b B grave b
keycode 57 = n N asciitilde n
keycode 58 = m M colon M
keycode 59 = comma less semicolon less
keycode 60 = period comma semicolon comma
keycode 61 = slash question backslash question
keycode 82 = KP_Subtract underscore F11 KP_Subtract
keycode 86 = KP_Add KP_Equal F12 KP_Add
keycode 108 = Mode_switch Meta_R Alt_R Meta_R
keycode 111 = Up NoSymbol Prior
keycode 113 = Left NoSymbol Home
keycode 114 = Right NoSymbol End
keycode 116 = Down NoSymbol Next

.xinitrc

if [ -s ~/.Xmodmap ]; then
xmodmap ~/.Xmodmap
fi

wget https://raw.githubusercontent.com/ALLGray/PocketDesk/master/Scripts/touchscreen.sh && chmod +x touchscreen.sh && ./touchscreen.sh

touchscreen.sh

#!/bin/bash

# Touchscreen
xinput_calibrator
mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
wget -O /etc/X11/xorg.conf https://raw.githubusercontent.com/AllGray/PocketDesk/master/files/xorg.conf

xorg.conf

Section "Files"
ModulePath "/usr/lib/arm-linux-gnueabihf/xorg/modules/"
ModulePath "/usr/lib/xorg/modules/"
EndSection

Section "Monitor"
Identifier "VGA"
Option "PreferredMode" "1024x768_60.00"
EndSection

Section "Monitor"
Identifier "HDMI"
Option "PreferredMode" "1280x720_60.00"
EndSection

Section "Monitor"
Identifier "Composite"
Option "PreferredMode" "NTSC10"
EndSection

Section "Device"
Identifier "Allwinner sun4i DRM"
Driver "armsoc"
Option "Monitor-Composite-0" "Composite"
Option "Monitor-VGA-0" "VGA"
Option "Monitor-HDMI-A-0" "HDMI"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
EndSection

Section "InputClass"
Identifier "calibration"
MatchProduct "1c25000.rtp"
Option "Calibration" "3980 226 3564 343"
Option "SwapAxes" "0"
EndSection

Add the following for long-press right-click.

Section “InputClass”
Identifier “calibration”
Driver “evdev”
MatchProduct “FT5406 memory based driver”
Option “EmulateThirdButton” “1”
Option “EmulateThirdButtonTimeout” “750”
Option “EmulateThirdButtonMoveThreshold” “30”
EndSection

Now you should find that a long-press behaves like a right click, time to unplug your mouse and keyboard.

PocketCHIP battery status for xfce4 desktop

git clone https://github.com/editkid/chip-battery-status && cd chip-battery-status && ./install.sh

Note: Follow the instructions from here [ https://github.com/editkid/chip-battery-status/blob/master/README.md ]

Right-click (or Ctrl-click) on an existing panel item, e.g your clock. Choose Panel > Add New Items...

Select Generic Monitor from the list and hit Add

You’ll see (genmon) xxx appear in your panel. Right-click (or Ctrl-click) it and choose Properties

In the Command field enter chip-battery-xfce-genmon and for the Period (s) enter 5. Hit Close

All Done.

Goodies.

DOOM
apt-get -y install prboom doom-wad-shareware

RetroArch
apt wget https://www.dropbox.com/s/w9mtoq85tu791am/RetroArch-PCHIP.tar.gz?dl=1 -O RetroArch-PCHIP.tar.gz

tar -xzvf RetroArch-PCHIP.tar.gz && cd RetroArch && ./install.sh sdl2

Launching Retro Arch: ./retroarch.sh

Putting built-in wifi in monitor mode :

PocketChip has 2 interfaces build in. wlan0 and wlan1 . wlan0 is the one that connect to the wifi network the Chip is connected to and wlan1 can be put into monitor mode. However putting wlan1 into monitor mode is a bit tricky , you have to bring down wlan0 then switch wlan1 into monitor mode and then run airodump-ng.

sudo apt-get install aircrack-ng

sudo ifconfig wlan0down
sudo ifconfig wlan1 mode monitor
sudo airodump-ng wlan1

Include the IP address of the Chip into the command line:

THEIP=$(/sbin/ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')PS1="\[\033[01;32m\]\u@"$THEIP"$\[\033[00m\] ";

Add some swap space onto an external usb thumbdrive:

sudo mkswap /dev/sda1
sudo swapon /dev/sda1

wifimenu.sh

menu driven shell script sample template
## ----------------------------------
# Step #1: Define variables
# ----------------------------------
RED='033[0;41;30m'
STD='033[0;0;39m'

# ----------------------------------
# Step #2: User defined function
# ----------------------------------
pause(){
read -p "Press [Enter] key to continue..." fackEnterKey
}

one(){
clear
nmcli d wifi
break
}

# do something in two()
two(){
clear
sudo ifconfig wlan0 down
sudo iwconfig wlan1 mode monitor
now=$(date +'%mm-%dd-&Y')
sudo xterm -maximized -e horst -i wlan1 -o /home/chip/dumps//horst-$now.txt
break
}
three(){
clear
sudo ifconfig wlan0 down
sudo iwconfig wlan1 mode monitor
sudo airodump-ng wlan1
break
}
four(){
clear
sudo iwlist scan
break
}
five(){
clear
echo "Bringing if up and down"
sudo ifconfig wlan0 up
echo "changing wlan1 mode"
sudo iwconfig wlan1 mode managed
sudo sleep 5
echo "Restarting Network Manager"
sudo service network-manager restart
break
}

# function to display menus
show_menus() {
clear
echo "~~~~~~~~~~~~~~~~~~~~~"
echo "HACK CHIP WIFI TOOLS"
echo "~~~~~~~~~~~~~~~~~~~~~"
echo "1. Network Manger cli wifi scan"
echo "2. horst"
echo "3. Airodump-ng"
echo "4. iwlist scan"
echo "5. Restart Network Manger"
echo "6. Exit"
}

read_options(){
local choice
read -p "Enter choice [ 1 - 6] : " choice
case $choice in
1) one ;;
2) two ;;
3) three ;;
4) four ;;
5) five ;;
6) exit 0;;
*) echo -e "${RED}Error...${STD}" && sleep 2
esac
}

# ----------------------------------------------
# Step #3: Trap CTRL+C, CTRL+Z and quit singles
# ----------------------------------------------
trap '' SIGINT SIGQUIT SIGTSTP

# -----------------------------------
# Step #4: Main logic - infinite loop
# ------------------------------------
while true
do

show_menus
read_options
done

PocketCHIP: First Run

passwd
$ sudo -i
# apt-get update && apt-get upgrade && apt-get dist-upgrade
# apt-get install locales
# dpkg-reconfigure tzdata
# locale-gen en_US en_US.UTF-8
# apt-get install openssh-server
# iw wlan0 set power_save off
# wget http://bit.ly/29uWueR
# mv 29uWueR install-pockethome
# chmod +x install-pockethome
# ./install-pockethome
# apt-get install rsync
# apt-get install git

Determine USB identification

This is a bit tricky, so follow closely. Load the Terminal application on the Mac and issue the command below.

ls /dev/tty*

You will see a long list of tty devices similar to the image below:

Most likely, the C.H.I.P. tty device is not on the current page. Use the arrow keys and scroll up. Look for a tty device with the following format:

/dev/tty.usbmodemXXXX where XXXX is a four digit number

Write down that four digit number, or better yet, write that entire line with the four digit numbers. In my case, I have the following serial device name:

`/dev/tty.usbmodem2623 `

Connect using a Serial Terminal

The Mac has a serial connection command built-in called screen and we will use the screen command to make a serial connection to the C.H.I.P. so we can issue commands on the C.H.I.P.

  • Use the command below (remember to substitute XXXX for your four digit number) to establish a serial connection to the C.H.I.P.:
    screen /dev/tty.usbmodemXXXX 115200
    The 115200 (115,200bps) at the end of the command is the connection speed between the Mac and the C.H.I.P.

If the connection is successful, the C.H.I.P. will promote you for a username and password. The defaults are below:

username: chip password: chip

After the login process, you will see the prompt in the image below:

You can now issue commands to the C.H.I.P. I will not discuss the many possibilities; however, I do want to share two useful things we can do with the C.H.I.P. and this serial connection:

  1. Connect the C.H.I.P. to Wi-Fi
  2. Determine the C.H.I.P. IP address

Once you do these two things, you can untether your C.H.I.P. from your Mac and administer it remotely.

Connect C.H.I.P. to Wi-Fi

To connect your C.H.I.P. to your Wi-Fi network, first see that your C.H.I.P. can access your network. Scan the Wi-Fi spectrum with the command below:

nmcli device wifi list

You will see a listing similar to the one below:

If you see the name of your Wi-Fi network (along with others depending on the proximity to your neighbors), you are ready to make a connection.

Use the command below:

sudo nmcli device wifi connect 'SSID' password 'password' ifname wlan0

Remember to make the substitutions to include your Wi-Fi SSID and password.

The C.H.I.P. will ask for a password. This is the C.H.I.P. user password, chip, not the Wi-Fi password. You will type blind and will not see the password or * placeholders.

Enter chip and hit the enter key. After a second or two, you will see a line similar to the following:

Connection with UUID '211yui4-d0fc-601c-4ddeb-3b4f5z690d0b' created and activated on device 'wlan0'

Success! The C.H.I.P. will remember the Wi-Fi connection even after a reboot.

Add a Speaker to PocketC.H.I.P. in Less Than 20 Minutes:

https://web.archive.org/web/20180421111351/http://blog.nextthing.co/add-a-speaker-to-pocketc-h-i-p-in-less-than-20-minutes/

Sources and Further Read:

https://archive.org/details/C.h.i.p.FlashCollection

https://gist.githubusercontent.com/verticalgrain/deae2821213a891747e08e2d6492808a/raw/8a0333b206b43c07bfdb4b5a4ceb5582fd4cbbb9/chip-flashing-guide-nov-2018.md

https://www.instructables.com/id/Playing-OpenArena-on-PocketCHIP/

https://www.instructables.com/id/Retro-Arcade-Gaming-on-PocketCHIP/

https://www.reddit.com/r/ChipCommunity/

https://github.com/AllGray/PocketDesk

https://twitter.com/nextthingco

https://opensource.com/article/17/2/pocketchip-or-pi

--

--