Skip to content

Instantly share code, notes, and snippets.

@fpauser
Created May 22, 2017 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fpauser/e10f74585bde229a00027d67ccbd0222 to your computer and use it in GitHub Desktop.
Save fpauser/e10f74585bde229a00027d67ccbd0222 to your computer and use it in GitHub Desktop.
Nerves app
fpauser@2183NB223:~/dev/elixir$ mix new nerves_test --umbrella
* creating .gitignore
* creating README.md
* creating mix.exs
* creating apps
* creating config
* creating config/config.exs
Your umbrella project was created successfully.
Inside your project, you will find an apps/ directory
where you can create and host many apps:
cd nerves_test
cd apps
mix new my_app
Commands like "mix compile" and "mix test" when executed
in the umbrella project root will automatically run
for each application in the apps/ directory.
fpauser@2183NB223:~/dev/elixir$ cd nerves_test/
fpauser@2183NB223:~/dev/elixir/nerves_test$ mix local.hex
Found existing archive: /home/fpauser/.asdf/installs/elixir/1.4.4/.mix/archives/hex-0.16.0.
Are you sure you want to replace it with "https://repo.hex.pm/installs/1.4.0/hex-0.16.0.ez"? [Yn]
* creating /home/fpauser/.asdf/installs/elixir/1.4.4/.mix/archives/hex-0.16.0
fpauser@2183NB223:~/dev/elixir/nerves_test$ mix local.rebar
* creating /home/fpauser/.asdf/installs/elixir/1.4.4/.mix/rebar
* creating /home/fpauser/.asdf/installs/elixir/1.4.4/.mix/rebar3
fpauser@2183NB223:~/dev/elixir/nerves_test$ mix archive.install https://github.com/nerves-project/archives/raw/master/nerves_bootstrap.ez
Are you sure you want to install archive "https://github.com/nerves-project/archives/raw/master/nerves_bootstrap.ez"? [Yn] Y
* creating /home/fpauser/.asdf/installs/elixir/1.4.4/.mix/archives/nerves_bootstrap
fpauser@2183NB223:~/dev/elixir/nerves_test$ mix local.nerves
Found existing archive: /home/fpauser/.asdf/installs/elixir/1.4.4/.mix/archives/nerves_bootstrap.
Are you sure you want to replace it with "https://github.com/nerves-project/archives/raw/master/nerves_bootstrap.ez"? [Yn] Y
* creating /home/fpauser/.asdf/installs/elixir/1.4.4/.mix/archives/nerves_bootstrap
fpauser@2183NB223:~/dev/elixir/nerves_test$ cd apps/
fpauser@2183NB223:~/.../nerves_test/apps$ mix nerves.new fw
* creating fw/config/config.exs
* creating fw/lib/fw.ex
* creating fw/lib/fw/application.ex
* creating fw/test/test_helper.exs
* creating fw/test/fw_test.exs
* creating fw/rel/vm.args
* creating fw/.gitignore
* creating fw/mix.exs
* creating fw/README.md
Fetch and install dependencies? [Yn] Y
* running mix deps.get
* running mix nerves.release.init
Your Nerves project was created successfully.
You should now pick a target. See https://hexdocs.pm/nerves/targets.html#content
for supported targets. If your target is on the list, set `MIX_TARGET`
to its tag name:
For example, for the Raspberry Pi 3 you can either
$ export MIX_TARGET=rpi3
Or prefix `mix` commands like the following:
$ MIX_TARGET=rpi3 mix firmware
If you will be using a custom system, update the `mix.exs`
dependencies to point to desired system's package.
Now download the dependencies and build a firmware archive:
$ cd fw
$ mix deps.get
$ mix firmware
If your target boots up using an SDCard (like the Raspberry Pi 3),
then insert an SDCard into a reader on your computer and run:
$ mix firmware.burn
Plug the SDCard into the target and power it up. See target documentation
above for more information and other targets.
fpauser@2183NB223:~/.../nerves_test/apps$ cd fw
fpauser@2183NB223:~/.../apps/fw$ export MIX_TARGET=rpi3
fpauser@2183NB223:~/.../apps/fw$ mix deps.get
Mix environment
MIX_TARGET: rpi3
MIX_ENV: dev
Running dependency resolution...
Dependency resolution completed:
distillery 1.4.0
elixir_make 0.4.0
gen_stage 0.11.0
nerves 0.5.2
nerves_runtime 0.1.2
nerves_system_br 0.10.1
nerves_system_rpi3 0.12.0
nerves_toolchain_arm_unknown_linux_gnueabihf 0.10.0
nerves_toolchain_ctng 0.9.0
* Getting nerves (Hex package)
Checking package (https://repo.hex.pm/tarballs/nerves-0.5.2.tar)
Using locally cached package
* Getting nerves_runtime (Hex package)
Checking package (https://repo.hex.pm/tarballs/nerves_runtime-0.1.2.tar)
Using locally cached package
* Getting nerves_system_rpi3 (Hex package)
Checking package (https://repo.hex.pm/tarballs/nerves_system_rpi3-0.12.0.tar)
Using locally cached package
* Getting nerves_system_br (Hex package)
Checking package (https://repo.hex.pm/tarballs/nerves_system_br-0.10.1.tar)
Using locally cached package
* Getting nerves_toolchain_arm_unknown_linux_gnueabihf (Hex package)
Checking package (https://repo.hex.pm/tarballs/nerves_toolchain_arm_unknown_linux_gnueabihf-0.10.0.tar)
Using locally cached package
* Getting nerves_toolchain_ctng (Hex package)
Checking package (https://repo.hex.pm/tarballs/nerves_toolchain_ctng-0.9.0.tar)
Using locally cached package
* Getting elixir_make (Hex package)
Checking package (https://repo.hex.pm/tarballs/elixir_make-0.4.0.tar)
Using locally cached package
* Getting gen_stage (Hex package)
Checking package (https://repo.hex.pm/tarballs/gen_stage-0.11.0.tar)
Using locally cached package
* Getting distillery (Hex package)
Checking package (https://repo.hex.pm/tarballs/distillery-1.4.0.tar)
Using locally cached package
fpauser@2183NB223:~/.../apps/fw$ mix nerves.release init
Mix environment
MIX_TARGET: rpi3
MIX_ENV: dev
==> distillery
Compiling 18 files (.ex)
Generated distillery app
==> nerves
Compiling 26 files (.ex)
Generated nerves app
==> nerves_system_br
Generated nerves_system_br app
==> nerves_toolchain_ctng
Compiling 2 files (.ex)
Generated nerves_toolchain_ctng app
==> nerves_toolchain_arm_unknown_linux_gnueabihf
Compiling 1 file (.ex)
Generated nerves_toolchain_arm_unknown_linux_gnueabihf app
==> nerves_system_rpi3
Generated nerves_system_rpi3 app
==> gen_stage
Compiling 7 files (.ex)
Generated gen_stage app
==> elixir_make
Compiling 1 file (.ex)
Generated elixir_make app
==> nerves_runtime
/home/fpauser/.nerves/artifacts/nerves_toolchain_arm_unknown_linux_gnueabihf-0.10.0.linux-x86_64/bin/arm-unknown-linux-gnueabihf-gcc -c -I/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging/usr/lib/erlang/erts-8.3/include -I/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging/usr/lib/erlang/lib/erl_interface-3.9.3/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -pipe -Os -I/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging/usr/include -std=gnu99 -o src/uevent.o src/uevent.c
/home/fpauser/.nerves/artifacts/nerves_toolchain_arm_unknown_linux_gnueabihf-0.10.0.linux-x86_64/bin/arm-unknown-linux-gnueabihf-gcc -c -I/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging/usr/lib/erlang/erts-8.3/include -I/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging/usr/lib/erlang/lib/erl_interface-3.9.3/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -pipe -Os -I/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging/usr/include -std=gnu99 -o src/erlcmd.o src/erlcmd.c
/home/fpauser/.nerves/artifacts/nerves_toolchain_arm_unknown_linux_gnueabihf-0.10.0.linux-x86_64/bin/arm-unknown-linux-gnueabihf-gcc src/uevent.o src/erlcmd.o -L/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging/usr/lib/erlang/erts-8.3/lib -L/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging/usr/lib/erlang/lib/erl_interface-3.9.3/lib -lerts -lerl_interface -lei --sysroot=/home/fpauser/.nerves/artifacts/nerves_system_rpi3-0.12.0.arm_unknown_linux_gnueabihf/staging -lmnl -o priv/uevent
Compiling 14 files (.ex)
Generated nerves_runtime app
==> fw
Compiling 2 files (.ex)
Generated fw app
** (Mix) The task "nerves.release" could not be found. Did you mean "nerves.release.init"?
fpauser@2183NB223:~/.../apps/fw$ mix nerves.release.init
Mix environment
MIX_TARGET: rpi3
MIX_ENV: dev
An example config file has been placed in rel/config.exs, review it,
make edits as needed/desired, and then run `mix release` to build the release
fpauser@2183NB223:~/.../apps/fw$ less rel/config.exs
fpauser@2183NB223:~/.../apps/fw$ mix firmware
Mix environment
MIX_TARGET: rpi3
MIX_ENV: dev
|nerves_bootstrap| Building OTP Release...
==> Cleaning all releases..
==> Release output directory not found! Nothing to do.
Updating base firmware image with Erlang release...
Parallel mksquashfs: Using 8 processors
Creating 4.0 filesystem on /home/fpauser/dev/elixir/nerves_test/apps/fw/_nerves-tmp/combined.squashfs, block size 131072.
Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
compressed data, compressed metadata, compressed fragments, compressed xattrs
duplicates are removed
Filesystem size 17574.78 Kbytes (17.16 Mbytes)
54.68% of uncompressed filesystem size (32139.69 Kbytes)
Inode table size 11860 bytes (11.58 Kbytes)
21.07% of uncompressed inode table size (56283 bytes)
Directory table size 11650 bytes (11.38 Kbytes)
44.54% of uncompressed directory table size (26157 bytes)
Xattr table size 53 bytes (0.05 Kbytes)
100.00% of uncompressed xattr table size (53 bytes)
Number of duplicate files found 11
Number of inodes 1061
Number of files 803
Number of fragments 121
Number of symbolic links 142
Number of device nodes 1
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 115
Number of ids (unique uids + gids) 3
Number of uids 3
root (0)
unknown (33)
fpauser (1000)
Number of gids 3
root (0)
tape (33)
fpauser (1000)
Building /home/fpauser/dev/elixir/nerves_test/_build/rpi3/dev/nerves/images/fw.fw...
fpauser@2183NB223:~/.../apps/fw$ ls
config lib mix.exs README.md rel test
fpauser@2183NB223:~/.../apps/fw$ ls
config lib mix.exs README.md rel test
fpauser@2183NB223:~/.../apps/fw$ ls -al
insgesamt 36
drwxrwxr-x. 6 fpauser fpauser 4096 22. Mai 17:42 .
drwxrwxr-x. 3 fpauser fpauser 4096 22. Mai 17:40 ..
drwxrwxr-x. 2 fpauser fpauser 4096 22. Mai 17:40 config
-rw-rw-r--. 1 fpauser fpauser 124 22. Mai 17:40 .gitignore
drwxrwxr-x. 3 fpauser fpauser 4096 22. Mai 17:40 lib
-rw-rw-r--. 1 fpauser fpauser 2032 22. Mai 17:40 mix.exs
-rw-rw-r--. 1 fpauser fpauser 1141 22. Mai 17:40 README.md
drwxrwxr-x. 3 fpauser fpauser 4096 22. Mai 17:40 rel
drwxrwxr-x. 2 fpauser fpauser 4096 22. Mai 17:40 test
fpauser@2183NB223:~/.../apps/fw$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment