gpio control using esptool

Seungwhan
Posts: 10
Joined: Mon Jul 29, 2019 11:23 pm

gpio control using esptool

Postby Seungwhan » Tue Aug 20, 2019 12:26 am

Hi,

So, I want to control GPIOs of ESP32 from a PC using esptool.py.
Is this possible?
My theory was to use write_mem(), but also I found this code snippet which made me less certain about what I was thinking.

----------------------------
# Commands supported by ESP8266 ROM bootloader
ESP_FLASH_BEGIN = 0x02
ESP_FLASH_DATA = 0x03
ESP_FLASH_END = 0x04
ESP_MEM_BEGIN = 0x05
ESP_MEM_END = 0x06
ESP_MEM_DATA = 0x07
ESP_SYNC = 0x08
ESP_WRITE_REG = 0x09
ESP_READ_REG = 0x0a

# Some comands supported by ESP32 ROM bootloader (or -8266 w/ stub)
ESP_SPI_SET_PARAMS = 0x0B
ESP_SPI_ATTACH = 0x0D
ESP_CHANGE_BAUDRATE = 0x0F
ESP_FLASH_DEFL_BEGIN = 0x10
ESP_FLASH_DEFL_DATA = 0x11
ESP_FLASH_DEFL_END = 0x12
ESP_SPI_FLASH_MD5 = 0x13
----------------------------

Can you please confirm?
If it's not possible through esptool.py(or current version of esptool.py) can you please let me know way to do what I want to do?

Thank you!

ESP_Angus
Posts: 1786
Joined: Sun May 08, 2016 4:11 am

Re: gpio control using esptool

Postby ESP_Angus » Tue Aug 20, 2019 3:33 am

This is technically possible, you can use "write_reg" to write a word at any address so could use this to configure the GPIO registers as needed.

If you do it from the command line it will be slow because the ESP32 needs to be reset each time, but you can write some Python code to do it.

This is how some internal esptool feature are implemented, for example take a look at the code for sending an arbitrary command to the SPI flash (by configuring the SPI peripheral registers):
https://github.com/espressif/esptool/bl ... ol.py#L794

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 19 guests