RAK11310 second core

Hi - is it possible to use the second core of the RP2040? Is there support for pico_multicore?

thanks

Welcome to the forum @markn

We are using a fork of ArduinoCore-mbed, we are not actively developing the BSP.

The ArduinoCore-mbed theoretically supports multi core, but there are many issues ==> Issues with RP2040 multi core and when I tried a simple program to use the 2nd core, it basically does not work and crashes either immediately or after a while:

#include <Arduino.h>
#include <mbed.h>
#include <multicore.h>
// #define delay(x) sleep_ms(x) // Normal delay doesnt work on 2nd core

void loop2(void);

void setup()
{
	pinMode(LED_GREEN, OUTPUT);
	pinMode(LED_BLUE, OUTPUT);

	digitalWrite(LED_GREEN, LOW);
	digitalWrite(LED_BLUE, LOW);

	Serial.begin(115200);

	time_t serial_timeout = millis();
	// On nRF52840 the USB serial is not available immediately
	while (!Serial)
	{
		if ((millis() - serial_timeout) < 5000)
		{
			delay(100);
			digitalWrite(LED_GREEN, !digitalRead(LED_GREEN));
		}
		else
		{
			break;
		}
	}

	digitalWrite(LED_GREEN, HIGH);
	Serial.println("Launching Core 2");
	multicore_launch_core1(loop2);
}

void loop()
{
	Serial.println("Hello from Core 1");

	delay(5000);
}

void loop2()
{
	uint32_t t_int = millis();
	while (1)
	{
		if ((millis() - t_int) > 1000)
		{
			digitalWrite(LED_BLUE, !digitalRead(LED_BLUE));
			digitalWrite(LED_GREEN, !digitalRead(LED_GREEN));
			t_int = millis();
		}
		yield();
	}
}

So final answer NO SUPPORT unless ArduinoCore-mbed solves the issues.

Thank you so much for your prompt and informative reply.

Interestingly I am able to use both cores using the Raspberry Pi Pico libraries. Using Visual Studio Code and GCC for arm-none-eabi I can build a simple blink test and install it on the RAK11300 by pressing the boot button on the RAK11300 while connecting USB. This brings up file manager where I can copy the uf2 file to which causes the RAK11300 to restart like any standard Pico. This is the code I am using:

#include <stdio.h>
#include “pico/stdlib.h”
#include “D:\Pico\pico-sdk\src\rp2_common\pico_multicore\include\pico\multicore.h”

#define LED_GREEN 23
#define LED_BLUE 24

//this function will execute on core1
void core1_blink() {
//initialize pin, and set to output
gpio_init(LED_BLUE);
gpio_set_dir(LED_BLUE, GPIO_OUT);

// create infinite loop, which will toggle the green on-board LED with 333ms delays
while(1) {
    gpio_put(LED_BLUE, 1);
    sleep_ms(333);
    gpio_put(LED_BLUE, 0);
    sleep_ms(333);
}

}

int main() {

multicore_launch_core1(core1_blink);

gpio_init(LED_GREEN);
gpio_set_dir(LED_GREEN, GPIO_OUT);
while (1) {

// printf(“blinking!\r\n”);
gpio_put(LED_GREEN, 1);
sleep_ms(250);
gpio_put(LED_GREEN, 0);
sleep_ms(250);
}
}

The two LEDs blink at different rates and it seems quite stable. So it appears that there are issues with ArduinoCore-mbed but using the “native” Pico SDK will work. I have had problems with VS Code finding include files. No idea why it would find pico/stdlib but not pico/multicore so I took the easy way out and put in the full path.

Anyway my next step is to set it up with the SWD connections on the RAK11300 connected to I2C on a separate Pico using this a a guide:

https://www.digikey.ca/en/maker/projects/raspberry-pi-pico-and-rp2040-cc-part-2-debugging-with-vs-code/470abc7efb07432b82c95f6f67f184c0

One unfortunate issue is that printf statements are routed to UART0 but only UART1 appears to be available on the J12 connector of the RAK19001 base board. However I should be able to use uart_puts to write debug messages to UART1.

If you know of any issues with using the SWD output pins on the RAK11300 please let me know.

I am using the SWD port only for flashing firmware if I need to, I never tried the debug functionality. But theoretically there should be no problem.

Unfortunately I am not able to get the SWD interface to work with picoprobe installed on a RP Pico. I get the following messages:

Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Info : clock speed 5000 kHz
Info : DAP init failed

However I have been able to use UART0 and UART1 to send debug messages to a Raspberry Pi Nano and display them in Minicom. The odd thing is that the messages are not on the UART channel that I would expect. I am using the following code, which works very well:

#include <stdio.h>
#include “pico/stdlib.h”
#include “D:\Pico\pico-sdk\src\rp2_common\pico_multicore\include\pico\multicore.h”

#define LED_GREEN 23
#define LED_BLUE 24

#define IO1 6
#define IO2 22

#define UART1TX 4
#define UART1Rx 5

//this function will execute on core1
void core1_blink() {
//initialize pin, and set to output
gpio_init(LED_BLUE);
gpio_set_dir(LED_BLUE, GPIO_OUT);

// create infinite loop, which will toggle the green on-board LED with 333ms delays
while(1) {
    printf("blinking core 1\r\n");
    gpio_put(LED_BLUE, 1);
    sleep_ms(333);
    gpio_put(LED_BLUE, 0);
    sleep_ms(333);
    gpio_put(LED_BLUE, 1);
    sleep_ms(333);
    gpio_put(LED_BLUE, 0);
    sleep_ms(1000);
}

}

int main() {
stdio_init_all();

multicore_launch_core1(core1_blink);

gpio_init(LED_GREEN);
gpio_set_dir(LED_GREEN, GPIO_OUT);

gpio_init(IO1);
gpio_set_dir(IO1, GPIO_OUT);

gpio_init(IO2);
gpio_set_dir(IO2, GPIO_OUT);

uart_init(uart1, 115200);
gpio_set_function(4, GPIO_FUNC_UART);
gpio_set_function(5, GPIO_FUNC_UART);

while (1) {
    printf("blinking core 0\r\n");
    gpio_put(LED_GREEN, 1);
    gpio_put(IO1, 1);
    gpio_put(IO2, 1);
    uart_puts(uart1, "blinking uart 1!\r\n");
    sleep_ms(250);
    gpio_put(LED_GREEN, 0);
    gpio_put(IO1, 0);
    gpio_put(IO2, 0);
    sleep_ms(250);
}

}

When I connect the RP Nano to RAK19001 J10/J15 pin labeled TXD0 I see

blinking uart1!
blinking uart1!

and on TXD1 I see the messages

blinking core 0
blinking core 0
blinking core 0
blinking core 0
blinking core 1
blinking core 0

Very odd since printf should go to UART0 and shows up on TXD1 and writes specifically to UART1 come out on TXD0.

My intention is to read and process accelerometer data on core 1 and display and transmit it using LoRa on core 0. At least I am able to show debug messages easily so I am feeling encouraged.