Assorted CHIP Stuff

Some stuff from playing with the stupidly named CHIP.

Battery

There is a script shipped with the CHIP images that will dump some information from the battery controller. Which is sort of useful I guess.

[chip@chip] $ sudo battery.sh
BAT_STATUS=0
CHARG_IND=1
BAT_EXIST=1
CHARGE_CTL=0xc9
CHARGE_CTL2=0x45
Battery voltage = 3930.3mV
Battery discharge current = 0mA
Battery charge current = 882.5mA
Internal temperature = 51.9c

LEDs

There are two leds on board, a pink one that is directly wired into power and a status led connected over i2c. The led can be control directly over i2c with the i2cset command.

[chip@chip] $ sudo i2cset -f -y 0 0x34 0x93 0x0 #turn off

[chip@chip] $ sudo i2cset -f -y 0 0x34 0x93 0x1 #turn on

On my CHIP image the led is showing some sort of heartbeat that isn't stopped when I manually intervene. On their forums the i2cset method is reccomended to control the led, but the heartbeat made this impossible.

After a ton of poking and searching, trying to see if you can get strace to log processes that access a path (doesn't look like you can) I came across ledtrig-cpu in the dmesg.

[    2.315000] ledtrig-cpu: registered to indicate activity on CPUs

ledtrig-cpu is a kernel module for showing event status on built in leds, there is some inscruitable BBB documentation that somewhat shows how to control it.

In /sys/class there is an entry for each on the leds on board, listed with their colour. We can have a play with the led by looking at the following:

[root@chip] # cd /sys/class/leds/chip:white:status
[root@chip] # ls
brightness  device  max_brightness  power  subsystem  trigger  uevent
[root@chip] # cat brightness 
0
[root@chip] # cat max_brightness 
255
[root@chip] # echo 24 > brightness 
[root@chip] # echo 10 > brightness
[root@chip] # echo 255 > brightness
[root@chip] # echo 0 > brightness

Changing the value in brightness didn't dim the STAT led at all, I can only set it on or off.

[root@chip] # cat trigger
[none] kbd-scrollock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock nand-disk usb-gadget usb-host axp20x-usb-online timer oneshot heartbeat backlight gpio cpu0 default-on transient flash torch mmc0 rfkill0 rfkill1 rfkill2 rfkill3 

The trigger functionality was much more fun. Trigger modes can be changed by writing their name to the file

[root@chip] # echo backlight > trigger
[root@chip] # echo transient > trigger
[root@chip] # echo torch > trigger    
[root@chip] # echo mmc0 > trigger 
[root@chip] # echo timer > trigger

Setting the trigger mode to timer added two more files the /sys entry:

[root@chip] # ls
brightness  delay_off  delay_on  device  max_brightness  power    subsystem  trigger  uevent
[root@chip] # cat delay_on 
500
[root@chip] # cat delay_off
500
[root@chip] # echo 2000 > delay_off

We can restore the trigger to the heartbeat with:

[root@chip] # echo heartbeat > trigger 

Reading: Babylon's Ashes, Diamond Age

Aberdeen, Scotland: 0°C, Overcast throughout the day.