Debugging


Overview

While you develop new packages it is often necessary to debug on one of your devices.

The runtime environment

Accessing your device

You have two options to get a command prompt on your device. SSH or Remote terminal.

SSH

If your device is in the local network, activate SSH on the device. This will allow you root access to the device using key based authentication. It's not possible to use password authentication.

Example assuming your device IP is 192.168.1.123 (you can find out your IP address by visiting the Device detail page in your account):

user@local:~$ ssh root@192.168.1.123
info-beamer-2429607372 ~ #

Remote terminal

The easier method is to use the "Remote terminal" feature. Enable "Show remote terminal on device page" on your account page. Then head to the device's page and click on "Connect" in the "Remote terminal" section. By default you get a limited shell that allows you to check out log files. If you need root access, click the dropdown button next to the "Connect" button and select "Connect as root.." and confirm.

A quick tour

You are now connected to the running info-beamer device. The process list will usually look something like this:

info-beamer-2429607372 ~ # ps fax
  PID TTY      STAT   TIME COMMAND
    2 ?        S      0:00 [kthreadd]
   [ ... various kernel threads ...]
    1 ?        Ss     0:02 init 
  166 ?        Ss     0:00 klogd
  191 ?        Ss     0:00 runsvdir /service ...............................
  194 ?        S      0:00  \_ runsv syncer
  197 ?        S      0:01  |   \_ logger -t 2429607372.syncer
  201 ?        SNl    0:40  |   \_ /usr/bin/python /syncer/syncer.pyo
  196 ?        S      0:00  \_ runsv ssh
  199 ?        SN     0:00  |   \_ dropbear -F
  437 ?        SNs    0:00  |       \_ dropbear -F
  438 pts/0    SNs    0:00  |           \_ -sh
  439 pts/0    RN+    0:00  |               \_ ps fax
  198 ?        S      0:00  \_ runsv ntpdate
  202 ?        S      0:00  |   \_ logger -t 2429607372.ntpdate
  403 ?        S      0:00  |   \_ sleep 3600
  203 ?        S      0:00  \_ runsv info-beamer
  208 ?        S      0:04  |   \_ logger -t 2429607372.info-beamer
  257 ?        S<l  160:29  |   \_ ./info-beamer /space/root
  207 ?        S      0:00  \_ runsv dhcp
  210 ?        S      0:00  |   \_ logger -t 2429607372.dhcp
  213 ?        S      0:00  |   \_ udhcpc -f -n -i eth0 -s /etc/udhcpc.script
  345 ?        S      0:00  \_ runsv service.root
  346 ?        SN     0:00      \_ logger -t 2429607372.service.root
  422 ?        SNsl   0:45      \_ /usr/bin/python ./service root
  192 tty1     Ss+    0:00 /bin/sh /etc/shell
info-beamer-2429607372 ~ # 

Log file

To see what the device is doing, you can tail the logfile:

info-beamer-2429607372 ~ # logread -f
[..] 2429607372.info-beamer:     uptime 17488s, cpu 4081s+5760s, rss 12160kb, temp=51.9'C
[..] 2429607372.info-beamer:     mem fps   rps allocs width height   boot update  event     name (alias)
[..] 2429607372.info-beamer: ---------------------------------------------------------------------------
[..] 2429607372.info-beamer: * 684kb  36   0.2    0.0  1280    720   0.0%   0.0%  93.8%  '- root (-)
[..] 2429607372.info-beamer: ---------------------------------------------------------------------------
...

To see all log information (up to one megabyte is stored) use logread.

Synced files

The currently active node code is available in /space/root.

info-beamer-2429607372 ~ # ls -l /space/root/
total 68
-rw-r--r--    2 root     root          1075 Jun 24 14:58 COPYRIGHT
-rw-r--r--    2 root     root           251 Jul 13 14:17 README.creole
-rw-r--r--    2 root     root             2 Jun 24 14:58 config.json
-rw-r--r--    2 root     root          5261 Jun 24 14:58 lua.png
-rw-r--r--    2 root     root            48 Jun 24 14:58 node.json
-rw-r--r--    2 root     root           223 Jun 24 14:58 node.lua
-rw-r--r--    2 root     root           124 Jun 24 14:58 package.json
-rw-r--r--    2 root     root          3800 Jun 24 14:58 package.png
-rw-r--r--    2 root     root           458 Jun 24 14:58 shader.frag
-rw-r--r--    2 root     root         20625 Jun 24 14:58 shader.jpg
info-beamer-2429607372 ~ # 

Useful tools

jq (a json parser and display tool)

jq is a small json parser and display tool that can be used to inspect json files. Learn more about it on http://stedolan.github.io/jq/

info-beamer-2429607372 ~ # jq . /space/root/package.json 
{
  "name": "Shader Example",
  "author": "fw@dividuum.de",
  "desc": "Minimal Example for a non-configurable node"
}

vcdbg

The raspberry PI debugging tool. More information is available in this wiki.

Example: See current memory usage of the GPU:

info-beamer-2429607372 ~ # vcdbg reloc

Relocatable heap version 4 found at 0x8000000
total space allocated is 108M, with 32M relocatable, 2.3M legacy and 74M offline
1 legacy blocks of size 2359296

free list at 0x838d1a0
24M free memory in 8 free block(s)
largest free block is 9.5M bytes

[   1] 0x8000000: used 4.0K (refcount 1 lock count 0, size 0, align 4096, data 0x8001000, d1rual) 'camera fast alloc arena'
... more lines...
0x9b9b000: free 8.4M
0xa400000: offline 11M
0xaf00000: legacy block 2.3M
0xb140000: offline 59M
small allocs not requested
info-beamer-2429607372 /space/root # 

sv

All services (info-beamer pi, the syncing service and services included in packages) can be managed using sv. You can restart info-beamer like this:

info-beamer-2429607372 ~ # sv i /service/info-beamer
info-beamer-2429607372 ~ #