├── .gitignore ├── README.md ├── Vagrantfile └── setup_ubuntu1404.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | CHIP-tools 3 | CHIP-Flasher 4 | CHIP-buildroot 5 | sunxi-tools 6 | chip-mtd-utils 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CHIP-SDK 2 | Everything needed to develop software for C.H.I.P. 3 | 4 | While it is possible to install the SDK natively, currently the only supported way is to run it from a virtual machine. 5 | 6 | *NOTE: the CHIP-SDK is updated regulary if you have an existing installation please have a look at the updating CHIP-SDK section below* 7 | 8 | ## System Requirements 9 | You'll need VirtualBox and Vagrant. 10 | For the virtual machine at least of free 1 GB RAM are necessary. 11 | Up to 40 GB of disk space may be used. 12 | 13 | ## Installation 14 | 15 | ### VirtualBox 16 | 1. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) 17 | 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. 18 | 3. Operating system specific stuff: 19 | - If you are on Windows, you need to add the VirtualBox installation directory to your PATH. 20 | - In case of a Ubuntu host: add your user to the vboxusers group! 21 | 22 | ### Vagrant 23 | You may need to install Vagrant. There are a couple options: 24 | 25 | * Download from [the Vagrant website](https://www.vagrantup.com/downloads.html) 26 | * On OS X, you can use the [homebrew](http://brew.sh) package manager: 27 | 1. you'll need [Cask](http://caskroom.io), so if you don't have it: `brew install caskroom/cask/brew-cask` 28 | 2. then `brew cask install vagrant` 29 | 30 | ### Git 31 | Installation of Git depends on your operating system: 32 | * On Windows, look at https://git-scm.com/download/win 33 | * On a Debian based Linux you can do: `sudo apt-get install git` 34 | * On Mac OS, the most convenient way is [homebrew](http://brew.sh): `brew install git` 35 | 36 | ### Clone the CHIP-SDK Git repository 37 | Assuming you have `git` in your PATH, open up a terminal and type: 38 | 39 | git clone https://github.com/NextThingCo/CHIP-SDK 40 | 41 | ### Start up the virtual machine 42 | 43 | In a shell on the host, change to the the CHIP-SDK directory and start up the virtual machine: 44 | 45 | cd CHIP-SDK 46 | vagrant up 47 | 48 | A couple notes for the bleary eyed. If you get an error like: 49 | 50 | error: The guest machine entered an invalid state while waiting for it to boot. 51 | 52 | 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. 53 | 54 | If you get the error: 55 | 56 | error: Couldn't open file /Volumes/Satellite/gitbins/CHIP-SDK/base 57 | 58 | that means you didn't `cd CHIP-SDK`. 59 | 60 | ### Login 61 | 62 | In the same shell on the host type the following: 63 | 64 | vagrant ssh 65 | 66 | If everything went well you should see the following prompt: 67 | 68 | vagrant@vagrant-ubuntu-trusty-32:~$ 69 | 70 | Now you're ready to Flash a C.H.I.P. from your SDK! 71 | 72 | ## Prepare your C.H.I.P. for Flashing 73 | 74 | 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**. 75 | 76 | Here's a diagram that labels the headers and pins assuming the components are facing you and the USB port is oriented up: 77 | 78 | ![Image of CHIP](https://nextthingco.zendesk.com/hc/en-us/article_attachments/203279037/CHIP_ALPHA_V02_Pinouts2.png "Image of jumpered CHIP") 79 | 80 | And here's a photo with the jumper plugged in... 81 | 82 | ![Image of CHIP](https://nextthingco.zendesk.com/hc/en-us/article_attachments/203164668/DSCF2062.JPG "Image of jumpered CHIP") 83 | 84 | 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. 85 | 86 | Now connect CHIP to your computer with a micro-USB→USB-B cable. The power LED will illuminate. 87 | 88 | It's time to begin! Open a terminal on your computer, and let's start up a virtual machine. 89 | 90 | cd CHIP-SDK 91 | vagrant up 92 | vagrant ssh 93 | 94 | If everything went well you should see the following prompt: 95 | 96 | vagrant@vagrant-ubuntu-trusty-32:~$ 97 | 98 | Now we're into C.H.I.P. and ready to flash an image. 99 | 100 | ## Help section 101 | 102 | 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: 103 | 104 | vagrant@vagrant-ubuntu-trusty-32:~$ ./chip-update-firmware.sh -h 105 | 106 | == Help == 107 | 108 | -s -- Server [Debian + Headless] 109 | -g -- GUI [Debian + XFCE] 110 | -p -- PocketCHIP [CHIP on the go!] 111 | -b -- Buildroot [Tiny, but powerful] 112 | -f -- Force clean [re-download if applicable] 113 | -n -- No limit [enable greater power draw] 114 | -r -- Reset [reset device after flash] 115 | -B -- Branch [eg. -B testing] 116 | -N -- Build# [eg. -N 150] 117 | -F -- Format [eg. -F Toshiba_4G_MLC] 118 | -L -- Local [eg. -L ../img/buildroot/] 119 | 120 | ## Flash a new C.H.I.P. with the NTC headless Debian image... 121 | 122 | 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! 123 | 124 | With our virtual machine running, we'll start at our *trusty* prompt: 125 | 126 | vagrant@vagrant-ubuntu-trusty-32:~$ 127 | 128 | 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. 129 | 130 | cd ~/CHIP-tools 131 | ./chip-update-firmware.sh 132 | This may take a while - please be patient. 133 | 134 | If everything went OK, you can now power up your CHIP again and connect by typing: 135 | 136 | screen /dev/ttyACM0 115200 137 | 138 | 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... 139 | 140 | hwtest 141 | 142 | If everything passed, your C.H.I.P. is ready to go! Have fun! 143 | 144 | ## Flash a C.H.I.P. with Debian + GUI 145 | 146 | 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. 147 | 148 | ./chip-update-firmware.sh -g 149 | 150 | 151 | ## Flash a C.H.I.P. with Buildroot 152 | 153 | ./chip-update-firmware.sh -b 154 | 155 | You can login to CHIP as **chip** or if you feel more powerful as **root**. In both cases the password is **chip**. 156 | 157 | ## To Flash C.H.I.P. with your own custom buildroot image... 158 | 159 | #### Start the build process 160 | 161 | Logged in to the virtual machine again starting from our *trusty* prompt: 162 | 163 | vagrant@vagrant-ubuntu-trusty-32:~$ 164 | 165 | Lets' get in there and make something. 166 | 167 | cd ~/CHIP-buildroot 168 | make chip_defconfig 169 | make nconfig 170 | 171 | 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). 172 | 173 | When you're finished with your selections, exit by hitting the F9 key, which will automatically save your custom buildroot to... 174 | 175 | /home/vagrant/CHIP-buildroot/.config 176 | 177 | **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.* 178 | 179 | Now let's build your buildroot... 180 | 181 | make 182 | 183 | This will take a while. Depending on your computer, maybe an hour. Maybe grab some coffee... 184 | 185 | 186 | #### Flash your own buildroot image 187 | 188 | Logged in to the virtual machine again starting from our *trusty* prompt: 189 | 190 | vagrant@vagrant-ubuntu-trusty-32:~$ 191 | 192 | type... 193 | 194 | cd ~/CHIP-tools 195 | sudo ./chip-create-nand-images.sh ../CHIP-buildroot/output/build/uboot-nextthing_2016.01_next ../CHIP-buildroot/output/images/rootfs.tar my-new-images 196 | sudo chown -R vagrant:vagrant my-new-images 197 | ./chip-flash-nand-images.sh my-new-images 198 | 199 | Ok, there's a lot of information there, but what's happening? 200 | 201 | 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. 202 | 203 | ## Shutdown 204 | 205 | To log out of the virtual machine at anytime, type: 206 | 207 | exit 208 | 209 | The virtual machine will still be running. To shut it down, type: 210 | 211 | vagrant halt 212 | 213 | ## Troubleshooting' 214 | 215 | 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: 216 | 217 | vagrant plugin install vagrant-vbguest 218 | 219 | Also look at [this blog post](http://kvz.io/blog/2013/01/16/vagrant-tip-keep-virtualbox-guest-additions-in-sync/) 220 | 221 | In case you get the error 222 | 223 | `ERROR: You don't have permission to access Allwinner USB FEL device` 224 | 225 | You'll need to run `./chip-update-firmware.sh` as `sudo`: 226 | 227 | sudo ./chip-update-firmware.sh 228 | 229 | ## Updating the CHIP-SDK 230 | 231 | If you have an already existing installation and want to update it, follow these steps: 232 | 233 | On you host operating system, pull the latest changes from our Git repository. 234 | This can be done by changing into the CHIP-SDK directory and run git pull: 235 | 236 | cd ~/CHIP-SDK 237 | git pull 238 | 239 | Make sure the virtual machine is shut down and re-provision: 240 | 241 | vagrant halt 242 | vagrant provision 243 | vagrant up 244 | 245 | This should do the trick - ssh into the virtual machine: 246 | 247 | vagrant ssh 248 | 249 | Once you see the trusty prompt, you can start developing! 250 | 251 | vagrant@vagrant-ubuntu-trusty-32:~$ 252 | 253 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | def which(cmd) 4 | exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] 5 | ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| 6 | exts.each { |ext| 7 | exe = File.join(path, "#{cmd}#{ext}") 8 | return exe if File.executable?(exe) && !File.directory?(exe) 9 | } 10 | end 11 | return nil 12 | end 13 | 14 | # usbfilter_exists and better_usbfilter_add originally part of a pull request 15 | # https://github.com/mitchellh/vagrant/issues/5774 16 | def usbfilter_exists(vendor_id, product_id) 17 | # Determine if a usbfilter with the provided Vendor/Product ID combination 18 | # already exists on this VM. 19 | # NOTE: The "machinereadable" output for usbfilters is more 20 | # complicated to work with (due to variable names including 21 | # the numeric filter index) so we don't use it here. 22 | # 23 | machine_id_filepath = File.join(".vagrant", "machines", "default", "virtualbox", "id") 24 | 25 | if not File.exists? machine_id_filepath 26 | # VM hasn't been created yet. 27 | return false 28 | end 29 | 30 | machine_id = File.read(machine_id_filepath) 31 | 32 | vm_info = `VBoxManage showvminfo #{machine_id}` 33 | filter_match = "VendorId: #{vendor_id}\nProductId: #{product_id}\n" 34 | 35 | return vm_info.include? filter_match 36 | end 37 | 38 | def better_usbfilter_add(vb, vendor_id, product_id, filter_name) 39 | # This is a workaround for the fact VirtualBox doesn't provide 40 | # a way for preventing duplicate USB filters from being added. 41 | # 42 | # TODO: Implement this in a way that it doesn't get run multiple 43 | # times on each Vagrantfile parsing. 44 | if not usbfilter_exists(vendor_id, product_id) 45 | vb.customize ["usbfilter", "add", "0", 46 | "--target", :id, 47 | "--name", filter_name, 48 | "--vendorid", vendor_id, 49 | "--productid", product_id 50 | ] 51 | end 52 | end 53 | 54 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 55 | # configures the configuration version (we support older styles for 56 | # backwards compatibility). Please don't change it unless you know what 57 | # you're doing. 58 | Vagrant.configure(2) do |config| 59 | # The most common configuration options are documented and commented below. 60 | # For a complete reference, please see the online documentation at 61 | # https://docs.vagrantup.com. 62 | 63 | # Every Vagrant development environment requires a box. You can search for 64 | # boxes at https://atlas.hashicorp.com/search. 65 | config.vm.box = "ubuntu/trusty32" 66 | 67 | # Disable automatic box update checking. If you disable this, then 68 | # boxes will only be checked for updates when the user runs 69 | # `vagrant box outdated`. This is not recommended. 70 | # config.vm.box_check_update = false 71 | 72 | # Create a forwarded port mapping which allows access to a specific port 73 | # within the machine from a port on the host machine. In the example below, 74 | # accessing "localhost:8080" will access port 80 on the guest machine. 75 | # config.vm.network "forwarded_port", guest: 80, host: 8080 76 | 77 | # Create a private network, which allows host-only access to the machine 78 | # using a specific IP. 79 | # config.vm.network "private_network", ip: "192.168.33.10" 80 | 81 | # Create a public network, which generally matched to bridged network. 82 | # Bridged networks make the machine appear as another physical device on 83 | # your network. 84 | # config.vm.network "public_network" 85 | 86 | # Share an additional folder to the guest VM. The first argument is 87 | # the path on the host to the actual folder. The second argument is 88 | # the path on the guest to mount the folder. And the optional third 89 | # argument is a set of non-required options. 90 | config.vm.synced_folder ".", "/home/vagrant/CHIP-SDK", disabled:true 91 | 92 | # Provider-specific configuration so you can fine-tune various 93 | # backing providers for Vagrant. These expose provider-specific options. 94 | # Example for VirtualBox: 95 | # 96 | config.vm.provider "virtualbox" do |vb| 97 | # # Display the VirtualBox GUI when booting the machine 98 | # vb.gui = true 99 | # 100 | # Customize the amount of memory on the VM: 101 | # Git fails to clone the 102 | vb.memory = "1024" 103 | vb.customize ['modifyvm', :id, '--usb', 'on'] 104 | vb.customize ['modifyvm', :id, '--usbehci', 'on'] 105 | unless which('VBoxManage').nil? 106 | better_usbfilter_add(vb, "18d1", "1010", "CHIP in fastboot mode") 107 | better_usbfilter_add(vb, "1f3a", "1010", "CHIP in fastboot mode") 108 | better_usbfilter_add(vb, "0525", "a4a7", "CHIP Linux Gadget USB Serial Port") 109 | better_usbfilter_add(vb, "067b", "2303", "PL2303 Serial Port") 110 | better_usbfilter_add(vb, "1f3a", "efe8", "CHIP") 111 | 112 | end 113 | end 114 | # 115 | # View the documentation for the provider you are using for more 116 | # information on available options. 117 | 118 | # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 119 | # such as FTP and Heroku are also available. See the documentation at 120 | # https://docs.vagrantup.com/v2/push/atlas.html for more information. 121 | # config.push.define "atlas" do |push| 122 | # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" 123 | # end 124 | 125 | # Enable provisioning with a shell script. Additional provisioners such as 126 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 127 | # documentation for more information about their specific syntax and use. 128 | config.vm.provision "shell", path:"https://raw.githubusercontent.com/Project-chip-crumbs/CHIP-SDK/master/setup_ubuntu1404.sh" 129 | #end 130 | end 131 | -------------------------------------------------------------------------------- /setup_ubuntu1404.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -e "\n Setting up environment in Ubuntu 14.04" 4 | sudo apt-get -y update 5 | sudo apt-get -y install \ 6 | build-essential \ 7 | git \ 8 | mercurial \ 9 | cmake \ 10 | curl \ 11 | screen \ 12 | unzip \ 13 | device-tree-compiler \ 14 | libncurses-dev \ 15 | ppp \ 16 | cu \ 17 | linux-image-extra-virtual \ 18 | u-boot-tools \ 19 | android-tools-fastboot \ 20 | android-tools-fsutils \ 21 | python-dev \ 22 | python-pip \ 23 | libusb-1.0-0-dev \ 24 | g++-arm-linux-gnueabihf \ 25 | pkg-config \ 26 | libacl1-dev \ 27 | zlib1g-dev \ 28 | liblzo2-dev \ 29 | uuid-dev 30 | 31 | if uname -a |grep -q 64; 32 | then 33 | echo -e "\n Installing 32bit compatibility libraries" 34 | sudo apt-get -y install libc6-i386 lib32stdc++6 lib32z1 35 | fi 36 | 37 | echo -e "\n Adding current user to dialout group" 38 | sudo usermod -a -G dialout $(logname) 39 | 40 | echo -e "\n Adding current user to plugdev group" 41 | sudo usermod -a -G plugdev $(logname) 42 | 43 | 44 | echo -e "\n Adding udev rule for Allwinner device" 45 | echo -e 'SUBSYSTEM=="usb", ATTRS{idVendor}=="1f3a", ATTRS{idProduct}=="efe8", GROUP="plugdev", MODE="0660" SYMLINK+="usb-chip" 46 | SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="1010", GROUP="plugdev", MODE="0660" SYMLINK+="usb-chip-fastboot" 47 | SUBSYSTEM=="usb", ATTRS{idVendor}=="1f3a", ATTRS{idProduct}=="1010", GROUP="plugdev", MODE="0660" SYMLINK+="usb-chip-fastboot" 48 | SUBSYSTEM=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="plugdev", MODE="0660" SYMLINK+="usb-serial-adapter" 49 | ' | sudo tee /etc/udev/rules.d/99-allwinner.rules 50 | sudo udevadm control --reload-rules 51 | 52 | echo -e "\n Installing sunxi-tools" 53 | if [ -d sunxi-tools ]; then 54 | rm -rf sunxi-tools 55 | fi 56 | git clone http://github.com/linux-sunxi/sunxi-tools 57 | pushd sunxi-tools 58 | make 59 | make misc 60 | SUNXI_TOOLS=(sunxi-bootinfo 61 | sunxi-fel 62 | sunxi-fexc 63 | sunxi-nand-part 64 | sunxi-pio 65 | pheonix_info 66 | sunxi-nand-image-builder) 67 | for BIN in ${SUNXI_TOOLS[@]};do 68 | if [[ -L /usr/local/bin/${BIN} ]]; then 69 | sudo rm /usr/local/bin/${BIN} 70 | fi 71 | sudo ln -s $PWD/${BIN} /usr/local/bin/${BIN} 72 | done 73 | popd 74 | 75 | git clone http://github.com/Project-chip-crumbs/chip-mtd-utils 76 | pushd chip-mtd-utils 77 | git checkout by/1.5.2/next-mlc-debian 78 | make 79 | sudo make install 80 | popd 81 | 82 | echo -e "\n Installing CHIP-tools" 83 | if [ -d CHIP-tools ]; then 84 | pushd CHIP-tools 85 | git pull 86 | popd 87 | fi 88 | git clone https://github.com/Project-chip-crumbs/CHIP-tools.git 89 | 90 | echo -e "\n Installing CHIP-buildroot" 91 | if [ ! -d CHIP-buildroot ]; then 92 | git clone http://github.com/Project-chip-crumbs/CHIP-buildroot 93 | else 94 | pushd CHIP-buildroot 95 | git pull 96 | popd 97 | fi 98 | 99 | if [ $(echo $PWD | grep vagrant) ];then 100 | sudo chown -R vagrant:vagrant * 101 | fi 102 | --------------------------------------------------------------------------------