Testing out the C.H.I.P.

Added by J. Simmons over 7 years ago

So, one of our efforts this year will be to migrate from Arduino-like boards for our controller to something more full featured. We have discussed the Raspberry Pi Zero and Pocket Computing's C.H.I.P.. We are heavily leaning toward the C.H.I.P. (it is open source and Pocket Computing has what looks like an awesome developer version).

We already have a couple of Pi Zeros and C.H.I.P.s on hand, so while we work out the details of our 2017 plan, I am going to test a couple of things out on the C.H.I.P. Specifically, I want to do the following:

As usual, I will track my progress here. Feel free to follow along or comment.


Replies (21)

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

Today's work will focus on the first set of tasks. Specifically, I am going to

  1. Get CHIP booted
  2. install additional tools
    1. svn
    2. Node.js
    3. Johnny-Five
  3. Check out the test stand scripts
  4. Run a Hello world Node.js project
  5. Try and blink an LED

There are several CHIP docs that I have been reading in prep for today's work.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

I plan to use the HDMI DIP module to connect to my display. According to the DIPS documentation, I need to update the CHIP kernel before using the HDMI DIP. So, my first step today will be to update the CHIP.

  1. Go to http://flash.getchip.com/ in Chrome
  2. Install CHIP Flasher App for Chrome
  3. Jumper FEL and GND pins on the CHIP per instructions on CHIP flash webpage
  4. Plug in the CHIP to a USB port, the flasher app will detect the CHIP and read its version info
  5. Select an OS to flash to the CHIP (I selected GUI 4.4 so I can run the CHIP like a desktop computer)
  6. Click Start Flashing on the Step 4 Flashing dialog and wait for the flasher app to flash the new OS onto the CHIP
  7. Unplug the CHIP from the USB port and then click the Exit Flasher button

Next up is to connect the HDMI DIP and set things up to power up the CHIP.

  1. Remove jumper from FEL/GND pins
  2. Attach the DIP per the DIP instructions
  3. Attach USB hub to CHIP and USB keyboard and mouse to the hub
  4. Attach monitor with HDMI cable to the CHIP
  5. Power up monitor and CHIP

In theory, this is where the CHIP should boot up to its desktop. However, instead I am getting "Out of Range" errors on my monitor, followed by the CHIP powering off. Going to try another display.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

No dice on the second display. Looking at a troubleshooting wiki page now. According to this page, the first diagnostic step is to flash with the "no limit" version of the OS (note, this disable the current limiter, and should not be used with direct connections to a laptop). Next step then is to re-flash with the no-limit OS.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

That did it. Past today, I think I will switch over to the headless configuration. But for now I will continue testing. Next up is following the user guide.

  1. Configure network
  2. Update apt-get: sudo apt-get update (default password is "chip")
  3. Install svn: sudo apt-get install subversion
  4. Check out test-rig scripts from svn (under ~/ Documents/holoseat/): svn co https://opendesignengine.net/svn/holoseat/trunk/test_rig/test-scripts
  5. Install Node.js per https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
  6. Install npm: sudo apt-get install npm
  7. Run Node.js hello world examples (per above link)
    Note - use ip addr show wlan0 to find ip address of CHIP (from https://bbs.nextthing.co/t/ssh-to-pocket-chip/4694/2)

This covers everything but hardware integration. In general, so far, so good.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

So, moving on to Johnny-Five, CHIP is supported, but it needs a newer install of Node than we just installed (specifically so node will run as node and not nodejs).

  1. Remove old install of node: sudo apt-get remove nodejs
  2. Follow the Additional Instructions for Johnny-Five on CHIP
    So, in my rush to test things, I skipped over an error with apt-get update, specifically some hash sum mismatches. The fix was to edit /etc/apt/sources.list and comment out the backports line, then run sudo apt-get clean and sudo apt-get update. (I also installed node 7.) I also ran into out of memory errors during chip-io installation. Reinstalled chip-io under a session started with sudo bash and with no other software running and it finally worked.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

Here is the first attempt at a Johnny-Five test script (to blick the onboard status LED).

var five = require('johnny-five');
var chipio = require('chip-io');

var board = new five.Board({
  io: new chipio()
});

board.on('ready', function() {
  // do Johnny-Five stuff
  var statusLed = new chipio.StatusLed();
  statusLed.blink(500);
});

Unfortunately, the display shutdown and I did not see an LED blinking every 1/2 second.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

After rebooting I discovered the chip-io package file (among others: ffi, ref, and ref-struct) was corrupt. So, I uninstalled and reinstalled chip-io. When I tried it again, the display still went dark. I rebooted and managed to get an error on the commend line: cannot open shared object file." So, two things come to mind here:

  1. The HDMI DIP must only work for a limited period of time with the current build. I need to repeat these tests in headless server mode
  2. Guessing the shared object it cannot find is the status LED. Going to try changing the code to use a pin as an LED.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

I tried just initializing Johnny-Five and writing out to the console, and still no luck. So, generally productive day, but clearly I need to go back and redo some work to get to the point where Johnny-Five will work. Next step is reviewing headless setup for CHIP (followed by careful review of my work with Johnny-Five on the original test rig).

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

So, a quick search on Google turned up this tutorial for setting up CHIP as a headless server. It covers using Putty to connect to the CHIP over the USB serial port and how to set up the wifi over the CLI. Just what I was looking for. Since I am on a Mac, I also looked up how to connect to a device over a serial connection.

With that info in hand, I started today's experiments in headless mode.

  1. Install minicom
  2. Flash the CHIP with the Headless OS
  3. Remove the jumper and reconnect the CHIP to the computer
  4. Locate the USB serial port: ls /dev/cu.usb*
  5. Connect to the CHIP at 9600 baud: screen /dev/xx.usbXXXXX-XXXXXXXX 9600 –L
  6. Login to the CHIP (default username:password: chip:chip)
  7. Setup the wifi: sudo nmtui
  8. Shutdown the CHIP: sudo shutdown -h now
  9. Power up the CHIP off of AC power
  10. Connect to the CHIP over ssh: ssh chip@chip.local

These steps got me to the point where I could login and use the CHIP from the cli (much better so far - more responsive and more reliable).

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

As the last step for the night, I am implementing the fix for apt that I mentioned earlier and then running sudo apt-get update.

So, in my rush to test things, I skipped over an error with apt-get update, specifically some hash sum mismatches. The fix was to edit /etc/apt/sources.list and comment out the backports line, then run sudo apt-get clean and sudo apt-get update. (I also installed node 7.) I also ran into out of memory errors during chip-io installation. Reinstalled chip-io under a session started with sudo bash and with no other software running and it finally worked.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

Now that I am doing all of the testing/development over the network, I think my next step will be to put samba (or something similar) on the CHIP so I can code in a local copy of Atom. Back to research.

RE: Testing out the C.H.I.P. - Added by J. Simmons over 7 years ago

So, two thoughts for tonight.

  1. As I continue with testing the CHIP, I can see one of the products of this set of experiments will be a wiki page covering how to initialize a new CHIP for Holoseat development (starting with flashing the correct OS and going all the way through setting up all required development software).
  2. The next step is to set up Samba (someone else has indeed gotten Samba running on CHIP and I found a very quick tutorial for Samba on Ubuntu to try out)

Setting up Samba

  1. Install Samba: sudo apt-get install samba
  2. Set password for Samba user chip (to match the main user for ease of use; use the same password as the chip user): sudo smbpasswd -a chip
  3. Create dev directory to store our development work: mkdir /home/chip/dev
  4. Make a back up of the Samba conf file: sudo cp /etc/samba/smb.conf ~
  5. Open the Samba conf file for editing in nano: sudo nano /etc/samba/smb.conf
  6. Add the configuration block below to the end of the Samba conf file
  7. Save the Samba conf file and exit nanor
  8. Restart Samba: sudo service smbd restart
  9. Verify the Samba conf file syntax: testparm
  10. Test the new dev share from another machine by trying to connect to \\chip.local\dev\ as the chip user
[dev]
path = /home/chip/dev
valid users = chip
read only = no

That all seems to work (I can add files directly on the CHIP over ssh to the dev share and delete them over Samba and vice versa. Note, do not get confused and try connecting to the share named chip. This is a default share that you will not have full access to over Samba (in my testing it was read-only for some reason). To keep things simple, we will use the dev share to host development code.

Next up, installing svn and node, then reviewing my notes about how to get node + johnny-five running based on my work with the test rig last year.

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

OK, so tonight we are ready to get node running. But first, I will be revisiting the work I did on the test rig.

  1. Install svn: sudo apt-get install subversion
  2. Install Node.js using the official instructions (making sure to use v6.x and not 7.x) with the following three commands
    1. curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
    2. sudo apt-get install -y nodejs
    3. sudo apt-get install -y build-essential
  3. Set up npm per Best Practices for Node.js Development
    1. npm config set save=true
    2. npm config set save-exact=true

Now things should be ready to start working with the test rig files to demo Johnny-Five.

  1. Check out test-rig scripts from svn (under /home/chip/dev/): svn co https://opendesignengine.net/svn/holoseat/trunk/test_rig/test-scripts
  2. Edit package.json and remove raspi-io (this is the library for the Raspberry Pi)
  3. Run npm install in /home/chip/dev/test-scripts/ to install everything but chip-io
  4. Add chip user to i2c group: sudo adduser chip i2c
    When I ran this command, it reported chip was already a member of the i2c group
  5. Install chip-io: npm install chip-io
    This will also add chip-io to the package.json file

At this point everything should be installed. Going to post this much then look at running an example or two.

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

The first test will be to blink an LED. I have wired up a 220 Ohm resistor to positive leg of an LED with an alligator jumper. I then plugged the resistor into pin XIO-P0 of the CHIP and the negative leg of the LED into ground on the CHIP. I then modified the previous blink.js to match the chip-io LED example

// "johnny five hello world, aka blink an LED
var chipio = require('chip-io');
var five = require('johnny-five');
var board = new five.Board({
  io: new chipio()
});

board.on('ready', function() {
  // Create an Led on XIO-P0 pin
  // and strobe it on/off
  var led = new five.Led('XIO-P0');
  led.strobe(500);
});

Finally, I tried running it with the command node blink.js. Everything looks like it is running fine, but there is no blinking on my LED (I confirmed the LED worked by moving the resistor to the +5v pin). Going to upgrade the versions of Node and Johhny-Five in the package file and upgrade my install to see if that resolves the issue. No dice. Interestingly enough, I think I got the blink status demo working. So the problem must be with writing to the pins.

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

So, I have been continuing my experiments with trying to get the LED blink demo working. To isolate the issue, I am setting Node.js solutions aside and trying a more direct route. There is a post called Blinky LED with C.H.I.P. and BASH that looked very promising. It blinks the LED with direct filesystem level calls in BASH. When I first gave it a try I was getting errors like sh: line 0: echo: write error: Invalid argument. A little digging indicated the new OS release for the CHIP (4.4.x) broke the original scripts and a simple change of the initial address for the ports from 408 to 1016 should fix things.

That change did eliminate the error message, but it did not make things work. Thanks to some additional searching by Bryan, we have learned the correct replacement value is 1013, not 1016. When I account for this I am able to get the LED to light up. But, that only works when I plug the LED in "backwards" and treat the pin as ground. The XIO pins on the CHIP apparently don't have the juice to light the LED.

So, we have learned two things from this experiment:

  • the XIO pins are working on the CHIP
  • the XIO pins cannot drive an LED directly

Next test is to try runnign blink.js again with the LED plugged in "backwards" (that is the long leg in 3.3v pin and the short leg in the XIO pin).

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

Success from Node.js!!! Using the "backward" wiring for the LED, the blink.js script works. Now, I would prefer to wire things up closer to what I am used to in Arduino-land. A little more googlng gives us this post on the CHIP forums. Apparently the XIO pins are a little different than I am used to, but it sounds like the CSID pins are more what I am expecting to see.

According to the chip-io docs I should be able to control these, they just need me to run the script as root. So, going back to a normal wiring for the blink example (resistor > long leg of LED and short leg of LED > GND using CSID0. And that works!!

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

So, now that we have output working, the next question is how to get input working. And here we run into a temporary snag. The IO pins (XIO and CSID) are "3.3V tolerant for input" - CHIP Wiki - GPIO Info: Electrical Characteristics. Of course, this doc still shows the address base for the XIO pins as 1016 for OS v4.4.x, but still the input voltage is not one of those things that changes. A little more reading shows that the Introduction makes it very clear the GPIO pins are 3.3V only for input.

So, before we explore input, we need to source replacement sensors with the same sensitivity but running at 3.3V. Back to the BoM.

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

Alternately, we could make a Voltage Divider (thanks SparkFun). I think that will be the next thing I read up on.

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

So, I went back and looked at the data for the Adafruit Feather Proto. The Feather is one do the new generation of Arduino-like boards that is 3.3v logic only (just like the CHIP. Yet, in the hours and hours of use of the 5V logic Hall effect sensor, we have not fried the Feather.

So, I thought it was time to get brave. I took one of the sensor assemblies I have left over from v0.3 development and I wired it up to the CHIP (red wire to 5V, black wire to GND, and green wire to CSID0). I then updated the hall-read.js file from the test rig to use the chip-io library and set the input pin to CSID0. I fired up the script under root (sudo node hall-read.js) and it just worked! I am now quite confident I can port the test rig over to the CHIP. It is just a matter of time.

This just leaves one open question: can we get the CHIP to look like an HID keyboard over USB.

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

A quick look at the HID Gadget links and it looks like we have to build a custom kernel to make this work on the CHIP. Bryan is going to take over that part while I move on to non-CHIP related research.

RE: Testing out the C.H.I.P. - Added by J. Simmons about 7 years ago

So, the real question this thread of research was intended to answer was should we go with the CHIP (by way of answering can we make the CHIP work?). In terms of Node.js, Johnny-Five, and our sensors, the answer is a resounding yes. And while we need to sort out how we want to emulate HID devices so we can send user input to games, that question is more of a which way should we go (HID Gadget through the Linux Kernel or slave the Atmel chip from the Leonardo style boards to the CHIP controller). So we know we can make the HID interface work, which added to the test results above means we can make CHIP work.

After discussing these overall results with Bryan, we have decided to go with the CHIP as our new controller for v0.4 and to move the HID testing into separate threads in the forums. One will be testing the HID Gadget feature by compiling a custom CHIP kernel (Bryan will take point on that) and the other will look at slaving a Leonardo style board with an eye towards simplifying the circuitry if we use this option (these tests will be led by me).

That just leaves one clean up step from this thread - creating wiki page documenting the CHIP setup I created as part of my research to go from fresh CHIP to ready for Holoseat development. That is something else I will work on shortly.

(1-21/21)