Esp32 MicroPython development

1. esptool.py –chip esp32 –port COM9 erase_flash
2. esptool.py –chip esp32 –port COM9 –baud 921600 –before default_reset –after no_reset write_flash -z –flash_mode dio –flash_freq 40m –flash_size detect 0x1000 bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
3. ampy –port COM9 –baud 115200 put main.py

esptool.py –chip esp32 –port /dev/ttyUSB0 –baud 921600 –before default_reset –after no_reset write_flash -z –flash_mode dio –flash_freq 40m –flash_size detect 0x1000 bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
1. VuzeScript.
2. wkhtmltopdf upgrade.
3. DrawIO.
4. Drone hardware test and support.
5. Rebuild MicroPython from source to enable extension of Xtensa instructions and drone software.
https://github.com/micropython/micropython/
Test the following features of the implementation.
http://docs.micropython.org/en/latest/esp32/quickref.html#real-time-clock-rtc
Teensy (Arm-Cortex), Linux (testing), and Esp32 (Xtensa)
ESP32 is a series of low cost, low power system on a chip microcontrollers with integrated Wi-Fi & dual-mode Bluetooth.
The ESP32 series employs a Tensilica Xtensa LX6 microprocessor in both dual-core and single-core variations.
ESP32 is created and developed by Espressif Systems, a Shanghai-based Chinese company, and is manufactured by TSMC using their 40nm process.

Preparation for drone development. MicroPython development for Esp32 in 6 steps:
Install a 10 uF electrolytic capacitor between GND (short pin) and EN pin to avoid packet error when uploading.
The built-in OLED version does not seem to have this issue (4 MB flash).
1. Download Python 3.7
https://www.python.org/downloads/release/python-374/
Choose the installer on Windows 10 to install Python at
Users\ldao\AppData\Local\Programs\Python\Python37-32
2. At the terminal prompt, install the flash eraser tool (esptool)
python -m pip install esptool
python -m pip install –upgrade pip (this is optional to upgrade pip)
3. The esptool is installed at the subdirectory Scripts\, erase the chip (8 sec).
Scripts\esptool.py –chip esp32 erase_flash
4. Download the MicroPython firmware binarỵ
https://micropython.org/resources/firmware/esp32-20190529-v1.11.bin
*Need how to rebuild this firmware to access all 4 MB of flash.
5. Upload the firmware to the Esp32 (9 sec).
cd Scripts
esptool.py –chip esp32 –port COM17 –baud 460800 write_flash -z 0x1000 esp32-20190529-v1.11.bin
6. MicroPython IDE (probably not needed, see 7):
https://thonny.org/
type help() at the prompt.
7. SSH terminal (serial interface).
This eliminates the need for an IDE.
import os
os.listdir() to see all uploaded .py files
8. gfx and oled ssd1306 driver.
git clone https://github.com/adafruit/micropython-adafruit-ssd1306
git clone https://github.com/adafruit/micropython-adafruit-gfx
9. Download the ampy tool to manage test scripts (ls, rm, get option).
python -m pip install adafruit-ampy
10. gfx and oled ssd1306 driver.
ampy –port COM9 –baud 115200 put gfx.py
ampy –port COM9 –baud 115200 put ssd1306.py
11. Add delay time in pyboard.py to avoid “could not enter raw repl”.
#Added 10.2.2019
time.sleep(2)
Users\ldao\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\ampy\pyboard.py
12. Pinout differences between Heltec and Esp-Wroom-32D
13. Documentation folder for Heltec.
14. ESP-IDF toolchain for C development (no OS).
Rebuild this on .88 and .90
https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html#get-started-set-up-tools
https://docs.espressif.com/projects/esp-idf/en/latest/get-started/linux-setup-scratch.html
dnf install git wget ncurses-devel flex bison gperf python pyserial python-pyelftools cmake ninja-build ccache
15. PsRAM expansion for additional free memory.
https://esp32.com/viewtopic.php?f=17&t=2446
16. There is a git repository that can build the custom Esp32 image with psRAM support.
*In-line Xtensa assembly test.
*Custom C module import test.
*Documentation of build procedure for additional Python packages (formatting tools).

15. Zephyr os.
Installation of the RTOS.
https://docs.zephyrproject.org/1.9.0/getting_started/installation_linux.html
dnf upgrade
dnf group install “Development Tools”
dnf install git make gcc glibc-static libstdc++-static ncurses-devel doxygen dfu-util dtc python3-pip python3-ply python3-yaml dfu-util dtc python3-pykwalify
dnf search pykwali
[root@kimberly ldao]#
du -hs zephyr/
425M zephyr/
du -hs zephyr-sdk/
1.4G zephyr-sdk
source zephyr-env.sh
export ZEPHYR_GCC_VARIANT=”espressif”
export ZEPHYR_SDK_INSTALL_DIR=/home/ldao/zephyr-sdk/

Installation of the esp32 toolchain.
Works on .85 (kimberly), needs to build on odroid (*not working).
https://docs.zephyrproject.org/1.9.0/boards/xtensa/esp32/doc/esp32.html

Build example blink using idf.py build.
export ESP_IDF_PATH=”/home/ldao/esp/esp-idf”
export ESPRESSIF_TOOLCHAIN_PATH=”/home/ldao/esp/xtensa-esp32-elf/”
cd ~/esp/esp-idf/
source export.sh
rm -rdf blink/
cp -r $IDF_PATH/examples/get-started/blink/ .
cd ~/esp/blink
idf.py build (approximately 115 MB with 835 components)
Copy to Windows Scripts\
To flash the Esp32 chip (retest with only 3 files)
esptool.py –after hard_reset write_flash –flash_mode dio –flash_size detect –flash_freq 40m 0x1000 blink/build/bootloader/bootloader.bin 0x8000 blink/build/partition_table/partition-table.bin 0x10000 blink/build/blink.bin

#export ZEPHYR_GCC_VARIANT=zephyr
#export ZEPHYR_SDK_INSTALL_DIR=/home/ldao/zephyr-sdk/

export ZEPHYR_GCC_VARIANT=”espressif”
export ESP_IDF_PATH=”/home/ldao/esp/esp-idf”
export ESPRESSIF_TOOLCHAIN_PATH=”/home/ldao/xtensa-esp32-elf/”
16. Larger display and E-ink screens.
17. Custom instruction set development for Tensilica Xtensa LX6.
MicroPython suuports only inline ARM assembly instructions.
There are GNU toolchain for Xtensa and TIE development.
https://docs.zephyrproject.org/latest/boards/xtensa/xt-sim/doc/index.html

https://www.instructables.com/id/MicroPython-on-an-ESP32-Board-With-Integrated-SSD1/
http://docs.micropython.org/en/latest/esp32/quickref.html

ESP32 MicroPython: Executing scripts with uPyCraft


https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/modules-and-boards-previous.html#esp-wrover-kit-v3
18. Customization and tests.
1. Test gfx and ssd1306 graphics, scrolling, switch buttons (pin 2), and two LEDs (pins 16 and 2).
import blink (see the definition of run in blink.py)
blink.run() has issues with pin 4, 5, and 25.
Solved: The OLED display uses pins 4 (SDA) and 5 (SCL) to communicate on the I2C bus with the ESP32.
2. Font control (see Arduino projects).
3. d/a converter for analog fading.
4. Serial to parallel.
5. Voltage regulator for 3.3 and 5-volt power supply from 18650 batteries.
6. Temperature sensor (both digital & analog).
7. Neopixels RGB LEDs.
8. RGB LEDs (Common cathode & anode).
9. esp32 MicroPython.
import esp
esp.flash_size() to see 4 MB (4,194,304 bytes)
import gc (garbage collector, need to expand free_mem to 4 MB)
gc.mem_free() 115712 bytes
19. Blue tooth wireless protocols.
20. Drone software development. Test the gyroscope on the evaluation board.
Check to see if anything is fried (battery issue).
JTAG debugging. One of the ESP-32 chip is fried (brownout detected).

ESP32 Bluetooth: Using the BTstack library

Getting Started with MicroPython on ESP32 – Hello World, GPIO, and WiFi


4-inch hi-speed LCD.
https://www.waveshare.com/4inch-rpi-lcd-c.htm

21. Windows restore point to restore after update damage.
Firefox key3.db, key4.db, cert8.sqlite, cert9.sqlite, places.sqlite to restore bookmarks & passwords.
Create a new profile (about:profiles), close Firefox before copying to the new profile.
22. Esp32 assembly language (xtensa).
http://cholla.mmto.org/esp8266/xtensa.html
23. https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki

Leave a Reply

Your email address will not be published. Required fields are marked *