I have been trying to upload MicroPython to a ESP32 on a Mac. It uses the CP210x serial-to-usb driver, so you need to have this installed before you even bother.
ESP32, an amazing little board.
Flashing MicroPython from a Mac to ESP32
I got MicroPython from the official site, at http://micropython.org/download/#esp32. Current version is v1.9.3-240-ga275cb0f, from January 21st, 2018 (today).
To upload it, I used the NodeMCU flasher tool, which I got from Marcel Stör’s github. It allows you to use a GUI to Flash ESP8266 and ESP32 boards. You might need to install WxWidgets – the python’s PIP doesn’t work, but the brew one works. Easy peasy:
brew install wxpython
And you are good to go:
git clone https://github.com/marcelstoer/nodemcu-pyflasher.git
And follow the instructions on how to build it.
Once you have it, you can try the GUI, but when I try to flash it, I have an error like this:
rst:0x1 (POWERON_RESET),boot:0x16 (SPI_FAST_FLASH_BOOT) flash read err, 1000 Falling back to built-in command interpreter. OK >ets Jun 8 2016 00:22:57
So, I went to the directory where I cloned it, and ran from the command-line:
python esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x1000 ~/Downloads/micropython-esp32-20180121-v1.9.3-240-ga275cb0f.bin
Which gave me a working MicroPython on the ESP32.
Making the wifi scan test is a four-liner:
import network station = network.WLAN(network.STA_IF) station.active(True) station.scan()
This is the output I get on Arduino Serial monitor, from the reboot to the moment I type those commands (shown in red):
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) ets Jun 8 2016 00:22:57 rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:4332 load:0x40078000,len:0 load:0x40078000,len:10992 entry 0x4007a6c4 [0;32mI (205) cpu_start: Pro cpu up.[0m [0;32mI (205) cpu_start: Single core mode[0m [0;32mI (205) heap_init: Initializing. RAM available for dynamic allocation:[0m [0;32mI (208) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m [0;32mI (215) heap_init: At 3FFDCD68 len 00003298 (12 KiB): DRAM[0m [0;32mI (221) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m [0;32mI (227) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m [0;32mI (233) heap_init: At 4008FC7C len 00010384 (64 KiB): IRAM[0m [0;32mI (240) cpu_start: Pro cpu start user code[0m [0;32mI (33) cpu_start: Starting scheduler on PRO CPU.[0m OSError: [Errno 2] ENOENT MicroPython v1.9.3-240-ga275cb0f on 2018-01-21; ESP32 module with ESP32 Type "help()" for more information. >>> import network >>> station = network.WLAN(network.STA_IF) I (42465) wifi: wifi firmware version: 111e74d I (42465) wifi: config NVS flash: enabled I (42465) wifi: config nano formating: disabled [0;32mI (42465) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE[0m [0;32mI (42475) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE[0m I (42495) wifi: Init dynamic tx buffer num: 32 I (42495) wifi: Init data frame dynamic rx buffer num: 64 I (42495) wifi: Init management frame dynamic rx buffer num: 64 I (42505) wifi: wifi driver task: 3ffe2d38, prio:23, stack:4096 I (42505) wifi: Init static rx buffer num: 10 I (42515) wifi: Init dynamic rx buffer num: 0 I (42515) wifi: Init rx ampdu len mblock:7 I (42525) wifi: Init lldesc rx ampdu entry mblock:4 I (42525) wifi: wifi power manager task: 0x3ffe852c prio: 21 stack: 2560 [0;32mI (42555) phy: phy_version: 362.0, 61e8d92, Sep 8 2017, 18:48:11, 0, 0[0m I (42555) wifi: mode : null >>> station.active(True) I (68635) wifi: mode : sta (24:0a:c4:03:a8:90) [0;32mI (68635) wifi: STA_START[0m True >>> station.scan() [0;32mI (79565) network: event 1[0m [(b'FRITZ 6360C', b'\x9c\xc7\xa6\x0cc\xbe', 1, -84, 4, False), (b'WLAN-565914', b'\xd4!"\xe9\xb7K', 11, -92, 3, False)] >>>
I still have to figure out how to write python scripts to the filesystem, haven’t checked on it yet. But I am happy to make it work 🙂