mirror of
https://github.com/NextThingCo/CHIP-SDK
synced 2025-07-17 12:13:20 +00:00
initial commit
This commit is contained in:
251
README.md
Normal file
251
README.md
Normal file
@ -0,0 +1,251 @@
|
||||
# CHIP-SDK
|
||||
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.
|
||||
|
||||
*NOTE: the CHIP-SDK is updated regulary if you have an existing installation please have a look at the updating CHIP-SDK section below*
|
||||
|
||||
## System Requirements
|
||||
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.
|
||||
|
||||
## Installation
|
||||
|
||||
### VirtualBox
|
||||
1. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
|
||||
2. Install the [Oracle VM VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads) for the host - this is necessary to flash C.H.I.P from inside the virtual machine.
|
||||
3. 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!
|
||||
|
||||
### Vagrant
|
||||
You may need to install Vagrant. There are a couple options:
|
||||
|
||||
* Download from [the Vagrant website](https://www.vagrantup.com/downloads.html)
|
||||
* On OS X, you can use the [homebrew](http://brew.sh) package manager:
|
||||
1. you'll need [Cask](http://caskroom.io), so if you don't have it: `brew install caskroom/cask/brew-cask`
|
||||
2. then `brew cask install vagrant`
|
||||
|
||||
### Git
|
||||
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](http://brew.sh): `brew install git`
|
||||
|
||||
### Clone the CHIP-SDK Git repository
|
||||
Assuming you have `git` in your PATH, open up a terminal and type:
|
||||
|
||||
git clone https://github.com/NextThingCo/CHIP-SDK
|
||||
|
||||
### Start up the virtual machine
|
||||
|
||||
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](https://www.virtualbox.org/wiki/Downloads). 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`.
|
||||
|
||||
### Login
|
||||
|
||||
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 you're ready to Flash a C.H.I.P. from your SDK!
|
||||
|
||||
## Prepare your C.H.I.P. for Flashing
|
||||
|
||||
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.
|
||||
|
||||
## Help section
|
||||
|
||||
If you're familiar with the old version of the scripts, these options should sound pretty familiar to you, but some of the options have been moved around. So we added a help command to the flashing script:
|
||||
|
||||
vagrant@vagrant-ubuntu-trusty-32:~$ ./chip-update-firmware.sh -h
|
||||
|
||||
== Help ==
|
||||
|
||||
-s -- Server [Debian + Headless]
|
||||
-g -- GUI [Debian + XFCE]
|
||||
-p -- PocketCHIP [CHIP on the go!]
|
||||
-b -- Buildroot [Tiny, but powerful]
|
||||
-f -- Force clean [re-download if applicable]
|
||||
-n -- No limit [enable greater power draw]
|
||||
-r -- Reset [reset device after flash]
|
||||
-B -- Branch [eg. -B testing]
|
||||
-N -- Build# [eg. -N 150]
|
||||
-F -- Format [eg. -F Toshiba_4G_MLC]
|
||||
-L -- Local [eg. -L ../img/buildroot/]
|
||||
|
||||
## Flash a new C.H.I.P. with the NTC headless Debian 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 headless 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
|
||||
This may take a while - please be patient.
|
||||
|
||||
If everything went OK, you can now power up your CHIP again and connect by typing:
|
||||
|
||||
screen /dev/ttyACM0 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!
|
||||
|
||||
## Flash a C.H.I.P. with Debian + GUI
|
||||
|
||||
Along with the instructions above, to flash our Debian image with the official C.H.I.P. GUI, you'll have to insert another option into the command. The `-g` flag will pull in Debian with a GUI-based version of the image.
|
||||
|
||||
./chip-update-firmware.sh -g
|
||||
|
||||
|
||||
## Flash a C.H.I.P. with Buildroot
|
||||
|
||||
./chip-update-firmware.sh -b
|
||||
|
||||
You can login to CHIP as **chip** or if you feel more powerful as **root**. In both cases the password is **chip**.
|
||||
|
||||
## To Flash C.H.I.P. with your own custom buildroot image...
|
||||
|
||||
#### Start the build process
|
||||
|
||||
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](http://buildroot.uclibc.org/docs.html).
|
||||
|
||||
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...
|
||||
|
||||
|
||||
#### Flash your own buildroot image
|
||||
|
||||
Logged in to the virtual machine again starting from our *trusty* prompt:
|
||||
|
||||
vagrant@vagrant-ubuntu-trusty-32:~$
|
||||
|
||||
type...
|
||||
|
||||
cd ~/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-images
|
||||
sudo chown -R vagrant:vagrant my-new-images
|
||||
./chip-flash-nand-images.sh my-new-images
|
||||
|
||||
Ok, there's a lot of information there, but what's happening?
|
||||
|
||||
chip-create-nand-images.sh needs to know where to find the uboot binaries as well as the rootfs. From there, it formats these binaries and creates images appropriate for the different types of NAND memory on CHIP and CHIP Pro. That script needs to be run as root to maintain certain permissions in the rootfs. Afterwards though, we can chown the directory that your new images are in, and flash them with chip-flash-nand-images.sh.
|
||||
|
||||
## Shutdown
|
||||
|
||||
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
|
||||
|
||||
## Troubleshooting'
|
||||
|
||||
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](http://kvz.io/blog/2013/01/16/vagrant-tip-keep-virtualbox-guest-additions-in-sync/)
|
||||
|
||||
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
|
||||
|
||||
## Updating the CHIP-SDK
|
||||
|
||||
If you have an already existing installation and want to update it, follow these steps:
|
||||
|
||||
On you host operating system, pull the latest changes from our Git repository.
|
||||
This can be done by changing into the CHIP-SDK directory and run git pull:
|
||||
|
||||
cd ~/CHIP-SDK
|
||||
git pull
|
||||
|
||||
Make sure the virtual machine is shut down and re-provision:
|
||||
|
||||
vagrant halt
|
||||
vagrant provision
|
||||
vagrant up
|
||||
|
||||
This should do the trick - ssh into the virtual machine:
|
||||
|
||||
vagrant ssh
|
||||
|
||||
Once you see the trusty prompt, you can start developing!
|
||||
|
||||
vagrant@vagrant-ubuntu-trusty-32:~$
|
130
Vagrantfile
vendored
Normal file
130
Vagrantfile
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
def which(cmd)
|
||||
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
||||
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
||||
exts.each { |ext|
|
||||
exe = File.join(path, "#{cmd}#{ext}")
|
||||
return exe if File.executable?(exe) && !File.directory?(exe)
|
||||
}
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
# usbfilter_exists and better_usbfilter_add originally part of a pull request
|
||||
# https://github.com/mitchellh/vagrant/issues/5774
|
||||
def usbfilter_exists(vendor_id, product_id)
|
||||
# Determine if a usbfilter with the provided Vendor/Product ID combination
|
||||
# already exists on this VM.
|
||||
# NOTE: The "machinereadable" output for usbfilters is more
|
||||
# complicated to work with (due to variable names including
|
||||
# the numeric filter index) so we don't use it here.
|
||||
#
|
||||
machine_id_filepath = File.join(".vagrant", "machines", "default", "virtualbox", "id")
|
||||
|
||||
if not File.exists? machine_id_filepath
|
||||
# VM hasn't been created yet.
|
||||
return false
|
||||
end
|
||||
|
||||
machine_id = File.read(machine_id_filepath)
|
||||
|
||||
vm_info = `VBoxManage showvminfo #{machine_id}`
|
||||
filter_match = "VendorId: #{vendor_id}\nProductId: #{product_id}\n"
|
||||
|
||||
return vm_info.include? filter_match
|
||||
end
|
||||
|
||||
def better_usbfilter_add(vb, vendor_id, product_id, filter_name)
|
||||
# This is a workaround for the fact VirtualBox doesn't provide
|
||||
# a way for preventing duplicate USB filters from being added.
|
||||
#
|
||||
# TODO: Implement this in a way that it doesn't get run multiple
|
||||
# times on each Vagrantfile parsing.
|
||||
if not usbfilter_exists(vendor_id, product_id)
|
||||
vb.customize ["usbfilter", "add", "0",
|
||||
"--target", :id,
|
||||
"--name", filter_name,
|
||||
"--vendorid", vendor_id,
|
||||
"--productid", product_id
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure(2) do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://atlas.hashicorp.com/search.
|
||||
config.vm.box = "ubuntu/trusty32"
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Create a public network, which generally matched to bridged network.
|
||||
# Bridged networks make the machine appear as another physical device on
|
||||
# your network.
|
||||
# config.vm.network "public_network"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
config.vm.synced_folder ".", "/home/vagrant/CHIP-SDK", disabled:true
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# Customize the amount of memory on the VM:
|
||||
# Git fails to clone the
|
||||
vb.memory = "1024"
|
||||
vb.customize ['modifyvm', :id, '--usb', 'on']
|
||||
vb.customize ['modifyvm', :id, '--usbehci', 'on']
|
||||
unless which('VBoxManage').nil?
|
||||
better_usbfilter_add(vb, "18d1", "1010", "CHIP in fastboot mode")
|
||||
better_usbfilter_add(vb, "1f3a", "1010", "CHIP in fastboot mode")
|
||||
better_usbfilter_add(vb, "0525", "a4a7", "CHIP Linux Gadget USB Serial Port")
|
||||
better_usbfilter_add(vb, "067b", "2303", "PL2303 Serial Port")
|
||||
better_usbfilter_add(vb, "1f3a", "efe8", "CHIP")
|
||||
|
||||
end
|
||||
end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||
# such as FTP and Heroku are also available. See the documentation at
|
||||
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||
# config.push.define "atlas" do |push|
|
||||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||
# end
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
config.vm.provision "shell", path:"https://raw.githubusercontent.com/NextThingCo/CHIP-SDK/master/setup_ubuntu1404.sh"
|
||||
#end
|
||||
end
|
101
setup_ubuntu1404.sh
Executable file
101
setup_ubuntu1404.sh
Executable file
@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo -e "\n Setting up environment in Ubuntu 14.04"
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install \
|
||||
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 \
|
||||
libusb-1.0-0-dev \
|
||||
g++-arm-linux-gnueabihf \
|
||||
pkg-config \
|
||||
libacl1-dev \
|
||||
zlib1g-dev \
|
||||
liblzo2-dev \
|
||||
uuid-dev
|
||||
|
||||
if uname -a |grep -q 64;
|
||||
then
|
||||
echo -e "\n Installing 32bit compatibility libraries"
|
||||
sudo apt-get -y install libc6-i386 lib32stdc++6 lib32z1
|
||||
fi
|
||||
|
||||
echo -e "\n Adding current user to dialout group"
|
||||
sudo usermod -a -G dialout $(logname)
|
||||
|
||||
echo -e "\n Adding current user to plugdev group"
|
||||
sudo usermod -a -G plugdev $(logname)
|
||||
|
||||
|
||||
echo -e "\n Adding udev rule for Allwinner device"
|
||||
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
|
||||
|
||||
echo -e "\n Installing sunxi-tools"
|
||||
if [ -d sunxi-tools ]; then
|
||||
rm -rf sunxi-tools
|
||||
fi
|
||||
git clone http://github.com/linux-sunxi/sunxi-tools
|
||||
pushd sunxi-tools
|
||||
make
|
||||
make misc
|
||||
SUNXI_TOOLS=(sunxi-bootinfo
|
||||
sunxi-fel
|
||||
sunxi-fexc
|
||||
sunxi-nand-part
|
||||
sunxi-pio
|
||||
pheonix_info
|
||||
sunxi-nand-image-builder)
|
||||
for BIN in ${SUNXI_TOOLS[@]};do
|
||||
if [[ -L /usr/local/bin/${BIN} ]]; then
|
||||
sudo rm /usr/local/bin/${BIN}
|
||||
fi
|
||||
sudo ln -s $PWD/${BIN} /usr/local/bin/${BIN}
|
||||
done
|
||||
popd
|
||||
|
||||
git clone http://github.com/nextthingco/chip-mtd-utils
|
||||
pushd chip-mtd-utils
|
||||
git checkout by/1.5.2/next-mlc-debian
|
||||
make
|
||||
sudo make install
|
||||
popd
|
||||
|
||||
echo -e "\n Installing CHIP-tools"
|
||||
if [ -d CHIP-tools ]; then
|
||||
pushd CHIP-tools
|
||||
git pull
|
||||
popd
|
||||
fi
|
||||
git clone https://github.com/NextThingCo/CHIP-tools.git
|
||||
|
||||
echo -e "\n Installing CHIP-buildroot"
|
||||
if [ ! -d CHIP-buildroot ]; then
|
||||
git clone http://github.com/NextThingCo/CHIP-buildroot
|
||||
else
|
||||
pushd CHIP-buildroot
|
||||
git pull
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ $(echo $PWD | grep vagrant) ];then
|
||||
sudo chown -R vagrant:vagrant *
|
||||
fi
|
Reference in New Issue
Block a user