Git Product home page Git Product logo

nerves_examples's Introduction

Nerves Examples

CircleCI

Setup

Please see the main Nerves installation docs if you haven't used Nerves before.

Nerves can work with quite a few Elixir and Erlang versions, but we recommend using the following versions for the examples. These are used on our CI and should be easier for us to support.

  • Elixir 1.16.2 or later
  • Erlang OTP 26.2.5 or later

See the EmbeddedElixir post on using ASDF-VM

This repository contains several Nerves example projects as sub-directories. Most of these projects should work on all of the Nerves supported targets.

For detailed information on how to build an example, see the README.md in each application's root directory.

Other examples

The Nerves community has additional projects that may be useful. Here are a few:

Support

If you are having trouble, let us know. The Nerves community can be found on Elixir Forum and the #nerves channel on the Elixir Slack.

nerves_examples's People

Contributors

alfert avatar allenwyma avatar angrycandy avatar artob avatar connorrigby avatar deanchouinard avatar dependabot[bot] avatar fhunleth avatar gballet avatar ghitchens avatar gregmefford avatar ityonemo avatar jimjsong avatar jjcarstens avatar kelfink avatar lmarlow avatar mattjg908 avatar mattludwigs avatar mnishiguchi avatar mobileoverlord avatar paulanthonywilson avatar pdgonzalez872 avatar pkinney avatar raksonibs avatar ramortegui avatar ream88 avatar ringlej avatar segeda avatar theendisnear avatar ulve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nerves_examples's Issues

The case for poncho project doesn't seem to apply anymore

Environment

  • Elixir version (elixir -v):
  • Nerves environment: (mix nerves.env --info)
  • Additional information about your host, target hardware or environment that
    may help

Current behavior

From the post:

By default, umbrella projects have the following in their top-level config/config.exs file:

import_config "../apps/*/config/config.exs"

But when creating an umbrella project, I don't have distinct config files per app, instead this is added into each app's mix.exs:

config_path: "../../config/config.exs",

I suppose the post refers to an old mix behavior, which no longer applies.

Expected behavior

Given umbrella apps seem to have closed the gap of configuration, I would like to see an example nerves project using umbrella instead of poncho.

Config file in hello_phoenix is missing

If I build and burn as per instructions in the hello_phoenix project the device will not accept any connections. My guess is that there should be ui-config in the fw-project in the hello_phoenix project (there is in the examplex on the nerve-project page).

I made a solution that works and it's in PR #24

Add Erlang example

There's a misconception that you can't use Erlang with Nerves. While our tooling and APIs are Elixir, there's a ton that you can still do in pure Erlang so it would be nice to point to an example.

Update examples to match Nerves new project generator

There are a few minor updates in the latest new project generator that should be reflected in the examples:

  1. The Nerves integration was simplified to remove the bootstrap mix.exs alias and add a line to the the config.exs
  2. The vm.args were updated to turn off Erlang's busy wait
  3. Various dependency specs in the mix.exs were bumped

hello_phoenix compile fails

Hey guys, I've tried to nail down the issue, but I can't really find, where it goes wrong.
Right after

|==================================================| 100% (105 / 105) MB
|Elixir.Nerves.Package.Providers.HTTP| Artifact nerves_system_rpi3-0.11.0.arm_unknown_linux_gnueabihf.tar.gz Downloaded

|Elixir.Nerves.Package.Providers.HTTP| Unpacking nerves_system_rpi3-0.11.0.arm_unknown_linux_gnueabihf.tar.gz
  To Destination:
    /home/melix/projects/tmp/nerves-examples/hello_phoenix/deps/nerves_system_rpi3/.nerves/artifacts/nerves_system_rpi3-0.11.0.arm_unknown_linux_gnueabihf

the compiler fails.

** (FunctionClauseError) no function clause matching in Nerves.System.BR.bootstrap/1
    lib/mix/tasks/nerves/loadpaths.ex:16: Mix.Tasks.Nerves.Loadpaths.run/1
    (mix) lib/mix/task.ex:300: Mix.Task.run_task/3
    (nerves) lib/mix/tasks/firmware.ex:21: Mix.Tasks.Firmware.run/1
    (mix) lib/mix/task.ex:300: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2

I've tried already updating packages to:

  def project do
    [app: :fw,
     version: "0.1.0",
     elixir: "~> 1.4.0",
     target: @target,
     archives: [nerves_bootstrap: "~> 0.3.1"],
     deps_path: "../../deps/#{@target}",
     build_path: "../../_build/#{@target}",
     lockfile: "../../mix.lock",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     aliases: aliases(@target),
     deps: deps()]
  end

  def deps do
    [{:nerves, "~> 0.5.2", runtime: false},
    ] ++
    deps(@target)
  end

  # Specify target specific dependencies
  def deps("host"), do: []
  def deps(target) do
    [{:nerves_runtime, "~> 0.1.2"},
     {:"nerves_system_#{target}", "~> 0.12.0", runtime: false},
     {:nerves_networking, "~> 0.6.0"},
     {:nerves_interim_wifi, "~> 0.2.0"},
     {:ui, in_umbrella: true}]
  end

with no luck. Maybe you will see the problem directly and can give me an advice, how to fix it.

neopixel doesnt address 1 pixel per 4 pixel device tested on 7,8,12 neopixel

I just received new 7,8,12 pixel neopixels and a new RPI3. After building the neopixel example fresh with updated packages I found that whether I use Nerves.Neopixel.render or Nerves.Neopixel.Animate.pulse or Nerves.Neopixel.Animate.spinner, it doesn't address (devicePixels/4). The un-activated pixels are in a row and judging by the position of the IN_wire on the 8stick and 12ring I suspect they're the highest addresses in the chain.

my config.exs is:
config :neopixel, :channel0, pin:18, count:12 or 7,8 depending on the device attached.

The example also doesn't work for me when I try to use the example's workers I have to trigger via Iex but that's an issue after the fact and probably on me.

Add OSD32MP1 to example targets

The OSD32MP1 is now an official target, so support should be added to all of the mix.exs files to use it. It should also be added to CI.

Phoenix Jason library configuration for Phoenix 1.4.3 with nerves

I am building Nerves-Phoenix app and following ‘hello-phoenix’ from ‘nerves_examples’ repository as a reference.

I am using ‘poncho project structure’ as suggested in ‘User Interfaces’ documentation for the ‘Nerves’ project. So I have two projects - ui (Phoenix project) and firmware (nerves project).

When I build the firmware app with ‘mix firmware’ I get warning compiling ‘phoenix' and compilation of ‘ui’ aborts with the following error:


==> phoenix
Compiling 67 files (.ex)
Generated phoenix app
warning: failed to load Jason for Phoenix JSON encoding
(module Jason is not available).

Ensure Jason exists in your deps in mix.exs,
and you have configured Phoenix to use it for JSON encoding by
verifying the following exists in your config/config.exs:

    config :phoenix, :json_library, Jason

  (phoenix) lib/phoenix.ex:40: Phoenix.start/2
  (kernel) application_master.erl:277: :application_master.start_it_old/4

==> ui
Compiling 12 files (.ex)

== Compilation error in file lib/ui_web/endpoint.ex ==
** (ArgumentError) invalid :json_decoder option. The module Poison is not loaded and could not be found

The :json_library configuration for :phoenix app does exist in ui project (ui/config/config.exs) and I have a dependency to ‘ui’ project from ‘firmware’ project.

I fixed the problem by adding following configuration for :phoenix in ‘firmware’ project (in addition to the similar configuration in 'ui' project) and the build was successful.

firmware/config/config.exs

config :phoenix, :json_library, Jason

I use Phoenix 1.4.3 and Nerves 1.4.2. I see the example (hello-phoenix) uses Phoenix 1.3.3.

Is my fix for Phoenix 1.4 correct or am I missing something?

Fix the `hello_network` docs about how to use WiFi

It seems that when we added nerves_init_gadget to the hello_network example, it made things more confusing about how to use WiFi instead of USB gadget Ethernet because now that's handled by nerves_init_gadget instead of the actual hello_network code.

Go through the process and get it working, then update the config.exs and README.md to make it more obvious for people to end up in the right place.

no case clause matching: :eacces

Elixir 1.3.4
following the instructions in the README file

craigc@samantha:~/Projects/nerves-examples/blinky$ git pull
Already up-to-date.
craigc@samantha:~/Projects/nerves-examples/blinky$ mix deps.get
Running dependency resolution
Dependency resolution completed
  bbmustache: 1.0.4
  cf: 0.2.2
  erlware_commons: 0.22.0
  exrm: 1.0.8
  getopt: 0.8.2
  nerves: 0.3.4
  nerves_leds: 0.7.0
  nerves_system: 0.1.6
  nerves_system_br: 0.7.0
  nerves_system_rpi: 0.7.0
  nerves_toolchain: 0.7.1
  nerves_toolchain_armv6_rpi_linux_gnueabi: 0.7.2
  nerves_toolchain_ctng: 0.7.1
  providers: 1.6.0
  relx: 3.22.0
All dependencies up to date
craigc@samantha:~/Projects/nerves-examples/blinky$ mix firmware
Compiling 1 file (.ex)
Generated blinky app
Building release with MIX_ENV=dev.

You have dependencies (direct/transitive) which are not in :applications!
The following apps should be added to :applications in mix.exs:

        nerves_system_rpi -> nerves_system                                                     => nerves_system is missing from nerves_system_rpi
        nerves_system_rpi -> nerves_system_br                                                  => nerves_system_br is missing from nerves_system_rpi
        nerves_system_rpi -> nerves_toolchain_armv6_rpi_linux_gnueabi -> nerves_toolchain      => nerves_toolchain is missing from nerves_toolchain_armv6_rpi_linux_gnueabi
        nerves_system_rpi -> nerves_toolchain_armv6_rpi_linux_gnueabi -> nerves_toolchain_ctng => nerves_toolchain_ctng is missing from nerves_toolchain_armv6_rpi_linux_gnueabi
        nerves                                                                                 => nerves is missing from blinky

==> Modifying release for Nerves System rpi
** (CaseClauseError) no case clause matching: :eacces
    lib/exrm/utils/utils.ex:110: ReleaseManager.Utils.relx/5
    lib/mix/tasks/release.ex:339: anonymous fn/4 in Mix.Tasks.Release.do_release/1
    lib/ex_unit/capture_io.ex:146: ExUnit.CaptureIO.do_capture_io/2
    lib/ex_unit/capture_io.ex:119: ExUnit.CaptureIO.do_capture_io/3
    lib/mix/tasks/release.ex:338: Mix.Tasks.Release.do_release/1
    lib/mix/tasks/release.ex:78: Mix.Tasks.Release.do_run/1
    (mix) lib/mix/task.ex:296: Mix.Task.run_task/3
    lib/mix/tasks/firmware.ex:27: Mix.Tasks.Firmware.run/1

It looks like a permissions error, but on what?

elixir_ale example

Is there any interest for an example using elixir_ale. If so I would be happy to make a pull request, something simple like controlling a stepper motor perhaps or just a led connected to gpio.

Raspberry pi zero w hangs on boot for multiple projects

Environment

  • Elixir version (elixir -v):
    Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.10.3 (compiled with Erlang/OTP 22)

  • Nerves environment: (mix nerves.env --info)
    mix

|nerves_bootstrap| Environment Package List

Pkg: nerves_system_br
Vsn: 1.12.0
Type: system_platform
BuildRunner: {nil, []}

Pkg: nerves_system_rpi0
Vsn: 1.12.1
Type: system
BuildRunner: {Nerves.Artifact.BuildRunners.Docker, []}

Pkg: nerves_toolchain_armv6_rpi_linux_gnueabi
Vsn: 1.3.2
Type: toolchain
BuildRunner: {Nerves.Artifact.BuildRunners.Local, []}

Pkg: nerves_toolchain_ctng
Vsn: 1.7.2
Type: toolchain_platform
BuildRunner: {nil, []}

|nerves_bootstrap| Loadpaths Start

Nerves environment
MIX_TARGET: rpi0
MIX_ENV: dev

|nerves_bootstrap| Environment Variable List
target: rpi0
toolchain: /Users/jsong10/.nerves/artifacts/nerves_toolchain_armv6_rpi_linux_gnueabi-darwin_x86_64-1.3.2
system: /Users/jsong10/.nerves/artifacts/nerves_system_rpi0-portable-1.12.1
app: /Users/jsong10/Projects/elixir/2_nerves_examples/blinky

|nerves_bootstrap| Loadpaths End

  • Additional information about your host, target hardware or environment that
    may help
    running macosx 10.15.5

Current behavior

Single Raspberry shows up when pi zero is powered on. underscore blinking curse is underneath and stays that way.

The same projects work fine for raspi4b. Same sd card. When using export MIX_TARGET=rpi0, the projects don't work.

Raspberrian OS can be put on the sd card and the raspberry pi boots into linux with no issues.

modifying /etc/erlinit.config

Putting this here since it's the repo closest to what I've been doing in, e.g., developing this PR: nerves-project-attic/nerves_system_qemu_arm#3

I'm aiming to soon run dozens of nerves instances under QEMU on a single machine, and the way that works right now one ends up with dozens of SDL windows displaying the console framebuffer. When nerves starts up, it mentions that the elixir shell can be started on a different tty (ttyAMA0 vs tty1), which would allow me to add something like -nographic to my QEMU command to dispose of the framebuffers entirely.

It would be nice if in these example projects (which l imagine eventually become part of a system development kit) we could do things like alter or overlay the /etc/erlinit.conf that gets baked into the firmware image. The rootfs-additions capability doesn't reach down to here yet.

Seems-Related: nerves-project/nerves#25

Simplify and make WiFi configuration consistent between examples

Currently some examples allow you to hardcode WiFi credentials in firmware by setting environment variables. This isn't supported by all examples and its implementation is inconsistent. I would be nice if there were common instructions for setting up WiFi and that every example that could use WiFi would be done the same way.

hello_network fresh build console stuck on the error

elixir version - Elixir 1.6.6 (compiled with OTP 19)

|nerves_bootstrap| Environment Package List

Pkg: nerves_system_br
Vsn: 1.4.1
Type: system_platform
BuildRunner: nil

Pkg: nerves_system_rpi0
Vsn: 1.3.0
Type: system
BuildRunner: {Nerves.Artifact.BuildRunners.Local, []}

Pkg: nerves_toolchain_armv6_rpi_linux_gnueabi
Vsn: 1.1.0
Type: toolchain
BuildRunner: {Nerves.Artifact.BuildRunners.Local, []}

Pkg: nerves_toolchain_ctng
Vsn: 1.5.0
Type: toolchain_platform
BuildRunner: nil

|nerves_bootstrap| Loadpaths Start

Nerves environment
MIX_TARGET: rpi0
MIX_ENV: dev

|nerves_bootstrap| Environment Variable List
target: rpi0
toolchain: /home/ganesh/.nerves/artifacts/nerves_toolchain_armv6_rpi_linux_gnueabi-linux_x86_64-1.1.0
system: /home/ganesh/.nerves/artifacts/nerves_system_rpi0-portable-1.3.0
app: /home/ganesh/notes/nerves_examples/hello_network

|nerves_bootstrap| Loadpaths End`

After burning new hello_network firmware on rpi0 console is stuck here

IPv6 ADDRCONF(NETDEV_CHANGE) wlan0: link becomes ready

And Keyboard doesnt works

Unable to get "hello_wifi" working

Environment

Elixir version 1.9.1
Nerves environment
MIX_TARGET: rpi0
MIX_ENV: dev

Current behavior

I have cloned the repo, set MIX_TARGET to rpi0, and ran deps.get, firmware, and firmware.burn successfully.

When I attempt to visit http://192.168.0.1/ via Chrome a connection is never completed.

I tried to ssh into nerves.local and have run RingLogger.attach, and here are pieces that may be relevant:

00:00:00.029 [debug] VintageNet(usb0): :configured -> internal configure                                                                                
                                                                                                                                                        
00:00:00.034 [info]  RTC (NervesTime.FileTime) reports that the time is ~N[2020-02-19 00:00:00]                                                         
                                                                                                                                                        
00:00:00.040 [warn]  ntpd crash detected. Delaying next start...                                                                                        
                                                                                                                                                        
00:00:00.137 [info]  VintageNet(wlan0): loading config failed: :enoent                                                                                  
                                                                                                                                                        
00:00:00.137 [info]  VintageNet(wlan0): starting with default config (:no_config)  

I have also tried connecting via power to the host (and not usb), but still got the same behavior.

I am very much new to elixir, nerves, and developing embedded programs. please advise, thank you!!

Expected behavior

Access VintageNet Wizard UI via http://192.168.0.1/ on the browser.

hello_network wireless issue

I couldn’t get HelloNetwork working with wireless until I adjusted Nerves.Network.setup to use the settings from :nerves_network :wlan0 in config.exs.

I’m using an rpi3.

hello_phoenix does not compile the UI in host mode

Thank you for the Nerves project, and for these fantastic examples!

Overview

The hello_phoenix example currently does not work in host mode because the firmware's local path dependency on ui only uses it for targets. Moreover, the config in the firmware project does not work in host mode against the ui dependency. The result is that the ui Phoenix app is unavailable to the firmware app in host mode, which prevents firmware-ui interactions in local dev or automated testing.

Suggested fix (PR forthcoming):

  • allow the ui dep to be compiled in host mode as well as for all targets
  • correctly configuring the ui app in host mode
  • add simple code and smoke test to the firmware test suite to verify that ui is available in host mode

Environment

  • Elixir version (elixir -v):
Erlang/OTP 25 [erts-13.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Elixir 1.13.4 (compiled with Erlang/OTP 25)
  • Nerves environment: (mix nerves.env --info)
==> firmware
|nerves_bootstrap| Environment Package List

  No packages found
|nerves_bootstrap| Loadpaths Start

|nerves_bootstrap| Precompile Start

|nerves_bootstrap| Precompile End


Nerves environment
  MIX_TARGET:   host
  MIX_ENV:      dev

NERVES_SYSTEM is unset
NERVES_TOOLCHAIN is unset
|nerves_bootstrap| Environment Variable List
  target:     host
  toolchain:  unset
  system:     unset
  app:        .

|nerves_bootstrap| Loadpaths End
  • Additional information about your host, target hardware or environment that
    may help
    • Running in host mode on macOS 12.5.1

Current behavior

Include errors, stacktraces, screenshots or code that may help us reproduce the
issue.

  1. Clone the repo and check out the main branch
  2. Follow the initial setup directions for the hello_phoenix example, through step 4. Stop before step 5 and the following steps, which are target-specific.
  3. cd into hello_phoenix/firmware
  4. MIX_ENV=host mix deps.get
  5. MIX_ENV=host iex -S mix
You have configured application :ui in your configuration file,
but the application is not available.

This usually means one of:

  1. You have not added the application as a dependency in a mix.exs file.

  2. You are configuring an application that does not really exist.

Please ensure :ui exists or remove the configuration.
  1. iex(1)> Ui.Accounts.list_users()
** (UndefinedFunctionError) function Ui.Accounts.list_users/0 is undefined (module Ui.Accounts is not available)
    Ui.Accounts.list_users()

Expected behavior

  1. Step 5 should not produce the above warning (i.e. the :ui application should be available in the firmware context`)
  2. Step 6 should return an empty list [], with no errors.

What *exactly* is "firmware"?

This looks like a really cool project -- I'm just curious how that all actually works.

This repo says Nerves will create a bootable SD card that will work for a Raspberry Pi (no Raspian OS) and a handful of other boards -- how is this possible? How does nerves talk to the LEDs? Is there a common way of interacting with I/O in "firmware-land" or is there low-level raspberry pi documentation that I've never seen.

Thanks

Chet

Move neopixel example out?

How do people feel about moving the Neopixel example out of this project? It's the one project in here that requires additional hardware beyond a BBB or RPi, and it only runs on one platform. It also seems like the example would be easier to maintain if it were included in the nerves_neopixel project.

does not blink on my bbb

Hello i did
bake system get --target bbb
bake toolchain get --target bbb
bake firmware --target bbb
bake burn --target bbb

the files were created in my sdcard

i put it inside the bbb and boot it.

No blinking leds and no hdmi output...

can you help??

rpi3 firmware builds fail on x86_64 macOS

Environment

  • Elixir version (elixir -v):
Erlang/OTP 26 [erts-14.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]

Elixir 1.16.0 (compiled with Erlang/OTP 26)
  • Nerves environment: (mix nerves.env --info)
==> nerves
==> blinky

Nerves environment
  MIX_TARGET:   rpi3
  MIX_ENV:      dev

Current behavior

mix firmware attempts to use a binary of the wrong architecture.
The command works as intended in older releases, e.g. 1.24.0.
Error log:


* [Nerves] validating vm.args
* using config/runtime.exs to configure the release at runtime
* creating _build/rpi3_dev/rel/hello_live_view/releases/0.1.0/vm.args
Updating base firmware image with Erlang release...
scrub-otp-release.sh: ERROR: Unexpected executable format for '/****/_build/rpi3_dev/_nerves-tmp/rootfs_overlay/srv/erlang/lib/file_system-0.2.10/priv/mac_listener'

Got:
 file:Mach-O 64-bit executable x86_64

Expecting:
 readelf:ARM;0x5000400, Version5 EABI, hard-float ABI

This file was compiled for the host or a different target and probably
will not work.

Expected behavior

A new firmware is built.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.