Skip to content

Instantly share code, notes, and snippets.

@luzhuomi
Last active January 27, 2024 21:53
  • Star 69 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save luzhuomi/526fbcc30f3522f09eacf20d0f776fa5 to your computer and use it in GitHub Desktop.
A tutorial to upgrade NXT pocket C.H.I.P to Debian Buster

Pocket Chip Debian 10 Upgrade Guide

The purpose of this tutorial is to walk through the required steps to upgrade NXT chip (or pocketchip) from debian jessie to debian buster.

If you would like to start your Chip from scratch, follow the steps in the Preparation section.

Preparation (Optional)

A linux host machine, recommended Ubuntu 18.04. However I managed to do it with 20.10 with some tweak.

  1. Remove the C.H.I.P from its case (in case you have a Pocket C.H.I.P).
  2. Connect the FEL and a GROUND pin of the C.H.I.P (for example, with a paperclip).
  3. Connect the C.H.I.P its micro USB port to a USB port of your Linux machine.
  4. In the Linux machine:
    • run git clone https://github.com/thore-krug/Flash-CHIP.git to clone this repository.
    • cd into the location where you stored this repository.
    • run sudo chmod +x Flash.sh
    • run ./Flash.sh
    • Select the version you want to install.
    • Wait until the installation finishes.
    • Restart the Chip
  5. Connect to your chip using USB network or ssh over wifi. For USB network, run screen /dev/ttyACM0 For Wifi ssh, run ssh chip@<ip_address_of_chip>
  6. Your chip is running Debian Jessie now.
  7. Update the apt source file. Replace all jessie with stretch in /etc/apt/source.list. Comment away or remove the following
# deb http://http.debian.net/debian jessie-backports main contrib non-free
# deb-src http://http.debian.net/debian jessie-backports main contrib non-free

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

and add

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

After the modification, your /etc/apt/source.list should look something like

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://chip.jfpossibilities.com/chip/debian/repo jessie main
deb http://chip.jfpossibilities.com/chip/debian/pocketchip jessie main
  1. sudo apt update && sudo apt upgrade

Note I started with the headless server version and manually install lightdm and i3wm after the upgrade. Your experience might defer if you use other images.

Trouble-shooting

  1. If you are stuck at waiting for FEL..., try to run the script without plugin the chip to the USB port of the host machine. Instead, you start the script ./Flash.sh and proceed until you see the prompt waiting for FEL..., then plug in the chip.
  2. If you are stuck at flash usb_bulk_send() ERROR -7: Operation timed out, your host machine is probably running a latest version of the sunix tool. Try to downgrade it by download the deb file from sunxi-tools_1.4.1-1_amd64.deb from https://ubuntu.pkgs.org/18.04/ubuntu-universe-amd64/sunxi-tools_1.4.1-1_amd64.deb.html. Then overwrite the existing installation with
$ sudo dpkg -i sunxi-tools_1.4.1-1_amd64.deb

And edit the Flash.sh file to comment away the following lines.

 # sunxi-tools \

Upgrade From Jessie to Stretch

  1. Login to your chip.
  2. Update the apt source file. Replace all jessie with stretch in /etc/apt/source.list. Comment away or remove to the two lines
# deb http://chip.jfpossibilities.com/chip/debian/repo jessie main
# deb http://chip.jfpossibilities.com/chip/debian/pocketchip jessie main

After the modification, /etc/apt/source.list file should be like the following

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

deb http://security.debian.org/ stretch/updates main contrib non-free
deb-src http://security.debian.org/ stretch/updates main contrib non-free
  1. sudo apt update && sudo apt full-upgrade
  2. Modify the file /etc/NetworkManager/NetworkManager.conf to the following
[main]
plugins=ifupdown,keyfile

[connection]
wifi.mac-address-randomization=1

[device]
wifi.scan-rand-mac-address=no

[ifupdown]
managed=false

[keyfile]
unmanaged-devices=interface-name:wlan1
  1. If you have X running, modify the file /etc/X11/xorg.conf to the following
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 "Device"
	Identifier	"Card0"
	Driver		"modesetting"
EndSection
  1. Restart your chip and it should be in Stretch now.

Stretch to Buster

  1. Login to your chip
  2. Update /etc/apt/source.list to the following
deb http://deb.debian.org/debian/ buster main contrib non-free
#deb-src http://deb.debian.org/debian/ buster main contrib non-free
#deb http://security.debian.org/ buster/updates main contrib non-free
#deb-src http://security.debian.org/ buster/updates main contrib non-free
#deb http://deb.debian.org/debian buster-backports main contrib non-free
#deb-src http://deb.debian.org/debian buster-backports main contrib non-free
  1. sudo apt update && sudo apt full-upgrade
  2. Update /etc/X11/xorg.conf to the following
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 "Screen"
	Identifier	"Screen0"
	Device		"Card0"
EndSection


Section "Device"
	Identifier	"Card0"
	Driver		"fbdev"
EndSection
  1. (Optional) install lightdm and i3 by following this link https://www.reddit.com/r/ChipCommunity/comments/abndo9/an_updated_guide_for_installing_i3_window_manager/

  2. Reboot. If your touch screen cursor movement is reversed, append the following to either /etc/X11/xorg.conf or /usr/share/X11/xorg.conf.d/99-calibration.conf

Section "InputClass"
        Identifier "calibration"
        MatchProduct "1c25000.rtp"
        Option "Calibration"  "3992 182 3694 276"
        Option "SwapAxes" "0"
	Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
EndSection

Fixing the issue with pressing the home button causing chip to shutdown

Thanks to https://www.reddit.com/user/pernig_/ awesome finding

  1. Edit this file /etc/systemd/logind.conf and change the following line
#HandlePowerKey=poweroff

to

HandlePowerKey=ignore
  1. Save the file and run the following in the terminal as root
$ systemctl kill -s HUP systemd-logind

Reference

Most of the steps in this tutorial were inspired/modified from the following references.

  1. https://github.com/Thore-Krug/Flash-CHIP
  2. https://yoursunny.com/t/2019/bye-CHIP/
  3. http://maba.dk/index.php/demo/pocketchip/
  4. https://www.reddit.com/r/ChipCommunity/comments/l3xli8/upgraded_my_pocketchip_to_debian_10/
@roberttco
Copy link

roberttco commented Sep 30, 2021

Since Jessie is now archived, the repository is not at archive.debian.org/debian (RE step 7). Also you may need to update the keyring using
apt install debian-keyring debian-archive-keyring You should alsoupdate the keyrings after changing the sources list to the next release before running apt update

@aykaramba
Copy link

Does this still leave in place and working the custom desktop that the Pocket CHIP devs created? I don't want a standard desktop, the one they created is extremely efficient in the use of ram and cpu.

Anyone know?

@roberttco
Copy link

I’m going to say it might but if it doesn’t, you can use a light weight WDM like lxde or something. I use command line only to YMMV.

@aykaramba
Copy link

You were correct. Thanks for the heads up.

@dag7dev
Copy link

dag7dev commented Nov 21, 2021

Same goes for Debian11?

@aykaramba
Copy link

aykaramba commented Nov 21, 2021

Correct. Just keep changing the repo and dist-upgrade. I suspect you can go directly to debian 11, but, I prefer to go version by version because I've had problems with flashing and did not want to take a chance.

@dag7dev
Copy link

dag7dev commented Nov 21, 2021

@aykaramba fiy: maybe i am just out of luck, but after having upgraded to Debian 11, I can't login to my machine anymore.
I'm now figuring out a way to flash Debian 7 and then upgrading to Debian 11...

@aykaramba
Copy link

Are you sure you are typing your password in correctly? Are you using PocketChip keyboard? If so, the keyboard is very sensitive and will overtype many letters multiple times. Do you have a Linux laptop? If so there is a way to connect to the chip it self by plugging its microusb into the laptops and connecting to it via screen. That will give you access to a keyboard that won't overtype too many characters. I think you can connect to it that way using other operating systems but I don't use them so I don't know. Anyway, if you are using pocketchip to input your credentials, let me know, and I will try to dig up info on how to ssh into your Chip over usb from a laptop/desktop.

@dag7dev
Copy link

dag7dev commented Nov 21, 2021

@aykaramba I was using puTTY to access CHIP through serial connection. The keyboard I used was my "host" pc keyboard. It was working before updating, now it doesn't work anymore. Yes, I am sure I am typing user and password correctly (they are the default ones chip/chip root/chip).

I can't manage to make it work on Linux btw, neither ssh nor screen.

EDIT: just figured out more and more and more. I will update this comment soon with many other interesting information!

@aykaramba
Copy link

Aha, sounds good. The only other issue that I found was that I had to remove the chip from the PocketChip case to get it to fully power down. If I rebooted it, I would end up with no post and no image on the PocketChip. Okay good to see you can connect over tty/serial.

@vigliag
Copy link

vigliag commented Jan 26, 2022

on ubuntu 21.10 (pop-os) I also had to remove the -i 0x1f3a and -u flags from the fastboot commands, as I found here: https://www.reddit.com/r/ChipCommunity/comments/cdrc5s/how_the_heck_do_you_flash_a_chip_nowdays/etw5jwf/?utm_source=reddit&utm_medium=web2x&context=3

from the help on ubuntu bionic, the flag help said:

  -u                                       Do not erase partition before
                                           formatting.
  -i <vendor id>                           Specify a custom USB vendor id.

@dag7dev
Copy link

dag7dev commented Jan 27, 2022

@vigliag oh damn, thanks. Everytime I tried to use it I needed to downgrade fastboot and a big amount of packages.
Also, it is nice finding someone who still uses Chip in 2022!

@meanderer-tech
Copy link

I followed this instruction and upgraded by regular chip to stretch and the HDMI dip stopped working. Do you know what component is missing?

@vigliag
Copy link

vigliag commented Jan 29, 2022

I noticed the ssh keys were re-generated at every boot, the culprit seems to be /etc/rc.local, which tries to run /usr/bin/ssh-keygen -t rsa1 -N '' -f /etc/ssh/ssh_host_key and then checks at the next boot if /etc/ssh/ssh_host_key exists. Since rsa1 is not supported anymore, and the output is not there, the script re-generates all the keys.

You can disable this behavior by restoring the original /etc/rc.local, via mv /etc/rc.local.orig /etc/rc.local

@dag7dev
Copy link

dag7dev commented Jan 29, 2022

Additionally, you'll have a problem with network manager: if wifi goes down for any cause, chip won't reconnect to network.

You can avoid this by giving: nmcli c to figure out your connection, and then nmcli c m SSID autoconnect yes.

Now if wifi goes down, you're safe and sound.

@Nast4
Copy link

Nast4 commented Mar 5, 2022

Will this work if I can't login to my chip and it will not boot the home page either I just want a hard reset on the debian

@emdash
Copy link

emdash commented Apr 4, 2022

on ubuntu 21.10 (pop-os) I also had to remove the -i 0x1f3a and -u flags from the fastboot commands, as I found here: https://www.reddit.com/r/ChipCommunity/comments/cdrc5s/how_the_heck_do_you_flash_a_chip_nowdays/etw5jwf/?utm_source=reddit&utm_medium=web2x&context=3

from the help on ubuntu bionic, the flag help said:

  -u                                       Do not erase partition before
                                           formatting.
  -i <vendor id>                           Specify a custom USB vendor id.

I also had to do this, flashing from Debian 11.

Copy link

ghost commented Jun 25, 2022

I found I can build sunxi-tools from git without downgrading anything. It works 100%

Copy link

ghost commented Jun 25, 2022

Btw, if you guys find FN key misbehavior, try to use a modified xmodmap. Bind FN key (Code 108) to Mode_switch and modify other keymaps.

@Dezorian
Copy link

Dezorian commented Jan 19, 2023

nmcli c m SSID autoconnect yes

thanks for the right direction! You do need to add '.connection' to the command before it works. Like so:
nmcli c m yourSSID connection.autoconnect yes

@Dezorian
Copy link

Dezorian commented Jan 19, 2023

Btw, why dont you need the deb-src and security buster/updates anymore? Are they coming through the only active line below?
deb http://deb.debian.org/debian/ buster main contrib non-free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment