What is Nerves?
A set Elixir libraries for embedded hardware development.
+
What is Nerves?
This Talk
Explore workflows for Nerves in various contexts.
Develop, debug, and deploy firmware to Nerves targets.
Nerves #FTW
- Developer experience (DX)
- Documentation
- Open source community
- Nerves Core Team
- Hardware support
Now is the best time to get started with Nerves.
"What about the chip shortage? Why now?"
Reasons
Workflows:
- Host
- SD Card
- Serial Cable
- HDMI Cable
- USB Cable
- WiFi
- IEx
- Hotswap
- OTP
- Livebook
- NervesHub
What's in store?
Host
Host
What/how?
Code written on and for the host environment.
It works, ship it!
Keep application and hardware code separate.
Add hardware abstraction layers or adapters.
Host
What/how?
Nerves Project
Dependencies
Configuration
Application Code
Hardware
Host
Test
Host
Use cases
- Literally everywhere
- Testing
- Except for HAL
- Mocking HAL
Resources
Host
Benefits
- Best DX
- Shortest feedback loop
- Separation of concerns
- Hardware interoperability
- Faster debugging
- Code easier to reason about
- Simplified tests
Drawbacks
- More configuration
- Mocking
- Not actual hardware
5
SD Card
SD Card
Use cases
- Early development
- Custom Nerves system
- Unsupported development board/hardware
- Device provisioning sequences
SD Card
Drawbacks
- Cumbersome
- Interrupts "flow"
- Wears out SD cards
Benefits
- Ensures fresh firmware
- Sometimes it's faster than WiFi
45
Serial Cable
What/How?
Allows you to open a direct console connection to the Nerves target through a terminal emulator like screen.
Serial Cable
Use cases
- Early development
- Firmware debugging
- Hardware debugging
Can I help?
Serial Cable
Drawbacks
- Wires
- Confusing tx/rx
- Impaired console
- Not always available
Benefits
- See console output immediately
- No networking or configuration!
HDMI Cable
What/How?
Some Nerves targets include micro HDMI or mini HDMI ports that you can connect directly to an external display.
HDMI Cable
HDMI Cable
Warning
- May require config
Benefits
- See console output early
- No networking or configuration!*
Drawbacks
- Wires
- Not always available
USB Cable
What/How?
The suggested path of least resistance for connecting to a Nerves target in the official Getting Started guide.
USB Cable
Use cases
- New to Nerves
- Early development
- Other options unavailable
USB Cable
Drawbacks
- Wires
- Requires DATA cable, not just power
Benefits
- Fast, easy, convenient
- Supplies both power and data
25
WiFi
What/How?
Nerves targets can be configured to connect to WiFi.
OTA firmware updates via nerves_ssh.
Vintage Net supports a myriad of WiFi configurations.
WiFi
Use cases
- Hobby projects
- Prototyping
- Commercial use
WiFi
Drawbacks
- Even with Vintage Net, wireless networking may present confusing situations.
Benefits
- No wires!
- Commonly available
- Vintage Net
- Vintage Net Wizard
40
IEx
IEx
Use cases
- Host development
- Testing during development
- Remote shell sessions
- Pretty much anytime!
IEx
Warning
- Use caution when changing code in memory
Benefits
- Interact with runtime
- RingLogger
- RamoopsLogger
- Toolshed
Hotswap
What/How?
Enables fast and easy OTA updates to Nerves targets.
Passes compiled modules to IEx.Helpers.nl/2, which leverages Erlang's rpc:call to load new BEAM code.
Hotswap
Use cases
- Firmware development
- Hardware hacking
- Debugging application startup
Fixed it!
Hotswap
Drawbacks
- All modules replaced each time
- Doesn't support changes to config or deps
Benefits
- No wires!
- Tight feedback loop
- Relatively easy to setup
- Great DX with OTP
Warning
- May present confusing situations
15
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.
OTP
Use cases
- Concurrent process management
- Tweaking startup sequences
- Designing supervision trees
- Debugging failure conditions
OTP
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.
Livebook
Use cases
- Experimenting with new hardware
- Documentation and guides
- Onboarding developers
- Demos!
Livebook
Warnings
- 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:
Install on AWS with nerves-hub/terraform repo.
Run as separate services on another platform.
NervesHub
Use cases
- Commercial IoT
- Consultancy
- Community
NervesHub
Drawbacks
- Community hosted version no longer available
- Hard to configure self-hosted Nerves Hub
Benefits
- OTA updates
- Products
- Deployments
- Tags
- Remote IEx
180
Workflows:
- Host
- SD Card
- Serial Cable
- HDMI Cable
- USB Cable
- WiFi
- IEx
- Hotswap
- OTP
- Livebook
- NervesHub
Rewind Recap
Advanced Workflows:
Thoughts? Questions?
How are you using Nerves?
Thanks!
Workflows and use cases for Elixir Nerves (ElixirConf 2022)
By Jason Johnson
Workflows and use cases for Elixir Nerves (ElixirConf 2022)
Presented at ElixirConf US 2022.
- 308