Hot code reload


#1

Hi, I’ve been working on making localhost farmbot. I can connect my localhost web_app and mqtt-gateway. Knowing that the web-app can auto update the farmbot-os. Is there possible to hot code reload the farmbot_os which I have make some change. So I can make change without using mix firmware.burn each time.
Thanks for any reply.


#2

@mophy85

Good question. When we write features for FarmBot OS, we typically don’t work off of the Pi unless we are debugging specific hardware issues or are working on a very specific hardware related feature.

If you are just tinkering with the source code on your local desktop, you can simply run the software locally (mix deps.get; iex -S mix). You will need to run configuration on localhost:5000 instead of WiFi. You can plug the Arduino directly into your desktop for serial support.

CC: @connor


#3

Ah yes the age old question. The Code that runs on the Raspberry Pi uses a framework called Nerves of which i am a core contributor/maintainer. We have support for Hot code reloading but it’s not completely ready yet.

In the meantime i personally spend very little time developing on the pi itself. I work from my “host” machine, run tests and whatnot there - then deploy to the Raspberry Pi. There is no “hot code reload” built in by default but from the shell you can issue a r Farmbot.WhatEverMod.Changed and it will reload and tell you of any compiler errors.


#4

ALSO i forgot to mention. You can upload firmware over network.

so do a mix firmware.burn to your device then make any changes and do mix firmware.upload


#5

@RickCarlino
Thanks a lot for replying.
I have tried iex -S mix but compile go wrong at nerves_runtime.I set the TARGET as host, and ENV with dev.


#6

@connor
Thanks a lot for replying.
I have tried mix firmware.upload 192.168..(The IP that my pi connect to the wifi).
It fail at Uploading. With HTTP Request fail (400) body: fwup_error. What may cause this happen. I am edit on VM box. Show I for connect the Internet I use NAT, the IP will become 10.0.
.**. Is this makes the error?


#7

Can you post the output of your terminal?
i suspect you are trying too flash an image you built onto a production image.
Official Farmbot images are signed so they can’t be updated unless it comes from the Farmbot Team directly. You will probably have to do a MIX_TARGET=rpi3 mix firmware, then MIX_TARGET=rpi3 mix firmware.burn (with your SDCARD plugged into your computer), then after you configure your bot run MIX_TARGET=rpi3 mix firmware.upload <ip address>


#8

@connor
Thanks a lot for replying.
The origin system on my Rpi3 is use MIX_TARGET=rpi3 MIX_ENV=prod, then mix firmware and mix firmware.burn on SD directly plug on my notebook.
Below is the terminal picture.
20

Does mix firmware.upload 140.138.137.19 need the supply of WEB_APP or mqtt-gateway?
Because for connecting to rpi3 I need change the Internet setting of VM to NAT. While that without Internet setting of VM be bridge the WEB_APP and mqtt-gateway can’t be access except in the VM system.