概要
wsl(wsl2じゃない)でnervesやってみる。
qemu(x86_64エミュレータ、ラズパイじゃない)でやってみた。
環境を作り直した。
qemuで起動した。
環境
windows 10
ubuntu 20.04LTS(WSL)
手順
qemuをインストール
qemu-w64-setup-20220831.exe
imageを作る。
$ mix local.hex
Are you sure you want to install "https://builds.hex.pm/installs/1.14.0/hex-2.0.6.ez"? [Yn] y
* creating /home/ore/.asdf/installs/elixir/1.15.7-otp-26/.mix/archives/hex-2.0.6
$ mix local.rebar
* creating /home/ore/.asdf/installs/elixir/1.15.7-otp-26/.mix/elixir/1-15/rebar3
$ mix archive.install hex nerves_bootstrap
Resolving Hex dependencies...
Resolution completed in 0.032s
New:
nerves_bootstrap 1.12.1
* Getting nerves_bootstrap (Hex package)
All dependencies are up to date
Compiling 5 files (.ex)
Generated nerves_bootstrap app
Generated archive "nerves_bootstrap-1.12.1.ez" with MIX_ENV=prod
Are you sure you want to install "nerves_bootstrap-1.12.1.ez"? [Yn] y
* creating /home/ore/.asdf/installs/elixir/1.15.7-otp-26/.mix/archives/nerves_bootstrap-1.12.1
$ mix help | grep nerves
mix local.nerves # Checks for updates to nerves_bootstrap
mix nerves.new # Creates a new Nerves application
$ mix nerves.new hello_nerves
* creating hello_nerves/config/config.exs
* creating hello_nerves/config/host.exs
* creating hello_nerves/config/target.exs
* creating hello_nerves/lib/hello_nerves.ex
* creating hello_nerves/lib/hello_nerves/application.ex
* creating hello_nerves/test/test_helper.exs
* creating hello_nerves/test/hello_nerves_test.exs
* creating hello_nerves/rel/vm.args.eex
* creating hello_nerves/rootfs_overlay/etc/iex.exs
* creating hello_nerves/.gitignore
* creating hello_nerves/.formatter.exs
* creating hello_nerves/mix.exs
* creating hello_nerves/README.md
Fetch and install dependencies? [Yn] y
* running mix deps.get
* running mix format
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 hello_nerves
$ 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 burn
Plug the SDCard into the target and power it up. See target documentation
above for more information and other targets.
$ cd hello_nerves
$ export MIX_TARGET=x86_64
$ mix deps.get
Resolving Hex dependencies...
Resolution completed in 0.206s
Unchanged:
beam_notify 1.1.0
castore 1.0.4
circular_buffer 0.4.1
elixir_make 0.7.7
gen_state_machine 3.0.0
jason 1.4.1
mdns_lite 0.8.8
muontrap 1.3.2
nerves 1.10.4
nerves_logging 0.2.2
nerves_motd 0.1.13
nerves_pack 0.7.0
nerves_runtime 0.13.6
nerves_ssh 0.4.3
nerves_system_bbb 2.19.1
nerves_system_br 1.24.1
nerves_system_grisp2 0.8.1
nerves_system_mangopi_mq_pro 0.6.1
nerves_system_osd32mp1 0.15.1
nerves_system_rpi 1.24.1
nerves_system_rpi0 1.24.1
nerves_system_rpi2 1.24.1
nerves_system_rpi3 1.24.1
nerves_system_rpi3a 1.24.1
nerves_system_rpi4 1.24.1
nerves_system_x86_64 1.24.1
nerves_time 0.4.6
nerves_toolchain_aarch64_nerves_linux_gnu 1.8.0
nerves_toolchain_armv6_nerves_linux_gnueabihf 1.8.0
nerves_toolchain_armv7_nerves_linux_gnueabihf 1.8.0
nerves_toolchain_ctng 1.9.3
nerves_toolchain_riscv64_nerves_linux_gnu 1.8.0
nerves_toolchain_x86_64_nerves_linux_musl 1.8.0
nerves_uevent 0.1.0
one_dhcpd 2.0.2
property_table 0.2.4
ring_logger 0.10.5
shoehorn 0.9.1
ssh_subsystem_fwup 0.6.1
toolshed 0.3.1
uboot_env 1.0.1
vintage_net 0.13.5
vintage_net_direct 0.10.7
vintage_net_ethernet 0.11.2
vintage_net_wifi 0.11.7
All dependencies are up to date
==> jason
Compiling 10 files (.ex)
Generated jason app
==> castore
Compiling 1 file (.ex)
Generated castore app
==> elixir_make
Compiling 6 files (.ex)
Generated elixir_make app
==> nerves
HOST_CC port.o
HOST_LD port
Compiling 50 files (.ex)
Generated nerves app
==> hello_nerves
Nerves environment
MIX_TARGET: x86_64
MIX_ENV: dev
Checking for prebuilt Nerves artifacts...
Found nerves_system_x86_64 in cache
/home/ore/.nerves/artifacts/nerves_system_x86_64-portable-1.24.1
Found nerves_toolchain_x86_64_nerves_linux_musl in cache
/home/ore/.nerves/artifacts/nerves_toolchain_x86_64_nerves_linux_musl-linux_x86_64-1.8.0
$ mix firmware.image
==> nerves
==> nerves_system_br
Generated nerves_system_br app
==> nerves_toolchain_ctng
Compiling 1 file (.ex)
Generated nerves_toolchain_ctng app
==> nerves_toolchain_x86_64_nerves_linux_musl
Generated nerves_toolchain_x86_64_nerves_linux_musl app
==> nerves_system_x86_64
Compiling 1 file (.ex)
Generated nerves_system_x86_64 app
==> hello_nerves
Nerves environment
MIX_TARGET: x86_64
MIX_ENV: dev
==> gen_state_machine
Compiling 3 files (.ex)
Generated gen_state_machine app
==> shoehorn
Compiling 7 files (.ex)
Generated shoehorn app
==> circular_buffer
Compiling 1 file (.ex)
Generated circular_buffer app
==> ring_logger
Compiling 6 files (.ex)
Generated ring_logger app
==> ssh_subsystem_fwup
Compiling 4 files (.ex)
Generated ssh_subsystem_fwup app
==> uboot_env
Compiling 5 files (.ex)
Generated uboot_env app
==> property_table
Compiling 8 files (.ex)
Generated property_table app
==> one_dhcpd
CC arp_set.o
LD arp_set
Compiling 8 files (.ex)
Generated one_dhcpd app
==> muontrap
CC muontrap.o
LD muontrap
Compiling 5 files (.ex)
Generated muontrap app
==> nerves_logging
CC kmsg_tailer.o
LD kmsg_tailer
Compiling 5 files (.ex)
Generated nerves_logging app
==> nerves_uevent
CC uevent.o
LD uevent
Compiling 3 files (.ex)
Generated nerves_uevent app
==> nerves_runtime
Compiling 13 files (.ex)
Generated nerves_runtime app
==> toolshed
Compiling 5 files (.ex)
Generated toolshed app
==> nerves_ssh
Compiling 7 files (.ex)
Generated nerves_ssh app
==> beam_notify
CC beam_notify.o
LD beam_notify
Compiling 1 file (.ex)
Generated beam_notify app
==> vintage_net
CC if_monitor.o
LD if_monitor
Compiling 55 files (.ex)
Generated vintage_net app
==> mdns_lite
Compiling 1 file (.erl)
Compiling 18 files (.ex)
Generated mdns_lite app
==> vintage_net_direct
Compiling 2 files (.ex)
Generated vintage_net_direct app
==> vintage_net_ethernet
Compiling 4 files (.ex)
Generated vintage_net_ethernet app
==> vintage_net_wifi
CC force_ap_scan.o
LD force_ap_scan
CC mesh_mode.o
LD mesh_mode
CC mesh_param.o
LD mesh_param
Compiling 16 files (.ex)
Generated vintage_net_wifi app
==> nerves_time
CC ntpd_script.o
LD ntpd_script
Compiling 9 files (.ex)
Generated nerves_time app
==> nerves_motd
Compiling 3 files (.ex)
Generated nerves_motd app
==> nerves_pack
Compiling 1 file (.ex)
Generated nerves_pack app
==> hello_nerves
Compiling 2 files (.ex)
Generated hello_nerves app
|nerves| Building OTP Release...
* [Nerves] validating vm.args
* skipping runtime configuration (config/runtime.exs not found)
* creating _build/x86_64_dev/rel/hello_nerves/releases/0.1.0/vm.args
Updating base firmware image with Erlang release...
Copying rootfs_overlay: /home/ore/nerves/hello_nerves/_build/x86_64_dev/nerves/rootfs_overlay
Copying rootfs_overlay: /home/ore/nerves/hello_nerves/rootfs_overlay
Building /home/ore/nerves/hello_nerves/_build/x86_64_dev/nerves/images/hello_nerves.fw...
Firmware built successfully! ?
Now you may install it to a MicroSD card using `mix burn` or upload it
to a device with `mix upload` or `mix firmware.gen.script`+`./upload.sh`.
Writing to /home/ore/nerves/hello_nerves/hello_nerves.img...
100% [====================================] 24.72 MB in / 25.26 MB out
Success!
Elapsed time: 5.620 s
qemuで起動。
コマンドプロンプトで実行。
> "C:\Program Files\qemu\qemu-system-x86_64.exe" -drive file="hello_nerves.img",if=virtio,format=raw -net nic,model=virtio -net user,hostfwd=tcp::10022-:22 -serial stdio
写真
以上。