How-to manual

Tutorial and reference book for using CHIP in control and instrument applications

Version 01.00.03, 2017-02-22

This work by Peter Seng is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Page 1 of 21 Disclaimer of Warranty THERE IS NO WARRANTY FOR THE CONTENT, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE CONTENT “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE CONTENT IS WITH YOU. SHOULD THE CONTENT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

Limitation of Liability IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE CONTENT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE CONTENT (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAM), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Page 2 of 21 Contents 1 About...... 4 2 External sources - credits and reference...... 4 3 Using CHIP without keyboard and monitor...... 5 3.1 USB serial connection...... 5 3.1.1 Things needed:...... 5 3.1.2 Workflow...... 5 3.2 SSH over wired Ethernet...... 6 3.2.1 Things needed:...... 6 3.2.2 Workflow...... 6 3.3 SSH over wireless Ethernet...... 7 3.3.1 Things needed:...... 7 3.3.2 Workflow...... 7 3.4 Remote desktop via VNC...... 8 3.4.1 Things needed:...... 8 3.4.2 Workflow...... 8 3.5 Remote desktop via RDP...... 9 3.5.1 Things needed:...... 9 3.5.2 Workflow...... 9 4 Language and Location...... 9 5 Heartbeat indicated at status LED...... 10 6 Blink – health service...... 11 6.1.1 Things needed:...... 11 6.1.2 Workflow...... 11 7 File transfer - Secure Copy...... 13 7.1 From CHIP (ssh host) to ssh client:...... 13 7.2 From ssh client to CHIP (ssh host):...... 13 8 USB storage devices...... 13 9 Media player...... 14 9.1 ...... 14 9.2 ...... 14 9.2.1 Compiling...... 14 9.2.2 Start process in background...... 14 9.3 Other players...... 15 9.4 stations...... 15 10 GPIO use via shell script, audio amplifier control...... 15 11 To Do's...... 16 12 Appendix...... 17 12.1 Update CHIP...... 17 12.2 Commands...... 17 12.3 Programs...... 18 12.4 Programs for administration...... 18 12.5 CHIP docs and data...... 19 12.5.1 Power consumption and rejected heat...... 19 12.6 Intro's...... 20 12.7 Links...... 20 13 Revision history...... 21

Page 3 of 21 1 About CHIP is a 41x61mm sized GNU/ computer with on board UPS controller, WiFi, Bluetooth, and various serial interfaces. This document is a tutorial and reference manual for using CHIP in control and instrument applications or just for fun. Most content is a summary of freely available external sources (see 2) and general knowledge. Consider this manual as a summary and extension of these external guides and pages. If any questions arise, please first have a look at the external sources where much more aspects are touched and explained. For better reading of this document command inputs and outputs via a terminal window (or serial terminal) are in a format like this. The content of source files is enclosed in frames. Hint: PDF documents do not contain tab formatting marks and empty lines. So it is not possible to copy source code out of a PDF document by copy and paste without loss of this information. The content of this manual may not be up to date. So before downloading and installing any package, please check if the mentioned packages are still up to date. If newer packages exist and it is sensible to use them please adapt the instructions to these conditions. Computer work described herein is done on a GNU/Linux machine, for other Operating Systems (OS) commands/procedures may need adaption. Much thanks and lot's of greetings to all those people developing and improving these artful tools running on GNU/Linux and the makers of CHIP. Any comments welcome, please mail to: [email protected] The current version of this manual is available at : http://www.seng.de

2 External sources - credits and reference Without the marvelous content of the sources mentioned this work would not exist. Some fist choice sources are: CHIP manufacturer: http://getchip.com/ CHIP documentation: http://docs.getchip.com/chip.html CHIP forum: http://bbs.nextthing.co/ In addition please look at chapter 12 (Appendix) to find a summary of additional links and sources.

Page 4 of 21 3 Using CHIP without keyboard and monitor In some cases it might be very handy to attach keyboard, mouse and monitor to CHIP. But first interest here is using CHIP headless - a small GNU/Linux machine capable doing lots of things, mostly hidden in a small and unremarkable box. This chapter describes 4 ways to access CHIP: 1. USB serial connection directly to Personal Computer (PC) 2. Secure Shell (SSH) over wired Ethernet using an USB-Ethernet adapter 3. SSH over wireless Ethernet (WLAN) via the on-board WiFi-module 4. Remote desktop via VNC using wired or wireless Ethernet 5. Remote desktop via RDP using wired or wireless Ethernet In addition CHIP can also be accessed via it's on board UART using a serial terminal, see external links (search for “headlesss CHIP”) how to establish this kind of connection.

3.1 USB serial connection Connect CHIP directly to PC via USB cable without using the Ethernet. PROS: simple CONS: no access to the Ethernet

3.1.1 Things needed: 1. CHIP 2. USB-cable, USB-A male to USB Micro-B male 3. PC with USB port and serial terminal emulation program

3.1.2 Workflow 1. connect CHIP via USB-cable to PC 2. wait a while till CHIP ended boot-process 3. find out the device name of the emulated serial port (by use of lsusb and dmesg | grep tty) 4. Open a serial terminal on your PC set to 115200 baud, 8 bits, no parity, 1 stop bit, no flow control (for example: picocom -b 115200 -d 8 -p n -f n /dev/ttyACM0) 5. Log in (default) as “chip” using password (default) “chip” on serrial terminal → DONE, play around now using the serial terminal… Hints: when work is finished shut off CHIP using command: sudo shutdown -P now, close picocom by push and hold “strg” followed by “a” and “x”.

Page 5 of 21 3.2 SSH over wired Ethernet Connect CHIP over wired Ethernet using an USB-Ethernet adapter (CHIP comes with SSH-server already installed and running by default). PROS: simple access to the Ethernet network CONS: USB-Ethernet adapter needed

3.2.1 Things needed: 1. CHIP 2. stable USB-power-supply 5V/1A or CHIP BaseX carrier (optionally attach LiPo battery) 3. USB-Ethernet adapter compatible to CHIP 4. PC connected to Ethernet network with active DHCP server

3.2.2 Workflow 1. connect CHIP with USB-power-supply or CHIP BaseX carrier and power on 2. connect USB-Ethernet adapter to CHIP 3. wait a while till CHIP ended boot-process 4. Log in at your local DHCP server and check IP-address given to CHIP (e.g. 192.168.178.32) 5. open terminal window and enter ssh [email protected] 6. enter password (default) “chip” → DONE, play around now using the terminal window… 7. now it's good time to update CHIP with the actual software: sudo apt-get update sudo apt-get upgrade

Hints: when work is finished shut off CHIP using command: sudo shutdown -P now. Configure local DHCP server (router) to always assign same IP-address to CHIP ('s MAC-address) or configure CHIP to use static IP (sudo nmtui → configure address, gateway and DNS server). USB-Ethernet adapter takes lot of power → use stable and sufficient power supply, otherwise CHIP may hang (current via USB-port may not be sufficient).

Page 6 of 21 3.3 SSH over wireless Ethernet Connect CHIP over wireless Ethernet (WLAN) via the on-board WiFi-module (CHIP comes with SSH-server already installed and running by default). PROS: access to the Ethernet network without cable CONS: more complex to configure, Ethernet via WiFi instead of rugged cable

3.3.1 Things needed: 1. CHIP 2. USB-cable, USB-A male to USB Micro-B male (for setup only) 3. stable USB-power-supply 5V/1A or CHIP BaseX carrier 4. PC connected to Ethernet network with active DHCP server, USB port and serial terminal emulation program

3.3.2 Workflow 1. connect CHIP via USB-cable to PC 2. wait a while till CHIP ended boot-process 3. find out the device name of the emulated serial port (by use of lsusb and dmesg | grep tty) 4. Open a serial terminal on your PC set to 115200 baud, 8 bits, no parity, 1 stop bit, no flow control (for example: picocom -b 115200 -d 8 -p n -f n /dev/ttyACM0) 5. Log in (default) as “chip” using password (default) “chip” 6. enter nmcli device wifi list at serial terminal and check if your WLAN is listed 7. enter sudo nmcli device wifi connect 'network_name' password 'password' ifname wlan0 Example: sudo nmcli device wifi connect 'MyNet' password '1234' ifname wlan0 Hint: to connect to a hidden network, append hidden yes to the command, after ifname wlan0 8. verify connection: nmcli device status → wlan0 must now be connected to given network name, enter ping - 4 8.8.8.8 (Google's DNS) to check if WiFi connection works. 9. assign a static IP address to CHIP → sudo nmtui → change Wi-Fi settings from 'Automatic' to 'Manual' and enter static IP-address, gateway and DNS server. 10. Shut down and restart CHIP: at serial terminal enter sudo shutdown -P now → remove USB cable → close serial terminal window → connect power-supply to CHIP 11. wait a while till CHIP ended boot-process 12. open a terminal window (not serial terminal) and enter ssh chip@IP-address Example: ssh [email protected] 13. enter password (default) “chip” → DONE, play around now using the terminal window… 14. now it's good time to update CHIP with the actual software: sudo apt-get update sudo apt-get upgrade

Hints: when work is finished shut off CHIP using command: sudo shutdown -P now. To disconnect from wireless network to prevent future auto-connection enter sudo nmcli dev disconnect wlan0. Command nmcli c lists available network connections, to delete network from list enter sudo nmcli connection delete id “network_name”. When entering the ssh command including the -X option (e.g. ssh -X chip@IP-address) X11-Forwarding is enabled, so that graphical programs also can be used via SSH.

Page 7 of 21 3.4 Remote desktop via VNC Access to CHIP and view it's desktop without attaching display and input devices using VNC. PROS: view desktop without attaching hardware CONS: slow graphics, screen resolution limited to CHIP setting (Video, VGA or HDMI) Hint: VNC connections do not use any kind of encryption by default. If safety is a concern additional steps are needed in addition the following description → use ssh or some kind of encrypted tunneling.

3.4.1 Things needed: 1. CHIP with access to Ethernet network 2. stable USB-power-supply 5V/1A or CHIP BaseX carrier

3.4.2 Workflow 1. Install VNC server on CHIP: sudo apt-get install x11vnc 2. Store VNC password: x11vnc -storepasswd

Enter VNC password: abcd Verify password: abcd Write password to /home/chip/.vnc/passwd? [y]/n y Password written to: /home/chip/.vnc/passwd

HINT: this given password is not safe and can be spied out.

3. to add VNC server to autostart, first add a new directory to the home directory: mkdir -p ~/.config/autostart 4. add a new file named x11vnc.desktop to this directory: leafpad ~/.config/autostart/x11vnc.desktop 5. Insert following lines in x11vnc.desktop and save file:

[Desktop Entry] Encoding=UTF-8 Type=Application Name=x11vnc Comment= Exec=x11vnc -display :0 -forever -nevershared -usepw -ultrafilexfer StartupNotify=false Terminal=false

x11vnc.desktop 6. re-start system and graphical desktop: sudo shutdown -r now 7. start VNC-viewer on other system in network and enjoy viewing Hint: install package vinagre (remote viewer) on client system. Start vinagre → connect → computer: → input 192.168.178.18 → connect → password → enter abcd → connect

Page 8 of 21 3.5 Remote desktop via RDP Access to CHIP and view it's desktop without attaching display and input devices using RDP. PROS: view desktop without attaching hardware, screen resolution scalable CONS: slow graphics Hint: RDP connections do not use any kind of encryption by default. If safety is a concern additional steps are needed in addition the following description → use ssh or some kind of encrypted tunneling.

3.5.1 Things needed: 1. CHIP with access to Ethernet network 2. stable USB-power-supply 5V/1A or CHIP BaseX carrier

3.5.2 Workflow 1. install RDP server on CHIP: sudo apt-get install xrdp 2. start RDP server: sudo service xrdp restart Hint: RDP server starts automatically on system re-boot. 3. start RDP-viewer on client system in network and enjoy viewing the remote desktop Hint: install package vinagre (remote viewer) on client system. Start vinagre → connect → at protocol select RDP, at computer enter 192.168.178.18 → connect → username → enter chip → password → enter chip → connect. Instead of package vinagre package rdesktop can be installed, if used start program with command rdesktop 192.168.178.18 -g 1024x768

To uninstall xrdp execute following steps: 1. sudo apt-get remove xrdp 2. sudo apt-get purge xrdp

4 Language and Location CHIP’s comes with a default language of English. You can change the language and the location: sudo apt-get update && sudo apt-get install locales && sudo dpkg-reconfigure locales && sudo locale-gen

You’ll get a large menu to select locales. Use the arrow keys to scroll down and spacebar to mark your location with an [*]. It’s advised that you choose the location marked UTF8. You can set the timezone with: sudo dpkg-reconfigure tzdata

Page 9 of 21 5 Heartbeat indicated at status LED White status LED is always blinking after boot-process (system version >= 4.4). The blinking is the kernel's "heartbeat", documented here: https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/common.txt69 To disable enter: echo none | sudo tee /sys/class/leds/chip\:white\:status/trigger > /dev/null

To make the fix persistent across reboot add the following to the bottom of /etc/crontab:

… ... @reboot root echo none | sudo tee "/sys/class/leds/chip:white:status/trigger" >/dev/null

/etc/crontab

To view the full list of available triggers enter: cat /sys/class/leds/chip\:white\:status/trigger

To set any other "trigger", for example a HD-style access LED for the nand enter: echo nand-disk | sudo tee /sys/class/leds/chip\:white\:status/trigger > /dev/null

Page 10 of 21 6 Blink – health service Any reliable operating system driven computer needs to be carefully shut down (even when power fails), files and programs have to be closed before power is switched off. Therefore an uninterrupted power supply (UPS) should be mandatory and if present must be supervised. On headless systems should be some kind of heartbeat message showing the systems activity, such systems must be capable to power on and shut-down under control of a pushbutton. The systems needs to be automatically shut down when the UPS battery goes low or temperature raises above a certain level. Systems residing in a small plastic case need some kind of temperature monitoring (see 12.5.1) even when power dissipation is 2W or less, when active cooling is inevitable a fan must be controlled. This is what's “Blink” for. It's a service that: 1. drives a status LED monitoring systems status 2. executes shutdown when reset button is briefly pressed or charge level of the UPS battery is low or systems temperature is above a reasonable level 3. is capable to control a fan based on the temperature measured with the AXP209's internal sensor See https://github.com/fordsfords/blink/tree/gh-pages to have a full description of the services capabilities.

6.1.1 Things needed: 1. CHIP with access to Ethernet network 2. stable USB-power-supply 5V/1A or CHIP BaseX carrier 3. battery compatible to CHIP 4. fan (optionally) Note: do not connect fan directly to CHIP pins. A power stage as included in CHIP BaseX carriers is mandatory!

6.1.2 Workflow 1. Disable heartbeat indicated at status LED, see chapter 5 if you want Blink to control the LED 2. To install enter: sudo apt-get install i2c-tools sudo wget -O /usr/local/bin/gpio.sh http://fordsfords.github.io/gpio_sh/gpio.sh 3. If you have an earlier version of blink running, kill it: sudo service blink stop If that returns a failure, enter: sudo kill `cat /tmp/blink.pid` 4. Get the project files onto CHIP: sudo wget -O /usr/local/bin/blink.sh http://fordsfords.github.io/blink/blink.sh sudo chmod +x /usr/local/bin/blink.sh sudo wget -O /etc/systemd/system/blink.service http://fordsfords.github.io/blink/blink.service sudo systemctl enable /etc/systemd/system/blink.service If installing blink for the first time, get the configuration file: sudo wget -O /usr/local/etc/blink.cfg http://fordsfords.github.io/blink/blink.cfg If upgrading blink and have a configuration file, you can skip that step. 5. Now test it: sudo service blink start Hint: Since blink is a service, you can manually stop it: sudo service blink stop 6. After a few seconds watching the blinking LED, briefly press the reset button and watch CHIP shut down. Restart CHIP, and when it has completed its reboot, watch the status LED start to blink again. 7. Check logging: grep blink /var/log/syslog 8. To configure service edit file /usr/local/etc/blink.cfg: sudo nano /usr/local/etc/blink.cfg

Page 11 of 21 When using CHIP with CHIP BaseA carrier (Version 0007B) blink.cfg may look like this:

# blink.cfg -- version: "17-Sep-2016" # Configuration for /usr/local/bin/blink.sh which is normally # installed as a service started at bootup. # See https://github.com/fordsfords/blink/tree/gh-pages

BLINK_STATUS=1 # Blink CHIP's status LED (Defaultvalue: 1, enabled). #BLINK_GPIO=XIO_P7 # Blink a GPIO (Defaultvalue: XIO_P7, disabled).

MON_RESET=1 # Monitor reset button for short press (Defaultvalue: 1, enabled). #MON_GPIO=XIO_P4 # Shutdown when this GPIO is triggered (Defaultvalue: XIO_P4, disabled). #MON_GPIO_VALUE=0 # The value read from MON_GPIO that initiates shutdown (Defaultvalue: 0, disabled).

MON_BATTERY=95 # When battery percentage is below this, shut down (Defaultvalue: 7, disabled). WARN_BATTERY=97 # When battery percentage is below this, assert warning (Defaultvalue: 9, disabled). WARN_BATTERY_GPIO=CSID0 # When battery warning, activate this GPIO (Defaultvalue: XIO_P5, disabled). WARN_BATTERY_GPIO_VALUE=1 # Warning value to write to WARN_BATTERY_GPIO (Defaultvalue: 0, disabled).

MON_TEMPERATURE=800 # Shutdown temperature in tenths of a degree C (Defaultvalue: 800, disabled). WARN_TEMPERATURE=500 # Warning temperature in tenths of a degree C (Defaultvalue: 750, disabled). WARN_TEMPERATURE_GPIO=CSID1 # When temperature warning, activate this GPIO (Defaultvalue: XIO_P6, disabled). WARN_TEMPERATURE_GPIO_VALUE=1 # Warning value to write to WARN_TEMPERATURE_GPIO (Defaultvalue: 0, disabled).

/usr/local/etc/blink.cfg

Hints: Adjust content of file blink.cfg according your needs. You can enable a function by uncommenting it (remove the hash signs). Or you can comment lines (add the hash) to disable a function. Do not add any spaces before or after the equals sign. Settings in above configuration file are optimized for a system that shall power down short time (when 5% of the battery charge is depleted) after mains power breakdown.

Notes: 1. Blink logs informational (and maybe error) messages to /var/log/daemon.log 2. As long as the status LED continues to blink, you know that your CHIP is still running. But if you are running some useful application, the blinking LED does not necessarily give you a good indication of the overall health of your system. Basically, blink shows that the OS is still running, but your application may have crashed. 3. There are often ways of automatically monitoring the health of applications. At a crude level, you can periodically run the "ps" command and at least make sure the process itself is still running. Even better would be to be able to "poke" the application in some way to produce an expected result (like maybe sending it a signal and writing the application to write a message to a log file). You could build this capability into blink, and if it detects a failure, change the blink rate of the LED (like to 3 pulses per second). This still won't tell you what is wrong, but at least it narrows things down a bit. 4. The battery charge level is susceptible to "bit bobble", i.e. it can cycle between two values fairly rapidly. The CHIP temperature measurement can vary randomly within about a .9 degree range. To avoid rapid cycling of the warning state, blink adds hysteresis to the warning thresholds. For example, if CHIP's temperature exceeds the warning threshold, the temperature warning state is entered. If the temperature then starts to fall, it must fall to 1.1 degrees lower then the warning threshold to exit the warning state. To adjust hysteresis to another value open file /usr/local/bin/blink.sh and search for function check_warn_temperature(). Inside function change constant value 11 to desired value. Hysteresis constant is given in tenths of a degree C, so a value of 50 will result in a hysteresis of 5°C . Additional information: 1) Following command reads the fuel gauge from the AXP209 power management unit (PMU) and is in percent (convert resulting value from hex to decimal). If just pluged in a LiPo battery it takes a while before it starts working, until it gets a valid value it will output 0x7f. sudo i2cget -f -y 0 0x34 0xb9 2) For more commands concerning the AXP209 PMU see 12.2

Page 12 of 21 7 File transfer - Secure Copy Send files to and from CHIP using SSH connection.

7.1 From CHIP (ssh host) to ssh client: Syntax: scp user@host:directory/sourcefile targetfile scp [email protected]:/home/chip//ComeDi. /home/sengp/98_Temp/COMEDI.mp3

7.2 From ssh client to CHIP (ssh host): Syntax: scp sourcefile user@host:directory/targetfile scp /home/sengp/98_Temp/COMEDI.mp3 [email protected]:/home/chip/Music/comedi.mp3

8 USB storage devices This chapter describes how to use the USB port to add more storage with a thumb drive, hard drive, card reader, or whatever else. 1. Attach formated drive to CHIP's USB port, enter terminal: dmesg or ls /dev/sd* 2. and you’ll see something like: /dev/sda /dev/sda1 With one thumb drive attached, it appears as two devices: the device itself (sda), and the storage partitions (sda1). There is only one partition on this drive. 3. Make a directory where your drive can mount: sudo mkdir /drives 4. Mount the drive: sudo mount /dev/sda1 /drives

To remove the drive from the USB port on CHIP, unmount it: sudo umount /dev/sda1

For automatic mounting on boot do following steps: 1. At end of file /etc/fstab add one line:

… … /dev/sda1 /drives vfat defaults 0 0

/etc/fstab 2. Save file /etc/fstab 3. Test it by entering: 4. mount -a ls /drives 5. On reboot the drive will now mount automatically. If drive is removed and inserted again it must be mounted manually by: mount -a again.

Page 13 of 21 9 Media player When playing mp3 audio files or streaming Internet radio there is stuttering and dropouts on using system version 4.4.13. https://bbs.nextthing.co/t/stuttering-while-playing-music-from-c-h-i-p/11717/3 tells that use of mpv lessens stuttering when increasing buffer . https://bbs.nextthing.co/t/alsa-causing-stutter-hanging-in-pico-8-mednafen-retroarch-arm-solved- maybe-please-help-us-test-verify/13765 tells that there may be problems with Ubihealthd.

9.1 mplayer Standard player, lot's of features. Streaming internet radio: mplayer --=http://www.dradio.de/streaming/dlf.m3u Playing mp3 file: mplayer comedi.mp3

9.2 mpv Lot's of features, lesser stuttering. On system 4.4.13 program must be manually compiled, https://bbs.nextthing.co/t/mpv-symbol-lookup-error-mpv-undefined-symbol-wl-egl-window- destroy/12173 mpv --playlist=http://www.dradio.de/streaming/dkultur.m3u –audio-buffer=1.0 mpv comedi.mp3 --audio-buffer=1.0

9.2.1 Compiling Compiling will take some time (hours): sudo apt-get -y install devscripts git clone https://github.com/mpv-player/mpv-build.git cd mpv-build ./update rm -f mpv-build-deps_*_*.deb Now Install all the deps: mk-build-deps -s sudo -i Configure and build libass, and mpv: ./build Check that ./mpv/build/mpv works, then install: sudo ./install

9.2.2 Start process in background mpv --playlist=http://www.dradio.de/streaming/dkultur.m3u –audio-buffer=1.0 & returns job-number and precess-ID (for example: [1] 12572) to quit mpv press:Ctrl-C → mpv now invisible, but music continues playing... Remove job from current shell: disown job-number (for example: disown 1) Close shell: exit → shell terminated, but process mpv is still running… To stop process ssh-connection must exist, enter: kill process-ID (for example: kill 12572)

Page 14 of 21 9.3 Other players mpd (lots of clients for any OS available), mpg123, MOC, , , ...

9.4 Internet radio stations Name URL Deutschlandfunk http://www.dradio.de/streaming/dlf.m3u

Deutschlandradio Kultur http://www.dradio.de/streaming/dkultur.m3u

DRadio Wissen http://www.dradio.de/streaming/dradiowissen.m3u

SWR_1 http://mp3-live.swr.de/swr1bw_m.m3u

SWR_2 http://mp3-live.swr.de/swr2_m.m3u

SWR_3 http://mp3-live.swr3.de/swr3_m.m3u

DRS_3 http://stream.srg-ssr.ch/drs3/mp3_128.m3u

DRadio Nachrichten http://ondemand-mp3.dradio.de/file/dradio/nachrichten/nachrichten.mp3

10 GPIO use via shell script, audio amplifier control By default the amplifier on CHIP BaseA carrier (Version > 0007A) is shut down. To enable the amps shutdown pin must be set to high-level. Therefore a shell script must be executed. Shell script amp_on.sh controlling GPIO-CSID2:

#!/bin/bash

# read and execute commands from filename in the current shell environment if [ -f /usr/local/bin/gpio.sh ]; then : source /usr/local/bin/gpio.sh fi

SD_GPIO="CSID2" gpio_export $SD_GPIO; ST=$? if [ $ST -ne 0 ]; then : echo "Error: cannot export pin $SD_GPIO" else gpio_direction $SD_GPIO out gpio_output $SD_GPIO 1 # enable audio amp #gpio_output $SD_GPIO 0 # disable audio amp gpio_unexport $SD_GPIO # done with GPIO, clean it up fi

/usr/local/bin/amp_on.sh

Hints: File gpio.sh must be already installed, see chapter 6.1.2 Permissions for the file first must be set to executable: chmod +x /usr/local/bin/amp_on.sh

To enable audio amplifier enter following command: sudo amp_on.sh Additional information see: http://blog.geeky-boy.com/2016/07/beginner-shell-script-examples.html http://www.chip-community.org/index.php/GPIO_Info

Page 15 of 21 11 To Do's Things that should appear in future versions of this document: 1. developing and running python applications. 2. building an autonomous media player/internet radio. 3. sync server for mobile phone contacts and calendar. 4. Install and activate watchdog-daemon. The Allwinner MCU includes an hardware watchdog peripheral, but this must be configured. Hints see: http://www.gieseke- buch.de/raspberrypi/eingebauten-hardware-watchdog-zur-ueberwachung-nutzen https://www.datenreise.de/raspberry-pi-stabiler-24-7-dauerbetrieb/ http://www.gtkdb.de/index_36_2104.html http://strobelstefan.org/?p=4863 5. 6. 7. 8.

Page 16 of 21 12 Appendix

12.1 Update CHIP Execute following commands on CHIP whilst having access to the internet: sudo apt-get update Update information from repositories sudo apt-get upgrade Upgrade any installed packages

12.2 Commands Often used commands on CHIP: sudo shutdown -P now Shutdown and power off sudo shutdown -r now Shutdown and restart sudo service --status-all Show status of init script or startup job sudo axp209 --usage AXP209 power management unit (PMU), show help sudo axp209 --temperature AXP209, read temperature in degree Celsius sudo axp209 --charge-current AXP209, read current charged into the battery (mA) sudo axp209 --discharge-current AXP209, read current discharged from the battery (mA) sudo axp209 --battery-voltage AXP209, read voltage of battery (mV) sudo i2cget -f -y 0 0x34 0xb9 AXP209, reads fuel gauge. Returns hex value scaled in %. An output value of 0x7F denotes that data is not yet valid. uname -rm Show kernel version and system architecture id Show UID, GIP, groups sudo lshw -short Show hardware info free -m Show total, used and free memory dmesg | grep tty List serial ports

Page 17 of 21 12.3 Programs Programs nice to have on CHIP: ProgramName Description mc File-manager, midnight commander picocom Terminal emulation (terminate by Ctrl-a-q) Example: picocom -b 115200 -d 8 -p n -f n /dev/ttyACM0 minicom Terminal emulation Example: minicom -D /dev/ttyACM0 -b 115200 leafpad Graphical text editor nano Tini text editor blink Monitor program to blink status LED, execute shutdown when reset button if qbriefly pressed or charge level is low, control fan using AXP209's temperature. https://github.com/fordsfords/blink/tree/gh-pages sysbench Benchmark test ps -A -f Report a snapshot of the current processes pstree Display a tree of processes top Display Linux processes htop Interactive process viewer

If not present → install, to install programs enter sudo apt-get install ProgramName

12.4 Programs for administration This programs may be useful running on the PC used for configuring CHIP: Program Description minicom Terminal emulation picocom Terminal emulation (terminate by Ctrl-a-q) vinagre Remote desktop client (SSH, VNC and RDP) remmina Comfortable remote desktop client (SSH, VNC and RDP) ssvnc VNC client rdesktop RDP client

Page 18 of 21 12.5 CHIP docs and data Documents and data around CHIP.

12.5.1 Power consumption and rejected heat Measurements made at an ambient temperature of 22°C. CHIP connected to CHIP BaseA carrier containing DC/DC converter (TRACO TSR-1-2450) supplied by 12V DC. 100% processing load generated with sysbench: sysbench --test=cpu --num-threads=1 --cpu-max-prime=2000000 run CHIP and CHIP BaseA carrier mounted in plastic box of size 82x80x56mm. Temperature measured by on board AXP209 power management unit (PMU): sudo axp209 --temperature . Additional temperature sensor attached to CPU. Fan type Sunon MC30100V2-000U-A99, operating voltage 2V5...6V DC, size 30x30x10mm. CPU temperature operating range: -20°C...+70°C. CPU Heatsink 20x20x5mm, aluminum, black.

Power consumption @ 12VDC: Processing load Supply-current Power consumption Idle 100mA 1W2 100% 200mA 2W4

Rejected heat: Processing load Condition Fan AXP209 CPU Heatsink attached to CPU Idle Box open halt 39°C 41°C none 100% Box open halt 57°C 57°C yes 100% Box open halt 60°C 63°C none 100% Box closed halt 65°C 70°C none 100% Box closed 5V 38°C 40°C none 100% Box closed 3V3 39°C 40°C none 100% Box closed 2V5 42°C 44°C none 100% Box closed 2V5 43°C 41°C yes

Results: 1. Temperature measured by AXP209 is close to CPU temperature, so the sensor can be used to measure systems temperature and for fan control. 2. running the system in a plastic box requires active cooling at ambient temperatures > 22°C. 3. running the system (without any case) at ambient temperatures > 29°C requires some kind of cooling. 4. attaching a heatsink to the CPU makes not much sense. When placing the system in a 82x80x56mm plasic box the use of a fan is mandatory. Running the fan at a voltage of 2V5 is sufficient, this minimizes the sound level too. Under this circumstances an ambient temperature up to 48°C is permitted. In addition system temperatures at minimum levels will lead to maximum lifetime.

Page 19 of 21 12.6 Intro's General knowledge:

12.7 Links Where to find more information:

CHIP single board computer Wiki http://www.chip-community.org

Sources, Schematics, Layouts from Next Thing Co. https://github.com/NextThingCo/

Collection of design files for C.H.I.P. https://github.com/NextThingCo/CHIP-Hardware

C.H.I.P. VGA Display DIP PCBA https://github.com/NextThingCo/DIP-VGA-PCB

C.H.I.P. HDMI Display DIP https://github.com/NextThingCo/DIP-HDMI-PCB

Pocket C.H.I.P. PCBA Release Files https://github.com/NextThingCo/PocketCHIP-PCB

Page 20 of 21 13 Revision history Document revision history: Date Revision Changes 2017-01-27 01.00.00 Initial release 2017-01-30 01.00.01 Added chapter about USB storage devices and media player 2017-02-16 01.00.02 Added chapter about language and location 2017-02-22 01.00.03 Added chapter GPIO use via shell skript

Page 21 of 21