Permalink
Browse files

Update firmware

  • Loading branch information...
ConnorRigby committed Dec 13, 2018
1 parent 0df6f33 commit d21f5ade363cfca15d8c778ef774641f146f68cd
@@ -58,7 +58,7 @@ config :farmbot, :builtins,
]

config :farmbot,
expected_fw_versions: ["6.4.0.F", "6.4.0.R", "6.4.0.G"],
expected_fw_versions: ["6.4.1.F", "6.4.1.R", "6.4.1.G"],
default_server: "https://my.farm.bot",
default_currently_on_beta: String.contains?(to_string(:os.cmd('git rev-parse --abbrev-ref HEAD')), "beta"),
firmware_io_logs: false,
@@ -17,7 +17,14 @@ defmodule Farmbot.Firmware.UartHandler.AutoDetector do
use Farmbot.Logger

#TODO(Connor) - Maybe make this configurable?
@ignore_devs ["ttyAMA0", "ttyS0", "ttyS3"]
case Farmbot.Project.target() do
"rpi3" ->
@ignore_devs ["ttyAMA0", "ttyS0", "ttyS3"]
"rpi" ->
@ignore_devs ["ttyS0", "ttyS3"]
"rpi0" ->
@ignore_devs ["ttyS0", "ttyS3"]
end

@doc "Autodetect relevent UART Devs."
def auto_detect do
@@ -147,10 +147,13 @@ defmodule Farmbot.Firmware.UartHandler.Update do

def avrdude(fw_file, uart, tty) do
close(uart)
Logger.busy 3, "Starting avrdude: #{fw_file}"
args = ~w"-q -q -patmega2560 -cwiring -P#{tty} -b#{@uart_speed} -D -V -Uflash:w:#{fw_file}:i"
args = ~w"-patmega2560 -cwiring -P#{tty} -b#{@uart_speed} -D -V -Uflash:w:#{fw_file}:i"
Logger.busy 3, "Starting avrdude: #{inspect(args)}"
reset = reset_init()
opts = [stderr_to_stdout: true, into: IO.stream(:stdio, :line)]
do_reset(reset)
res = System.cmd("avrdude", args, opts)
reset_close(reset)
Process.sleep(1500) # wait to allow file descriptors to be closed.
case res do
{_, 0} ->
@@ -162,4 +165,21 @@ defmodule Farmbot.Firmware.UartHandler.Update do
:error
end
end

if Farmbot.Project.target() in ["rpi0", "rpi"] do
@reset_pin 19
defp reset_init do
{:ok, pid} = ElixirALE.GPIO.start_link(@reset_pin, :output)
pid
end
defp do_reset(pid) do
ElixirALE.GPIO.write(pid, 1)
ElixirALE.GPIO.write(pid, 0)
end
defp reset_close(pid), do: ElixirALE.GPIO.release(pid)
else
defp reset_init(), do: nil
defp do_reset(nil), do: :ok
defp reset_close(nil), do: :ok
end
end
Oops, something went wrong.

0 comments on commit d21f5ad

Please sign in to comment.