koleto

koleto

How to deploy file resource on Nerves device?

I am trying to deploy I simple text file on a Nerves BBB device application partition. For this I created custom config/fwup.conf where I add an custom file-resource just below the rootfs.img like this:

file-resource test.txt {
    host-path = "${NERVES_APP}/config/test.txt"
}

The text file is also under config/test.txt
In the task upgrade.b …

on-resource test.txt { fat_write(${ROOTFS_B_PART_OFFSET}, "test.txt") }

When I start ./upload.sh I get fwup message:

 ./upload.sh
Path: ./_build/bbb_dev/nerves/images/hello_nerves.fw
Product: hello_nerves 0.1.0
UUID: 4cc602a0-71dc-5398-5a5c-bf4727494331
Platform: bbb

Uploading to nerves.local...
Running fwup...
fwup: Upgrading partition B
fwup: Can't open file on FAT partition(test.txt): FATFS: There is no valid FAT volume

Is there a way deploy a file or file bundle resource on the application partition?

Most Liked

fhunleth

fhunleth

Co-author of Nerves

Hi Koleto,

There are several ways of putting files on Nerves devices. Here are the compile-time ways:

  1. Add the file to your application’s or library’s priv directory. Then use :code.priv_dir/1 or Application.app_dir/2 to get a path to it. The file will be read-only on the device.
  2. Configure a rootfs_overlay. This lets you put a file in any directory on the root filesystem. It will still be read-only.
  3. Edit the fwup.conf to add a file to the boot partition. Unless you need to modify the bootloader or update kernel device tree overlays, I’d stay away from this. The boot filesystem is small and since your device depends on it to boot up, it’s generally a good idea to leave it be.

I highly recommend sticking with option 1 if you can.

If you need a file to be writable, the recipe is to add code to your app that initializes files or directories under /root. For example, if you have a sqlite database that’s been pre-seeded, you’d add the database file to a priv directory. Then at run time, you’d check if /root/mydb.sqlite3 exists. If not, you’d copy over the pre-seeded one from your priv directory.

When the device is running, you can run sftp to get and put files on the device.

If none of these options works for you, let me know more about the constraints on the files that you have.

koleto

koleto

sftp is working very well I don’t know why I didn’t try this by myself it is probably because I try to use scp but this didn’t work. For my first test evaluation sftp is working perfect…

Thank you Frank!

fhunleth

fhunleth

Co-author of Nerves

The rootfs_overlay can put a file most places, but anything in /tmp won’t be visible since a tmpfs filesystem is mounted there. The other special locations are /proc, /sys, and /dev. /opt should have worked. Of course, using priv directories is still better since it’s namespaced and keeps with Erlang/OTP conventions.

Since it sounds like you’re just making one device, running sftp to copy your current database on /root would be easiest, right? Or could the database magically replicate there if you start CouchDB with an empty database there.

Frank

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement