Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RP2350: boot_stage2 never run? resulting in incorrect flash config #1903

Open
asumagic opened this issue Sep 4, 2024 · 2 comments
Open

RP2350: boot_stage2 never run? resulting in incorrect flash config #1903

asumagic opened this issue Sep 4, 2024 · 2 comments

Comments

@asumagic
Copy link

asumagic commented Sep 4, 2024

I recently noticed that PICO_FLASH_SPI_CLKDIV was not having any effect on my project ported to RP2350, whereas it worked fine with RP2040 before.

This reproduced when using the stock Pico 2 and Pimoroni Pico Plus 2 board files, which use the same boot2_w25q080.S boot_stage2. It does get assembled.

The QMI timing values I am seeing on a MCVE (provided below) don't match my expectations reading the boot script.

qmi[0].timing = 60007203
qmi[0].rfmt   = 492a8
qmi[0].rcmd   = 00eb

When ripping out all the code from boot2_w25q080.S, behavior is unchanged! (Adding garbage to it, it fails to assemble, so it is still getting selected somewhere.)

The lower byte of timing should be 2 (the default CLKDIV), the rcmd is missing the upper byte that should have gotten configured, etc. -- so I am assuming it is inheriting whatever the bootrom had configured.

(EDIT: Writing to those regs works fine; I've been doing it.)

I observed this issue both selecting the 2.0.0 tag and the latest develop tip.

Repro:

#include <stdio.h>
#include <hardware/structs/qmi.h>
#include <hardware/structs/xip.h>
#include <pico/stdlib.h>

int main()
{
    stdio_init_all();
    while (true) {
        printf("qmi[0].timing = %04x\n", qmi_hw->m[0].timing);
        printf("qmi[0].rfmt   = %04x\n", qmi_hw->m[0].rfmt);
        printf("qmi[0].rcmd   = %04x\n", qmi_hw->m[0].rcmd);
        sleep_ms(1000);
    }

}
cmake_minimum_required(VERSION 3.13)

include(pico_sdk_import.cmake)

project(pico-sdk-boot2-rp2350-repro LANGUAGES C CXX ASM)
pico_sdk_init()

add_executable(repro main.c)
target_link_libraries(repro pico_stdlib pico_stdio)
pico_enable_stdio_usb(repro 1)
pico_enable_stdio_uart(repro 0)
pico_add_extra_outputs(repro)
#!/bin/bash
set -ex
mkdir build -p
cd build
cmake .. -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350-arm-s -DPICO_COMPILER=pico_arm_cortex_m33_gcc -DPICO_SDK_PATH="<whatever_sdk_path_here>"  -GNinja
cmake --build .
@asumagic asumagic changed the title RP2350: boot_stage2 broken? resulting in incorrect flash config RP2350: boot_stage2 never run? resulting in incorrect flash config Sep 4, 2024
@kilograham
Copy link
Contributor

Per release notes:

  • A boot_stage2 is not needed on RP2350, but one can be included via the define PICO_EMBED_XIP_SETUP=1.

Could perhaps be better documented (this is a compile definition).. also perhaps surprising that it builds without it but that is orthogonal

@asumagic
Copy link
Author

asumagic commented Sep 4, 2024

For clarification, by "ripping out all the code" from the stage2 I mostly meant the instructions under _stage2_boot.

But thank you, PICO_EMBED_XIP_SETUP=1 does indeed solve the problem. However, shouldn't that be the default for any non-default flash configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants