RK11300 WizBlock compilation fails with Platform.io: "pico/rand.h" no such file

Hi!,

I’m trying to get started with the RAK11310 LoRa module. My first attempts with Arduino IDE have been working fine.

Now I’m setting up my PlatformIO based development environment, but can’t get compilation to work. I’ve taken all the steps at https://learn.rakwireless.com/hc/en-us/articles/26687276346775-How-To-Perform-Installation-of-Board-Support-Package-in-PlatformIO

  • Set up Visual Studio Code
  • Set up Platformio extension
  • Added the “Raspberry Pi 2040” platform
  • Created new project, so the platform files are downloaded
  • Added the RAK_PATCH.zip, extracted it to ~/.platformio/RAK_PATCH and can the Python script (succeeded - no error messages):
[thomas@thomas-nb]~/.platformio/RAK_PATCH% python rak_patch.py 
Patching RAK4631
Could not find ../platforms/nordicnrf52/boards
Patching RAK11200
Could not find ../platforms/espressif32/boards
Patching RAK11310
Patched RAK11310
Patch done, check output if successful

After that I tried to compile the new (almost empty) project again, which only includes this example source file:

#include <Arduino.h>

// put function declarations here:
int myFunction(int, int);

void setup() {
  // put your setup code here, to run once:
  int result = myFunction(2, 3);
}

void loop() {
  // put your main code here, to run repeatedly:
}

// put function definitions here:
int myFunction(int x, int y) {
  return x + y;
}

but compilation fails:

Processing rak11300 (platform: raspberrypi; board: rak11300; framework: arduino)
---------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/raspberrypi/rak11300.html
PLATFORM: Raspberry Pi RP2040 (1.14.0) > WisBlock RAK11300
HARDWARE: RP2040 133MHz, 264KB RAM, 2MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink, raspberrypi-swd)
PACKAGES: 
 - framework-arduino-mbed @ 4.1.5 
 - tool-rp2040tools @ 1.0.2 
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 42 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/rak11300/src/main.cpp.o
Compiling .pio/build/rak11300/FrameworkArduinoVariant/double_tap_usb_boot.cpp.o
Compiling .pio/build/rak11300/FrameworkArduinoVariant/variant.cpp.o
Compiling .pio/build/rak11300/FrameworkArduino/Interrupts.cpp.o
In file included from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/device.h:35,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/platform.h:28,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/FileHandle.h:25,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/macros.h:41,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/variants/WisBlock_RAK11300_Board/pins_arduino.h:2,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/Arduino.h:76,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/Interrupts.cpp:19:
/home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/objects.h:36:10: fatal error: pico/rand.h: No such file or directory
   36 | #include "pico/rand.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/rak11300/FrameworkArduino/Interrupts.cpp.o] Error 1
In file included from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/device.h:35,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/platform.h:28,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/FileHandle.h:25,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/macros.h:41,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/variants/WisBlock_RAK11300_Board/pins_arduino.h:2,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/Arduino.h:76,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/variants/WisBlock_RAK11300_Board/variant.cpp:1:
/home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/objects.h:36:10: fatal error: pico/rand.h: No such file or directory
   36 | #include "pico/rand.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/rak11300/FrameworkArduinoVariant/variant.cpp.o] Error 1
In file included from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/device.h:35,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/platform.h:28,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/FileHandle.h:25,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/Serial.h:27,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/Arduino.h:104,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/macros.h:26,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/variants/WisBlock_RAK11300_Board/double_tap_usb_boot.cpp:6:
/home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/objects.h:36:10: fatal error: pico/rand.h: No such file or directory
   36 | #include "pico/rand.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/rak11300/FrameworkArduinoVariant/double_tap_usb_boot.cpp.o] Error 1
In file included from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/device.h:35,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/platform.h:28,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/FileHandle.h:25,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/macros.h:41,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/variants/WisBlock_RAK11300_Board/pins_arduino.h:2,
                 from /home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/Arduino.h:76,
                 from src/main.cpp:1:
/home/thomas/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/objects.h:36:10: fatal error: pico/rand.h: No such file or directory
   36 | #include "pico/rand.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/rak11300/src/main.cpp.o] Error 1
================================ [FAILED] Took 3.81 seconds ================================

 *  The terminal process "platformio 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

It looks like some files from the Pico SDK cannot be found. I’m quite new to Platform.io and the whole evosystem, so I’m grateful for some guidance and tips how to fix it. :slight_smile:

Update: Compilation works fine when setting

board = pico

in platformio.ini, but that of course does not match the RAK11300 board. Still it shows that the problem is probably specific to the RAK11300 files / patches.

Not 100 % sure, but I might have fixed this myself by appending the following lines to ~/.platformio/packages/framework-arduino-mbed/variants/WisBlock_RAK11300_Board/includes.txt:

-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand/include
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand/include/pico

right below

-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_platform/include/pico

then recompile => works! Seems like the RAKWireless files are outdated?

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

Thank you @stoerfall for the fix.

Long time since I touched the RAK11310 the last time. Just tried today and got the same error.
I updated the RAK_PATCH script in our WisBlock Repo.