Reputation: 59
I'm using pico with VSCode & picoProbe & openOcd as it's described in getting-started-with-pico.pdf for Windows. It works nice (build & debug) when the application runs from the beginning of internal flash (0x10000000). But when I move the application next into flash (start address 0x10011000), after correct building and loading, debugging doesn't work correctly. I tried to keep .boot2 section at the beginning of the flash but got the same result.
When I jump to the Application from my bootloader, which starts from 0x10000000, the application works fine.
Did I forget something in the linker or JSON configuration? Please, give me a hint.
Upvotes: 0
Views: 494
Reputation: 11
The bootloader of the rp2040 checks for boot2 in the first 256 bytes starting from 0x10000000, to boot from flash there needs to be a valid boot2 in flash (checked by the bootloader by calculating a checksum). If the checksum is not valid, the device will go to usb boot mode.
From the linker script:
/* Second stage bootloader is prepended to the image. It must be 256 bytes big
and checksummed. It is usually built by the boot_stage2 target
in the Raspberry Pi Pico SDK
*/
.flash_begin : {
__flash_binary_start = .;
} > FLASH
.boot2 : {
__boot2_start__ = .;
KEEP (*(.boot2))
__boot2_end__ = .;
} > FLASH
ASSERT(__boot2_end__ - __boot2_start__ == 256,
"ERROR: Pico second stage bootloader must be 256 bytes in size")
/* The second stage will always enter the image at the start of .text.
The debugger will use the ELF entry point, which is the _entry_point
symbol if present, otherwise defaults to start of .text.
This can be used to transfer control back to the bootrom on debugger
launches only, to perform proper flash setup.
*/
After running boot2, the second stage will always inter the image at the start of .text.
Should this not make anything clearer, could you post your linker script and build options/config?
Upvotes: 1