Skip to content

cordx56/micropython-deploy-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroPython Deploy Server

What's this?

Deploying MicroPython code on the board requires connecting it to a PC, which is tedious and time consuming.

This project aim to deploy MicroPython code faster via network.

Requirements

These need to be installed on your PC:

  • curl
  • ampy
    • pip install adafruit-ampy

This project tested only on ESP32.

How to use this?

Setup the board

Install MicroPython

Install MicroPython to your board.

The guide can be found here. 日本語版ガイドはこちら

Edit secrets.py

Edit src/secrets.py to enable WiFi connection.

Example:

WIFI_SSID = "your WiFi SSID"
WIFI_PASSWORD = "your WiFi password"

WIFI_IFCONFIG = None
# You can specify static IPv4 address
# (If you not specify static IPv4 address, IPv4 address is determined using DHCP)
# WIFI_IFCONFIG = ("192.168.1.1", "255.255.255.0", "192.168.1.1", "8.8.8.8")

Put main.py and secrets.py to your board

Run ./put.sh [serial].

If you use macOS, serial will look like /dev/tty.usbserial-0001.

Then, Power on your board!

How to deploy the program?

Use deploy.sh. This script will automatically transfer files under src directory via network and reset your board.

When your board is reset, main.py opens init.py and run the contents. This means that the entry point for your program must be written in src/init.py.

How to use with my repository?

You can add this repository as your repository's submodule.

$ git submodule add https://github.com/cordx56/micropython-deploy-server deploy

Then, create your source files directory.

$ mkdir src

Create required files.

$ echo 'WIFI_SSID = "ssid"\nWIFI_PASSWORD = "password" > src/secrets.py'
$ echo 'print("Hello, world!")' > src/init.py

Run deploy.sh

$ ./deploy/deploy.sh 192.168.1.102 ./src

That's all! Your script is deployed.

How to use API?

The API is simple. Server listing TCP port 9000. You can send HTTP request to the server.

PUT [path]

You can deploy your script to specified path.

Example:

$ curl -X PUT -H "Content-Type: application/octet-stream" --data-binary @src/init.py "http://192.168.1.102:9000/init.py"

DELETE [path]

Delete specified file.

Example:

$ curl -X DELETE http://192.168.1.102:9000/init.py"

POST /reset

Reset your board.

Example:

$ curl -X POST http://192.168.1.102:9000/reset"

POST /tar [DEPRECATED]

Deploy tar file.

Example:

$ curl -X POST -H "Content-Type: application/octet-stream" --data-binary @deploy.tar "http://192.168.1.102:9000/tar"

POST /cleanup

Delete all files except boot.py, main.py, secrets.py.

Example:

$ curl -X POST http://192.168.1.102:9000/cleanup"

About

Deploy your MicroPython code via network

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published