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.
These need to be installed on your PC:
- curl
- ampy
pip install adafruit-ampy
This project tested only on ESP32.
Install MicroPython to your board.
The guide can be found here. 日本語版ガイドはこちら。
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")
Run ./put.sh [serial]
.
If you use macOS, serial
will look like /dev/tty.usbserial-0001
.
Then, Power on your board!
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
.
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.
The API is simple. Server listing TCP port 9000. You can send HTTP request to the server.
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 specified file.
Example:
$ curl -X DELETE http://192.168.1.102:9000/init.py"
Reset your board.
Example:
$ curl -X POST http://192.168.1.102:9000/reset"
Deploy tar file.
Example:
$ curl -X POST -H "Content-Type: application/octet-stream" --data-binary @deploy.tar "http://192.168.1.102:9000/tar"
Delete all files except boot.py
, main.py
, secrets.py
.
Example:
$ curl -X POST http://192.168.1.102:9000/cleanup"