Use Pico-SDK RNG

This commit is contained in:
Sergio R. Caprile 2024-11-06 17:38:53 -03:00
parent 5559d0fa68
commit 094202ff16
8 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -16775,6 +16775,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

View File

@ -254,6 +254,7 @@ static inline int mg_mkdir(const char *path, mode_t mode) {
#include <time.h>
#include <pico/stdlib.h>
#include <pico/rand.h>
int mkdir(const char *, mode_t);
#if MG_OTA == MG_OTA_PICOSDK

View File

@ -11,6 +11,7 @@
#include <time.h>
#include <pico/stdlib.h>
#include <pico/rand.h>
int mkdir(const char *, mode_t);
#if MG_OTA == MG_OTA_PICOSDK

View File

@ -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