umbrella? i think so

pull/216/head
connor rigby 2016-12-18 12:33:59 -08:00
parent 19e6e69bd3
commit 4983cdcf0e
166 changed files with 3898 additions and 449 deletions

26
.gitignore vendored
View File

@ -1,14 +1,26 @@
# App artifacts
# The directory Mix will write compiled artifacts to.
/_build
/db
# If you run "mix test --cover", coverage assets end up here.
/cover
# The directory Mix downloads your dependencies sources to.
/deps
/*.ez
# Nerves images
/_images
# Where 3rd-party dependencies like ExDoc output generated docs.
/doc
# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez
# Web stuffs
npm*
node_modules
bundle.js
# Generate on crash by the VM
erl_crash.dump
npm-debug.log
ttb_last_config
cover

125
README.md
View File

@ -1,125 +1,4 @@
[![Build Status](https://travis-ci.org/FarmBot/farmbot_os.svg?branch=master)](https://travis-ci.org/FarmBot/farmbot_os.svg?branch=master)
# FarmbotOs
# FarmBot Software for the Raspberry Pi 3
The "brains" of Farmbot. Responsible for receiving the commands from [the browser](https://github.com/FarmBot/farmbot-web-frontend) or the [FarmBot API](https://github.com/FarmBot/Farmbot-Web-API). It executes them and reports back the results to any subscribed user(s).
**TODO: Add description**
# First Time Installation
If you are setting up your FarmBot for the first time, download the latest FarmBot OS `.img` file [here](https://github.com/FarmBot/farmbot_os/releases/latest).
## Windows users
* Download [Win32 Disk Imager](https://sourceforge.net/projects/win32diskimager/)
* Select the `.img` file you downloaded
* Select your sdcard's drive letter
* Click `write`
## Linux / OSX / UNIX
* `dd if=img_file of=/dev/sdX`
* where img_file is the path to you `.img` file, and X is your device's drive letter.
## Running
0. Plug your SD Card into your RPi3
0. Plug your Arduino into your RPi3
0. Plug your power into your RPi3
0. From a WiFi enabled device*, search for the SSID `FarmbotConfigurator`
0. Connect to that and open a web browser to [http://192.168.24.1/](http://192.168.24.1)
0. Follow the on screen instructions to configure your FarmBot. Once you save your configuration FarmBot will connect to your home WiFi network and to the FarmBot web application.
\* If you are using a smartphone you may need to disable cellular data to allow your phone's browser to connect to the configurator.
## Updating the firmware
To update the firmware on the Raspberry Pi and the Arduino, simply use the "update" buttons on the web application. There is no need to reinstall the entire OS.
# Issues
Please read through the [FAQ](FAQ.md). If you don't see what you need please by all means open a Github Issue!
# Building / Development (for developers only)
## Technical Stuff
* Written in [Elixir](http://elixir-lang.org/) using [Nerves Project](http://nerves-project.org/).
* Device status info such as X,Y,Z and calibration data is stored on the Data partition Nerves allows.
* Backups to the cloud provided by [Farmbot API](https://github.com/farmbot/farmbot-web-api)
* Messaging happens via [MQTT](https://github.com/farmbot/mqtt-gateway)
## Building
[You need Linux to build Linux.](http://www.whylinuxisbetter.net/). Windows is not supported. Bash for Windows and Cygwin will not work. A VM or dual boot environment will work. So with that rant out of the way, and ready for revision here are the steps to build:
* Install Elixir and Erlang. ([installer script]("https://gist.github.com/ConnorRigby/8a8bffff935d1a43cd74c4b8cf28a845"))
* Install [`Nerves`](https://hexdocs.pm/nerves/installation.html) and all related dependencies.
* clone this repo. `git clone https://github.com/FarmBot/farmbot-raspberry-pi-controller.git`
* `cd farmbot-raspberry-pi-controller`.
* Insert an sdcard into your development machine and run:
```bash
MIX_ENV=prod mix deps.get
MIX_ENV=prod mix firmware
MIX_ENV=prod mix firmware.burn
```
You can also run locally (not on an RPI3- Windows is supported for this):
```bash
export MIX_ENV=dev
rm -rf _deps build _images
mix deps.get
iex -S mix
```
You should only need to do the first two commands once.
## Running Tests
There aren't a lot of tests, but they do exist and can be run by executing the following:
```bash
MIX_ENV=test mix deps.get
mix test --no-start
```
Make sure to have the `--no-start` in there. Otherwise it will try to start the
supervision tree, and tests will be broken and what not.
## Debugging on hardware
The Raspberry Pi will boot up with an Iex console on the hardware UART. If you need to debug something this is the easiest to get too.
If you do not have a 3.3v FTDI cable, you can build the firmware with the console on HDMI.
In the `erlinit.config` file change `-c ttyS0` to `-c ttyS1`. This requires a usb mouse, keyboard and monitor into your pi.
## Development Tips
You can connect IEx to the running pi by running
`iex --name console@localhost --remsh farmbot@<FARMBOT IP ADDRESS> --cookie democookie`.
Debug message still only will print to UART or HDMI (whichever you have configured)
If you frequently build the firmware, removing the sdcard and writing the build every time gets pretty old. You can upload firmware to an already running farmbot one of two ways after you run a successful `mix firmware`
0. You can upload the image to the pi using CURL or similar. `curl -T _images/rpi3/fw.fw "http://$RPI_IP_ADDRESS:8988/firmware" -H "Content-Type: application/x-firmware" -H "X-Reboot: true"`
0. Or you can host the .fw file on your pc using a webserver ie `npm install serve` and download it from the pi.This should be ran ON THE PI ITSELF `Downloader.download_and_install_update("http://<DEV_PC_IP_ADDRESS>/WHEREVER YOUR FILE IS")`
# Building for production
## Major version change
you will have to do one of two things:
0. Do a fresh clone of this repo. (prefered)
0. Clean everything out with something along the lines of `rm -rf _build deps _images rel/fw`
Then follow these steps then follow the steps for a minor version.
```bash
export MIX_ENV=prod
mix deps.get
```
this will generate a .fw file in the images dir. this will be an update file. A raw image file is then generated from this file
## Minor Version
```bash
export MIX_ENV=prod
mix firmware
cd _images/rpi3/
fwup -a -d firmware.img -i fw.fw -t complete
```
These two files should be put into the github release.
If someone would like to write a Mix Task for this it'd be much appreciated.
# Want to Help?
[Low Hanging Fruit](https://github.com/FarmBot/farmbot_os/search?utf8=%E2%9C%93&q=TODO)

17
apps/farmbot_auth/.gitignore vendored 100644
View File

@ -0,0 +1,17 @@
# The directory Mix will write compiled artifacts to.
/_build
# If you run "mix test --cover", coverage assets end up here.
/cover
# The directory Mix downloads your dependencies sources to.
/deps
# Where 3rd-party dependencies like ExDoc output generated docs.
/doc
# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 FarmBot
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,2 @@
# Farmbot.Auth
A helpful module for logging in to Farmbot Web Services.

View File

@ -0,0 +1,7 @@
use Mix.Config
# This app will go through this list of modules calling
# Module.on_token(token)
# When a token is recieved.
# config :farmbot_auth,
# callbacks: []

View File

@ -0,0 +1,111 @@
defmodule Farmbot.Auth do
@moduledoc """
Gets a token and device information
"""
@modules Application.get_env(:farmbot_auth, :callbacks) ++ [Farmbot.Auth]
use Timex
use GenServer
require Logger
@doc """
Application entry point
"""
def start(_type, args) do
Logger.debug("Farmbot.Auth Starting.")
start_link(args)
end
@doc """
Gets the public key from the API
"""
def get_public_key(server) do
case HTTPotion.get("#{server}/api/public_key") do
%HTTPotion.ErrorResponse{message: message} -> {:error, message}
%HTTPotion.Response{body: body,
headers: _headers,
status_code: 200} -> {:ok, RSA.decode_key(body)}
end
end
@doc """
Encrypts the key with the email, pass, and server
"""
def encrypt(email, pass, pub_key) do
f = Poison.encode!(%{"email": email,
"password": pass,
"id": Nerves.Lib.UUID.generate,
"version": 1})
|> RSA.encrypt({:public, pub_key})
|> String.Chars.to_string
{:ok, f}
end
@doc """
Get a token from the server with given token
"""
def get_token_from_server(secret, server) do
# I am not sure why this is done this way other than it works.
payload = Poison.encode!(%{user: %{credentials: :base64.encode_to_string(secret) |> String.Chars.to_string }} )
case HTTPotion.post "#{server}/api/tokens", [body: payload, headers: ["Content-Type": "application/json"]] do
# Any other http error.
%HTTPotion.ErrorResponse{message: reason} -> {:error, reason}
# bad Password
%HTTPotion.Response{body: _, headers: _, status_code: 422} -> {:error, :bad_password}
# Token invalid. Need to try to get a new token here.
%HTTPotion.Response{body: _, headers: _, status_code: 401} -> {:error, :expired_token}
# We won
%HTTPotion.Response{body: body, headers: _headers, status_code: 200} ->
token = Poison.decode!(body) |> Map.get("token")
do_callbacks(token)
{:ok, token}
end
end
@doc """
Gets the token.
Will return a token if one exists, nil if not.
Returns {:error, reason} otherwise
"""
def get_token do
GenServer.call(__MODULE__, {:get_token})
end
# Genserver stuff
def init(_args) do
{:ok, nil}
end
def start_link(args) do
GenServer.start_link(__MODULE__, args, name: __MODULE__ )
end
def handle_call({:get_token}, _from, nil) do
{:reply, nil, nil}
end
def handle_call({:get_token}, _from, token) do
{:reply, {:ok, token}, token}
end
def handle_info({:authorization, token}, _) do
{:noreply, token}
end
def terminate(:normal, state) do
Logger.debug("AUTH DIED: #{inspect {state}}")
end
def terminate(reason, state) do
Logger.error("AUTH DIED: #{inspect {reason, state}}")
end
defp do_callbacks(token) do
spawn(fn ->
Enum.all?(@modules, fn(module) ->
send(module, {:authorization, token})
end)
end)
end
end

View File

@ -0,0 +1,29 @@
defmodule Farmbot.Auth.Mixfile do
use Mix.Project
def project do
[app: :farmbot_auth,
version: "0.1.0",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
deps: deps()]
end
def application do
[mod: {Farmbot.Auth, []},
applications: [:logger, :timex, :httpotion, :rsa, :nerves_lib, :poison]]
end
defp deps do
[{:timex, "~> 3.0"},
{:httpotion, "~> 3.0.0"},
{:rsa, "~> 0.0.1"},
{:nerves_lib, github: "nerves-project/nerves_lib"},
{:poison, "~> 3.0"}]
end
end

View File

@ -0,0 +1,8 @@
defmodule Farmbot.AuthTest do
use ExUnit.Case
doctest Farmbot.Auth
test "the truth" do
assert 1 + 1 == 2
end
end

View File

@ -0,0 +1 @@
ExUnit.start()

View File

@ -0,0 +1,22 @@
# The directory Mix will write compiled artifacts to.
/_build
# If you run "mix test --cover", coverage assets end up here.
/cover
# The directory Mix downloads your dependencies sources to.
/deps
# Where 3rd-party dependencies like ExDoc output generated docs.
/doc
# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez
*.secret*
node_modules
npm*
bundle.js

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 FarmBot
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,2 @@
# Farmbot.Configurator
Configuration application for farmbot_os

View File

@ -0,0 +1 @@
use Mix.Config

View File

@ -0,0 +1,33 @@
defmodule ERM do
use GenEvent
alias Farmbot.Configurator.EventManager, as: EM
require Logger
def start do
GenEvent.add_handler(EM, __MODULE__, [])
end
def stop do
GenEvent.remove_handler(EM, __MODULE__, [])
end
def init(_) do
{:ok, []}
end
def handle_event( {:from_socket, %{"id" => id, "method" => "hey_bot", "params" => []}}, state) do
thing = %{id: id, results: "hey_front_end", error: nil} |> Poison.encode!
Logger.debug thing
EM.send_socket({:from_bot, thing})
{:ok, state}
end
def handle_event({:from_socket, rpc}, state) do
Logger.debug "Got rpc: #{inspect rpc}"
{:ok, state}
end
def handle_event(_,s) do
{:ok, s}
end
end

View File

@ -0,0 +1,75 @@
defmodule Farmbot.Configurator.EventHandler do
@moduledoc """
Handles websocket to bot communication
"""
require Logger
alias Farmbot.Configurator.EventManager, as: EM
# Public api
@doc """
Adds a socket to the handler
"""
def add_socket(socket),
do: GenEvent.call(EM, __MODULE__, {:add_socket, socket})
@doc """
Removes a socket to the handler
"""
def remove_socket(socket),
do: GenEvent.call(EM, __MODULE__, {:remove_socket, socket})
@doc """
Gets all the sockets
"""
def sockets, do: GenEvent.call(EM, __MODULE__, :sockets)
@doc """
Starts the event handler.
"""
def start_link do
Logger.debug ">> a websocket event handler is starting"
GenEvent.add_handler EM, __MODULE__, []
{:ok, self}
end
@doc """
Stops the event handler
"""
def stop_link do
Logger.debug ">> a websocket event handler is stopping"
GenEvent.remove_handler(EM, __MODULE__, [])
end
def init(_args) do
{:ok, []}
end
def handle_event({:from_bot, event}, sockets) do
broadcast(sockets, {:from_bot, event})
{:ok, sockets}
end
# we don't really care about anything else.
def handle_event(_event, sockets), do: {:ok, sockets}
# called from a socket instance
def handle_call({:add_socket, socket}, sockets) do
{:ok, :ok, [socket | sockets]}
end
# called from a socket instance
def handle_call({:remove_socket, socket}, sockets) do
{:ok, :ok, sockets -- [socket]}
end
def handle_call(:sockets, sockets), do: {:ok, sockets, sockets}
def handle_call(_, sockets), do: {:ok, :unhandled, sockets}
def terminate(_,_), do: :ok
# Probably a better way to do this...
defp broadcast(sockets, event) do
Enum.each(sockets, fn(socket) ->
send(socket, event)
end)
end
end

View File

@ -0,0 +1,10 @@
defmodule Farmbot.Configurator.EventManager do
# alias Farmbot.Configurator.EventHandler
def start_link() do
GenEvent.start_link(name: __MODULE__)
end
def send_socket(event) do
GenEvent.notify(__MODULE__, event)
end
end

View File

@ -0,0 +1,36 @@
defmodule Farmbot.Configurator do
use Supervisor
alias Plug.Adapters.Cowboy
alias Farmbot.Configurator.Router
alias Farmbot.Configurator.EventHandler
alias Farmbot.Configurator.EventManager
@port Application.get_env(:configurator, :port, 4000)
@env Mix.env
def init(_) do
children = [
# genevent manager for the handler to connect to.
# worker(GenEvent,
# [[name: EventManager]],
# [id: EventManager]),
worker(EventManager, [], []),
worker(EventHandler, [], []),
Plug.Adapters.Cowboy.child_spec(
:http, Router, [], port: @port, dispatch: dispatch),
worker(WebPack, [@env])
]
opts = [strategy: :one_for_one, name: Farmbot.Configurator]
supervise(children, opts)
end
def start(_type, args), do: Supervisor.start_link(__MODULE__,args)
defp dispatch do
[
{:_, [
{"/ws", Farmbot.Configurator.SocketHandler, []},
{:_, Plug.Adapters.Cowboy.Handler, {Router, []}}
]}
]
end
end

View File

@ -0,0 +1,13 @@
defmodule Mix.Tasks.Compile.Configurator do
use Mix.Task
@moduledoc """
Compiles Configurator JS and HTML
"""
def run(_args) do
# IO.puts "Running `npm install`"
# System.cmd("npm", ["install"])
IO.puts "Building the javascripts"
System.cmd("npm", ["run", "build"])
end
end

View File

@ -0,0 +1,17 @@
defmodule Farmbot.Configurator.Router do
@moduledoc """
Routes incoming connections.
"""
use Plug.Router
plug Plug.Static, at: "/", from: :farmbot_configurator
plug :match
plug :dispatch
match _, do: conn |> send_resp(200, make_html)
def make_html do
"#{:code.priv_dir(:farmbot_configurator)}/static/index.html"
|> File.read!
end
end

View File

@ -0,0 +1,59 @@
defmodule Farmbot.Configurator.SocketHandler do
@moduledoc """
Handles the websocket connection from a browser.
"""
alias Farmbot.Configurator.EventManager, as: EM
alias Farmbot.Configurator.EventHandler, as: EH
require Logger
@behaviour :cowboy_websocket_handler
@timeout 60000 # terminate if no activity for one minute
def init(_, _req, _opts), do: {:upgrade, :protocol, :cowboy_websocket}
#Called on websocket connection initialization.
def websocket_init(_type, req, _options) do
Logger.debug ">> encountered a new local websocket connection."
:erlang.start_timer(1000, self, [])
# :ok = EH.start_link(self)
:ok = EH.add_socket(self)
{:ok, req, [], @timeout}
end
# Handle other messages from the browser - don't reply
def websocket_handle({:text, message}, req, state) do
message |> Poison.decode |> handle_message
{:ok, req, state}
end
def websocket_info({:timeout, _, []}, req, state) do
:erlang.start_timer(1000, self, [])
{:reply, {:text, ping_message}, req, state}
end
def websocket_info({:from_bot, event}, req, state) do
{:reply, {:text, event}, req, state}
end
def websocket_info(message, req, state) do
Logger.debug "got a info message: #{inspect message}"
{:ok, req, state}
end
def websocket_terminate(_reason, _req, _state) do
Logger.debug ">> is closing a websocket connection."
# :ok = EH.stop_link(self)
:ok = EH.remove_socket(self)
:ok
end
def handle_message({:ok, m}), do: GenEvent.notify(EM, {:from_socket, m})
def handle_message(_) do
Logger.warn ">> Got unhandled websocket message!"
end
defp ping_message do
# lazy_id = :os.system_time(:seconds) |> Integer.to_string
Poison.encode! %{"id" => nil, "method" => "ping", "params" => [] }
end
end

View File

@ -0,0 +1,32 @@
defmodule WebPack do
require Logger
use GenServer
def start_link(env) do
GenServer.start_link(__MODULE__, env, name: __MODULE__)
end
def init(:prod), do: {:ok, self}
def init(:dev) do
Logger.debug("Starting webpack")
port = Port.open({:spawn, "npm run watch"},
[:stream,
:binary,
:exit_status,
:hide,
:use_stdio,
:stderr_to_stdout])
{:ok, port}
end
def handle_info({_, {:data, data}}, port) do
IO.puts data
{:noreply, port}
end
def handle_info(stuff, port) do
IO.inspect stuff
{:noreply, port}
end
end

View File

@ -0,0 +1,39 @@
defmodule Farmbot.Configurator.Mixfile do
use Mix.Project
System.put_env("NODE_ENV", Mix.env |> Atom.to_string)
def project do
[app: :farmbot_configurator,
version: "0.1.0",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
compilers: [:yecc, :leex, :erlang, :elixir, :xref, :app, :configurator],
deps: deps]
end
def application do
[mod: {Farmbot.Configurator, []},
applications: applications]
end
defp applications do
[
:logger,
:plug,
:cors_plug,
:poison,
:cowboy
]
end
defp deps do
[
{:plug, "~> 1.0"},
{:cors_plug, "~> 1.1"},
{:poison, "~> 3.0"},
{:cowboy, "~> 1.0.0"},
]
end
end

View File

@ -0,0 +1,35 @@
{
"name": "farmbot_configurator",
"version": "1.0.0",
"description": "Configuration application for FarmbotOS",
"dependencies": {
"@types/lodash": "^4.14.43",
"css-loader": "^0.26.1",
"lodash": "^4.17.2",
"node-sass": "^4.0.0",
"preact": "^7.1.0",
"preact-redux": "^1.2.0",
"redux": "^3.6.0",
"sass-loader": "^4.1.0",
"style-loader": "^0.13.1",
"ts-loader": "^1.3.3",
"typescript": "^2.1.4",
"webpack": "^2.2.0-rc.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"watch": "webpack --watch --color"
},
"repository": {
"type": "git",
"url": "git+https://github.com/farmbot/farmbot_configurator.git"
},
"author": "Farmbot.IO",
"license": "MIT",
"bugs": {
"url": "https://github.com/farmbot/farmbot_configurator/issues"
},
"homepage": "https://github.com/farmbot/farmbot_configurator#readme"
}

View File

@ -0,0 +1,8 @@
<html>
<head>
</head>
<body>
<div id="app"></div>
<script src="/bundle.js"></script>
</body>
</html>

View File

@ -0,0 +1,8 @@
defmodule Farmbot.ConfiguratorTest do
use ExUnit.Case
doctest Farmbot.Configurator
test "the truth" do
assert 1 + 1 == 2
end
end

View File

@ -0,0 +1 @@
ExUnit.start()

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"lib": [
"es7",
"dom"
],
"target": "es5",
"module": "commonjs",
"jsx": "react",
"jsxFactory": "h",
"experimentalDecorators": true,
"noImplicitAny": true,
"allowUnreachableCode": false,
"strictNullChecks": true,
"sourceMap": true
},
"exclude": [
"node_modules",
"typings"
],
"compileOnSave": false,
"buildOnSave": false
}

View File

@ -0,0 +1,10 @@
import { render, h } from "preact";
import { Main } from "./main";
import { GlobalState } from "./interfaces";
import "../css/main.scss"
let el = document.querySelector("#app");
if (el) {
render(<Main />, el);
}

View File

@ -0,0 +1,8 @@
export interface GlobalState {
statusBox: StatusBoxProps;
ws: WebSocket;
}
export interface StatusBoxProps {
message: string;
}

View File

@ -0,0 +1,20 @@
export type RpcMessage = RpcNotification | RpcRequest | RpcResponse
/** just like a request but doesn't expect a response. */
export interface RpcNotification {
method: string;
params: any;
id: string;
}
/** request a thing to happen and get info back as a response. */
export interface RpcRequest {
method: string;
params: any;
id: null;
}
/** A response to a request. */
export interface RpcResponse {
results: any;
error: null | any;
/** the id od the request that waranted this response. */
id: string;
}

View File

@ -0,0 +1,89 @@
// import * as React from "react";
import { h, Component } from "preact";
import {
RpcMessage,
RpcNotification,
RpcRequest,
RpcResponse
} from "./json_rpc";
import { GlobalState } from "./interfaces";
export class Main extends Component<{}, GlobalState> {
constructor(props: {}) {
super(props);
// open web socket connection to the bot.
let ws_host = "ws://" + location.host + "/ws"
let ws = new WebSocket(ws_host);
// set initial state.
this.state = { statusBox: { message: "" }, ws: ws };
// i dont know how to javascript.
let that = this
let handleNotification = function (notification: RpcNotification) {
switch (notification.method) {
case "ping":
// console.log("got ping.");
break;
default:
break;
}
}
let handleResponse = function (response: RpcResponse) {
console.log("response to: " + response.id);
}
this.state.ws.onmessage = function (event) {
let data = (JSON.parse(event.data) as RpcMessage);
// we have a new RPC message
if (data.id == null) {
// we have a notification probably shouldnt be doing so much
// type casting
handleNotification((data as RpcNotification));
return;
}
else {
console.dir(data);
// either a request or a response.
if (data.hasOwnProperty("results")) {
// its a response.
handleResponse((data as RpcResponse));
return;
} else if (data.hasOwnProperty("method")) {
// its a request.
console.log("The bot is asking for information??");
return;
} else {
// something terrible has happened.
console.log("uhhh...");
return;
}
}
}
}
render() {
let state = this.state;
let setState = this.setState;
let send_request = function (request: RpcRequest) {
setState({ [request.id]: "pending" });
state.ws.send(JSON.stringify(request));
}
return (
<div>
<button onClick={function () {
let message = {
id: "1234",
method: "hey_bot",
params: [{}]
};
send_request(message);
} }> ask bot something? </button>
</div>
);
}
}

View File

@ -0,0 +1,27 @@
module.exports = {
resolve: {
extensions: [".js", ".ts", ".json", ".tsx", ".css", ".scss"]
},
entry: "./web/ts/entry.tsx",
output: {
path: "./priv/static/",
filename: "bundle.js",
publicPath: "/assets/",
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader"
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
'style-loader',
'css-loader',
'sass-loader'
]
}]
}
}

View File

@ -0,0 +1,7 @@
/_build
/cover
/deps
erl_crash.dump
*.ez
build.log
.nerves

View File

@ -0,0 +1,2 @@
# How to build this repository
NOTE: it is more detailed [here](https://github.com/nerves-project/nerves_system_br)

View File

@ -0,0 +1,94 @@
# Changelog
## v0.9.0-farmbot1
This fork will have added packages for farmbot_os.
* buildroot settings:
* enabled ccache
* added extra busybox config file
* nerves settings:
* changed sname
* linux packages:
* hostapd
* dnsmasq
* avrdude
* dropbear
* BusyBox pacakges:
* mkfs.ext*
* fwup config:
* change data partition do ext4
## v0.9.0
This version switches to using the `nerves_package` compiler. This will
consolidate overall deps and compilers.
* Nerves.System.BR v0.8.1
* Support for distillery
* Support for nerves_package compiler
## v0.7.0
When upgrading to this version, be sure to review the updates to
nerves_defconfig if you have customized this system.
* nerves_system_br v0.6.2
* Package updates
* Buildroot 2016.08
* Linux 4.4
## v0.6.1
* Package versions
* Nerves.System.BR v0.6.1
* New features
* All Raspberry Pi 3-specific configuration is now in this repository
## v0.6.0
* Nerves.System.BR v0.6.0
* Package updates
* Erlang OTP 19
* Elixir 1.3.1
* fwup 0.8.0
* erlinit 0.7.3
* bborg-overlays (pull in I2C typo fix from upstream)
* Bug fixes
* Synchronize file system kernel configs across all platforms
## v0.5.2
* Enhancements
* Enabled USB Printer kernel mod. Needs to be loaded with `modprobe` to use
* Bug Fixes(raspberry pi)
* Enabled multicast in linux config
## v0.5.1
* Nerves.System.BR v0.5.1
* Bug Fixes(nerves-env)
* Added include paths to CFLAGS and CXXFLAGS
* Pass sysroot to LDFLAGS
## v0.5.0
* Nerves.System.BR v0.5.0
* New features
* WiFi drivers enabled by default on RPi2 and RPi3
* Include wireless regulatory database in Linux kernel by default
on WiFi-enabled platforms. Since kernel/rootfs are read-only and
coupled together for firmware updates, the normal CRDA/udev approach
isn't necessary.
* Upgraded the default BeagleBone Black kernel from 3.8 to 4.4.9. The
standard BBB device tree overlays are included by default even though the
upstream kernel patches no longer include them.
* Change all fwup configurations from two step upgrades to one step
upgrades. If you used the base fwup.conf files to upgrade, you no
longer need to finalize the upgrade. If not, there's no change.
## v0.4.1
* Nerves.System.BR v0.4.1
* Bug fixes
* syslinux fails to boot when compiled on some gcc 5 systems
* Fixed regression when booting off eMMC on the BBB
* Package updates
* Erlang 18.3
* Elixir 1.2.5

View File

@ -0,0 +1,4 @@
# Add project-specific packages for Buildroot here
#
# If these are non-proprietary, please consider contributing them back to
# Nerves or Buildroot.

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,48 @@
# Raspberry Pi 3 Model B
This is the base Nerves System configuration for the Raspberry Pi 3 Model B.
![Fritzing Raspberry Pi 3 image](assets/images/raspberry-pi-3-model-b.png)
<br><sup>[Image credit](#fritzing)</sup>
| Feature | Description |
| -------------------- | ------------------------------- |
| CPU | 1.2 GHz quad-core ARMv8 |
| Memory | 1 GB DRAM |
| Storage | MicroSD |
| Linux kernel | 4.1 w/ Raspberry Pi patches |
| IEx terminal | HDMI and USB keyboard (can be changed to UART) |
| GPIO, I2C, SPI | Yes - Elixir ALE |
| ADC | No |
| PWM | Yes, but no Elixir support |
| UART | 1 available - ttyS0 |
| Camera | Yes - via rpi-userland |
| Ethernet | Yes |
| WiFi | Yes - Nerves.InterimWiFi |
| Bluetooth | Not yet |
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
1. Add nerves_system_rpi3 to your list of dependencies in `mix.exs`:
def deps do
[{:nerves_system_rpi3, github: "ConnorRigby/nerves_system_rpi3"}]
end
2. Ensure nerves_system_rpi3 is started before your application:
def application do
[applications: [:nerves_system_rpi3]]
end
## Built-in WiFi Firmware
WiFi modules almost always require proprietary firmware to be loaded for them to work. The
Linux kernel handles this and firmware blobs are maintained in the
`linux-firmware` project. The firmware for the built-in WiFi module on the RPi3
hasn't made it to the `linux-firmware` project nor Buildroot, so it is included
here in a `rootfs-additions` overlay directory. The original firmware files came from
https://github.com/RPi-Distro/firmware-nonfree/blob/master/brcm80211/brcm.
[Image credit](#fritzing): This image is from the [Fritzing](http://fritzing.org/home/) parts library.

View File

@ -0,0 +1 @@
0.9.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
console=tty1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait

View File

@ -0,0 +1,24 @@
# Please note that this is only a sample, we recommend you to change it to fit
# your needs.
# You should override this file using a post-build script.
# See http://buildroot.org/downloads/manual/manual.html#rootfs-custom
# and http://elinux.org/RPiconfig for a description of config.txt syntax
# Device tree options are documented at
# https://github.com/raspberrypi/documentation/blob/master/configuration/device-tree.md
kernel=zImage
# This, along with the Raspberry Pi "x" firmware is need for the camera
# to work. See Target packages->Hardware handling->Firmware for "x" firmware.
gpu_mem=128
# Enable I2C and SPI
dtparam=i2c_arm=on,spi=on
# Comment this in or modify to enable OneWire
# NOTE: check that the overlay that you specify is in the boot partition or
# this won't work.
#dtoverlay=w1-gpio-pullup,gpiopin=4
# Enable the UART (/dev/ttyS0) on the RPi3.
enable_uart=1

View File

@ -0,0 +1,319 @@
# Firmware configuration file for the Raspberry Pi 3
# Default paths if not specified via the commandline
define(ROOTFS, "${NERVES_SYSTEM}/images/rootfs.squashfs")
# This configuration file will create an image that
# has an MBR and the following 3 partitions:
#
# +----------------------------+
# | MBR |
# +----------------------------+
# | p0: Boot partition (FAT32) |
# | zImage, bootcode.bin, |
# | config.txt, etc. |
# +----------------------------+
# | p1*: Rootfs A (squashfs) |
# +----------------------------+
# | p1*: Rootfs B (squashfs) |
# +----------------------------+
# | p2: Application (FAT32) |
# +----------------------------+
#
# The p1 partition points to whichever of Rootfs A or B that
# is active.
#
# The image is sized to be less than 1 GB so that it fits on
# nearly any SDCard around. If you have a larger SDCard and
# need more space, feel free to bump the partition sizes
# below.
# The Raspberry Pi is incredibly picky on the partition sizes
# and in ways that I don't understand. Test changes one at a
# time to make sure that they boot. (Sizes are in 512 byte
# blocks)
define(BOOT_PART_OFFSET, 63)
define(BOOT_PART_COUNT, 77261)
# Let the rootfs have room to grow up to 128 MiB and align
# it to the nearest 1 MB boundary
define(ROOTFS_A_PART_OFFSET, 77324)
define(ROOTFS_A_PART_COUNT, 289044)
define(ROOTFS_B_PART_OFFSET, 366368)
define(ROOTFS_B_PART_COUNT, 289044)
# Application partition. This partition can occupy all of the
# remaining space. Size it to fit the destination.
define(APP_PART_OFFSET, 655412)
define(APP_PART_COUNT, 1048576)
# Firmware metadata
meta-product = "Nerves Firmware"
meta-description = ""
meta-version = ${NERVES_SDK_VERSION}
meta-platform = "rpi3"
meta-architecture = "arm"
meta-author = "Frank Hunleth"
# File resources are listed in the order that they are included in the .fw file
# This is important, since this is the order that they're written on a firmware
# update due to the event driven nature of the update system.
file-resource bootcode.bin {
host-path = "${NERVES_SYSTEM}/images/rpi-firmware/bootcode.bin"
}
file-resource fixup.dat {
host-path = "${NERVES_SYSTEM}/images/rpi-firmware/fixup.dat"
}
file-resource start.elf {
host-path = "${NERVES_SYSTEM}/images/rpi-firmware/start.elf"
}
file-resource config.txt {
host-path = "${NERVES_SYSTEM}/images/config.txt"
}
file-resource cmdline.txt {
host-path = "${NERVES_SYSTEM}/images/cmdline.txt"
}
file-resource zImage {
# All Nerves configs use the DT kernel, but if you don't want it, remove
# the .mkknlimg part of the next line.
host-path = "${NERVES_SYSTEM}/images/zImage.mkknlimg"
}
file-resource bcm2710-rpi-3-b.dtb {
host-path = "${NERVES_SYSTEM}/images/bcm2710-rpi-3-b.dtb"
}
file-resource w1-gpio-pullup.dtbo {
host-path = "${NERVES_SYSTEM}/images/rpi-firmware/overlays/w1-gpio-pullup.dtbo"
}
file-resource rootfs.img {
host-path = ${ROOTFS}
}
mbr mbr-a {
partition 0 {
block-offset = ${BOOT_PART_OFFSET}
block-count = ${BOOT_PART_COUNT}
type = 0xc # FAT32
boot = true
}
partition 1 {
block-offset = ${ROOTFS_A_PART_OFFSET}
block-count = ${ROOTFS_A_PART_COUNT}
type = 0x83 # Linux
}
partition 2 {
block-offset = ${APP_PART_OFFSET}
block-count = ${APP_PART_COUNT}
type = 0x83 # FAT32
}
# partition 3 is unused
}
mbr mbr-b {
partition 0 {
block-offset = ${BOOT_PART_OFFSET}
block-count = ${BOOT_PART_COUNT}
type = 0xc # FAT32
boot = true
}
partition 1 {
block-offset = ${ROOTFS_B_PART_OFFSET}
block-count = ${ROOTFS_B_PART_COUNT}
type = 0x83 # Linux
}
partition 2 {
block-offset = ${APP_PART_OFFSET}
block-count = ${APP_PART_COUNT}
type = 0x83 # FAT32
}
# partition 3 is unused
}
# This firmware task writes everything to the destination media
task complete {
# Only match if not mounted
require-unmounted-destination = true
# Everything that gets written can be verified on the fly.
# This speeds things up, since we don't care about detecting
# errors before data gets written.
verify-on-the-fly = true
on-init {
mbr_write(mbr-a)
fat_mkfs(${BOOT_PART_OFFSET}, ${BOOT_PART_COUNT})
fat_setlabel(${BOOT_PART_OFFSET}, "BOOT")
fat_mkdir(${BOOT_PART_OFFSET}, "overlays")
}
on-resource config.txt { fat_write(${BOOT_PART_OFFSET}, "config.txt") }
on-resource cmdline.txt { fat_write(${BOOT_PART_OFFSET}, "cmdline.txt") }
on-resource bootcode.bin { fat_write(${BOOT_PART_OFFSET}, "bootcode.bin") }
on-resource start.elf { fat_write(${BOOT_PART_OFFSET}, "start.elf") }
on-resource fixup.dat { fat_write(${BOOT_PART_OFFSET}, "fixup.dat") }
on-resource zImage { fat_write(${BOOT_PART_OFFSET}, "zImage") }
on-resource bcm2710-rpi-3-b.dtb { fat_write(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb") }
on-resource w1-gpio-pullup.dtbo { fat_write(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo") }
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_A_PART_OFFSET})
}
on-finish {
# Initialize a big partition for application data
# This is done last so that the boot partition can be written to completely
# before the first write to this partition. Not skipping back and forth between
# FAT filesystems saves a little time when programming the Flash.
fat_mkfs(${APP_PART_OFFSET}, ${APP_PART_COUNT})
fat_setlabel(${APP_PART_OFFSET}, "APPDATA")
}
}
task upgrade.a {
# This task upgrades the A partition
require-partition1-offset = ${ROOTFS_B_PART_OFFSET}
# Since the upgrade won't run until it has been finalized, it's ok
# to write data as it is read.
verify-on-the-fly = true
on-init {
# Erase any old saved files from previous upgrades
fat_rm(${BOOT_PART_OFFSET}, "zImage.pre")
fat_rm(${BOOT_PART_OFFSET}, "config.txt.pre")
fat_rm(${BOOT_PART_OFFSET}, "cmdline.txt.pre")
fat_rm(${BOOT_PART_OFFSET}, "bootcode.bin.pre")
fat_rm(${BOOT_PART_OFFSET}, "start.elf.pre")
fat_rm(${BOOT_PART_OFFSET}, "fixup.dat.pre")
fat_rm(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb.pre")
# Make the overlays directory in case it isn't already there.
fat_mkdir(${BOOT_PART_OFFSET}, "overlays")
fat_rm(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo.pre")
}
# Write the new firmware and Linux images, but don't
# commit them. That way if the user aborts midway, we
# still are using the original firmware.
on-resource config.txt { fat_write(${BOOT_PART_OFFSET}, "config.txt.new") }
on-resource cmdline.txt { fat_write(${BOOT_PART_OFFSET}, "cmdline.txt.new") }
on-resource bootcode.bin { fat_write(${BOOT_PART_OFFSET}, "bootcode.bin.new") }
on-resource start.elf { fat_write(${BOOT_PART_OFFSET}, "start.elf.new") }
on-resource fixup.dat { fat_write(${BOOT_PART_OFFSET}, "fixup.dat.new") }
on-resource zImage { fat_write(${BOOT_PART_OFFSET}, "zImage.new") }
on-resource bcm2710-rpi-3-b.dtb { fat_write(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb.new") }
on-resource w1-gpio-pullup.dtbo { fat_write(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo.new") }
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_A_PART_OFFSET})
}
on-finish {
# Switch over to boot the new firmware
mbr_write(mbr-a)
fat_mv(${BOOT_PART_OFFSET}, "zImage", "zImage.pre")
fat_mv(${BOOT_PART_OFFSET}, "config.txt", "config.txt.pre")
fat_mv(${BOOT_PART_OFFSET}, "cmdline.txt", "cmdline.txt.pre")
fat_mv(${BOOT_PART_OFFSET}, "bootcode.bin", "bootcode.bin.pre")
fat_mv(${BOOT_PART_OFFSET}, "start.elf", "start.elf.pre")
fat_mv(${BOOT_PART_OFFSET}, "fixup.dat", "fixup.dat.pre")
fat_mv(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb", "bcm2710-rpi-3-b.dtb.pre")
fat_mv(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo", "overlays/w1-gpio-pullup.dtbo.pre")
fat_mv(${BOOT_PART_OFFSET}, "zImage.new", "zImage")
fat_mv(${BOOT_PART_OFFSET}, "config.txt.new", "config.txt")
fat_mv(${BOOT_PART_OFFSET}, "cmdline.txt.new", "cmdline.txt")
fat_mv(${BOOT_PART_OFFSET}, "bootcode.bin.new", "bootcode.bin")
fat_mv(${BOOT_PART_OFFSET}, "start.elf.new", "start.elf")
fat_mv(${BOOT_PART_OFFSET}, "fixup.dat.new", "fixup.dat")
fat_mv(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb.new", "bcm2710-rpi-3-b.dtb")
fat_mv(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo.new", "overlays/w1-gpio-pullup.dtbo")
}
on-error {
# Clean up in case something goes wrong
fat_rm(${BOOT_PART_OFFSET}, "zImage.new")
fat_rm(${BOOT_PART_OFFSET}, "config.txt.new")
fat_rm(${BOOT_PART_OFFSET}, "cmdline.txt.new")
fat_rm(${BOOT_PART_OFFSET}, "bootcode.bin.new")
fat_rm(${BOOT_PART_OFFSET}, "start.elf.new")
fat_rm(${BOOT_PART_OFFSET}, "fixup.dat.new")
fat_rm(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb.new")
fat_rm(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo.new")
}
}
task upgrade.b {
# This task upgrades the B partition
require-partition1-offset = ${ROOTFS_A_PART_OFFSET}
# Since the upgrade won't run until it has been finalized, it's ok
# to write data as it is read.
verify-on-the-fly = true
on-init {
fat_rm(${BOOT_PART_OFFSET}, "zImage.pre")
fat_rm(${BOOT_PART_OFFSET}, "config.txt.pre")
fat_rm(${BOOT_PART_OFFSET}, "cmdline.txt.pre")
fat_rm(${BOOT_PART_OFFSET}, "bootcode.bin.pre")
fat_rm(${BOOT_PART_OFFSET}, "start.elf.pre")
fat_rm(${BOOT_PART_OFFSET}, "fixup.dat.pre")
fat_rm(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb.pre")
fat_mkdir(${BOOT_PART_OFFSET}, "overlays")
fat_rm(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo.pre")
}
on-resource config.txt { fat_write(${BOOT_PART_OFFSET}, "config.txt.new") }
on-resource cmdline.txt { fat_write(${BOOT_PART_OFFSET}, "cmdline.txt.new") }
on-resource bootcode.bin { fat_write(${BOOT_PART_OFFSET}, "bootcode.bin.new") }
on-resource start.elf { fat_write(${BOOT_PART_OFFSET}, "start.elf.new") }
on-resource fixup.dat { fat_write(${BOOT_PART_OFFSET}, "fixup.dat.new") }
on-resource zImage { fat_write(${BOOT_PART_OFFSET}, "zImage.new") }
on-resource bcm2710-rpi-3-b.dtb { fat_write(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb.new") }
on-resource w1-gpio-pullup.dtbo { fat_write(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo.new") }
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_B_PART_OFFSET})
}
on-finish {
# Switch over to boot the new firmware
mbr_write(mbr-b)
fat_mv(${BOOT_PART_OFFSET}, "zImage", "zImage.pre")
fat_mv(${BOOT_PART_OFFSET}, "config.txt", "config.txt.pre")
fat_mv(${BOOT_PART_OFFSET}, "cmdline.txt", "cmdline.txt.pre")
fat_mv(${BOOT_PART_OFFSET}, "bootcode.bin", "bootcode.bin.pre")
fat_mv(${BOOT_PART_OFFSET}, "start.elf", "start.elf.pre")
fat_mv(${BOOT_PART_OFFSET}, "fixup.dat", "fixup.dat.pre")
fat_mv(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb", "bcm2710-rpi-3-b.dtb.pre")
fat_mv(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo", "overlays/w1-gpio-pullup.dtbo.pre")
fat_mv(${BOOT_PART_OFFSET}, "zImage.new", "zImage")
fat_mv(${BOOT_PART_OFFSET}, "config.txt.new", "config.txt")
fat_mv(${BOOT_PART_OFFSET}, "cmdline.txt.new", "cmdline.txt")
fat_mv(${BOOT_PART_OFFSET}, "bootcode.bin.new", "bootcode.bin")
fat_mv(${BOOT_PART_OFFSET}, "start.elf.new", "start.elf")
fat_mv(${BOOT_PART_OFFSET}, "fixup.dat.new", "fixup.dat")
fat_mv(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb.new", "bcm2710-rpi-3-b.dtb")
fat_mv(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo.new", "overlays/w1-gpio-pullup.dtbo")
}
on-error {
# Clean up in case something goes wrong
fat_rm(${BOOT_PART_OFFSET}, "zImage.new")
fat_rm(${BOOT_PART_OFFSET}, "config.txt.new")
fat_rm(${BOOT_PART_OFFSET}, "cmdline.txt.new")
fat_rm(${BOOT_PART_OFFSET}, "bootcode.bin.new")
fat_rm(${BOOT_PART_OFFSET}, "start.elf.new")
fat_rm(${BOOT_PART_OFFSET}, "fixup.dat.new")
fat_rm(${BOOT_PART_OFFSET}, "bcm2710-rpi-3-b.dtb.new")
fat_rm(${BOOT_PART_OFFSET}, "overlays/w1-gpio-pullup.dtbo.new")
}
}

View File

@ -0,0 +1,256 @@
# CONFIG_ARM_PATCH_PHYS_VIRT is not set
CONFIG_PHYS_OFFSET=0
CONFIG_LOCALVERSION="-v7"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
CONFIG_FHANDLE=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_BSD_PROCESS_ACCT=y
CONFIG_BSD_PROCESS_ACCT_V3=y
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CPUSETS=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_MEMCG=y
CONFIG_BLK_CGROUP=y
CONFIG_NAMESPACES=y
CONFIG_SCHED_AUTOGROUP=y
CONFIG_BLK_DEV_INITRD=y
# CONFIG_RD_BZIP2 is not set
# CONFIG_RD_LZMA is not set
# CONFIG_RD_XZ is not set
# CONFIG_RD_LZO is not set
# CONFIG_RD_LZ4 is not set
CONFIG_EMBEDDED=y
# CONFIG_COMPAT_BRK is not set
CONFIG_JUMP_LABEL=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_MODVERSIONS=y
CONFIG_MODULE_SRCVERSION_ALL=y
CONFIG_BLK_DEV_THROTTLING=y
CONFIG_PARTITION_ADVANCED=y
CONFIG_MAC_PARTITION=y
CONFIG_CFQ_GROUP_IOSCHED=y
CONFIG_ARCH_BCM2709=y
# CONFIG_CACHE_L2X0 is not set
CONFIG_SMP=y
CONFIG_HAVE_ARM_ARCH_TIMER=y
CONFIG_VMSPLIT_2G=y
CONFIG_PREEMPT=y
CONFIG_AEABI=y
CONFIG_OABI_COMPAT=y
# CONFIG_CPU_SW_DOMAIN_PAN is not set
CONFIG_CLEANCACHE=y
CONFIG_FRONTSWAP=y
CONFIG_CMA=y
CONFIG_UACCESS_WITH_MEMCPY=y
CONFIG_SECCOMP=y
# CONFIG_ATAGS is not set
CONFIG_ZBOOT_ROM_TEXT=0x0
CONFIG_ZBOOT_ROM_BSS=0x0
CONFIG_CMDLINE="console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=squashfs rootwait"
CONFIG_CPU_FREQ=y
# CONFIG_CPU_FREQ_STAT is not set
CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
CONFIG_VFP=y
CONFIG_NEON=y
CONFIG_KERNEL_MODE_NEON=y
# CONFIG_SUSPEND is not set
CONFIG_PM=y
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_SYN_COOKIES=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
# CONFIG_INET_XFRM_MODE_BEET is not set
# CONFIG_INET_LRO is not set
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6 is not set
CONFIG_CFG80211=y
CONFIG_CFG80211_INTERNAL_REGDB=y
CONFIG_CFG80211_WEXT=y
CONFIG_MAC80211=y
CONFIG_RFKILL=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=5
CONFIG_OF_CONFIGFS=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_EEPROM_AT24=m
CONFIG_SCSI=y
# CONFIG_SCSI_PROC_FS is not set
CONFIG_BLK_DEV_SD=y
# CONFIG_SCSI_LOWLEVEL is not set
CONFIG_NETDEVICES=y
# CONFIG_ETHERNET is not set
CONFIG_USB_USBNET=y
# CONFIG_USB_NET_AX8817X is not set
# CONFIG_USB_NET_AX88179_178A is not set
# CONFIG_USB_NET_CDCETHER is not set
# CONFIG_USB_NET_CDC_NCM is not set
CONFIG_USB_NET_SMSC95XX=y
# CONFIG_USB_NET_NET1080 is not set
# CONFIG_USB_NET_CDC_SUBSET is not set
# CONFIG_USB_NET_ZAURUS is not set
CONFIG_BRCMFMAC=y
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
CONFIG_INPUT_EVDEV=m
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_SERIO is not set
CONFIG_BRCM_CHAR_DRIVERS=y
CONFIG_BCM_VC_CMA=y
CONFIG_BCM_VCIO=y
CONFIG_BCM_VC_SM=y
CONFIG_BCM2835_DEVGPIOMEM=y
# CONFIG_LEGACY_PTYS is not set
# CONFIG_DEVKMEM is not set
CONFIG_SERIAL_8250=y
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
CONFIG_SERIAL_8250_CONSOLE=y
# CONFIG_SERIAL_8250_DMA is not set
CONFIG_SERIAL_8250_NR_UARTS=1
CONFIG_SERIAL_8250_RUNTIME_UARTS=0
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
CONFIG_SERIAL_OF_PLATFORM=y
CONFIG_TTY_PRINTK=y
CONFIG_HW_RANDOM=y
CONFIG_RAW_DRIVER=y
CONFIG_I2C=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_BCM2708=y
CONFIG_SPI=y
CONFIG_SPI_BCM2835=y
CONFIG_SPI_SPIDEV=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_BCM_VIRT=y
CONFIG_GPIO_STMPE=y
CONFIG_W1=y
CONFIG_W1_MASTER_GPIO=y
CONFIG_W1_SLAVE_THERM=y
# CONFIG_HWMON is not set
CONFIG_THERMAL=y
CONFIG_THERMAL_BCM2835=y
CONFIG_WATCHDOG=y
CONFIG_BCM2835_WDT=m
CONFIG_MFD_STMPE=y
CONFIG_STMPE_SPI=y
CONFIG_FB=y
CONFIG_FB_BCM2708=y
CONFIG_FB_RPISENSE=m
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_LOGO=y
# CONFIG_LOGO_LINUX_MONO is not set
# CONFIG_LOGO_LINUX_VGA16 is not set
CONFIG_SOUND=y
CONFIG_SND=m
CONFIG_SND_SEQUENCER=m
CONFIG_SND_SEQ_DUMMY=m
CONFIG_SND_MIXER_OSS=m
CONFIG_SND_PCM_OSS=m
CONFIG_SND_BCM2835=m
CONFIG_SND_SOC=m
CONFIG_SND_BCM2835_SOC_I2S=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
CONFIG_SND_BCM2708_SOC_RPI_DAC=m
CONFIG_SND_BCM2708_SOC_RPI_PROTO=m
CONFIG_SND_BCM2708_SOC_BOOMBERRY_DAC=m
CONFIG_SND_BCM2708_SOC_BOOMBERRY_DIGI=m
CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC=m
CONFIG_SND_BCM2708_SOC_RASPIDAC3=m
CONFIG_SND_SOC_ADAU1701=m
CONFIG_SND_SOC_WM8804_I2C=m
CONFIG_SND_SIMPLE_CARD=m
CONFIG_SOUND_PRIME=m
CONFIG_HIDRAW=y
CONFIG_HID_PID=y
CONFIG_HID_APPLE=y
CONFIG_USB_HIDDEV=y
CONFIG_USB=y
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
CONFIG_USB_DWCOTG=y
CONFIG_USB_ACM=y
CONFIG_USB_PRINTER=m
CONFIG_USB_WDM=m
CONFIG_USB_STORAGE=y
CONFIG_MMC=y
CONFIG_MMC_BLOCK_MINORS=32
CONFIG_MMC_BCM2835=y
CONFIG_MMC_BCM2835_DMA=y
CONFIG_MMC_BCM2835_SDHOST=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_PLTFM=y
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_TIMER=y
CONFIG_LEDS_TRIGGER_ONESHOT=y
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
CONFIG_LEDS_TRIGGER_CPU=y
CONFIG_LEDS_TRIGGER_GPIO=y
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
CONFIG_LEDS_TRIGGER_TRANSIENT=y
CONFIG_LEDS_TRIGGER_CAMERA=y
CONFIG_LEDS_TRIGGER_INPUT=y
CONFIG_RTC_CLASS=y
# CONFIG_RTC_HCTOSYS is not set
CONFIG_DMADEVICES=y
CONFIG_DMA_BCM2835=y
CONFIG_DMA_BCM2708=y
CONFIG_UIO=m
CONFIG_UIO_PDRV_GENIRQ=m
CONFIG_STAGING=y
CONFIG_R8712U=y
CONFIG_STAGING_MEDIA=y
CONFIG_MAILBOX=y
CONFIG_BCM2835_MBOX=y
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_RASPBERRYPI_POWER=y
CONFIG_PWM=y
CONFIG_PWM_BCM2835=m
CONFIG_RASPBERRYPI_FIRMWARE=y
CONFIG_EXT4_FS=y
CONFIG_FANOTIFY=y
CONFIG_MSDOS_FS=y
CONFIG_VFAT_FS=y
CONFIG_TMPFS=y
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_SQUASHFS=y
# CONFIG_NETWORK_FILESYSTEMS is not set
CONFIG_NLS_DEFAULT="utf8"
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_CODEPAGE_850=y
CONFIG_NLS_ASCII=y
CONFIG_NLS_ISO8859_1=y
CONFIG_NLS_UTF8=y
CONFIG_PRINTK_TIME=y
CONFIG_BOOT_PRINTK_DELAY=y
CONFIG_DEBUG_MEMORY_INIT=y
CONFIG_DETECT_HUNG_TASK=y
# CONFIG_DEBUG_PREEMPT is not set
CONFIG_STACKTRACE=y
# CONFIG_FTRACE is not set
# CONFIG_CRYPTO_HW is not set

View File

@ -0,0 +1,240 @@
# CONFIG_ARM_PATCH_PHYS_VIRT is not set
CONFIG_PHYS_OFFSET=0
CONFIG_LOCALVERSION="-v7"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
CONFIG_FHANDLE=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_BSD_PROCESS_ACCT=y
CONFIG_BSD_PROCESS_ACCT_V3=y
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CPUSETS=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_MEMCG=y
CONFIG_BLK_CGROUP=y
CONFIG_NAMESPACES=y
CONFIG_SCHED_AUTOGROUP=y
CONFIG_BLK_DEV_INITRD=y
# CONFIG_RD_BZIP2 is not set
# CONFIG_RD_LZMA is not set
# CONFIG_RD_XZ is not set
# CONFIG_RD_LZO is not set
# CONFIG_RD_LZ4 is not set
CONFIG_EMBEDDED=y
# CONFIG_COMPAT_BRK is not set
CONFIG_JUMP_LABEL=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_MODVERSIONS=y
CONFIG_MODULE_SRCVERSION_ALL=y
CONFIG_BLK_DEV_THROTTLING=y
CONFIG_PARTITION_ADVANCED=y
CONFIG_MAC_PARTITION=y
CONFIG_CFQ_GROUP_IOSCHED=y
CONFIG_ARCH_BCM2709=y
# CONFIG_CACHE_L2X0 is not set
CONFIG_SMP=y
CONFIG_HAVE_ARM_ARCH_TIMER=y
CONFIG_VMSPLIT_2G=y
CONFIG_PREEMPT=y
CONFIG_AEABI=y
CONFIG_OABI_COMPAT=y
# CONFIG_CPU_SW_DOMAIN_PAN is not set
CONFIG_CLEANCACHE=y
CONFIG_FRONTSWAP=y
CONFIG_CMA=y
CONFIG_UACCESS_WITH_MEMCPY=y
CONFIG_SECCOMP=y
# CONFIG_ATAGS is not set
CONFIG_ZBOOT_ROM_TEXT=0x0
CONFIG_ZBOOT_ROM_BSS=0x0
CONFIG_CMDLINE="console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=squashfs rootwait"
CONFIG_CPU_FREQ=y
# CONFIG_CPU_FREQ_STAT is not set
CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
CONFIG_VFP=y
CONFIG_NEON=y
CONFIG_KERNEL_MODE_NEON=y
# CONFIG_SUSPEND is not set
CONFIG_PM=y
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_SYN_COOKIES=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
# CONFIG_INET_XFRM_MODE_BEET is not set
# CONFIG_INET_LRO is not set
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6 is not set
CONFIG_CFG80211=y
# CONFIG_CFG80211_DEFAULT_PS is not set
CONFIG_CFG80211_INTERNAL_REGDB=y
CONFIG_CFG80211_WEXT=y
CONFIG_MAC80211=y
CONFIG_MAC80211_LEDS=y
CONFIG_RFKILL=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=5
CONFIG_OF_CONFIGFS=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_EEPROM_AT24=m
CONFIG_SCSI=y
# CONFIG_SCSI_PROC_FS is not set
CONFIG_BLK_DEV_SD=y
# CONFIG_SCSI_LOWLEVEL is not set
CONFIG_NETDEVICES=y
# CONFIG_ETHERNET is not set
CONFIG_USB_USBNET=y
# CONFIG_USB_NET_AX8817X is not set
# CONFIG_USB_NET_AX88179_178A is not set
# CONFIG_USB_NET_CDCETHER is not set
# CONFIG_USB_NET_CDC_NCM is not set
CONFIG_USB_NET_SMSC95XX=y
# CONFIG_USB_NET_NET1080 is not set
# CONFIG_USB_NET_CDC_SUBSET is not set
# CONFIG_USB_NET_ZAURUS is not set
CONFIG_BRCMFMAC=y
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
CONFIG_INPUT_EVDEV=m
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_STMPE=m
# CONFIG_SERIO is not set
CONFIG_BRCM_CHAR_DRIVERS=y
CONFIG_BCM_VC_CMA=y
CONFIG_BCM_VCIO=y
CONFIG_BCM_VC_SM=y
CONFIG_BCM2835_DEVGPIOMEM=y
CONFIG_VT_HW_CONSOLE_BINDING=y
# CONFIG_LEGACY_PTYS is not set
# CONFIG_DEVKMEM is not set
CONFIG_SERIAL_8250=y
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
CONFIG_SERIAL_8250_CONSOLE=y
# CONFIG_SERIAL_8250_DMA is not set
CONFIG_SERIAL_8250_NR_UARTS=1
CONFIG_SERIAL_8250_RUNTIME_UARTS=0
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
CONFIG_SERIAL_OF_PLATFORM=y
CONFIG_TTY_PRINTK=y
CONFIG_HW_RANDOM=y
CONFIG_RAW_DRIVER=y
CONFIG_I2C=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_BCM2708=y
CONFIG_SPI=y
CONFIG_SPI_BCM2835=m
CONFIG_SPI_SPIDEV=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_BCM_VIRT=y
CONFIG_GPIO_STMPE=y
# CONFIG_HWMON is not set
CONFIG_THERMAL=y
CONFIG_THERMAL_BCM2835=y
CONFIG_WATCHDOG=y
CONFIG_BCM2835_WDT=m
CONFIG_MFD_RPISENSE_CORE=y
CONFIG_MFD_STMPE=y
CONFIG_STMPE_SPI=y
CONFIG_FB=y
CONFIG_FB_BCM2708=y
CONFIG_BACKLIGHT_LCD_SUPPORT=y
# CONFIG_LCD_CLASS_DEVICE is not set
CONFIG_BACKLIGHT_CLASS_DEVICE=y
CONFIG_BACKLIGHT_RPI=y
CONFIG_LOGO=y
# CONFIG_LOGO_LINUX_MONO is not set
# CONFIG_LOGO_LINUX_VGA16 is not set
CONFIG_HIDRAW=y
CONFIG_HID_APPLE=y
CONFIG_HID_PID=y
CONFIG_USB_HIDDEV=y
CONFIG_USB=y
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
CONFIG_USB_DWCOTG=y
CONFIG_USB_ACM=y
CONFIG_USB_STORAGE=y
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_CONSOLE=y
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_SERIAL_CH341=y
CONFIG_USB_SERIAL_CP210X=y
CONFIG_USB_SERIAL_FTDI_SIO=y
CONFIG_MMC=y
CONFIG_MMC_BLOCK_MINORS=32
CONFIG_MMC_BCM2835=y
CONFIG_MMC_BCM2835_DMA=y
CONFIG_MMC_BCM2835_SDHOST=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_PLTFM=y
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_TRIGGER_TIMER=y
CONFIG_LEDS_TRIGGER_ONESHOT=y
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
CONFIG_LEDS_TRIGGER_CPU=y
CONFIG_LEDS_TRIGGER_GPIO=y
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
CONFIG_LEDS_TRIGGER_TRANSIENT=y
CONFIG_LEDS_TRIGGER_CAMERA=y
CONFIG_LEDS_TRIGGER_INPUT=y
CONFIG_RTC_CLASS=y
# CONFIG_RTC_HCTOSYS is not set
CONFIG_DMADEVICES=y
CONFIG_DMA_BCM2835=y
CONFIG_DMA_BCM2708=y
CONFIG_UIO=m
CONFIG_UIO_PDRV_GENIRQ=m
CONFIG_STAGING=y
CONFIG_STAGING_MEDIA=y
CONFIG_MAILBOX=y
CONFIG_BCM2835_MBOX=y
CONFIG_RASPBERRYPI_POWER=y
CONFIG_PWM=y
CONFIG_PWM_BCM2835=m
CONFIG_GENERIC_PHY=y
CONFIG_RASPBERRYPI_FIRMWARE=y
CONFIG_EXT4_FS=y
CONFIG_FANOTIFY=y
CONFIG_MSDOS_FS=y
CONFIG_VFAT_FS=y
CONFIG_TMPFS=y
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_SQUASHFS=y
# CONFIG_NETWORK_FILESYSTEMS is not set
CONFIG_NLS_DEFAULT="utf8"
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_CODEPAGE_850=y
CONFIG_NLS_ASCII=y
CONFIG_NLS_ISO8859_1=y
CONFIG_NLS_UTF8=y
CONFIG_PRINTK_TIME=y
CONFIG_BOOT_PRINTK_DELAY=y
CONFIG_DEBUG_MEMORY_INIT=y
CONFIG_DETECT_HUNG_TASK=y
# CONFIG_DEBUG_PREEMPT is not set
CONFIG_STACKTRACE=y
# CONFIG_FTRACE is not set
# CONFIG_CRYPTO_HW is not set

View File

@ -0,0 +1,42 @@
defmodule NervesSystemRpi3.Mixfile do
use Mix.Project
@version Path.join(__DIR__, "VERSION")
|> File.read!
|> String.strip
def project do
[app: :nerves_system_rpi3,
version: @version,
elixir: "~> 1.2",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
compilers: Mix.compilers ++ [:nerves_package],
description: description(),
package: package(),
deps: deps()]
end
def application, do: []
defp deps do
[{:nerves, "~> 0.4.0"},
{:nerves_system_br, "~> 0.8.1"},
{:nerves_toolchain_arm_unknown_linux_gnueabihf, "~> 0.8.0"}]
end
defp description do
"""
Nerves System - Raspberry Pi 3 B
"""
end
defp package do
[maintainers: ["Frank Hunleth", "Justin Schneck"],
files: ["LICENSE", "mix.exs", "nerves_defconfig", "nerves.exs", "README.md", "VERSION", "rootfs-additions", "fwup.conf", "cmdline.txt", "linux-4.4.defconfig", "config.txt", "post-createfs.sh"],
licenses: ["Apache 2.0"],
links: %{"Github" => "https://github.com/nerves-project/nerves_system_rpi3"}]
end
end

View File

@ -0,0 +1,30 @@
use Mix.Config
version =
Path.join(__DIR__, "VERSION")
|> File.read!
|> String.strip
pkg = :nerves_system_rpi3
config pkg, :nerves_env,
type: :system,
version: version,
compiler: :nerves_package,
artifact_url: [
# TODO change this to farmbot
"https://github.com/nerves-project/#{pkg}/releases/download/v#{version}/#{pkg}-v#{version}.tar.gz",
],
platform: Nerves.System.BR,
platform_config: [
defconfig: "nerves_defconfig",
],
checksum: [
"rootfs-additions",
"linux-4.4.defconfig",
"fwup.conf",
"cmdline.txt",
"config.txt",
"post-createfs.sh",
"VERSION"
]

View File

@ -0,0 +1,71 @@
BR2_arm=y
BR2_cortex_a7=y
BR2_ARM_FPU_NEON_VFPV4=y
BR2_CCACHE=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/nerves-project/toolchains/releases/download/v0.8.0/nerves_toolchain_arm_unknown_linux_gnueabihf-0.8.0.linux-x86_64.tar.xz"
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-unknown-linux-gnueabihf"
BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_4=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_TARGET_GENERIC_HOSTNAME=""
BR2_TARGET_GENERIC_ISSUE=""
BR2_INIT_NONE=y
# BR2_TARGET_GENERIC_GETTY is not set
# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
BR2_ENABLE_LOCALE_WHITELIST="locale-archive"
BR2_GENERATE_LOCALE="en_US.UTF-8"
BR2_ROOTFS_OVERLAY="${NERVES_SYSTEM}/board/nerves-common/rootfs-additions ${NERVES_DEFCONFIG_DIR}/rootfs-additions"
BR2_ROOTFS_POST_BUILD_SCRIPT="${BR2_EXTERNAL}/board/nerves-common/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="${NERVES_DEFCONFIG_DIR}/post-createfs.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/raspberrypi/linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="26f3b72a9c049be10e6af196252283e1f6ab9d1f"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="${NERVES_DEFCONFIG_DIR}/linux-4.x.defconfig"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b"
BR2_LINUX_KERNEL_EXT_KERNEL_WIRELESS_REGDB=y
BR2_PACKAGE_BUSYBOX_CONFIG="${NERVES_SYSTEM}/board/nerves-common/busybox-1.22.config"
BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="${NERVES_DEFCONFIG_DIR}/busybox_defconfig"
BR2_PACKAGE_E2FSPROGS=y
# BR2_PACKAGE_E2FSPROGS_BADBLOCKS is not set
# BR2_PACKAGE_E2FSPROGS_CHATTR is not set
# BR2_PACKAGE_E2FSPROGS_DUMPE2FS is not set
# BR2_PACKAGE_E2FSPROGS_E2FREEFRAG is not set
# BR2_PACKAGE_E2FSPROGS_E2FSCK is not set
# BR2_PACKAGE_E2FSPROGS_E2LABEL is not set
# BR2_PACKAGE_E2FSPROGS_E2UNDO is not set
# BR2_PACKAGE_E2FSPROGS_FILEFRAG is not set
# BR2_PACKAGE_E2FSPROGS_FSCK is not set
# BR2_PACKAGE_E2FSPROGS_LOGSAVE is not set
# BR2_PACKAGE_E2FSPROGS_LSATTR is not set
# BR2_PACKAGE_E2FSPROGS_MKLOSTFOUND is not set
# BR2_PACKAGE_E2FSPROGS_TUNE2FS is not set
# BR2_PACKAGE_E2FSPROGS_UUIDGEN is not set
BR2_PACKAGE_FWUP=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_X=y
BR2_PACKAGE_AVRDUDE=y
BR2_PACKAGE_RPI_USERLAND=y
BR2_PACKAGE_ERLANG_SMP=y
BR2_PACKAGE_LIBMNL=y
BR2_PACKAGE_DNSMASQ=y
BR2_PACKAGE_DROPBEAR=y
BR2_PACKAGE_HOSTAPD=y
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_DEBUG_SYSLOG=y
BR2_TARGET_ROOTFS_SQUASHFS=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_NERVES_SYSTEM_NAME="nerves_system_rpi3"
BR2_NERVES_ADDITIONAL_IMAGE_FILES="$(NERVES_DEFCONFIG_DIR)/fwup.conf ${NERVES_DEFCONFIG_DIR}/cmdline.txt ${NERVES_DEFCONFIG_DIR}/config.txt"
BR2_PACKAGE_BOARDID=y
BR2_PACKAGE_ERLANG_HISTORY=y
BR2_PACKAGE_NERVES_CONFIG=y
BR2_PACKAGE_NERVES_CONFIG_NO_ERLINIT_CONF=y
BR2_PACKAGE_NERVES_CONFIG_APPS="crypto"
BR2_PACKAGE_NERVES_CONFIG_SNAME="farmbot"

View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
FWUP_CONFIG=$NERVES_DEFCONFIG_DIR/fwup.conf
# Mark the Raspberry Pi kernel image as using device tree
$HOST_DIR/usr/bin/mkknlimg \
$BINARIES_DIR/zImage $BINARIES_DIR/zImage.mkknlimg
# Run the common post-image processing for nerves
$BR2_EXTERNAL/board/nerves-common/post-createfs.sh $TARGET_DIR $FWUP_CONFIG

View File

@ -0,0 +1,40 @@
# bcm94330wlsdgb.txt
manfid=0x2d0
prodid=0x0552
vendid=0x14e4
devid=0x4360
boardtype=0x0552
boardrev=0x11
# this design has 2.4GHz SP3T switch
boardflags=0x00080200
nocrc=1
xtalfreq=37400
boardnum=22
macaddr=00:90:4c:c5:12:38
ag0=255
aa2g=1
ccode=CN
pa0b0=0x14d0
pa0b1=0xfd98
pa0b2=0xff78
rssismf2g=0xa
rssismc2g=0x3
rssisav2g=0x7
maxp2ga0=0x50
sromrev=3
il0macaddr=00:90:4c:c5:12:38
wl0id=0x431b
cckPwrOffset=5
ofdm2gpo=0x66666666
mcs2gpo0=0x6666
mcs2gpo1=0x6666
swctrlmap_2g=0x04040404,0x02020202,0x02020404,0x10202,0x1ff
swctrlmap_5g=0x00100010,0x00280020,0x00200010,0x14202,0x2f8
rfreg033=0x19
rfreg033_cck=0x1f
dacrate2g=160
txalpfbyp2g=1
bphyscale=17
cckPwrIdxCorr=-15
pacalidx2g=45
txgaintbl=1

View File

@ -0,0 +1,66 @@
# NVRAM file for BCM943430WLPTH
# 2.4 GHz, 20 MHz BW mode
# The following parameter values are just placeholders, need to be updated.
manfid=0x2d0
prodid=0x0727
vendid=0x14e4
devid=0x43e2
boardtype=0x0727
boardrev=0x1101
boardnum=22
macaddr=00:90:4c:c5:12:38
sromrev=11
boardflags=0x00404201
boardflags3=0x08000000
xtalfreq=37400
nocrc=1
ag0=255
aa2g=1
ccode=ALL
pa0itssit=0x20
extpagain2g=0
#PA parameters for 2.4GHz, measured at CHIP OUTPUT
pa2ga0=-168,7161,-820
AvVmid_c0=0x0,0xc8
cckpwroffset0=5
# PPR params
maxp2ga0=84
txpwrbckof=6
cckbw202gpo=0
legofdmbw202gpo=0x66111111
mcsbw202gpo=0x77711111
propbw202gpo=0xdd
# OFDM IIR :
ofdmdigfilttype=18
ofdmdigfilttypebe=18
# PAPD mode:
papdmode=1
papdvalidtest=1
pacalidx2g=42
papdepsoffset=-22
papdendidx=58
# LTECX flags
ltecxmux=0
ltecxpadnum=0x0102
ltecxfnsel=0x44
ltecxgcigpio=0x01
il0macaddr=00:90:4c:c5:12:38
wl0id=0x431b
deadman_to=0xffffffff
# muxenab: 0x1 for UART enable, 0x2 for GPIOs, 0x8 for JTAG
muxenab=0x1
# CLDO PWM voltage settings - 0x4 - 1.1 volt
#cldo_pwm=0x4
#VCO freq 326.4MHz
spurconfig=0x3
edonthd20l=-75
edoffthd20ul=-80

View File

@ -0,0 +1,66 @@
# NVRAM file for BCM943430WLPTH
# 2.4 GHz, 20 MHz BW mode
# The following parameter values are just placeholders, need to be updated.
manfid=0x2d0
prodid=0x0727
vendid=0x14e4
devid=0x43e2
boardtype=0x0727
boardrev=0x1101
boardnum=22
macaddr=00:90:4c:c5:12:38
sromrev=11
boardflags=0x00404201
boardflags3=0x08000000
xtalfreq=37400
nocrc=1
ag0=255
aa2g=1
ccode=ALL
pa0itssit=0x20
extpagain2g=0
#PA parameters for 2.4GHz, measured at CHIP OUTPUT
pa2ga0=-168,7161,-820
AvVmid_c0=0x0,0xc8
cckpwroffset0=5
# PPR params
maxp2ga0=84
txpwrbckof=6
cckbw202gpo=0
legofdmbw202gpo=0x66111111
mcsbw202gpo=0x77711111
propbw202gpo=0xdd
# OFDM IIR :
ofdmdigfilttype=18
ofdmdigfilttypebe=18
# PAPD mode:
papdmode=1
papdvalidtest=1
pacalidx2g=42
papdepsoffset=-22
papdendidx=58
# LTECX flags
ltecxmux=0
ltecxpadnum=0x0102
ltecxfnsel=0x44
ltecxgcigpio=0x01
il0macaddr=00:90:4c:c5:12:38
wl0id=0x431b
deadman_to=0xffffffff
# muxenab: 0x1 for UART enable, 0x2 for GPIOs, 0x8 for JTAG
muxenab=0x1
# CLDO PWM voltage settings - 0x4 - 1.1 volt
#cldo_pwm=0x4
#VCO freq 326.4MHz
spurconfig=0x3
edonthd20l=-75
edoffthd20ul=-80

View File

@ -0,0 +1 @@
/tmp

14
apps/os/.gitignore vendored 100644
View File

@ -0,0 +1,14 @@
# App artifacts
/_build
/db
/deps
/*.ez
# Nerves images
/_images
# Generate on crash by the VM
erl_crash.dump
npm-debug.log
ttb_last_config
cover

125
apps/os/README.md 100644
View File

@ -0,0 +1,125 @@
[![Build Status](https://travis-ci.org/FarmBot/farmbot_os.svg?branch=master)](https://travis-ci.org/FarmBot/farmbot_os.svg?branch=master)
# FarmBot Software for the Raspberry Pi 3
The "brains" of Farmbot. Responsible for receiving the commands from [the browser](https://github.com/FarmBot/farmbot-web-frontend) or the [FarmBot API](https://github.com/FarmBot/Farmbot-Web-API). It executes them and reports back the results to any subscribed user(s).
# First Time Installation
If you are setting up your FarmBot for the first time, download the latest FarmBot OS `.img` file [here](https://github.com/FarmBot/farmbot_os/releases/latest).
## Windows users
* Download [Win32 Disk Imager](https://sourceforge.net/projects/win32diskimager/)
* Select the `.img` file you downloaded
* Select your sdcard's drive letter
* Click `write`
## Linux / OSX / UNIX
* `dd if=img_file of=/dev/sdX`
* where img_file is the path to you `.img` file, and X is your device's drive letter.
## Running
0. Plug your SD Card into your RPi3
0. Plug your Arduino into your RPi3
0. Plug your power into your RPi3
0. From a WiFi enabled device*, search for the SSID `FarmbotConfigurator`
0. Connect to that and open a web browser to [http://192.168.24.1/](http://192.168.24.1)
0. Follow the on screen instructions to configure your FarmBot. Once you save your configuration FarmBot will connect to your home WiFi network and to the FarmBot web application.
\* If you are using a smartphone you may need to disable cellular data to allow your phone's browser to connect to the configurator.
## Updating the firmware
To update the firmware on the Raspberry Pi and the Arduino, simply use the "update" buttons on the web application. There is no need to reinstall the entire OS.
# Issues
Please read through the [FAQ](FAQ.md). If you don't see what you need please by all means open a Github Issue!
# Building / Development (for developers only)
## Technical Stuff
* Written in [Elixir](http://elixir-lang.org/) using [Nerves Project](http://nerves-project.org/).
* Device status info such as X,Y,Z and calibration data is stored on the Data partition Nerves allows.
* Backups to the cloud provided by [Farmbot API](https://github.com/farmbot/farmbot-web-api)
* Messaging happens via [MQTT](https://github.com/farmbot/mqtt-gateway)
## Building
[You need Linux to build Linux.](http://www.whylinuxisbetter.net/). Windows is not supported. Bash for Windows and Cygwin will not work. A VM or dual boot environment will work. So with that rant out of the way, and ready for revision here are the steps to build:
* Install Elixir and Erlang. ([installer script]("https://gist.github.com/ConnorRigby/8a8bffff935d1a43cd74c4b8cf28a845"))
* Install [`Nerves`](https://hexdocs.pm/nerves/installation.html) and all related dependencies.
* clone this repo. `git clone https://github.com/FarmBot/farmbot-raspberry-pi-controller.git`
* `cd farmbot-raspberry-pi-controller`.
* Insert an sdcard into your development machine and run:
```bash
MIX_ENV=prod mix deps.get
MIX_ENV=prod mix firmware
MIX_ENV=prod mix firmware.burn
```
You can also run locally (not on an RPI3- Windows is supported for this):
```bash
export MIX_ENV=dev
rm -rf _deps build _images
mix deps.get
iex -S mix
```
You should only need to do the first two commands once.
## Running Tests
There aren't a lot of tests, but they do exist and can be run by executing the following:
```bash
MIX_ENV=test mix deps.get
mix test --no-start
```
Make sure to have the `--no-start` in there. Otherwise it will try to start the
supervision tree, and tests will be broken and what not.
## Debugging on hardware
The Raspberry Pi will boot up with an Iex console on the hardware UART. If you need to debug something this is the easiest to get too.
If you do not have a 3.3v FTDI cable, you can build the firmware with the console on HDMI.
In the `erlinit.config` file change `-c ttyS0` to `-c ttyS1`. This requires a usb mouse, keyboard and monitor into your pi.
## Development Tips
You can connect IEx to the running pi by running
`iex --name console@localhost --remsh farmbot@<FARMBOT IP ADDRESS> --cookie democookie`.
Debug message still only will print to UART or HDMI (whichever you have configured)
If you frequently build the firmware, removing the sdcard and writing the build every time gets pretty old. You can upload firmware to an already running farmbot one of two ways after you run a successful `mix firmware`
0. You can upload the image to the pi using CURL or similar. `curl -T _images/rpi3/fw.fw "http://$RPI_IP_ADDRESS:8988/firmware" -H "Content-Type: application/x-firmware" -H "X-Reboot: true"`
0. Or you can host the .fw file on your pc using a webserver ie `npm install serve` and download it from the pi.This should be ran ON THE PI ITSELF `Downloader.download_and_install_update("http://<DEV_PC_IP_ADDRESS>/WHEREVER YOUR FILE IS")`
# Building for production
## Major version change
you will have to do one of two things:
0. Do a fresh clone of this repo. (prefered)
0. Clean everything out with something along the lines of `rm -rf _build deps _images rel/fw`
Then follow these steps then follow the steps for a minor version.
```bash
export MIX_ENV=prod
mix deps.get
```
this will generate a .fw file in the images dir. this will be an update file. A raw image file is then generated from this file
## Minor Version
```bash
export MIX_ENV=prod
mix firmware
cd _images/rpi3/
fwup -a -d firmware.img -i fw.fw -t complete
```
These two files should be put into the github release.
If someone would like to write a Mix Task for this it'd be much appreciated.
# Want to Help?
[Low Hanging Fruit](https://github.com/FarmBot/farmbot_os/search?utf8=%E2%9C%93&q=TODO)

View File

@ -0,0 +1,21 @@
use Mix.Config
import_config "#{Mix.env}.exs"
config :farmbot_auth,
callbacks: [Farmbot.RPC.Transport.GenMqtt.Handler]
config :json_rpc,
transport: Farmbot.RPC.Transport.GenMqtt.Handler,
handler: Farmbot.RPC.Handler
config :uart,
baud: 115200
config :logger,
utc_logs: true
config :quantum, cron: [
"5 1 * * *": {Farmbot.Updates.Handler, :do_update_check}
]
config :farmbot, config_file: "default_config_#{Mix.Project.config[:target]}.json"

View File

@ -0,0 +1,3 @@
use Mix.Config
config :farmbot, state_path: "/tmp"
import_config "hardware/#{Mix.Project.config[:target]}/hardware.exs"

View File

@ -0,0 +1,40 @@
# Additional configuration for erlinit
# Turn on the debug prints
#-v
# Specify the UART port that the shell should use.
-c ttyS0
# If more than one tty are available, always warn if the user is looking at
# the wrong one.
--warn-unused-tty
# Use dtach to capture the iex session so that it can be redirected
# to the app's GUI
#-s "/usr/bin/dtach -N /tmp/iex_prompt"
# Specify the user and group IDs for the Erlang VM
#--uid 100
#--gid 200
# Uncomment to hang the board rather than rebooting when Erlang exits
--hang-on-exit
# Run a program if the Erlang VM exits
--run-on-exit "/bin/sh"
# Run a program before the Erlang VM starts
# --pre-run-exec "/bin/sh -e /usr/bin/pre_erl.sh"
-m /dev/mmcblk0p3:/state:ext4::
# Enable UTF-8 filename handling in Erlang and custom inet configuration
-e LANG=en_US.UTF-8;LANGUAGE=en;ERL_INETRC=/etc/erl_inetrc
# Erlang release search path
-r /srv/erlang
# Assign a unique hostname based on the board id
-d "/usr/bin/boardid -b rpi -n 4"
-n nerves-%.4s

View File

@ -1,7 +1,7 @@
use Mix.Config
config :nerves, :firmware,
rootfs_additions: "config/rootfs-additions-#{Mix.Project.config[:target]}",
hardware: "config/rootfs-additions-#{Mix.Project.config[:target]}"
rootfs_additions: "config/hardware/#{Mix.Project.config[:target]}/rootfs-additions"
# hardware: "config/rootfs-additions-#{Mix.Project.config[:target]}"
config :configurator, port: 80
@ -26,4 +26,4 @@ config :iex,
:reset ] |> IO.ANSI.format |> IO.chardata_to_string
# overwrite anything on if need be.
import_config "hardware_#{Mix.Project.config[:target]}.exs"
import_config "hardware/#{Mix.Project.config[:target]}/hardware.exs"

Some files were not shown because too many files have changed in this diff Show More