raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.67k stars 913 forks source link

FreeRTOS with LWIP #1592

Closed hajmedwissem closed 8 months ago

hajmedwissem commented 9 months ago

hi , I use LWIP, which is part of my Pico SDK. I tried to integrate LWIP with FreeRTOS, but I encountered errors in lwip_port_rand. [build] /usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: CMakeFiles/pico_server.dir/pico-sdk/lib/lwip/src/core/dns.c.obj: in function dns_create_txid': [build] /home/wissem/Desktop/pico_server/pico-sdk/lib/lwip/src/core/dns.c:1025: undefined reference tolwip_port_rand' [build] /usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: CMakeFiles/pico_server.dir/pico-sdk/lib/lwip/src/core/tcp.c.obj: in function tcp_init': [build] /home/wissem/Desktop/pico_server/pico-sdk/lib/lwip/src/core/tcp.c:204: undefined reference tolwip_port_rand' [build] /usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: CMakeFiles/pico_server.dir/pico-sdk/lib/lwip/src/core/udp.c.obj: in function udp_init': [build] /home/wissem/Desktop/pico_server/pico-sdk/lib/lwip/src/core/udp.c:90: undefined reference tolwip_port_rand'

"I think the issue is in the configuration files of FreeRTOS and lwIP. Can someone assist me in configuring both FreeRTOS and lwIP to work together?"

peterharperuk commented 9 months ago

We already have freertos working with lwip. See pico-examples/pico_w/wifi/freertos. It sounds like you're missing a library

hajmedwissem commented 9 months ago

Thank you, Peter.

I apologize; maybe I was not clear in the details of my question. I want to send data over USB and integrate FreeRTOS, LWIP, and TinyUSB to work together. So, I don't need to use the CYW43 chip.

peterharperuk commented 8 months ago

I think this must be a bug in your code. Make sure you link to pico_lwip_freertos. This should add pico_lwip/include to the include path. arch/cc.h is included via something like this

pico-sdk/src/rp2_common/pico_lwip/include/arch/cc.h pico-sdk/lib/lwip/src/include/lwip/arch.h pico-sdk/lib/lwip/src/include/lwip/debug.h pico-sdk/lib/lwip/src/include/lwip/opt.h pico-sdk/lib/lwip/src/core/dns.c

We define LWIP_RAND in here

ifndef LWIP_RAND

include "pico/rand.h"

// Use the pico_rand library which goes to reasonable lengths to try to provide good entropy

define LWIP_RAND() get_rand_32()

endif

So you should ask why this isn't working for your code.

peterharperuk commented 8 months ago

Alternatively, just define lwip_port_rand yourself to be get_rand_32