cone10

cone10

Is there a better way to send tweaks to elixir source to RPi than burning firmware?

I’m new to both Elixir and RPi, so forgive me if I am missing something totally obvious.

After burning the firmware on the SD card, say I want to simply tweak one source file. Is there a simple way to do it? I don’t want to re-burn the SD card … that’s so 1980’s!

How does one do dynamic deployment at dev time?

Most Liked

axelson

axelson

Scenic Core Team

Welcome to the forum :wave:!

Assuming you created your project with nerves.new then nerves_ssh should be enabled by default: GitHub - nerves-project/nerves_ssh: Nerves SSH support · GitHub

The gist of it is to run mix firmware, then mix firmware.push (possibly providing the nerve’s device ip address). So that will upload the new firmware to the device and then it will automatically restart. If want to revert to the previous firmware you can ssh to the device and run Nerves.Runtime.revert.

elcritch

elcritch

You’ll probably use both methods.

Nerves builds a “firmware” in that it contains everything to run the RPi, including the Linux kernel and your elixir code. Assuming you’re using Nerves for this. That firmware image is readonly.

However, since Elixir is an interpreted language you can upload code into a running Elixir VM (called the BEAM) via the Elixir shell (basically IEx). You can paste a module and it’ll then recompile the code and run it. Super handy for trying out i2c devices, html tweaks. It only takes a few seconds usually.

The copy/paste method gets tedious for big changes or lots of modules. Also any changes will be lost on reboot since it’s read-only. So you’ll want to make an updated firmware and push it regularly. It’s a bit slower to build the firmware since it’s rebuilding the entire rpi system, but not too bad (only a minute or two).

I tend too try several small changes via ssh and then upload a new firmware once I’m done. It’s sort of like connecting to a running docker container, tweaking code, and then building a new docker container with the changes and re-booting the container instance.

Sebb

Sebb

Nerves is not meant for “compile-edit-run-debug” (on the hardware).
Build the system on your workstation (write tests) and only occasionally do an integration test on the hardware.
Even if you are heavily using hardware peripherals, its normally not too hard to write tests.
If you don’t want to / can’t do that, you could just not use nerves for development and set up sth like this:

This could also be worth a look:

https://github.com/nerves-project/nerves/blob/main/docs/Experimental%20Features.md#firmware-patches

Where Next?

Popular in Discussions Top

thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
Ankhers
Just a little information upfront. Generally speaking, if I feel like I need to either break a pipe chain or use an anonymous function in...
New
rower687
Hi all, I’ve been reading a lot about the “let it crash” term and how supervising processes and the whole messaging passing make an elixi...
New
jer
I’ve been using umbrellas for a while, and generally started off (on greenfield projects at least) by isolating subapps based on clearly ...
New
PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
eteeselink
Hi all, In the last days, two things happened: A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
MarioFlach
Hello, I want to share a project I’ve been working on for a while: https://github.com/almightycouch/gitgud Background Some time ago I ...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
axelson
Decided against including more info in the title, but the gist is that Plataformatec sponsored projects will continue with the assets bei...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement