>>> upip.install("micropython-uasyncio")
Installing to: /lib/
Warning: pypi.org SSL certificate is not validated
Installing micropython-uasyncio 2.3 from https://files.pythonhosted.org/packages/2f/d0/da285cf389f3736b204514f936b9621976735096ba02f6cd701ef0426a05/micropython-uasyncio-2.3.tar.gz
Installing micropython-uasyncio.core 2.3 from https://files.pythonhosted.org/packages/2b/3a/5737ff41dfe85d3ddf4c783e9289f6c869526fd31b495bf012612e6c82cf/micropython-uasyncio.core-2.3.tar.gz
>>> import uasyncio
$ esptool.py --chip esp32 -p /dev/tty.SLAB_USBtoUART write_flash -z 0x1000 esp32-bluetooth.bin
esptool.py v2.6
Serial port /dev/tty.SLAB_USBtoUART
Connecting.....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 84:0d:8e:0c:c9:f0
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 1549888 bytes to 970594...
Wrote 1549888 bytes (970594 compressed) at 0x00001000 in 85.5 seconds (effective 145.0 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
보드의 전원을 껐다가 다시 인가하고, 터미널에서 다음과 같이 입력하여 REPL 환경으로 진입.
$ screen /dev/tty.SLAB_USBtoUART 115200
처음엔 아무런 내용이 나타나지 않지만, 명령어를 입력하면 됨. 평소 사용한 REPL 환경와 동일.
>>> print("hello")
hello
>>>
REPL 환경에서 나오려면, ctrl + a, ctrl + \ 키를 순서대로 누르고, 화면 밑 프롬프트가 나오면 y를 눌러 종료 가능.
Adafruit에서 제공하는 Micro Python Tool을 이용해 보드 내부의 파일 시스템에 파일을 넣거나 스크립트를 실행할 수 있음.
$ pip3 install adafruit-ampy
보드 내부 파일 시스템에 있는 파일들 표시
$ ampy -p /dev/tty.SLAB_USBtoUART ls
/boot.py
다음의 명령어를 이용해 파일들 조작 가능.
ampy
Usage: ampy [OPTIONS] COMMAND [ARGS]...
ampy - Adafruit MicroPython Tool
Ampy is a tool to control MicroPython boards over a serial connection.
Using ampy you can manipulate files on the board's internal filesystem and
even run scripts.
Options:
-p, --port PORT Name of serial port for connected board. Can optionally
specify with AMPY_PORT environment variable. [required]
-b, --baud BAUD Baud rate for the serial connection (default 115200).
Can optionally specify with AMPY_BAUD environment
variable.
-d, --delay DELAY Delay in seconds before entering RAW MODE (default 0).
Can optionally specify with AMPY_DELAY environment
variable.
--version Show the version and exit.
--help Show this message and exit.
Commands:
get Retrieve a file from the board.
ls List contents of a directory on the board.
mkdir Create a directory on the board.
put Put a file or folder and its contents on the board.
reset Perform soft reset/reboot of the board.
rm Remove a file from the board.
rmdir Forcefully remove a folder and all its children from the board.
run Run a script and print its output.