-
Notifications
You must be signed in to change notification settings - Fork 31
/
esp_config.py
63 lines (53 loc) · 1.23 KB
/
esp_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# coding: utf-8
'''
@File :esp_config.py.py
@Author :youxinweizhi
@Date :2019/3/29
@Github :https://github.com/youxinweizhi
'''
import os
import time
def erase(com):
FLASH_START = "0x1000"
FLASH_MODE = "dio"
FLASH_FREQ = "40m"
import sys
sys.argv = [
'AutoFlash.py', '--chip', 'esp32',
'--port', com,
'--baud', '921600', # 921600
'erase_flash',
]
try:
from esptool import main
main()
return None
except Exception as e:
print(e)
return str(e)
def flash(com):
erase(com)
FLASH_START = "0x1000"
FLASH_MODE = "dio"
FLASH_FREQ = "40m"
import sys
sys.argv = [
'AutoFlash.py', '--chip', 'esp32',
'--port', com,
'--baud', '921600', # 921600
'write_flash', '-z',
'--flash_mode', FLASH_MODE,
'--flash_size', '4MB',
'--flash_freq', FLASH_FREQ,
'0x1000', os.getcwd() + '\\firmware.bin',
]
try:
from esptool import main
main()
return None
except Exception as e:
print(e)
return str(e)
if __name__ == "__main__":
flash('com3')