Packages
nerves_system_bbb
2.23.0
2.30.0
2.29.5
2.29.4
2.29.3
2.29.2
2.29.1
2.29.0
2.28.0
2.27.3
2.27.2
2.27.1
2.27.0
2.26.1
2.26.0
2.25.1
2.25.0
2.24.0
2.23.0
2.22.1
2.22.0
2.21.0
2.20.2
2.20.1
2.20.0
2.19.1
2.19.0
2.18.2
2.18.1
2.18.0
2.17.2
2.17.1
2.17.0
2.16.2
2.16.1
2.16.0
2.15.3
2.15.2
2.15.1
2.15.0
retired
2.14.0
2.13.4
2.13.3
2.13.2
2.13.1
2.13.0
2.12.3
2.12.2
2.12.1
2.12.0
2.11.2
2.11.1
2.11.0
2.10.1
2.10.0
2.9.0
2.8.3
2.8.2
2.8.1
2.8.0
2.7.2
2.7.1
2.7.0
2.6.2
2.6.1
2.6.0
2.5.2
2.5.1
2.5.0
2.4.2
2.4.1
2.4.0
2.3.2
2.3.1
2.3.0
2.2.2
2.2.1
2.2.0
2.1.3
2.1.2
2.1.1
2.1.0
2.0.0
2.0.0-rc.0
1.4.0
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
1.0.0-rc.1
1.0.0-rc.0
0.20.0
0.18.0
0.17.1
0.17.0
0.16.1
0.16.0
0.15.0
0.14.0
0.13.0
0.12.0
0.11.0
0.10.0
0.9.0
0.8.0
0.7.1
0.7.0
0.6.2
0.6.1
0.6.0
0.5.0
Nerves System - BeagleBone Black, BeagleBone Green, PocketBeagle and more
Current section
Files
Jump to
Current section
Files
nerves_system_bbb
README.md
README.md
# Generic BeagleBone Support[](https://circleci.com/gh/nerves-project/nerves_system_bbb)[](https://hex.pm/packages/nerves_system_bbb)This is the base Nerves System configuration for the [BeagleBone Black](http://beagleboard.org/black),[BeagleBone Green](http://beagleboard.org/green), [BeagleBone Green Wireless](https://beagleboard.org/green-wireless/),and [PocketBeagle](https://beagleboard.org/pocket).<br><sup>[Image credit](#fritzing)</sup>| Feature | Description || -------------------- | ------------------------------- || CPU | 1 GHz ARM Cortex-A8 || Memory | 512 MB DRAM || Storage | 4 GB eMMC Flash and MicroSD || Linux kernel | 6.6 w/ "ti" patches || IEx terminal | UART `ttyS0` || GPIO, I2C, SPI | Yes - [Elixir Circuits](https://github.com/elixir-circuits) || ADC | Yes || PWM | Yes, but no Elixir support || UART | ttyS0 + more via device tree overlay || Camera | None || Ethernet | Yes || WiFi | Beaglebone Green Wireless (wl18xx driver). Other requires USB WiFi dongle/driver || HW Watchdog | AM335x watchdog enabled on boot. Be sure to enable `heart` in your vm.args or the device will reboot |## UsingThe most common way of using this Nerves System is create a project with `mixnerves.new` and to export `MIX_TARGET=bbb`. See the [Getting startedguide](https://hexdocs.pm/nerves/getting-started.html#creating-a-new-nerves-app)for more information.If you need custom modifications to this system for your device, clone thisrepository and update as described in [Making customsystems](https://hexdocs.pm/nerves/customizing-systems.html).## Preparing your BeagleBoneIf your BeagleBone has eMMC (the PocketBeagle doesn't), it will be configured totry the eMMC first when looking for software on boot. If you haven'treprogrammed it, it will boot to Debian even if a MicroSD card is inserted withgood software. To boot from the MicroSD card, hold down the USER button andapply power.When starting with Nerves, you will find that booting from a MicroSD card isconvenient since you can easily recover from broken software images. Holdingdown the USER button will get old. To force the BeagleBone to boot from theMicroSD card, simply corrupt the image on the eMMC memory. Don't worry, theBeagleBone website has instructions for restoring Debian.From Debian:```bashdebian@beaglebone:~$ sudo dd if=/dev/zero of=/dev/mmcblk0 bs=1M count=100100+0 records in100+0 records out104857600 bytes (105 MB) copied, 5.72098 s, 18.3 MB/sdebian@beaglebone:~$ sudo reboot```When it reboots, it will boot from the MicroSD slot. If a MicroSD card hasn'tbeen inserted or if there are errors reading it, you will see the letter `C`printed repeatedly on the console port.## Console accessThe console is configured to output to the 6 pin header on theBeagleBone that's labeled J1. A 3.3V FTDI cable is needed to access the output.The HDMI output has been disabled via device tree to free up pins on the GPIOheader. If you would like console access via HDMI, you will need to enable HDMIsupport in the Linux kernel, remove the HDMI disable argument in the ubootscript providing kernel arguments, and change `erlinit.conf` to output to`tty1`.## Provisioning devicesThis system supports storing provisioning information in a small key-value storeoutside of any filesystem. Provisioning is an optional step and reasonabledefaults are provided if this is missing.Provisioning information can be queried using the Nerves.Runtime KV store's[`Nerves.Runtime.KV.get/1`](https://hexdocs.pm/nerves_runtime/Nerves.Runtime.KV.html#get/1)function.Keys used by this system are:Key | Example Value | Description:--------------------- | :---------------- | :----------`nerves_serial_number` | `"12345678"` | By default, this string is used to create unique hostnames and Erlang node names. If unset, it defaults to part of the BBB's serial number.The normal procedure would be to set these keys once in manufacturing or beforedeployment and then leave them alone.For example, to provision a serial number on a running device, run the followingand reboot:```elixiriex> cmd("fw_setenv nerves_serial_number 12345678")```This system supports setting the serial number offline. To do this, set the`NERVES_SERIAL_NUMBER` environment variable when burning the firmware. If you'reprogramming MicroSD cards using `fwup`, the commandline is:```shsudo NERVES_SERIAL_NUMBER=12345678 fwup path_to_firmware.fw```Serial numbers are stored on the MicroSD card so if the MicroSD card isreplaced, the serial number will need to be reprogrammed. The numbers are storedin a U-boot environment block. This is a special region that is separate fromthe application partition so reformatting the application partition will notlose the serial number or any other data stored in this block.Additional key value pairs can be provisioned by overriding the defaultprovisioning.conf file location by setting the environment variable`NERVES_PROVISIONING=/path/to/provisioning.conf`. The default provisioning.confwill set the `nerves_serial_number`, if you override the location to this file,you will be responsible for setting this yourself.## Linux and U-Boot versionsThe BeagleBone Black has many options for Linux that vary by kernel version andpatch set. Nerves tracks those maintained by Robert Nelson at[eewiki.net](https://eewiki.net/display/linuxonarm/BeagleBone+Black).Nerves also integrates the BeagleBone Black's U-boot patches to support devicetree overlays. Support mirrors the BeagleBone docs with the exception that toset U-boot environment variables, See the section below for more information.## Device tree overlaysMost pins on the BBB's headers are configurable via a mechanism called thedevice tree. The device tree is made up of device tree files and overlay filesthat get compiled down into one or more `.dtb` or `.dtbo` files. The files tellLinux what drivers to load and what parameters to use for things that it can'tfigure out by itself.There are two strategies for dealing with the device tree:1. Modify the device tree files for an existing board to make your own2. Load device tree overlay filesUpstream BBB encourages the second option since it can be easier. The tradeoffis that if anything goes wrong or your hardware doesn't match their assumptions,it's a little harder to debug.The device tree files are loaded by U-Boot. Nerves installs all of theBeagleboard overlay files to `/lib/firmware` and configures U-Boot to closelymatch upstream. This means that most of the upstream documentation on devicetree is usable. The difference is that instead of using `/boot/uEnv.txt` tocustomize the overlays, you need to set the variables in the U-Boot environmentblock. This can be done by running `cmd("fw_setenv <key> <value>")` from the IExprompt or by adding the variables to the `fwup_include/provisioning.conf` file.For example, at the IEx prompt:```elixircmd("fw_setenv uboot_overlay_addr7 /lib/firmware/BB-UART1-00A0.dtbo")```Or by updating the configuration file:```uboot_setenv(uboot-env, "uboot_overlay_addr7", "/lib/firmware/BB-UART1-00A0.dtbo")```See[elinux.org/Beagleboard:BeagleBoneBlack_Debian](https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_.2Fboot.2FuEnv.txt_configuration)for documentation on the variables.### Universal I/OThe BBB's Universal device tree overlay lets you configure pins at runtime. Thissystem enables the universal overlay by default. See the`enable_uboot_cape_universal` setting in the default `fwup_include/provisioning.conf` file.See[beaglebone-universal-io](https://github.com/cdsteinkuehler/beaglebone-universal-io)for documentation. You'll see references to an RCN-built kernel. RCN is theinitials for Robert Nelson and we use his kernel patches.### ADCsThe following example shows how to read values from the 7 ADC inputs in Elixir.You will first need to load "BB-ADC" device tree overlay using the guide describedabove.```elixiriex(nerves@nerves-0014.local)> ls "/sys/bus/iio/devices/iio:device0"buffer dev in_voltage0_raw in_voltage1_rawin_voltage2_raw in_voltage3_raw in_voltage4_raw in_voltage5_rawin_voltage6_raw name of_node powerscan_elements subsystem ueventiex(nerves@nerves-0014.local)> File.read("/sys/bus/iio/devices/iio:device0/in_voltage0_raw"){:ok, "3891\n"}iex(nerves@nerves-0014.local)> File.read("/sys/bus/iio/devices/iio:device0/in_voltage0_raw"){:ok, "3890\n"}iex(nerves@nerves-0014.local)> File.read("/sys/bus/iio/devices/iio:device0/in_voltage0_raw"){:ok, "3891\n"}```### SPIThe following examples shows how to get SPI0 functional in Elixir.Load the "BB-SPIDEV0" device tree overlay using the guide described above.Verify that the device drivers are loaded and read spi0 transfers:```elixiriex(nerves@nerves-0014.local)> ls "/dev" ... spidev1.0 spidev1.1 spidev2.0 spidev2.1 ...iex(nerves@nerves-0014.local)> File.read "/sys/bus/spi/devices/spi1.0/statistics/transfers"{:ok, "0"}```If you have included [circuits_spi](https://github.com/elixir-circuits/circuits_spi) as adependency, you can start it now and test a transfer:> The example below should work without any additional hardware connected to the> BBB. If you have SPI hardware connected to the BBB, your returned binary might> be different.```elixiriex(nerves@nerves-0014.local)> {:ok, ref} = Circuits.SPI.open("spidev0.0"){:ok, #Reference<...>}iex(nerves@nerves-0014.local)> Circuits.SPI.transfer(ref, <<1,2,3,4>>)<<255, 255, 255, 255>>```> Note: If you get back all 0's, then you have likely have not configured the> overlay pins correctly.## PRUSThe PRUs are controlled via `uio`. Two kernel modules are needed for them to work.```elixiriex> :os.cmd('modprobe uio uio_pruss')iex> ls "/sys/class/uio"uio0 uio1 uio2 uio3 uio4 uio5 uio6 uio7```Check the beaglebone [am335x_pru_package](https://github.com/beagleboard/am335x_pru_package/)repository for samples on how to interface PRUs.## Supported USB WiFi devicesThe base image includes drivers and firmware for the TI WiLink8 (`wl18xx`),Ralink RT53xx (`rt2800usb` driver) and RealTek RTL8712U (`r8712u` driver)devices. All WiFi drivers are compiled as modules. Some drivers can be loadedautomatically. If you have a Beaglebone Green or Beaglebone Black with built-inWiFi, see the next section.We are still working out which subset of all possible WiFi dongles to support inour images. At some point, we may have the option to support all dongles andselectively install modules at packaging time, but until then, these drivers andtheir associated firmware blobs add significantly to Nerves release images.If you are unsure what driver your WiFi dongle requires, run Raspbian andconfigure WiFi for your device. At a shell prompt, run `lsmod` to see whichdrivers are loaded. Running `dmesg` may also give a clue. When using `dmesg`,reinsert the USB dongle to generate new log messages if you don't see them.## BluetoothThe Beaglebone boards with built-in WiFi support use the WiLink8 WL1835 module.This is a combo WiFi/Bluetooth module. Bluetooth is not well supported inNerves. However, Nerves is built on Linux so you can enable and use `bluez`.Another option is to use [harald](https://hex.pm/packages/harald) which cancommunicate with the module using low level Bluetooth HCI commands.The WL1835 requires initialization before first use. This is done via a "BTS"file. The `TIInit_11.8.32.bts` file is included in this system under`lib/firmware/ti-connectivity`. The Bluetooth kernel modules know how to load itautomatically. If you're using `harald`, you will need to load it yourself. Thesource of the "BTS" file is http://www.ti.com/tool/wl18xx-bt-sp.[Image credit](#fritzing): This image is from the [Fritzing](http://fritzing.org/home/) parts library.## NervesKeyUsing NervesKey on an I2C bus requires the bus speed to be lowered. This can bedone using uboot overlays specific to the I2C bus that NervesKey is attachedto. The device tree blob can be found in `/lib/firmware`.Choose one of the following:```textuboot_setenv(uboot-env, "uboot_overlay_addr4", "/lib/firmware/i2c1-clock-frequency-100khz.dtbo")uboot_setenv(uboot-env, "uboot_overlay_addr5", "/lib/firmware/i2c2-clock-frequency-100khz.dtbo")```You can configure your project to enable these device tree overlays by copying the`fwup_include/provisioning.conf` file to your project, updating the file toenable the uboot overlay for your NervesKey i2c bus, and by adding the followingto your Mix Application configuration:```elixirconfig :nerves, :firmware, provisioning: "project/relative/path/to/provisioning.conf"```