diff --git a/examples/rp2040/pico-rmii/CMakeLists.txt b/examples/rp2040/pico-rmii/CMakeLists.txt index 05df7302..443ba2e3 100644 --- a/examples/rp2040/pico-rmii/CMakeLists.txt +++ b/examples/rp2040/pico-rmii/CMakeLists.txt @@ -12,7 +12,7 @@ add_executable(firmware target_include_directories(firmware PUBLIC .) -target_link_libraries(firmware hardware_pio hardware_dma pico_stdlib) +target_link_libraries(firmware hardware_pio hardware_dma pico_stdlib pico_rand) pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 1) # Route stdio diff --git a/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt b/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt index d2cdb555..32ca308d 100644 --- a/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt +++ b/examples/rp2040/pico-rndis-dashboard/CMakeLists.txt @@ -17,7 +17,7 @@ target_include_directories(firmware PUBLIC . pico-sdk/lib/tinyusb/lib/networking) -target_link_libraries(firmware pico_stdlib hardware_spi tinyusb_device) +target_link_libraries(firmware pico_stdlib pico_rand hardware_spi tinyusb_device) pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 0) # Route stdio diff --git a/examples/rp2040/pico-rndis-device/CMakeLists.txt b/examples/rp2040/pico-rndis-device/CMakeLists.txt index b3fc0ebf..7d7138b2 100644 --- a/examples/rp2040/pico-rndis-device/CMakeLists.txt +++ b/examples/rp2040/pico-rndis-device/CMakeLists.txt @@ -15,7 +15,7 @@ target_include_directories(firmware PUBLIC . pico-sdk/lib/tinyusb/lib/networking) -target_link_libraries(firmware pico_stdlib hardware_spi tinyusb_device) +target_link_libraries(firmware pico_stdlib pico_rand hardware_spi tinyusb_device) pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 0) # Route stdio diff --git a/examples/rp2040/pico-w-sdk-builtin/CMakeLists.txt b/examples/rp2040/pico-w-sdk-builtin/CMakeLists.txt index 035f8264..f0414489 100644 --- a/examples/rp2040/pico-w-sdk-builtin/CMakeLists.txt +++ b/examples/rp2040/pico-w-sdk-builtin/CMakeLists.txt @@ -16,7 +16,7 @@ target_include_directories(firmware PUBLIC . ) -target_link_libraries(firmware hardware_pio hardware_dma pico_stdlib cyw43_driver_picow) +target_link_libraries(firmware hardware_pio hardware_dma pico_stdlib pico_rand cyw43_driver_picow) pico_add_extra_outputs(firmware) # create map/bin/hex file etc. pico_enable_stdio_usb(firmware 1) # Route stdio diff --git a/mongoose.c b/mongoose.c index 25d92e41..5e0aba9d 100644 --- a/mongoose.c +++ b/mongoose.c @@ -16784,6 +16784,9 @@ bool mg_random(void *buf, size_t len) { #if MG_ARCH == MG_ARCH_ESP32 while (len--) *p++ = (unsigned char) (esp_random() & 255); success = true; +#elif MG_ARCH == MG_ARCH_RP2040 + while (len--) *p++ = (unsigned char) (get_rand_32() & 255); + success = true; #elif MG_ARCH == MG_ARCH_WIN32 static bool initialised = false; #if defined(_MSC_VER) && _MSC_VER < 1700 diff --git a/mongoose.h b/mongoose.h index ddf3d3cf..3749c6c5 100644 --- a/mongoose.h +++ b/mongoose.h @@ -254,6 +254,7 @@ static inline int mg_mkdir(const char *path, mode_t mode) { #include #include +#include int mkdir(const char *, mode_t); #if MG_OTA == MG_OTA_PICOSDK diff --git a/src/arch_rp2040.h b/src/arch_rp2040.h index e9c1eee3..c6f70d35 100644 --- a/src/arch_rp2040.h +++ b/src/arch_rp2040.h @@ -11,6 +11,7 @@ #include #include +#include int mkdir(const char *, mode_t); #if MG_OTA == MG_OTA_PICOSDK diff --git a/src/util.c b/src/util.c index 469d7d2a..83433758 100644 --- a/src/util.c +++ b/src/util.c @@ -17,6 +17,9 @@ bool mg_random(void *buf, size_t len) { #if MG_ARCH == MG_ARCH_ESP32 while (len--) *p++ = (unsigned char) (esp_random() & 255); success = true; +#elif MG_ARCH == MG_ARCH_RP2040 + while (len--) *p++ = (unsigned char) (get_rand_32() & 255); + success = true; #elif MG_ARCH == MG_ARCH_WIN32 static bool initialised = false; #if defined(_MSC_VER) && _MSC_VER < 1700