Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Enhanced Embedded Systems With Nerves

2,213 views

Published on

Nerves defines an entirely new way to build embedded systems with Elixir that could revolutionize an industry. Imagine booting to the BEAM VM in just a few seconds with your Elixir app in control of the entire system. Nerves makes this possible while replacing the traditional plethora of Linux init scripts or systemd configuration files with a toolchain that is delightful to use. The Nerves philosophy is that you already have a powerful, concurrent language to define what the system should do at start-up time: Elixir. Together, we'll explore the principles Nerves uses to create embedded systems that control 3d printers, power unmanned areal vehicles, and more. You'll see first-hand how Nerves can support service discovery, hot code swapping, and collaboration through PubSub messages and mesh networking. Finally, we will explore the Nerves development life-cycle; from running ExTest, to deployment and hot code reloading.
Talk objectives
* Introduce developing embedded systems in Elixir using Nerves
* Explore the Nerves development life-cycle
* Demonstrate autonomous robotics using service discovery and messaging
* Execute tests, create user interfaces with Phoenix, and perform hot code updates
Target audience
Creating devices and systems which enhance our environment is fundamental to our nature. The exploration into creating hardware that runs Elixir is geared toward the maker in all of us. Join us for an exciting demonstration into the creation of enhanced embedded systems with Elixir and Nerves.

Published in: Software

Enhanced Embedded Systems With Nerves

  1. 1. NERVES PROJECT ENHANCED EMBEDDED SYSTEMS
  2. 2. 198019801980
  3. 3. SMALLER! EASIER!
  4. 4. I NEED AN EMBEDDED SYSTEM AND I NEED IT IN 1 WEEK. Element ID
  5. 5. this page intentionally left blank
  6. 6. NERVES LET US CREATE AND DELIVER A PRODUCTION PRODUCT IN 5 DAYS WITHOUT SACRIFICING PERFORMANCE OR RELIABILITY. Element ID
  7. 7. …UNLIKE OTHER EMBEDDED PLATFORMS WE'VE USED, MODIFICATIONS AND FEATURE ENHANCEMENTS ARE GOING TO BE EASY TO DO IN THE FUTURE. Element ID
  8. 8. 2 Web Developers 5 Days
  9. 9. Community elixir-lang slack #nerves Frank Hunleth Justin Schneck Garth Hitchens
  10. 10. NERVES WHAT IS
  11. 11. WHAT IS NERVES FRAMEWORKS PLATFORM TOOLING
  12. 12. WHAT IS NERVES FRAMEWORKS PLATFORM TOOLING nerves_led nerves_networking nerves_uart elixir_ale nerves_io_neopixel nerves_ssdp_server nerves_ssdp_client nerves_hub nerves_system_ag150 nerves_system_alix nerves_system_bbb nerves_system_rpi nerves_system_rpi2 nerves_system_rpi3 nerves_system_br nerves_toolchain nerves_toolchain_… mix tasks • mix nerves.new • mix nerves.loadpaths • mix nerves.precompile • mix firmware • mix firmware.burn utilities • fwup • cell
  13. 13. WHAT IS NERVES SUPPORTED TARGETS TARGET NAME Raspberry Pi B / A+ /B+ / Zero rpi Raspberry Pi 2 rpi2 Raspberry Pi 3 rpi3 BeagleBone Black bbb Alix alix AG150 ag150 Intel Galileo 2 galileo Lego EV3 ev3 QEmu Arm qemu_arm
  14. 14. WHAT IS NERVES LINUX SINGLE BOARD COMPUTERS
  15. 15. SANDBOX GETTING STARTED
  16. 16. THE SANDBOX RASBIAN / DEBIAN LINUX • Update system • Establish network • SSH • Install Erlang (ESL) • Install Elixir • Checkout Blinky • mix run
  17. 17. THE SANDBOX RASBIAN / DEBIAN LINUX
  18. 18. THERE HAS TO BE A BETTER WAY!
  19. 19. NERVES PLATFORM GETTING STARTED
  20. 20. GETTING STARTED - NERVES PLATFORM LETS MAKE THIS EASY # install bake Bakefile… bake system get —target bake toolchain get —target bake firmware bake burn
  21. 21. GETTING STARTED - NERVES PLATFORM LETS MAKE THIS EASY mix deps.get mix firmware mix firmware.burn
  22. 22. GETTING STARTED - NERVES PLATFORM MIXING FIRMWARE YOUR APP ELIXIR C CODE NIF / PORTS
  23. 23. GETTING STARTED - NERVES PLATFORM COMPILING ON YOUR MACHINE YOUR APP ELIXIR C CODE NIF / PORTS MIX BEAM BINARY YOUR APP (ARCH SPECIFIC)
  24. 24. GETTING STARTED - NERVES PLATFORM MIXING FIRMWARE WITH BAKE YOUR APP ELIXIR C CODE NIF / PORTS BAKE MIX YOUR APP (FOR RPI2)
  25. 25. GETTING STARTED - NERVES PLATFORM MIXING FIRMWARE WITH BAKE BAKE MIX YOUR APP (FOR RPI2) TOOLCHAIN SYSTEM rpi2
  26. 26. GETTING STARTED - NERVES PLATFORM MIXING FIRMWARE MIX YOUR APP (FOR RPI2) TOOLCHAIN SYSTEM rpi2 Precompile compile
  27. 27. GETTING STARTED - NERVES PLATFORM TOOLCHAINS TOOLCHAINTOOLCHAIN CONFIG• crosstool ng • for target • host configs • compilers • run on host • compile for target
  28. 28. GETTING STARTED - NERVES PLATFORM TOOLCHAIN CONFIG CT_LOCAL_TARBALLS_DIR="${CT_TOP_DIR}/../dl" CT_SAVE_TARBALLS=y CT_PREFIX_DIR="${CT_TOP_DIR}/../x-tools/${CT_TARGET}" # CT_REMOVE_DOCS is not set CT_LOG_EXTRA=y CT_ARCH_FLOAT_HW=y CT_ARCH_arm=y CT_KERNEL_linux=y CT_KERNEL_V_3_4=y CT_BINUTILS_LINKER_LD_GOLD=y CT_BINUTILS_GOLD_THREADS=y CT_BINUTILS_LD_WRAPPER=y CT_BINUTILS_PLUGINS=y …
  29. 29. GETTING STARTED - NERVES PLATFORM SYSTEMS SYSTEMSYSTEM CONFIG • buildroot • defconfig • rootfs- additions • bootfoles • rootfs • linux kernel
  30. 30. GETTING STARTED - NERVES PLATFORM SYSTEM CONFIG BR2_arm=y BR2_cortex_a7=y BR2_ARM_FPU_NEON_VFPV4=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_PACKAGE_NERVES_CONFIG_APPS="crypto" BR2_PACKAGE_NERVES_CONFIG_EXTRA_MOUNTS="/dev/mmcblk0p3:/root:vfat: BR2_PACKAGE_NERVES_CONFIG_HANG_ON_EXIT=y BR2_PACKAGE_NERVES_CONFIG_UNIQUEID_PROG=""/usr/bin/boardid -b rpi 4"" BR2_PACKAGE_NERVES_CONFIG_HOSTNAME_PATTERN="nerves-%.4s" BR2_PACKAGE_HOST_ERLANG_RELSYNC=y BR2_PACKAGE_HOST_ERLANG_RELX=y BR2_PACKAGE_HOST_FWUP=y …
  31. 31. GETTING STARTED - NERVES PLATFORM MIX LIFECYCLE MIX deps.precompile BOOTSTRAP DEPS phoenix cowboy nerves_system_rpi2 nerves_system_br … nerves.exs config :nerves_system_rpi2, :nerves_env, type: :system, mirrors: [ "https://github.com/nerves-project/ nerves_system_rpi2/releases/download/ v#{version}/nerves_system_rpi2- v#{version}.tar.gz"], build_platform: Nerves.System.Platforms.BR, build_config: [ defconfig: "nerves_defconfig" ] nerves_system
  32. 32. DEPS phoenix cowboy nerves_system_rpi2 nerves_system_br … SYSTEM ENV GETTING STARTED - NERVES PLATFORM MIX LIFECYCLE MIX deps.precompile BOOTSTRAP nerves_system deps.loadpaths BOOTSTRAP nerves_system system toolchain compile NERVES ENV toolchain
  33. 33. GETTING STARTED - NERVES PLATFORM NERVES BOOTSTRAP mix archive.install https://github.com/nerves-project/archives/raw/ master/nerves_bootstrap.ez
  34. 34. GETTING STARTED - NERVES PLATFORM MIX FILE defmodule Blinky.Mixfile do use Mix.Project @target System.get_env("NERVES_TARGET") || “rpi2" … end
  35. 35. GETTING STARTED - NERVES PLATFORM MIX FILE defmodule Blinky.Mixfile do … def project do [app: :blinky, version: "0.1.0", archives: [nerves_bootstrap: "~> 0.1"], target: @target, deps_path: "deps/#{@target}", build_path: "_build/#{@target}", config_path: "config/#{@target}/config.exs", aliases: aliases, deps: deps ++ system(@target)] end end
  36. 36. GETTING STARTED - NERVES PLATFORM MIX FILE defmodule Blinky.Mixfile do … def system("rpi2") do [{:nerves_system_rpi2, “~> 0.4.0”}] end def aliases do ["deps.precompile": ["nerves.precompile", "deps.precompile"], "deps.loadpaths": ["deps.loadpaths", "nerves.loadpaths"]] end end
  37. 37. GETTING STARTED - NERVES PLATFORM MIX FILE defmodule Blinky.Mixfile do … def system("rpi") do [{:nerves_system_rpi, "~> 0.4.0"}] end def system("rpi2") do [{:nerves_system_rpi2, “~> 0.4.0”}] end def system("rpi3") do [{:nerves_system_rpi3, “~> 0.4.0”}] end … end
  38. 38. GETTING STARTED - NERVES PLATFORM CHANGING TARGETS NERVES_TARGET=rpi3 mix deps.get export NERVES_TARGET=rpi3 mix deps.get mix deps.get # @target System.get_env("NERVES_TARGET") || "rpi2"
  39. 39. GETTING STARTED - NERVES PLATFORM MIX FIRMWARE MIX compile YOUR APP (FOR RPI2) … firmware EXRM system erl_libs OTP RELEASE SYSTEM FIRMWARE BUNDLE fwupsquash fs
  40. 40. GETTING STARTED - NERVES PLATFORM MIX FIRMWARE MIX compile YOUR APP (FOR RPI2) … firmware FIRMWARE BUNDLE fwup SD CARD/ FIRMWARE IMAGE fwup firmware.burn
  41. 41. FIRMWARE A GETTING STARTED - NERVES PLATFORM THE RESULT linux erlinit your_app readonly FIRMWARE B linux erlinit your_app BOOT APPDATA read/write EXTRA readonly readonly
  42. 42. FIRMWARE A GETTING STARTED - NERVES PLATFORM THE RESULT linux erlinit your_app readonly FIRMWARE B linux erlinit your_app BOOT APPDATA read/write EXTRA readonly readonly
  43. 43. FIRMWARE A GETTING STARTED - NERVES PLATFORM THE RESULT linux erlinit your_app readonly FIRMWARE B linux erlinit your_app BOOT APPDATA read/write EXTRA readonly readonly frequent non frequent
  44. 44. NERVES FRAMEWORK GETTING STARTED
  45. 45. GETTING STARTED - NERVES FRAMEWORK NETWORKING {:nerves_networking, “~> 0.5.0”} {:ok, _} = Networking.setup :eth0 mode: "static", ip: "10.0.0.5", router: "10.0.0.1", mask: "16", subnet: "255.255.0.0", mode: "static", dns: "8.8.8.8 8.8.4.4", hostname: "myhost"
  46. 46. GETTING STARTED - NERVES FRAMEWORK WIFI {:nerves_wifi, “~> 0.1.0”}
  47. 47. GETTING STARTED - NERVES FRAMEWORK WIFI WPA SUPPLICANT IPINTERFACE DETECTION USB WLAN0 AP CONN CONN EST DHCP Actor Actor Actor Initialization Transitions
  48. 48. GETTING STARTED - NERVES FRAMEWORK INTERACTING WITH HARDWARE {:elixir_ale, “~> 0.4.0”} {:ok, pid} = Gpio.start_link(1, :output) Gpio.write(pid, 1)
  49. 49. USER INTERFACES GETTING STARTED
  50. 50. GETTING STARTED - USER INTERFACES PHOENIX FOR WEB ADMIN your_app_umbrella |- your_app_nerves |- your_app_ui UI CORE
  51. 51. DEV GETTING STARTED - USER INTERFACES UI CORESUPERVISOR STUB STUB STUB STUB PIN PIN PIN PIN
  52. 52. PROD GETTING STARTED - USER INTERFACES UI CORESUPERVISOR STUB STUB STUB STUB PIN PIN PIN PIN
  53. 53. GETTING STARTED - USER INTERFACES
  54. 54. NERVES FIRMWARE ADVANCED
  55. 55. ADVANCED - NERVES FIRMWARE ADDING FILES TO THE ROOT FILE SYSTEM config :nerves, :firmware, rootfs_additions: "config/rpi2/rootfs-additions" rootfs-additions |- etc |- my_utility.conf ROOTFS
  56. 56. ADVANCED - NERVES FIRMWARE ADDING FILES TO THE ROOT FILE SYSTEM config :nerves, :firmware, rootfs_additions: "config/rpi2/rootfs-additions" rootfs-additions |- etc |- my_utility.conf ROOTFS
  57. 57. ADVANCED - NERVES FIRMWARE CHANGING FILES ON ROOT FILESYSTEM config :nerves, :firmware, rootfs_additions: "config/rpi2/rootfs-additions" rootfs-additions |- etc |- erlinit.conf # Uncomment to hang the board rather than rebooting when Erlang exits #--hang-on-exit
  58. 58. ADVANCED - NERVES FIRMWARE CHANGING FILES ON ROOT FILESYSTEM ROOTFS
  59. 59. ADVANCED - NERVES FIRMWARE CHANGING FILES ON ROOT FILESYSTEM ROOTFS
  60. 60. ADVANCED - NERVES FIRMWARE CHANGING FILES ON BOOT PARTITION
  61. 61. ADVANCED - NERVES FIRMWARE CHANGING FILES ON BOOT PARTITION # config/rpi2/config.exs config :nerves, :firmware, fwup_conf: "config/rpi2/fwup.conf", # config/rpi2/fwup.conf file-resource cmdline.txt { host-path = “${NERVES_APP}/config/rpi2/cmdline.txt" } # config/rpi2/cmdline.txt console=tty1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait
  62. 62. ADVANCED - NERVES FIRMWARE CHANGING FIRMWARE PARTITIONS +----------------------------+ | MBR | +----------------------------+ | p0: Boot partition (FAT32) | | zImage, bootcode.bin, | | config.txt, etc. | +----------------------------+ | p1*: Rootfs A (squashfs) | +----------------------------+ | p1*: Rootfs B (squashfs) | +----------------------------+ | p2: Application (FAT32) | +----------------------------+
  63. 63. ADVANCED - NERVES FIRMWARE CHANGING FIRMWARE PARTITIONS # Log partition define(LOG_PART_OFFSET, 1643048) define(LOG_PART_COUNT, 1048576) partition 3 { block-offset = ${LOG_PART_OFFSET} block-count = ${LOG_PART_COUNT} type = 0x83 # Linux }
  64. 64. ADVANCED - NERVES FIRMWARE CONNECTING TO REMOTE NODES
  65. 65. NERVES PROJECT WHATS AHEAD
  66. 66. WHATS AHEAD THE FUTURE-ISH Display / Touch Screen support Network Firmware Update Develop Lifecycle • Always connected target nodes • Target Distributed ExText • Development Kits Easier IO for connecting to arduinos Video camera support Better Docs Tutorials Videos Books
  67. 67. THE REVOLUTION NERVES EMBEDDED SYSTEMS
  68. 68. THE REVOLUTION CHANGE THE WORLD
  69. 69. THE REVOLUTION CHANGE THE WORLD
  70. 70. LETS REWRITE EMBEDDED
  71. 71. THE REVOLUTION @wsmoak
  72. 72. THE REVOLUTION @diptimmo
  73. 73. 2016
  74. 74. 2016
  75. 75. Justin Schneck @mobileoverlord @nervesproject

×