Everything needed to develop software for C.H.I.P.
While it is possible to install the SDK natively, currently the only supported way is to run it from a virtual machine.
You'll need VirtualBox and Vagrant. For the virtual machine at least of free 1 GB RAM are necessary. Up to 40 GB of disk space may be used.
- Install VirtualBox
- Install the Oracle VM VirtualBox Extension Pack for the host - this is necessary to flash C.H.I.P from inside the virtual machine.
- Operating system specific stuff:
- If you are on Windows, you need to add the VirtualBox installation directory to your PATH.
- In case of a Ubuntu host: add your user to the vboxusers group!
You may need to install Vagrant. There are a couple options:
- Download from the Vagrant website
- On OS X, you can use the homebrew package manager:
- you'll need Cask, so if you don't have it:
brew install caskroom/cask/brew-cask
- then
brew cask install vagrant
- you'll need Cask, so if you don't have it:
Installation of Git depends on your operating system:
- On Windows, look at https://git-scm.com/download/win
- On a Debian based Linux you can do:
sudo apt-get install git
- On Mac OS, the most convenient way is homebrew:
brew install git
Assuming you have git
in your PATH, open up a terminal and type:
git clone https://github.com/NextThingCo/CHIP-SDK
In a shell on the host, change to the the CHIP-SDK directory and start up the virtual machine:
cd CHIP-SDK
vagrant up
A couple notes for the bleary eyed. If you get an error like:
error: The guest machine entered an invalid state while waiting for it to boot.
This probably means your version of VirtualBox needs updating and/or needs the Extension Pack. Update as necessary and try vagrant up
again.
If you get the error:
error: Couldn't open file /Volumes/Satellite/gitbins/CHIP-SDK/base
that means you didn't cd CHIP-SDK
.
In the same shell on the host type the following:
vagrant ssh
If everything went well you should see the following prompt:
vagrant@vagrant-ubuntu-trusty-32:~$
Now run the setup script that installs the necessary software inside of the virtual machine:
./CHIP-SDK/setup_ubuntu1404.sh
Congratulations! Your C.H.I.P. SDK is almost ready! To finish up and apply the updated permissions, log out of the virtual machine...
exit
Now you're ready to Flash a C.H.I.P. from your SDK!
First, prepare CHIP with a jumper wire between the FEL pin and GND. In other words, connect Pin 7 and Pin 39 on header U14.
Here's a diagram that labels the headers and pins assuming the components are facing you and the USB port is oriented up:
And here's a photo with the jumper plugged in...
It's worth noting that this jumper needs to be present only when you connect CHIP to power. If for some reason the wire becomes disconnected after you have powered CHIP, there is no problem or need to panic.
Now connect CHIP to your computer with a micro-USB→USB-B cable. The power LED will illuminate.
It's time to begin! Open a terminal on your computer, and let's start up a virtual machine.
cd CHIP-SDK
vagrant up
vagrant ssh
If everything went well you should see the following prompt:
vagrant@vagrant-ubuntu-trusty-32:~$
Now we're into C.H.I.P. and ready to flash an image.
If you want to flash C.H.I.P. with a custom image, scroll down the page...If you're cool with our current buildroot image, keep going!
With our virtual machine running, we'll start at our trusty prompt:
vagrant@vagrant-ubuntu-trusty-32:~$
Now let's download the latest firmware (i.e. a Linux kernel, U-Boot and a root filesystem all built with buildroot) and flash it to CHIP.
cd ~/CHIP-tools
./chip-update-firmware.sh
The flashing script will boot CHIP automatically for the first time, login and power off CHIP to make sure everything went well. This may take a while - please be patient.
If everything went OK, you can now power up your CHIP again and connect by typing:
cu -l /dev/ttyACM0 -s 115200
You can login to CHIP as chip or if you feel more powerful as root. In both cases the password is chip. Now let's give it a quick hardware test...
hwtest
If everything passed, your C.H.I.P. is ready to go! Have fun!
Flashing C.H.I.P with Debian is very similar to flashing with buildroot.
Actually, you only have to add the parameter -d
to the chip-update-firmware.sh
command.
Just log in to the virtual machine again and start from our trusty prompt:
vagrant@vagrant-ubuntu-trusty-32:~$
Follow these steps to flash your C.H.I.P with debian:
cd ~/CHIP-tools
./chip-update-firmware.sh -d
The flashing script will boot CHIP automatically for the first time, login and power off CHIP to make sure everything went well. This may take a while - please be patient.
If everything went OK, you can now power up your CHIP again and connect by typing:
cu -l /dev/ttyACM0 -s 115200
You can login to CHIP as chip or if you feel more powerful as root. In both cases the password is chip.
Logged in to the virtual machine again starting from our trusty prompt:
vagrant@vagrant-ubuntu-trusty-32:~$
Lets' get in there and make something.
cd ~/CHIP-buildroot
make chip_defconfig
make nconfig
From here, you can navigate the menu and select what you want to flash onto your C.H.I.P. and what you don't. Detailing custom buildroot images is outside the scope of this tutorial. If you're curious, read Free Electrons wonderful buildroot documentation.
When you're finished with your selections, exit by hitting the F9 key, which will automatically save your custom buildroot to...
/home/vagrant/CHIP-buildroot/.config
NOTE: You can save an alternate build by hitting the F6 key, but only the image save to the above path will flash to C.H.I.P.
Now let's build your buildroot...
make
This will take a while. Depending on your computer, maybe an hour. Maybe grab some coffee...
Logged in to the virtual machine again starting from our trusty prompt:
vagrant@vagrant-ubuntu-trusty-32:~$
type...
cd ~/CHIP-tools
BUILDROOT_OUTPUT_DIR=../CHIP-buildroot/output ./chip-fel-flash.sh
The flashing script will boot CHIP automatically for the first time, login and power off CHIP to make sure everything went well. This may take a while - please be patient.
If everything went OK, you can now power up your CHIP again and connect by typing:
cu -l /dev/ttyACM0 -s 115200
Unless you changed the users or passwords, you can login to CHIP as chip or root using the password chip.
To log out of the virtual machine at anytime, type:
exit
The virtual machine will still be running. To shut it down, type:
vagrant halt
In case you run into trouble because the kernel in the VM was updated and the shared vagrant folder can no longer be mounted, update the guest additions by typing the following in the CHIP-SDK directory on the host:
vagrant plugin install vagrant-vbguest
Also look at this blog post
In case you get the error
`ERROR: You don't have permission to access Allwinner USB FEL device`
You'll need to run ./chip-update-firmware.sh
as sudo
:
sudo ./chip-update-firmware.sh