Hi,
I need to read the MAC address from the ESP8266 after uploading the firmware in order to log it to a file. I’m trying to do this like so:
import esptool
Import("env")
def post_build(source, target, env):
esptool.main('--chip esp8266 read_mac')
But as result I get:
usage: esptool [-h]
[--chip {auto,esp8266,esp32,esp32s2,esp32s3beta2,esp32s3,esp32c3,esp32c6beta,esp32h2beta1,esp32h2beta2,esp32c2,esp32c6,esp32c61,esp32c5,esp32c5beta3,esp32h2,esp32p4}]
[--port PORT] [--baud BAUD] [--port-filter PORT_FILTER]
[--before {default_reset,usb_reset,no_reset,no_reset_no_sync}]
[--after {hard_reset,soft_reset,no_reset,no_reset_stub}]
[--no-stub] [--trace] [--override-vddsdio [{1.8V,1.9V,OFF}]]
[--connect-attempts CONNECT_ATTEMPTS]
{load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,read_flash_sfdp,merge_bin,get_security_info,version}
...
esptool: error: argument operation: invalid choice: '-' (choose from 'load_ram', 'dump_mem', 'read_mem', 'write_mem', 'write_flash', 'run', 'image_info', 'make_image', 'elf2image', 'read_mac', 'chip_id', 'flash_id', 'read_flash_status', 'write_flash_status', 'read_flash', 'verify_flash', 'erase_flash', 'erase_region', 'read_flash_sfdp', 'merge_bin', 'get_security_info', 'version')
When I run the same command in the PIO terminal it works as expected:
esptool --chip esp8266 read_mac
esptool.py v4.8.1
Serial port COM14
Connecting…
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: c4:d8:d5:30:5e:31
Uploading stub…
Running stub…
Stub running…
MAC: c4:d8:d5:30:5e:31
Hard resetting via RTS pin…
Any ideas?
Additional question: Is there a way in the script to read the configured comport which has been selected via the Platformio IDE?
Kind regards
Stefan