-
Notifications
You must be signed in to change notification settings - Fork 10
/
ecp5setup.py
206 lines (190 loc) · 4.1 KB
/
ecp5setup.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import os
def printfile(name):
try:
f=open(name,"r")
user_pass=f.read()
print(user_pass)
f.close()
except:
print("file '%s' not found." % name)
def boot():
f=open("boot.py","w")
f.write(
"# boot.py: executed on every boot (including wake-boot from deepsleep)\n"
"#import esp\n"
"#esp.osdebug(None)\n"
"import webrepl\n"
"webrepl.start()\n"
)
f.close()
def main():
f=open("main.py","w")
f.write(
"# main.py: executed on every boot\n"
"try:\n"
" import wifiman\n"
"except:\n"
" print('wifiman.py error')\n"
"import gc\n"
"gc.collect()\n"
"import uftpd\n"
"from ntptime import settime\n"
"try:\n"
" settime()\n"
" print('NTP time set')\n"
"except:\n"
" print('NTP not available')\n"
)
f.close()
def jtagpin_v20():
f=open("jtagpin.py","w")
f.write(
"# ULX3S v3.0.x, v2.x.x, v1.x\n"
"tms=const(21)\n"
"tck=const(18)\n"
"tdi=const(23)\n"
"tdo=const(19)\n"
"tcknc=const(17)\n"
"led=const(5)\n"
)
f.close()
def jtagpin_v31():
f=open("jtagpin.py","w")
f.write(
"# ULX3S v3.1.x\n"
"tms=const(5)\n"
"tck=const(18)\n"
"tdi=const(23)\n"
"tdo=const(34)\n"
"tcknc=const(21)\n"
"led=const(19)\n"
)
f.close()
def jtagpin_esp32s2():
f=open("jtagpin.py","w")
f.write(
"# ESP32-S2 prototype\n"
"tms=const(8)\n"
"tck=const(16)\n"
"tdi=const(15)\n"
"tdo=const(7)\n"
"tcknc=const(6)\n"
"led=const(5)\n"
)
f.close()
def jtagpin_esp32s3():
f=open("jtagpin.py","w")
f.write(
"# ESP32-S3 prototype\n"
"tms=const(2)\n"
"tck=const(1)\n"
"tdi=const(3)\n"
"tdo=const(4)\n"
"tcknc=const(10)\n"
"led=const(21)\n"
)
f.close()
def jtagpin_fjc():
f=open("jtagpin.py","w")
f.write(
"# FJC-ESP32-V0r2\n"
"tms=const(4)\n"
"tck=const(16)\n"
"tdi=const(15)\n"
"tdo=const(2)\n"
"tcknc=const(21)\n"
"led=const(19)\n"
)
f.close()
def sdpin_esp32():
f=open("sdpin.py","w")
f.write(
"# ESP32 SD-SPI-MMC\n"
"hiz=bytearray([2,4,12,13,14,15]) # to release SD\n"
)
f.close()
def sdpin_esp32s2():
f=open("sdpin.py","w")
f.write(
"# ESP32-S2 SD-SPI\n"
"d0=const(13) # miso\n"
"d3=const(10) # csn\n"
"clk=const(12) # sck\n"
"cmd=const(11) # mosi\n"
"hiz=bytearray([d0,d3,clk,cmd]) # to release SD\n"
)
f.close()
def sdpin_esp32s3():
f=open("sdpin.py","w")
f.write(
"# ESP32-S3 SD-SPI\n"
"d0=const(9) # miso\n"
"d3=const(6) # csn\n"
"clk=const(7) # sck\n"
"cmd=const(8) # mosi\n"
"hiz=bytearray([d0,d3,clk,cmd]) # to release SD\n"
)
f.close()
def set_wifi():
print("--- WiFi ---")
printfile("wifiman.conf")
yn=input("delete old and create new WiFi users:passwords (n/y)? ")
if yn.startswith("y"):
f=open("wifiman.conf","w")
f.close()
print("all WiFi users:passwords deleted")
yn="y"
while yn.startswith("y"):
yn=input("add WiFi user:password (n/y)? ")
if yn.startswith("y"):
user_pass=input("enter WiFi user:password> ")
if user_pass.find(":")>0:
f=open("wifiman.conf","a")
f.write(user_pass)
f.write("\n")
f.close()
printfile("wifiman.conf")
def set_boot():
print("--- BOOT ---")
printfile("boot.py")
printfile("main.py")
yn=input("overwrite 'boot.py' and 'main.py' to run WiFi, WebREPL, NTP and FTP at boot (n/y)? ")
if yn.startswith("y"):
boot()
main()
printfile("boot.py")
printfile("main.py")
def set_pinout():
print("--- PINOUT ---")
printfile("jtagpin.py")
printfile("sdpin.py")
yn=input("change JTAG and SD pinout (n/y)? ")
if yn.startswith("y"):
print("0: ULX3S v3.0.x, v2.x.x, v1.x")
print("1: ULX3S v3.1.x, ULX4M + ESP32 HAT, FFC-RBP V0r12")
print("2: ESP32-S2 prototype")
print("3: ESP32-S3 prototype")
print("4: FFC-RBP V0r10 + FJC-ESP32-V0r2")
pinout=input("select pinout (0-3)> ")
if pinout.startswith("0"):
jtagpin_v20()
sdpin_esp32()
if pinout.startswith("1"):
jtagpin_v31()
sdpin_esp32()
if pinout.startswith("2"):
jtagpin_esp32s2()
sdpin_esp32s2()
if pinout.startswith("3"):
jtagpin_esp32s3()
sdpin_esp32s3()
if pinout.startswith("4"):
jtagpin_fjc()
sdpin_esp32()
printfile("jtagpin.py")
printfile("sdpin.py")
def run():
set_wifi()
set_boot()
set_pinout()
run()