Enable UART on QSPI pins #2280

Open
opened 2025-02-16 14:57:40 -06:00 by retsifp · 10 comments
retsifp commented 2025-02-16 14:57:40 -06:00 (Migrated from github.com)

Hi,

I'm doing tests with the UART bootloader, which is described in the datasheet of RP2350 (Chapter 5.8).
The pins SD2 and SD3 of QSPI are used as TX and RX by the bootloader. It works very good, but it would make sense to use the same pins in 'user mode' for communication with another controller. However it looks like the SDK lacks any functions to switch UART to bank1 pins?
So at the moment it's not possible to use the same pins as the bootloader uses in 'user mode', disregarding the possibility to manually set the registers to do so (but for that I'm too far away ...).

Would be great if there could be a solution in the long term :)

BR Thomas.

Hi, I'm doing tests with the UART bootloader, which is described in the [datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf) of RP2350 (Chapter 5.8). The pins SD2 and SD3 of QSPI are used as TX and RX by the bootloader. It works very good, but it would make sense to use the same pins in 'user mode' for communication with another controller. However it looks like the SDK lacks any functions to switch UART to bank1 pins? So at the moment it's not possible to use the same pins as the bootloader uses in 'user mode', disregarding the possibility to manually set the registers to do so (but for that I'm too far away ...). Would be great if there could be a solution in the long term :) BR Thomas.
burtyb commented 2025-02-16 15:51:20 -06:00 (Migrated from github.com)

I think the example in https://github.com/raspberrypi/pico-examples/pull/571 does what you need? It uses qspi_gpio_set_function() to switch the pins to UART and then uses them to communicate with the RP2350 that booted it.

I think the example in https://github.com/raspberrypi/pico-examples/pull/571 does what you need? It uses qspi_gpio_set_function() to switch the pins to UART and then uses them to communicate with the RP2350 that booted it.
retsifp commented 2025-02-17 10:59:14 -06:00 (Migrated from github.com)

Wow, @burtyb thanks! :-)
This exactly what I needed, and it works just great!

By the way, my code is here: https://codeberg.org/retsifp/rp2350_uart
Didn't know about this pullrequest and found another solution to embed the 'remote' firmware in the 'main' firmware.

Wow, @burtyb thanks! :-) This exactly what I needed, and it works just great! By the way, my code is here: https://codeberg.org/retsifp/rp2350_uart Didn't know about this pullrequest and found another solution to embed the 'remote' firmware in the 'main' firmware.
lurch commented 2025-02-17 11:07:44 -06:00 (Migrated from github.com)

So can this issue be closed @retsifp , or is there still missing SDK functionality that you'd like to see added?

So can this issue be closed @retsifp , or is there still missing SDK functionality that you'd like to see added?
retsifp commented 2025-02-17 11:14:53 -06:00 (Migrated from github.com)

For me it's fine, can be closed if you want.
I guess it would maybe make sense to have the possibility to set the QSPI pin functions with the SDK, but I don't know how much effort that would be :)
Maybe it's as easy as integrating void qspi_gpio_set_function(...) in the SDK?

For me it's fine, can be closed if you want. I guess it would maybe make sense to have the possibility to set the QSPI pin functions with the SDK, but I don't know how much effort that would be :) Maybe it's as easy as integrating [void qspi_gpio_set_function(...)](https://github.com/raspberrypi/pico-examples/pull/571/files#diff-01e7bccabcba6cd47102f5d3e20168672d4644a717c2eb2ff2902b99aae67276R35) in the SDK?
lurch commented 2025-02-17 11:20:08 -06:00 (Migrated from github.com)

I'll close this as a duplicate of #1799 then 🙂

I'll close this as a duplicate of #1799 then 🙂
kilograham commented 2025-02-17 11:46:31 -06:00 (Migrated from github.com)

I'll leave this around, just because i thought (and maybe this isn't the case) that it might require changes to our UART code to make this friendly - if this is just a IO and FUNCSEL setup issue, then I guess we can indeed close - i just haven't looked at it in detail

I'll leave this around, just because i thought (and maybe this isn't the case) that it might require changes to our UART code to make this friendly - if this is just a IO and FUNCSEL setup issue, then I guess we can indeed close - i just haven't looked at it in detail
lurch commented 2025-02-17 11:49:51 -06:00 (Migrated from github.com)

i just haven't looked at it in detail

Me neither 😂 Pinging @will-v-pi as he wrote the previously-mentioned https://github.com/raspberrypi/pico-examples/pull/571

> i just haven't looked at it in detail Me neither 😂 Pinging @will-v-pi as he wrote the previously-mentioned https://github.com/raspberrypi/pico-examples/pull/571
will-v-pi commented 2025-02-18 05:24:50 -06:00 (Migrated from github.com)

Yeah, it was just an io/pads issue - although stdio_uart_init might need modifications too if we wanted to support that

Yeah, it was just an io/pads issue - although stdio_uart_init might need modifications too if we wanted to support that
etofigh commented 2025-09-03 14:12:22 -05:00 (Migrated from github.com)

Hi, I was just using the example in here to setup the QSPI pins for UART use. However i could only get the TX side working. The RP2350 doesn't receive anything at all on the RX pin. I know the hardware connections are good because I use the UART bootloader to load the firmware onto the MCU.

int main() {
    pico_led_init();

    // SD2 is QSPI GPIO 3, SD3 is QSPI GPIO 4
    qspi_gpio_set_function(3, GPIO_FUNC_UART_AUX);
    qspi_gpio_set_function(4, GPIO_FUNC_UART_AUX);

    uart_init(uart0, 1000000);

    while (true) {

       // This does not echo the data sent to the MCU. I expect the following to work though
	while (uart_is_readable(uart0))
		uart_putc(uart0, uart_getc(uart0));

        // uart_puts(uart0, "Hello, world\n");
        // pico_set_led(true);
        // sleep_ms(LED_DELAY_MS);
        // pico_set_led(false);
        // sleep_ms(LED_DELAY_MS);
    }
}

has anyone actually tried the RX side?

Hi, I was just using the example in [here](https://github.com/raspberrypi/pico-examples/pull/571) to setup the QSPI pins for UART use. However i could only get the TX side working. The RP2350 doesn't receive anything at all on the RX pin. I know the hardware connections are good because I use the UART bootloader to load the firmware onto the MCU. ```c int main() { pico_led_init(); // SD2 is QSPI GPIO 3, SD3 is QSPI GPIO 4 qspi_gpio_set_function(3, GPIO_FUNC_UART_AUX); qspi_gpio_set_function(4, GPIO_FUNC_UART_AUX); uart_init(uart0, 1000000); while (true) { // This does not echo the data sent to the MCU. I expect the following to work though while (uart_is_readable(uart0)) uart_putc(uart0, uart_getc(uart0)); // uart_puts(uart0, "Hello, world\n"); // pico_set_led(true); // sleep_ms(LED_DELAY_MS); // pico_set_led(false); // sleep_ms(LED_DELAY_MS); } } ``` has anyone actually tried the RX side?
will-v-pi commented 2025-09-04 03:23:30 -05:00 (Migrated from github.com)

There is a known bug on that example which prevents RX from working - fixed by https://github.com/raspberrypi/pico-examples/pull/697

There is a known bug on that example which prevents RX from working - fixed by https://github.com/raspberrypi/pico-examples/pull/697
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#2280
No description provided.