Page 1 of 2

Pico MicroPython with networking over USB

Posted: Tue Apr 20, 2021 9:03 pm
by HermannSW
Code currently is too bad for commit+push to my fork.
But running Pico Micropython on core0 and lwip networking plus webserver on core1 just works for the first time. You can download firmware.uf2 and try out yourself, see this posting for details:
https://www.raspberrypi.org/forums/view ... 1#p1854481

Webpage hosted on Pico 192.168.7.1 (left) in Pi4B (192.168.178.2) browser.
UART minicom session turning on Pico led (right).
16MP smartphone photo: https://stamm-wilbrandt.de/en/forum/mp/ ... 220347.jpg
Scaled to 15%:
Image

Re: Pico MicroPython with networking over USB

Posted: Wed Apr 21, 2021 6:21 pm
by HermannSW
I am done with cleanup and commited+pushed the changes to my micropython fork with this commit (it shows nicely what all needed to be changed and where):
https://github.com/Hermann-SW/micropyth ... 192ab2a123


In case you just want to try without building MicroPython yourself, here is prebuilt firmware.uf2:
https://github.com/Hermann-SW/micropyth ... rmware.uf2


For building MicroPython for the Pico with USB networking from source
https://datasheets.raspberrypi.org/pico ... pdf#page=5

lwip submodule needs to be inited as well:
git submodule update --init -- lib/pico-sdk lib/tinyusb lib/lwip

I added fork mission statement as well:
https://github.com/Hermann-SW/micropyth ... -statement
Image


Pi4B with official display Screenshot:
Image

Re: Pico MicroPython with networking over USB

Posted: Wed Apr 21, 2021 8:49 pm
by kevinkk525
This looks like a lot of development effort and it's great that it works, but I can't find a reason for this? Maybe you can explain it to me. What's the point of forwarding the network of a PC to the Pico? I could just do anything on the PC directly and any PC would be an expensive network adapter.

Why not use an Esp32 for the network?

Re: Pico MicroPython with networking over USB

Posted: Thu Apr 22, 2021 7:08 am
by pythoncoder
I may be wrong but my understanding of this project is that the Pico/ESP8266-01 combination hosts an HTTPS website on one core while running arbitrary Python code on the other. The Python side supports a REPL over UART for debugging. This could have plenty of applications.

As you say, I imagine you could do similar on an ESP32 using threading. The Pico solution may offer higher performance with processing shared between two cores and the ESP8266. The MicroPython architecture on ESP32 means that much of the work would be done on one core.

Re: Pico MicroPython with networking over USB

Posted: Thu Apr 22, 2021 7:15 am
by HermannSW
kevinkk525 wrote:
Wed Apr 21, 2021 8:49 pm
Why not use an Esp32 for the network?
I connected ESP01 to Pico for enabling Pico to do HTTPS GET requests over ESP01's Wifi -- but that was not real networking between Pico and ESP01. See thread pointed to in my signature.
kevinkk525 wrote:
Wed Apr 21, 2021 8:49 pm
This looks like a lot of development effort and it's great that it works, but I can't find a reason for this? Maybe you can explain it to me. What's the point of forwarding the network of a PC to the Pico?
The point is to give Pico MicroPython networking, so that any usocket code will work on it as is.

The webserver is only there (as of now) as 3rd layer of testing [ ifconfig usb / ping 192.168.7.1 / curl http://192.168.7.1 ] .

When I will have usocket running with lwIP over USB, I will revisit the connected ESP01 and get hopefully "real" Wifi networking for the Pico.

Re: Pico MicroPython with networking over USB

Posted: Thu Apr 22, 2021 7:19 am
by pythoncoder
HermannSW wrote:
Thu Apr 22, 2021 7:15 am
...
The point is to give Pico MicroPython networking, so that any usocket code will work on it as is.
...
When I will have usocket running with lwIP over USB, I will revisit the connected ESP01 and get hopefully "real" Wifi networking for the Pico.
Light dawns :D

Re: Pico MicroPython with networking over USB

Posted: Thu Apr 22, 2021 7:48 am
by HermannSW
pythoncoder wrote:
Thu Apr 22, 2021 7:19 am
Light dawns :D
I hope so :D

Can you help on MicroPython networking client examples (with and without ssl) only working with google. com?
viewtopic.php?f=15&t=10318

Re: Pico MicroPython with networking over USB

Posted: Thu Apr 22, 2021 10:39 am
by kevinkk525

HermannSW wrote:
When I will have usocket running with lwIP over USB, I will revisit the connected ESP01 and get hopefully "real" Wifi networking for the Pico.
Awesome, that was the long term goal I was hoping for!
Would be great if you get lwip over uart using an esp01/esp8266/Esp32 working.

Re: Pico MicroPython with networking over USB

Posted: Thu Apr 22, 2021 11:28 am
by HermannSW
HermannSW wrote:
Thu Apr 22, 2021 7:48 am
Can you help on MicroPython networking client examples (with and without ssl) only working with google. com?
viewtopic.php?f=15&t=10318
I identified root cause -- Micropython network http[s] examples are too sloppy, most webservers need "Host" header presented.

I committed and pushed fix for both examples on my fork, for details see commit:
https://github.com/Hermann-SW/micropyth ... cf85fbb86d

Both examples now work with MicroPython Unix port as well as python3:
mp_corrected_examples.png
mp_corrected_examples.png
mp_corrected_examples.png (80.08 KiB) Viewed 6673 times

Re: Pico MicroPython with networking over USB

Posted: Tue May 04, 2021 1:12 pm
by hippy
kevinkk525 wrote:
Thu Apr 22, 2021 10:39 am
Would be great if you get lwip over uart using an esp01/esp8266/Esp32 working.
Ultimately it will be great when 'lwip' is running on a Pico alongside MicroPython with the REPL available via USB Virtual Serial Port, supporting network interfacing via USB, ENC28J60 NIC, LAN8720 RMII PHY, UART+ESP and UART+SLIP - Ideally all, configurable at build time.

Currently there is proof of concept for all of that, nothing perfectly integrated with MicroPython so far, but I am sure it will come.