-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
picow: turn off CIRCUITPY_USB_HOST and CIRCUITPY_PICODVI #9303
Conversation
16a8186
to
46b172e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config:
Adafruit CircuitPython 9.1.0-beta.3-16-g9601f4e58b on 2024-06-04; Raspberry Pi Pico W with rp2040
adafruit-circuitpython-bundle-9.x-mpy-20240604
(except for HTTP Server from #88):
Results:
Not quite enough for the HTTP Server library with TLS, but should give a good bit more headroom for more complex HTTP[S] client, HTTP Server, or socket-level projects.
HTTPS Requests Code...
# HTTP[S] Requests Test
# Pico W + W5100S hat
import time
time.sleep(3) # wait for serial
import gc
print(f'{gc.mem_free()=}')
import os
import ssl
import adafruit_connection_manager
import adafruit_requests
print(f'{gc.mem_free()=}')
NATIVE = False
if NATIVE:
import wifi
radio = wifi.radio
radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD"))
else:
import board
import busio
import digitalio
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
spi = busio.SPI(board.GP18, board.GP19, board.GP16)
cs = digitalio.DigitalInOut(board.GP17)
rst = digitalio.DigitalInOut(board.GP20)
radio = WIZNET5K(spi, cs, reset=rst, mac='de:ad:be:ef:fe:cd')
pool = adafruit_connection_manager.get_radio_socketpool(radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(radio)
requests = adafruit_requests.Session(pool, ssl_context)
URL = "https://httpbin.org/get"
for _ in range(0, 10):
print("-" * 40)
print("Fetching JSON data from %s" % URL)
with requests.get(URL) as response:
print("JSON Response: ", response.json())
gc.collect()
print(f'{gc.mem_free()=}')
time.sleep(1)
PicoW HTTPS Requests:
84976 bytes free after each request
WIZnet HTTPS Requests:
45168 bytes free after each request
HTTP[S] Server Test Code...
# HTTP[S] Server Test
# Pico W + W5100S hat
import time
time.sleep(3) # wait for serial
import gc
print(f'{gc.mem_free()=}')
import os
import ssl
import adafruit_connection_manager
from adafruit_httpserver import Server, Request, Response
print(f'{gc.mem_free()=}')
PORT = 443
NATIVE = False
HTTPS = True
if NATIVE:
import wifi
radio = wifi.radio
radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD"))
ipv4_address = str(radio.ipv4_address)
else:
import board
import busio
import digitalio
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
spi = busio.SPI(board.GP18, board.GP19, board.GP16)
cs = digitalio.DigitalInOut(board.GP17)
rst = digitalio.DigitalInOut(board.GP20)
radio = WIZNET5K(spi, cs, reset=rst, mac='de:ad:be:ef:fe:cd')
ipv4_address = radio.pretty_ip(radio.ip_address)
pool = adafruit_connection_manager.get_radio_socketpool(radio)
server = Server(
pool,
root_path="/static",
https=HTTPS,
certfile="cert.pem",
keyfile="key.pem",
debug=True,
)
@server.route("/")
def base(request: Request):
gc.collect()
return Response(request, f"Hello from {ipv4_address}:{PORT} {gc.mem_free()=}")
server.start(ipv4_address)
while True:
try:
server.poll()
except OSError as error:
print(error)
PicoW HTTP Server:
71408 bytes free during each Response
WIZnet HTTP Server:
33328 bytes free during each Response
PicoW HTTPS Server:
MemoryError:
(in poll
)
WIZnet HTTPS Server:
MemoryError: memory allocation failed, allocating 2120 bytes
(in poll
)
How much do you gain by leaving PICODVI on? I could see it being useful for data display from wifi. Does usb host work at all as-is? |
Only CIRCUITPY_USB_HOST on:
Only CIRCUITPY_PICODVI on:
Both off (this PR):
So So I'm inclined to turn them both off, especially
I don't know at all, but I think using the Pico W for any reasonable-sized web work outweighs both of the above. |
How are the other boards with picow soldered down setup? I guess this is ok for picow because folks can use the pico build if they don't want wifi. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! Thanks for figuring this out.
@tannewt: I don't think so. The board led is wired differently. And VBUS and VSYS monitoring also are different. |
Free up RAM on the Pico W build so that more networking can be done, by disabling
CIRCUITPY_USB_HOST
andCIRCUITPY_PICODVI
. Note thatCIRCUIPY_PICODVI
off by default on many RP2040 boards.It still seems to be the case that once a networking error happens, the co-processor or its supporting code may get into a bad state that requires a hard reset.