In order to compile C programs, you need to bring up the CHIP SDK. Here's a list of things the doc didn't tell me. Much of this info was derived from other posts to this forum. Thanks to all who shared!
A Mac will not be able to flash the full CHIP OS (option 3 under http://docs.getchip.com/chip.html#flash-chip-firmware). The image is too large for the normal download, and fastboot doesn't work with the Mac. Fortunately, I'm happy with the Debian OS (option 2).
When following the instructions at http://docs.getchip.com/chip.html#installing-c-h-i-p-sdk everything goes smoothly until the Vagrant VM is brought up for the first time. After using "vagrant ssl" to log into the VM, the files are owned by root instead of the vagrant user. So before doing anything else, enter:
sudo chown -R vagrant: /home/vagrant
This changes the files to be owned by the vagrant user.
The Mac's "screen" command seems doesn't like CHIP's "nmtui" output. But the Vagrant VM's "screen" command seems to handle CHIP's "nmtui" output much better, and has some advantages. So use "screen" from the VM. The device name in the VM seems to always be "/dev/ttyACM0".
I've seen cases where the Vagrant VM doesn't recognize the USB connection unless it is connected while the VM is running. If "screen" complains that /dev/ttyACM0 can't be accessed, try unplugging CHIP and re-plugging it. (Then you'll have to wait 20 seconds or so for CHIP to boot enough to be recognized.)
You need to set up the WIFI. The easy way is to log onto chip and run the "nmtui" command:
screen /dev/ttyACM0 115200
Hit an extra return to get the login prompt. Log in with chip/chip.
The "sudo" command may prompt you for the chip account password, chip.
Ignore the "lo" section. The second line of the "wlan0" section shows the IP address after "inet addr:". Take note of that IP address, but also be aware that this address can change. If you need the IP address to stay constant, you'll have to configure it.
- To compile a C program, you can't use the normal C compiler. You need a cross-compiler. But the Vagrant VM doesn't start out with the cross-compiler available. So after changing file ownership (above), enter:
After building nconfig, it automatically runs it. Just enter F9 to exit. Then enter:
This takes a few minutes to run, after which the compiler and linker are ready to go.
- To compile the C program "HelloWorld.c", you'll want to create a script:
-I. -Os hello.c -o hello
- Now transfer it to CHIP. If CHIP's IP address is 10.0.0.20, enter:
scp hello firstname.lastname@example.org: