Skip to content

bfanger/micropython-livereload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LiveReload for Microcontrollers

  • Execute python on a microcontroller directly from a folder on your PC.
  • Restart when a file has changed.
  • Supports multiple microcontrollers at once

Usage

Edit client/boot.py with your IP and WIFI settings Upload client/boot.py and client/livereload.py into your microcontroller (using rshell or ampy

Start the server using the micropython_coverage version

micropython_coverage server/main.py your_project_folder

Setup

The server need a micropython with VfsFat enabled. (Not the regular unix port, but included in the micropython_coverage build)

Via docker

Build the image:

git clone https://github.com/bfanger/micropython_livereload
cd micropython_livereload
docker build --tag micropython-livereload .

In your project folder run:

docker run -v $PWD:/app --rm -it --publish 1808:1808 micropython-livereload /livereload/main.py /app

(of change $PWD to the folder with your main.py)

macOS

Download full source from: http://www.micropython.org/download

brew install libffi
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

cd micropython-?.??/ports/unix
make coverage

How it works

  1. The microcontroller connects to server on the PC (via socket).
  2. The server (PC) creates a new blockdevice in-memory, formats it in FAT and copies the contents of the given folder into that blockdevice.
  3. The client (microcontroller) mounts that blockdevice (via socket) and import the scripts from there.
  4. When a file's modified date is changed the server notifies the client and the client reboot.

Every client get it's own immutable filesystem (readonly and remains the same unit the microcontroller reboots).

Idea's / Goals / Roadmap

  • Option to use mpy-cross to pre-compile the python scripts to bytecode.
  • Faster reload: Use "soft reboot" (expose soft_reset() to python)
  • Faster reload: Use usb-serial / UART (skip networking)
  • Publish as a upip package
  • Publish to docker hub

Known bugs

  • Reloads on all file saves. Should only reload when a (used) python file has changed.
  • A hard reset is not detected by the socket.

About

LiveReload for Microcontrollers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published