> Sford wiki > CHIP startup

See my blog post for more information on the C.H.I.P. single-board computer.

Some of this information was derived from an excellent post by NinjaKun.


Contents


Initial connect to CHIP using Mac USB

Out of the box, CHIP's wifi is not configured for your local network. Instead of finding a TV, keyboard, mouse, powered hub, power supply, and all the required cables, let's just use a single cable (USB to micro USB) and a Mac. I use a Macbook Air.

Everything below is done from the Mac's terminal window.


Connect USB cable between Mac and CHIP. Make sure the cable is not a "power only" cable; you want data signals. Wait 30 seconds for CHIP to boot.

Enter:

ls /dev/tty.usb*

If it returns "No such file..." then either the cable is power-only, or CHIP isn't booting, or maybe you need to install the FTDI driver. To see if CHIP is booting, connect the video to a TV and verify that bootup messages scroll by (no need for keyboard/mouse). If it boots, maybe you need the FTDI driver. See http://pbxbook.com/other/mac-tty.html Also consider the USB cable - if it was provided to connect a device to a wall plug, then the cable might be power-only. You want a cable that passes signals, as would be used when connecting a device to a laptop.

Anyway, let's say it works and that that "ls /dev/tty.usb*" returns "/dev/tty.usbmodem2411". Enter:

sudo cu -l /dev/tty.usbmodem2411 -s 115200

Note: the usbmodem number 2411 may vary based on the results of the "ls". The number 115200 is the baud rate and is fixed. (Some experiments suggest that the baud rate is ignored for this kind of device.) Sudo will often prompt you for password. Since this is being entered to your Mac shell, use your Mac password. Then hit Enter two or three times.

This should prompt with "chip login:". Enter the chip account and password:

chip login: chip
Password:               (the password is also chip)

nmtui: set up CHIP network

Set up CHIP's Wifi:

sudo nmtui

Again, Sudo will often prompt for password. Since this is being entered to your CHIP shell, use "chip".

The "nmtui" program is a little awkward to use since it uses "ncurses" to simulate a GUI-like interface without a mouse. It should come up with "Edit a connection" highlighted.

This should return you to a Unix prompt. But the "nmtui" command sometimes leaves your terminal emulator in a bad state, so enter:

reset

This does NOT reset the CHIP, it just resets the state of the terminal.

Now determine CHIP's IP address:

sudo ifconfig | grep Bcast:

Ignore the IP address after "Bcast:", that was only used so that grep would find the right one. Instead look at the IP after "inet addr:". Take note - this is CHIP's IP address.

To log out of the chip account:

exit

But while that logs out, the "cu" command is still connected to CHIP. Disconnect from the CHIP device and exit the "cu" command using tilde-dot:

~.

It will delay for a second and then return to the Mac prompt.

From now on, you should be able to log in over the network using "ssh". There are various disadvantages to using the "cu" (or "screen") commands to log in over the USB cable, so I suggest using "ssh" once your network is set up. For example, let's say your CHIP's IP address is 10.0.0.20. Do this:

ssh chip@10.0.0.20


Shutdown

Like most modern general-purpose operating systems, you shouldn't just kill power to CHIP. You should do a graceful shutdown.

Log into CHIP and enter:

sudo shutdown now

The "sudo" command will prompt you for your password. Enter the chip account's password.


A first project

See CHIP Proj1 for a walkthrough for a first project that includes:

  1. Do some basic cleanup on CHIP.
  2. Running a web server on CHIP.
  3. Writing some C code to turn CHIP's status LED on and off.
  4. Building the C program so that a non-privileged account can run them without "sudo".

Now you can turn the status LED on and off from a web browser running on any computer in your network! What fun!


First-time Flashing CHIP

Using a mac, it looks like you can't flash option 1: the full GUI-based CHIP OS. See https://bbs.nextthing.co/t/libsub-usb-bulk-send-error-1-when-flashing-chip-os/1570/10 But that's fine because I don't want CHIP to boot up to its GUI.

I prefer option 2: debian (without gui).

The following commands only needs to be done once, after you've installed VirtualBox, git, and Vagrant. See http://docs.getchip.com/#installing-c-h-i-p-sdk

git clone https://github.com/NextThingCo/CHIP-SDK
cd CHIP-SDK

Enable a shared folder between the host OS and the vagrant VM. In vagrantfile, remove the ", disabled: true" from the "config.vm.synced_folder" line.

vi Vagrantfile
/synched
:s/, disabled: true//
:wq

If the above editor commands work right, the ~/CHIP-SDK folder should be shared between both the host and the VM.

Now bring up the Vagrant VM:

vagrant up
vagrant ssh
sudo chown -R vagrant: /home/vagrant

That last command is needed because installing and initializing the Vagrant VM leaves many files owned by root, which prevents some advanced things from working right.

Now make sure you have the jumper in CHIP, and plug in the USB cable. You must do this *after* vagrant is brought up so that the VM recognizes the device.

cd CHIP-tools
git pull
git checkout chip/stable
./chip-update-firmware.sh -d

When the script completes, DON'T TOUCH ANYTHING FOR 5 MINUTES! It takes a few minutes for the flash memory to be fully written. After 5 minutes, remove jumper, disconnect the micro-USB cable, and reconnect it. Wait about a minute for CHIP to finish booting. (Normally it only requires about 20 seconds, but the first time after a flash takes longer.)

Now you can log into CHIP. Up above were instructions which did the "cu" command to "/dev/tty.usbmodem2411. That was the Mac's device name. But now you are running in the Vagrant VM, which is a Ubuntu Linux. That VM now holds the device, which means you need to enter the "cu" command from the Vagrant VM and use Ubuntu's device name:

cu -l /dev/ttyACM0 -s 115200

Log in as chip/chip and set up WIFI again (see #nmtui: set up CHIP network above). Take note of the IP address.

Now log off and exit the "cu" command.

exit
~.

You can now re-run the initial steps of CHIP Proj1 to get CHIP cleaned up and secured.


Sensors

- Especially interested in https://www.adafruit.com/products/1782


Ubuntu on Mac

See Ubuntu on Mac


Cross compiling

For the most part, you should be able to compile your programs right on CHIP. But sometimes you might want to cross-compile on the Vagrant VM. It may not be the "right" way to do it, but it seems to work. I basically snagged it out of other build steps when rebuilding the kernel.

Get into Vagrant ("vagrant ssh"). Then:

cd CHIP-buildroot
make chip_defconfig
make toolchain
ARMGCC=/home/vagrant/CHIP-buildroot/output/host/usr/bin/arm-linux-gnueabihf-gcc
ARMINC=/home/vagrant/CHIP-buildroot/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/include
$ARMGCC -I. -I$ARMINC/uapi -I$ARMINC -Wall -Os -o HelloWorld HelloWorld.c


Buildroot OS

I could flash option 1: Buildroot. It comes up very primitive.

sudo visudo

(uncomment the line "%sudo ALL=(ALL) ALL")

:wq
adduser chip sudo
addgroup: group 'chip' in use
exit

The network utility either isn't there, or is in a strange path location.


Misc notes

- Persistant version: https://www.youtube.com/watch?v=MpwrrQ36yqM
- https://bbs.nextthing.co/t/need-help-reflashing-c-h-i-p/2387/3?u=fordsfords
- phototransistor
Retrieved from "http://wiki.geeky-boy.com/w/index.php?title=CHIP_startup"