Skip to content

Commit b249811

Browse files
Support IDE2, detect UF2 volumes (#897)
Allow the IDE to detect UF2 volumes (i.e. when you hold BOOTDEL and plug in the board). Allows the IDE2 to properly upload using OTA and serial. Fixes #890 and others
1 parent 7f216f3 commit b249811

File tree

5 files changed

+151
-59
lines changed

5 files changed

+151
-59
lines changed

docs/install.rst

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,14 @@ Them hit the upload button and your sketch should upload and run.
6565
In some cases the Pico will encounter a hard hang and its USB port will not respond to the auto-reset request. Should this happen, just
6666
follow the initial procedure of holding the BOOTSEL button down while plugging in the Pico to enter the ROM bootloader.
6767

68-
Unable to Upload First Sketch
69-
-----------------------------
70-
If the Arduino IDE has never seen a serial port from a working device (Pico, AVR, or any other serial port), you
71-
may not be able to install using the prior directions because the ``Tools->Port`` menu will be grayed out and
72-
empty. In this case, a special workaround identified by @fjansson in `this issue report <https://github.com/earlephilhower/arduino-pico/issues/688>`_ .
73-
74-
To allow subsequent uploads to automatically work, you will need to manually install a UF2 binary onto the Raspberry Pi Pico one time to
75-
allow it to present a Serial port for the Arduino IDE to detect and save.
76-
77-
Perform the following steps to program a dummy sketch:
78-
79-
1. Open a new, empty sketch (doesn't work with a read-only example sketch).
80-
2. Compile it by pressing the "Verify" checkmark button.
81-
3. Select the ``Sketch -> Export Compiled Binary`` menu. Select a location e.g. the desktop. A folder is created there, containing a file ending in .uf2
82-
4. Copy this file to the Pico's drive, by drag and drop in the Explorer.
83-
84-
The Pico restarts and now now has a serial port. Now the Port menu in Arduino is not gray anymore, select the port there.
85-
After this, normal uploading from the Arduino editor should work.
86-
68+
Uploading the First Sketch
69+
--------------------------
70+
The first time you upload a sketch to a board, you'll need to use the built-in ROM bootloader to handle the upload and not a serial port.
71+
72+
1. Hold the BOOTSEL button while plugging in the board.
73+
2. Select ``Tools->Port->UF2 Board`` from the menu.
74+
3. Upload as normal.
75+
4. After the board boots up, select the new serial port from the ``Tools->Port`` menu.
8776

8877
Windows 7 Driver Notes
8978
----------------------

package/build_boards_manager_package.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ sed 's/^tools.picoprobe.cmd=.*//g' | \
113113
sed 's/^#tools.picoprobe.cmd=/tools.picoprobe.cmd=/g' | \
114114
sed 's/^tools.picodebug.cmd=.*//g' | \
115115
sed 's/^#tools.picodebug.cmd=/tools.picodebug.cmd=/g' | \
116+
sed 's/^discovery.rp2040.pattern=.*//g' | \
117+
sed 's/^#discovery.rp2040.pattern=/discovery.rp2040.pattern=/g' | \
118+
sed 's/^pluggable_discovery.rp2040.pattern=.*//g' | \
119+
sed 's/^#pluggable_discovery.rp2040.pattern=/pluggable_discovery.rp2040.pattern=/g' | \
120+
sed 's/^tools.uf2conv-network.cmd=.*//g' | \
121+
sed 's/^#tools.uf2conv-network.cmd=/tools.uf2conv-network.cmd=/g' | \
116122
sed "s/version=.*/version=$ver/g" |\
117123
sed -E "s/name=([a-zA-Z0-9\ -]+).*/name=\1($ver)/g"\
118124
> $outdir/platform.txt

platform.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ build.lwipdefs=-DLWIP_IPV6=0 -DLWIP_IPV4=1
9898
build.wificc=-DWIFICC=CYW43_COUNTRY_WORLDWIDE
9999

100100
# Allow Pico boards do be auto-discovered by the IDE
101-
discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" -I "{runtime.platform.path}/tools/discovery.py"
101+
#discovery.rp2040.pattern={runtime.tools.pqt-python3.path}/python3 -I "{runtime.platform.path}/tools/pluggable_discovery.py"
102+
discovery.rp2040.pattern={runtime.platform.path}/system/python3/python3 -I "{runtime.platform.path}/tools/pluggable_discovery.py"
103+
#pluggable_discovery.rp2040.pattern="{runtime.tools.pqt-python3.path}/python3" -I "{runtime.platform.path}/tools/pluggable_discovery.py"
104+
pluggable_discovery.rp2040.pattern="{runtime.platform.path}/system/python3/python3" -I "{runtime.platform.path}/tools/pluggable_discovery.py"
102105

103106

104107
# Compile patterns
@@ -149,6 +152,12 @@ recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build
149152
recipe.size.regex=^(?:\.boot2|\.text|\.rodata|\.ARM\.extab|\.ARM\.exidx)\s+([0-9]+).*
150153
recipe.size.regex.data=^(?:\.data|\.bss|\.ram_vector_table|\.uninitialized_data)\s+([0-9]+).*
151154

155+
upload.tool.uf2conv=uf2conv
156+
upload.tool.serial=uf2conv
157+
upload.tool.network=uf2conv-network
158+
upload.tool.picoprobe=picoprobe
159+
upload.tool.picodebug=picodebug
160+
152161
tools.uf2conv.path=
153162
# Because the variable expansion doesn't allow one tool to find another, the following lines
154163
# will point to "{runtime.platform.path}/tools/python3/python3" in GIT and
@@ -163,6 +172,14 @@ tools.uf2conv.upload.params.quiet=
163172
tools.uf2conv.upload.pattern="{cmd}" -I "{runtime.platform.path}/tools/uf2conv.py" --serial "{serial.port}" --family RP2040 --deploy "{build.path}/{build.project_name}.uf2"
164173
tools.uf2conv.upload.network_pattern="{network_cmd}" -I "{runtime.platform.path}/tools/espota.py" -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
165174

175+
#tools.uf2conv-network.cmd={runtime.tools.pqt-python3.path}/python3
176+
tools.uf2conv-network.cmd={runtime.platform.path}/system/python3/python3
177+
tools.uf2conv-network.upload.protocol=uf2
178+
tools.uf2conv-network.upload.params.verbose=
179+
tools.uf2conv-network.upload.params.quiet=
180+
tools.uf2conv-network.upload.pattern="{cmd}" -I "{runtime.platform.path}/tools/espota.py" -i "{upload.port.address}" -p "{upload.port.properties.port}" "--auth={upload.field.password}" -f "{build.path}/{build.project_name}.bin"
181+
182+
166183
#tools.picoprobe.cmd={runtime.tools.pqt-openocd.path}
167184
tools.picoprobe.cmd={runtime.platform.path}/system/openocd
168185
tools.picoprobe.upload.protocol=picoprobe

tools/discovery.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

tools/pluggable_discovery.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import subprocess
4+
import sys
5+
import time
6+
import threading
7+
8+
9+
toolspath = os.path.dirname(os.path.realpath(__file__))
10+
try:
11+
sys.path.insert(0, os.path.join(toolspath, ".")) # Add pyserial dir to search path
12+
import uf2conv # If this fails, we can't continue and will bomb below
13+
except ImportError:
14+
sys.stderr.write("uf2conv not found next to this tool.\n")
15+
sys.exit(1)
16+
17+
18+
scannerGo = False
19+
20+
def scanner():
21+
global scannerGo
22+
scannerGo = True
23+
boards = False
24+
while scannerGo:
25+
l = uf2conv.get_drives()
26+
if (len(l) > 0) and scannerGo and not boards:
27+
boards = True
28+
print ("""{
29+
"eventType": "add",
30+
"port": {
31+
"address": "UF2_Board",
32+
"label": "UF2 Board",
33+
"protocol": "uf2conv",
34+
"protocolLabel": "UF2 Devices",
35+
"properties": {
36+
"mac": "ffffffffffff",
37+
"pid" : "0x2e8a",
38+
"vid" : "0x000a"
39+
}
40+
}
41+
}""", flush=True)
42+
elif (len(l) == 0) and scannerGo and boards:
43+
boards = False
44+
print("""{
45+
"eventType": "remove",
46+
"port": {
47+
"address": "UF2_Board",
48+
"protocol": "uf2conv"
49+
}
50+
}""", flush = True)
51+
n = time.time() + 2
52+
while scannerGo and (time.time() < n):
53+
time.sleep(.1)
54+
scannerGo = True
55+
56+
def main():
57+
while True:
58+
cmdline = input()
59+
cmd = cmdline.split()[0]
60+
if cmd == "HELLO":
61+
print(""" {
62+
"eventType": "hello",
63+
"message": "OK",
64+
"protocolVersion": 1
65+
}""", flush = True)
66+
elif cmd == "START":
67+
print("""{
68+
"eventType": "start",
69+
"message": "OK"
70+
}""", flush = True);
71+
elif cmd == "STOP":
72+
scannerGo = False
73+
while not scannerGo:
74+
time.sleep(.1)
75+
print("""{
76+
"eventType": "stop",
77+
"message": "OK"
78+
}""", flush = True)
79+
elif cmd == "QUIT":
80+
scannerGo = False
81+
print("""{
82+
"eventType": "quit",
83+
"message": "OK"
84+
}""", flush = True)
85+
return
86+
elif cmd == "LIST":
87+
l = uf2conv.get_drives()
88+
if len(l) > 0:
89+
print ("""{
90+
"eventType": "list",
91+
"ports": [
92+
{
93+
"address": "UF2_Board",
94+
"label": "UF2 Board",
95+
"protocol": "uf2conv",
96+
"protocolLabel": "UF2 Devices",
97+
"properties": {
98+
"mac": "ffffffffffff",
99+
"pid" : "0x2e8a",
100+
"vid" : "0x000a"
101+
}
102+
}
103+
]
104+
}""", flush=True)
105+
else:
106+
print ("""{
107+
"eventType": "list",
108+
"ports": [ ]
109+
}""", flush=True)
110+
elif cmd == "START_SYNC":
111+
print("""{
112+
"eventType": "start_sync",
113+
"message": "OK"
114+
}""", flush = True)
115+
scannerGo = True
116+
threading.Thread(target = scanner).start()
117+
time.sleep(.5)
118+
119+
main()

0 commit comments

Comments
 (0)