Workflows for Elixir Nerves
Introduction
Jason Johnson
+
Nerves #FTW
- Improved developer experience and on-ramps
- Better documentation than ever before
- More target device support
- Acceleration in open source contributions
- Nerves Core Team is growing
Now is the best time to get started with Nerves.
"What about the chip shortage? Why now?"
Reasons
(congrats Masatoshi! )
This Talk
Explore workflows for Nerves in various contexts.
Workflows include: connecting to, interfacing with, and loading firmware to Nerves targets.
Work flows:
- SD Card
- Serial Cable
- HDMI Cable
- USB Cable
- WiFi
- iEx
- Hotswap
- OTP
- Livebook
- NervesHub
What's in store?
SD Card
Use cases
- Early development
- Custom Nerves system
- Unsupported development board/hardware
- Device provisioning sequences
Drawbacks
- Cumbersome
- Wears out SD cards
- Interrupts "flow"
Benefits
- Ensures fresh firmware
- Sometimes it's faster than WiFi
Serial Cable
What/How?
Allows you to open a direct console connection to the Nerves target through a terminal emulator like screen.
Use cases
- Early development
- Firmware debugging
- Hardware debugging
Drawbacks
- Wires
- Confusing tx/rx
- Impaired console
- Not always available
Benefits
- See console output immediately
- No networking!
HDMI Cable
What/How?
Some Nerves targets include HDMI or HDMI mini ports that you can connect directly to an external display.
Use cases
- Early development
- Hardware debugging
- Kiosks
Drawbacks
- Wires
- Not always available
Benefits
- See console output early
- No networking!
USB Cable
What/How?
This is the suggested path of least resistance for connecting to your Nerves target in the official Getting Started guide.
Use cases
- Easy configuration
- Early development
- Other options unavailable
Drawbacks
- Wires
- Requires DATA cable, not just power
- Local networking with mDNS sometimes tricky
Benefits
- Fast, easy, convenient(?)
- Supplies both power and data
WiFi
What/How?
There are a LOT of ways your Nerves target can be configured to use WiFi. Vintage Net provides support for all the common and some uncommon WiFi configurations.
Use cases
- Hobby projects
- Prototyping
- Commercial use
Drawbacks
- Even with Vintage Net, wireless networking may present confusing situations.
Benefits
- No wires!
- Commonly available
- Vintage Net Wizard
iEx
What/How?
The REPL experience is an essential aspect of working with Elixir. Nerves enables iEx sessions with the target over ssh.
Use cases
- During active development on the host
- While running tests
- For remote shell connections to target(s)
- Pretty much anytime!
Drawbacks
- Possible to break things
- May produce confusing code situations
Benefits
- Access logs, debug, inspect, and run code
- Interact with runtime environment
- RingLogger
- RamoopsLogger
- Toolshed
- Copy and paste method
Hotswap
What/How?
This magical package enables fast and easy OTA updates to Nerves targets.
Use cases
- Project development
- Library development
- Hardware hacking
Drawbacks
- May present confusing situations
- All modules replaced each time
- Doesn't support changes to config
- Doesn't support changes to dependencies
Benefits
- No wires!
- Tight feedback loop
- Relatively easy to setup
- Combine with OTP to quickly iterate on supervision trees
Fixed it!
Passes compiled modules to IEx.Helpers.nl/2, which leverages Erlang's rpc:call to load new BEAM code.
OTP
What/How?
A special blend of powerful abstractions rolled into a small set of battle-tested Erlang libraries. Including the classics like supervisors, processes, links, and GenServer.
Use cases
- Concurrent process management
- Tweaking startup sequences
- Designing supervision trees
- Debugging failure conditions
Drawbacks?
Livebook
What/How?
A library for managing live, interactive, and collaborative code notebooks. Get started by downloading a pre-built firmware release that includes Livebook and some demo notebooks.
Use cases
- Experimenting with new hardware
- Documentation and guides
- Onboarding developers
- Demos!
Drawbacks
- Security considerations
- Overwriting notebooks by burning
Benefits
- It's a live coding journal that runs on Nerves!
- Collaborative
- Reproducible
- Tight feedback loop
NervesHub
What/How?
"An open-source firmware updates server"...
Also includes:
Use cases
- Commercial
- Consultancy
- Community(?)
Drawbacks
- Community hosted version no longer available
- Hard to configure self-hosted Nerves Hub
Benefits
- OTA updates
- Products
- Deployments
- Tags
Install on AWS with nerves-hub/terraform repo.
Run as separate services on another platform.
Work flows:
- SD Card
- Serial Cable
- HDMI Cable
- USB Cable
- WiFi
- iEx
- Hotswap
- OTP
- Livebook
- NervesHub
Rewind Recap
Questions?
Workflows for Elixir Nerves (Nerves Meetup July '22)
By Jason Johnson
Workflows for Elixir Nerves (Nerves Meetup July '22)
- 455