Success in Flashing C.H.I.P pro from Ubuntu 14.04


#1

This has been tested on Ubuntu 14.04 64bit using the C.H.I.P pro board as of 24 February 2017.

Install packages:

sudo apt-get update
sudo apt-get install git unzip bc libncurses5-dev mercurial lib32stdc++6 libc6-i386 lib32z1 u-boot-tools android-tools-fastboot build-essential libusb-1.0-0-dev curl android-tools-fsutils pkg-config libacl1-dev zlib1g-dev liblzo2-dev uuid-dev

Clone git repositories:

cd ~
git clone https://github.com/NextThingCo/CHIP-buildroot.git
git clone https://github.com/NextThingCo/CHIP-tools
git clone https://github.com/linux-sunxi/sunxi-tools
cd ~/sunxi-tools
git clone https://github.com/NextThingCo/chip-mtd-utils

These are the most recent commits as of 2017-02-24.
CHIP-buildroot b52c25c
CHIP-tools 6c16df5
sunxi-tools 7128c73
chip-mtd-utils f6a16e5

cd ~/CHIP-buildroot && git checkout b52c25c
cd ~/CHIP-tools && git checkout 6c16df5
cd ~/sunxi-tools && git checkout 7128c73
cd ~/sunxi-tools/chip-mtd-utils && checkout f6a16e5

Build sunxi tools:

cd ~/sunxi-tools
make
make misc
cd chip-mtd-utils
make
sudo make install

Create symbolic links for these sunxi-tool executibles in /usr/local/bin:
sunxi-bootinfo
sunxi-fel
sunxi-fexc
sunxi-nand-image-builder
sunxi-nand-part
sunxi-pio

cd ~/sunxi-tools
sudo ln -s $PWD/sunxi-bootinfo /usr/local/bin/sunxi-bootinfo
sudo ln -s $PWD/sunxi-fel /usr/local/bin/sunxi-fel
sudo ln -s $PWD/sunxi-fexc /usr/local/bin/sunxi-fexc
sudo ln -s $PWD/sunxi-nand-image-builder /usr/local/bin/sunxi-nand-image-builder
sudo ln -s $PWD/sunxi-nand-part /usr/local/bin/sunxi-nand-part
sudo ln -s $PWD/sunxi-pio /usr/local/bin/sunxi-pio

Setup Udev to allow programming the CHIPpro over serial:

sudo usermod -a -G dialout ${USER}
sudo usermod -a -G plugdev ${USER}

sudo gedit /etc/udev/rules.d/99-allwinner.rules

Add the following lines:

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"

Log out and then in again after making the udev rule.

cd ~/CHIP-buildroot
make chippro_defconfig
make

The build image is under:
~/CHIP-buildroot/output/images

Load it onto CHIPpro by these commands:

cd ~/CHIP-tools
sudo ./chip-create-nand-images.sh ../CHIP-buildroot/output/build/uboot-nextthing_2016.01_next ../CHIP-buildroot/output/images/rootfs.tar new-image

sudo chown -R username:username new-image

(your username is used in place of ‘username’)

sudo ./chip-flash-nand-images.sh new-image

When flashing use a USB2, not USB3 port. Hold down the FEL button on the CHIPpro, plug in USB, and then run the chip-flash-nand-images.sh command. Keep the FEL button held down. This can take a few minutes.

EDIT (2017-02-14):
I held down the FEL button for the entire length of the flashing. That is, the device was unplugged, I held down the FEL button, plugged the USB cable into the device and PC, started flashing by calling sudo ./chip-flash-nand-images.sh, and continued to hold down the button until I saw FLASH VERIFICATION COMPLETE. I was not keeping track of time, but it felt like this took about 3 to 5 minutes. If you are having trouble plugging in the device while holding down the button, ask a friend to help you. If you know how long the button actually needs to be held down please let me know.

The reason the flashing worked is because we are building the image from buildroot instead of using a pre-built debian image. This is the post where computermouth discusses the situation:

I have also been having trouble with uboot showing a device tree error on starting up the chip. This happens intermittently. It may be due to chip-flash-nand-images.sh not updating the boot memory on the chip correctly. If this happens, one thing you can try is to load the blinkenlights image from the web flasher (flash.getchip.com) and then load the buildroot image with chip-flash-nand-images.sh again.

EDIT (2017-02-17):
I am running Ubuntu 14.04 64bit Linux 3.19.0-51 generic

EDIT (2017-02-18):
From SlowBro:

  • added git, unzip, and bc to package list.
  • adding ~/sunxi-tools to the path.
  • fixed my-new-image typo

EDIT (2917-02-24):
Changes made to reflect the wiki:
http://www.chip-community.org/index.php/Flashing_Buildroot_Image_from_Ubuntu


Chrome flasher is insane
Buildroot app development using QtCreator
Yocto - Flashing timeout
Failure to flash with SDK tooling?
C.H.I.P. Pro - Cant Flash and Cant Boot
Several questions about ChipPro flashed with buildroot
[SOLVED] CUSTOM buildroot image doesn't works
#2

Great. I can’t wait to try this. Did you hold the fel button and if so when and for how long?


#3

FYI I’m using Ubuntu 16.10 32bit and I get the error below following your instructions. I am fairly certain that this is an acceptable message on 32bit versions of Ubuntu, because everything it is complaining about is a 32bit backwards-compatible library for 64bit systems.

root@lubuntu:~/CHIP-buildroot# sudo apt-get install libncurses5-dev mercurial lib32stdc++6 libc6-i386 lib32z1
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package libc6-i386 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
libc6

E: Unable to locate package lib32stdc++6
E: Couldn’t find any package by regex 'lib32stdc++6’
E: Package ‘libc6-i386’ has no installation candidate
E: Unable to locate package lib32z1
root@lubuntu:~/CHIP-buildroot#

Also, probably unrelated, I am getting the following error when running make. I’m not getting good results for this error on Google. I may be emailing NTC.

checking whether your compiler passes the ACC conformance test… FAILED
configure:
configure: Your compiler failed the ACC conformance test - for details see
configure: `config.log’. Please check that log file and consider sending
configure: a patch or bug-report to lzop-bugs@oberhumer.com.
configure: Thanks for your support.
configure:
configure: error: ACC conformance test failed. Stop.
package/pkg-generic.mk:146: recipe for target ‘/root/CHIP-buildroot/output/build/host-lzop-1.03/.stamp_configured’ failed
make: *** [/root/CHIP-buildroot/output/build/host-lzop-1.03/.stamp_configured] Error 1
root@lubuntu:~/CHIP-buildroot#


#4

I forgot to mention that I am using 64bit Linux. The lib32 compatibility libraries are what is needed when running 64bit Linux. If you are using 32bit you don’t need them.


#5

I’m rebuilding from scratch and I thought others may want to know how to quiet an error I encountered both times. Please note that I have NO IDEA IF THIS CAUSES ANOTHER PROBLEM. I only know it enabled me to get past a certain point.

error: format not a string literal, format string not checked [-Werror=format-nonliteral]

Here is the fix. Open this file in an editor: output/build/host-libglib2-2.44.1/glib/gdate.c

Do a search for this comment:
recognize whether strftime actually failed or just returned

Make the code below below that comment look like this:

  tmpbuf[0] = '\1';
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wformat-nonliteral"
  tmplen = strftime (tmpbuf, tmpbufsize, locale_format, &tm);
  #pragma GCC diagnostic pop

   if (tmplen == 0 && tmpbuf[0] != '\0')
     {

Found it here.


#6

What compiler are you using? Is it the cross compiler located at:
CHIP-buildroot/output/host/usr/bin/arm-linux-gnueabihf-gcc ?


#7

Indeed it is but remember, this is 32bit Ubuntu. The rules may be different enough to not let it work. If this fails I’m going to try it on a 64bit machine.

user@lubuntu:~/CHIP-buildroot$ ls -l output/host/usr/bin/arm-linux-gnueabihf-gcc
lrwxrwxrwx 1 christopher christopher 21 Feb 17 09:19 output/host/usr/bin/arm-linux-gnueabihf-gcc -> ext-toolchain-wrapper
user@lubuntu:~/CHIP-buildroot$ ls -l output/host/usr/bin/ext-toolchain-wrapper
-rwxr-xr-x 1 christopher christopher 9836 Feb 17 09:19 output/host/usr/bin/ext-toolchain-wrapper
user@lubuntu:~/CHIP-buildroot$


#8

Tried to follow the instructions on Ubuntu 16.10. Got as far as:

~/CHIP-tools$ sudo ./chip-create-nand-images.sh ../CHIP-buildroot/output/build/uboot-nextthing_2016.01_next ../CHIP-buildroot/output/images/rootfs.tar my-new-image

Whereupon I received the following:

  Error: Unable to locate sunxi-fel utility.
  Install sunxi-fel with:
  CHIP-SDK setup script      [github.com/NextThingCo/CHIP-SDK]

I have no idea where to go from here. This is my only hope of using the CHIP Pro Dev Kit, since the Chrome Flasher does not work on either of my computers.


#9

Try this, it worked for me.
export PATH=${PATH}:~/sunxi-tools


#10

After you do this, check to make sure sunxi-fel is in the path by typing fel into the command line. This utility is what ./chip-create-nand-images.sh is looking for. Backwoods, let me know if this works for you and I will update the guide.


[SOLVED] Cannot flash dev kit either with web or SDK
#11

Thanks. fel seems to work now.

UPDATE: Still getting an error on

sudo ./chip-create-nand-images.sh ../CHIP-buildroot/output/build/uboot-nextthing_2016.01_next ../CHIP-buildroot/output/images/rootfs.tar my-new-image

Seems it’s looking for sunxi-fel not fel.

I tried:

sudo ln -s ~/sunxi-tools/fel ~/sunxi-tools/sunxi-fel

That didn’t fix the error, either.


#12

Add this to your documentation. Should be obvious but sometimes the obvious needs to be stated:
sudo apt-get install git unzip bc

I setup a bare bones Ubuntu server with the lubuntu-core package for a GUI so I didn’t automatically get git or the other two.

FYI I encountered the same error as before under 64bit and fixed it with the same method as above. “error: format not a string literal, format string not checked [-Werror=format-nonliteral]”

And got the same ACC error as before. I found the solution.


#13

Eureka. I’m able to flash now.

@Backwoods success. I had to do this as root. I don’t recommend it to be done as root but it’s the only way I knew how to fix it. Hopefully someone with more sudo experience than I have can come along and give the correct commands.

sudo su -
cd ~username/CHIP-tools/ # The username that you ran the above commands as
export PATH=${PATH}:../CHIP-buildroot/output/build/host-sunxi-tools-v1.4.2/:../CHIP-buildroot/output/host/usr/sbin/
./chip-create-nand-images.sh ../CHIP-buildroot/output/build/uboot-nextthing_2016.01_next ../CHIP-buildroot/output/images/rootfs.tar my-new-image

By the way @chipper there is an error in your commands above:

Should be my-new-image.


#14

I just discovered something. It turns out that the NextThingCo git for sunxi-tools does not work with the chip-create-nand-image.sh. The git that works with chip-create-nand-images.sh is https://github.com/linux-sunxi/sunxi-tools. Under the NextThingCo git the tool is named fel, however under the linux-sunxi git it is named sunxi-fel.

I did not realize this because I had previously installed the CHIP-SDK in my home directory, so when I was running chip-create-nand-images.sh it was actually using the CHIP-SDK version of the sunxi-tools, which happen to be the linux-sunxi git instead of NextThingCo’s own git.
Also chip-create-nand-images.sh only works for me when sunxi-tools is located in a folder named CHIP-SDK:
~/CHIP-SDK/sunxi-tools
After doing a git clone into here, call make and make misc:

cd ~
mkdir CHIP-SDK
cd CHIP-SDK

git clone https://github.com/linux-sunxi/sunxi-tools

cd sunxi-tools
make
make misc

I want to reiterate that the reason I wrote this guide was because the CHIP-SDK virtual machine was non-functional.


Guide on Making Startup Program with Buildroot
#15

You don’t say :smirk:


#16

@chipper
I did the sunxi-tools checkout then make then make misc, as you describe above.

Then, I returned to CHIP-tools directory and tried again:

sudo ./chip-create-nand-images.sh ../CHIP-buildroot/output/build/uboot-nextthing_2016.01_next ../CHIP-buildroot/output/images/rootfs.tar my-new-image

I still receive the same error:

Error: Unable to locate sunxi-fel utility.
Install sunxi-fel with:
CHIP-SDK setup script      [github.com/NextThingCo/CHIP-SDK]

Unfortunately, I cannot login as root as @SlowBro suggests, because I don’t know the root password for the machine I’m using :blush: because I never needed it (did everything with sudo so far).

Any other suggestions?


#17

@SlowBro Why would NTC put out a virtual machine that does not work, after selling thouands of CHIP Pro boards? The things this company does make little sense to me sometimes. It makes one wonder how long they will continue making money selling hardware that has no functional operating system.


#18

sudo su -


#19

@SlowBro HA! That worked! What a security hole!


#20

It could be that you still need to add the miscellaneous sunxi scripts to your path. Type
echo $PATH. This should output a string that includes something like /home/username/sunxi-tools. If it doesn’t, you can add it to the path by editing the text file ~/.profile and adding export PATH=${PATH}:~/sunxi-tools to the end of the file. Alternatively you can make symbolic links for each of the sunxi tools in /usr/bin.