Thought Iâd run through this again now that we are using M2 specific board definitions and ESP files have been updated many times. Iâll write out each step so everyone can follow along. Result will be compiling and flashing the ESP32 board through M2:
-
Assuming you already have Arduino IDE installed (I am currently running latest version 1.8.5) , follow the Installation Instructions found here to install Espressif specific files to be able to use Arduino IDE to flask ESP32.
-
After installing ESP files, modify the file âplatform.txtâ file found on your computer here:
C:\Users[USER]\Documents\Arduino\hardware\espressif\esp32\platform.txt
by replacing âdefault_resetâ with âno_resetâ in 2 places like this:
# ------------------------------
tools.esptool.upload.protocol=esp32
tools.esptool.upload.params.verbose=
tools.esptool.upload.params.quiet=
tools.esptool.upload.pattern="{path}/{cmd}" --chip esp32 --port "{serial.port}" --baud {upload.speed} --before no_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size detect 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x1000 "{runtime.platform.path}/tools/sdk/bin/{build.boot}.bin" 0x10000 "{build.path}/{build.project_name}.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin"
tools.esptool.upload.pattern.linux=python "{path}/{cmd}" --chip esp32 --port "{serial.port}" --baud {upload.speed} --before no_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size detect 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x1000 "{runtime.platform.path}/tools/sdk/bin/{build.boot}.bin" 0x10000 "{build.path}/{build.project_name}.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin"
tools.esptool.upload.network_pattern={network_cmd} -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
-
Plug ESP32 board into M2 with notches pointed toward the USB connector. Plug M2 into your computer via USB cable.
-
Select âMacchina M2â from the board menu, and flash the following sketch:
int buttonState1 = 0;
int buttonState2 = 0;
void setup() {
pinMode(DS2, OUTPUT);
pinMode(DS3, OUTPUT);
pinMode(XBEE_RST, OUTPUT);
pinMode(XBEE_MULT4, OUTPUT);
pinMode(Button1, INPUT);
pinMode(Button2, INPUT);
SerialUSB.begin(115200);
Serial.begin(115200);
}
char rx_byte = 0;
void loop() {
if (SerialUSB.available() > 0) {
rx_byte = SerialUSB.read();
Serial.write(rx_byte);
}
if (Serial.available() > 0) {
rx_byte = Serial.read();
SerialUSB.write(rx_byte);
}
buttonState1 = digitalRead(Button1);
if (buttonState1 == LOW) {
digitalWrite(DS2, LOW);
digitalWrite(XBEE_RST, LOW);
} else {
digitalWrite(DS2, HIGH);
digitalWrite(XBEE_RST, HIGH);
}
buttonState2 = digitalRead(Button2);
if (buttonState2 == LOW) {
digitalWrite(DS3, LOW);
digitalWrite(XBEE_MULT4, LOW);
} else {
digitalWrite(DS3, HIGH);
digitalWrite(XBEE_MULT4, HIGH);
}
}
- Open a the Serial monitor. Press and HOLD the SW2 button (closest to the M in Macchina). The Yellow LED should come on. Then press and RELEASE SW1 button (closest to the A in Macchina). The Red LED should come on. You should see something similar to the following on the Serial terminal:
rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download
This means the ESP32 board is ready to flash!
-
Select âESP32 Dev Moduleâ from the boards menu. Set flash mode to DIO, Flash Frequency to 40Mhz, Set Flash size to 2MB, upload speed to 115200 and debug level to None.
-
Select an example from File -> Examples -> Examples for ESP32 Dev Module. For this example, weâll try: WIFI -> WifiScan.
-
Hit the Upload button. After a few seconds youâll see:
Leaving...
Hard resetting...
- Close the Serial monitor window. Change the board to âMacchina M2â. Open the Serial monitor again. Press SW1" to reset the ESP32 module. Soon you will see a list of all of the hotspots near you.
There are tons of cool code examples for the ESP32 board, including BLE.
Next steps will be to stream-line the above process where you donât need to press any buttons on M2 to flash the ESP32. @captain_morgan did this above by sending commands to M2 via Serial terminal to put ESP32 into Bootload mode. Weâll try to replicate that here soon.