HowTo (Mac) - Debug

Note: This page assumes that you have successfully completed the Install, Build, and Upload steps.

Introduction

Now that you have an app built and uploaded to the Nerves target, you may want to do some interactive debugging. The standard procedure involves plugging in a USB keyboard and an HDMI display, booting the target, and then interacting with the resulting IEx session. This is simple and direct, but may not be convenient for all users. So, I'd like to investigate assorted alternatives.

Connectivity

A typical Nerves target will support several forms of connectivity. Here's a table of possibilities, drawn from the Raspberry Pi 3B:

Forms Radio Wired
Direct Bluetooth USB 2
Network 802.11n 100base-T

Sessions

By default, interactive sessions on the Nerves target provide IEx, rather than (say) a Bash shell. This is a lightweight solution for Nerves to offer, but I'm not sure how convenient it would be in a situation where I'm integrating other Linux commands into a Nerves app. So, I'd like the option to run Bash and other Linux commands.

With some care, I should be able to provide a useful set of tools without too much expansion of the Nerves image. Although a proper approach will probably involve networking, here's a (rather primitive) way to try things out:

I haven't managed to get a Bash console. Apparently, you need to add --run-on-exit /bin/sh in your erlinit.config and then make your app crash.

-- @paco, on the Nerves Slack channel

The session also contains a slew of system messages at initialization and a continuing stream of them as the session proceeds. It might be interesting and useful to set up screen(1) or tmux(1) as a way to keep the log messages out of the interactive session. Again, this might work well in conjunction with networking.

Keyboard + Display

Using a USB keyboard and an HDMI-connected display is definitely the Golden Path, so I tried out my Raspberry Pi 3B (running Blinky) using the following additional hardware:

  • DVI display (Dell 2405FPW)
  • DVI-to-DVI cable (??? ???)
  • HDMI-to-DVI dongle (Apple ???)
  • USB keyboard (Apple A1242)

Unfortunately, support for USB keyboards seems to be a bit sketchy. The system didn't recognize any form of input from the Apple keyboard and didn't understand the shift keys on a CoolMacKeyboard I tried. Finally, I found a Happy Hacker keyboard that seems to function properly.

To be continued...

Other Prospects

Here are some other prospects, at various levels of availability.

The Raspberry Pi 3B has built-in Bluetooth (Bluetooth 4.1 Classic, Bluetooth Low Energy). It might be possible to use screen(1) or tmux(1) to multiplex connections over a Bluetooth link, but it sounds rather awkward. In any event:

The current systems do not have Bluetooth drivers included, so that's not an out of the box option.

-- @tattdcodemonkey, on the Nerves Slack channel

Networking

Some Raspberry Pi models (e.g., 2B, 3B) have an Ethernet socket (10/100-BaseT). Also, the Raspberry Pi 3B has built-in Wi-Fi (2.4GHz 802.11n wireless). So, we can put the target on the LAN and SSH in. See the Network HowTo for more details.

USB Cable

Some Raspberry Pi models (including the 2B and 3B) have multiple (e.g., 4) USB sockets. It might be possible to use screen(1) or tmux(1) to multiplex connections over a Bluetooth link, but it sounds rather awkward.

The Raspberry Pi 3B has built-in Wi-Fi (2.4GHz 802.11n wireless).

The interim wifi is definitely interim. It works for me, but can be a little finicky.

-- @tattdcodemonkey, on the Nerves Slack channel

To be continued...


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r12 - 19 Jul 2016, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email