OpenLightingProject / rp2040-dmxsun

RP2040-based USB DMX dongle with integrated web server
Apache License 2.0
96 stars 16 forks source link

Support Web interface, Art-Net, E1.31 and EDP via WiFi on the Pico W #49

Open kripton opened 2 years ago

kripton commented 2 years ago

Raspberry Pi released the Pico W including on-board WiFi :partying_face: https://www.raspberrypi.com/news/raspberry-pi-pico-w-your-6-iot-platform/

While the radio-module doesn't support narrow-band RF in the 2.4GHz band and Bluetooth is not yet supported/enabled, the new Pico W is pin-compatible (except the on-board LED) with the current one.

It sounds like a good "step up" from the regular Pico and to enhance the dmxsun with the web interface, Art-Net, E1.31 and EDP via the WiFi-interface in addition to the emulated CDC NCM via USB.

Things needing work:

6by9 commented 2 years ago
In file included from /opt/raspberrypi/pico-sdk/src/rp2_common/pico_cyw43_arch/cyw43_arch.c:12:
/opt/raspberrypi/pico-sdk/lib/cyw43-driver/src/cyw43.h:118:17: error: field 'dhcp_client' has incomplete type
  118 |     struct dhcp dhcp_client;
      |                 ^~~~~~~~~~~

Most likely unrelated to 2 copies of lwip. https://github.com/OpenLightingProject/rp2040-dmxsun/blob/main/src/lwipopts.h#L45

#define LWIP_DHCP                       0

which means that "lwip/dhcp.h" is not included.

Next issue comes up of netif_list not defined, which is due to https://github.com/OpenLightingProject/rp2040-dmxsun/blob/main/src/lwipopts.h#L75

#define LWIP_SINGLE_NETIF               1

Link then fails as we have multiple definitions for sys_arch_protect, ``sys_arch_unprotectandsys_now``` (pico-sdk/src/rp2_common/pico_lwip/nosys.c and rp2040-dmxsun/src/tusb_lwip_glue.c)

6by9 commented 2 years ago

Hacking done and it builds and runs for Pico-W. Branch pushed to https://github.com/6by9/rp2040-dmxsun/tree/pico-w

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug  -DPICO_BOARD=pico_w -DWIFI_SSID="Your Network" -DWIFI_PASSWORD="Your Password" ../src
make -j4

No code written to actually add the wifi side, but the USB network interface still works. I probably should have based it off your https://github.com/kripton/rp2040-dongle/tree/ethernet branch, but there you go.

kripton commented 2 years ago

Amazing, nice work! I can confirm that the compilation works and includes the cyw43-driver. However, I don't see the firmware getting included and the resulting uf2-file is still 1.5MByte. Regarding flash memory consumption, here's the idea to compress the firmware: https://github.com/georgerobotics/cyw43-driver/issues/4

kripton commented 2 years ago

Oh, this is how the firmware does actually get included:

[  2%] Generating cyw43_resource.o
make[2]: Entering directory '/home/kripton/git/rp2040-dmxsun/build2'
cd /opt/raspberrypi/pico-sdk/lib/cyw43-driver/firmware && /usr/bin/arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm --readonly-text --rename-section .data=.big_const,contents,alloc,load,readonly,data --redefine-sym _binary_43439A0_7_95_49_00_combined_start=fw_43439A0_7_95_49_00_start --redefine-sym _binary_43439A0_7_95_49_00_combined_end=fw_43439A0_7_95_49_00_end --redefine-sym _binary_43439A0_7_95_49_00_combined_size=fw_43439A0_7_95_49_00_size 43439A0-7.95.49.00.combined /home/kripton/git/rp2040-dmxsun/build2/pico-sdk/src/rp2_common/cyw43_driver/cyw43_resource.o

So, yes, the resulting uf2-file does not grow significantly :partying_face: . However, since objcopy is used, simply compressing the file won't work. Some more intelligence might be needed.

kripton commented 2 years ago

Correcting my previous comment: That objcopy call wraps the binary firmware in a valid elf object file so it can be linked. Content/format of the input doesn't matter so precompresssed should be fine

kripton commented 1 year ago

Mostly done with #68. WebUI, ArtNet and sACN work over WiFi when configured properly in the source code.