I have to upload a new firmware in the Raspbery PI PICO external flash via SWD from a different microcontroller (an ESP32) connected via UART and SWD lines (I asked here a previous question).
I decided to firstly upload a firmware into PICO SRAM and, secondly, send the firmware binaries via UART to the just uploaded firmware which, in turn, writes the firmware in FLASH memory.
The firmware that I try to load into SRAM is wrote with the C/C++ PICO SDK and it is compiled with PICO_NO_FLASH option enabled by adding pico_set_binary_type(TARGET no_flash) to CMakeLists.txt file.

At the moment, I wrote a custom SWD library to write the firmware in PICO SRAM, start and stop cores and write core registers.

To perfom such operation, I followed these useful tutorials (and many others, but they are the most relevant)

The problem appears when I try to restart the execution of RP core which doesn't execute the just loaded firmware but it remains stuck.

More in details, to halt the core, I write:

  • 0xA05F0003 to DHCSR register
  • 0x1 to DEMCR register
  • 0x05FA0004 to AIRCR register

after that operations the DHCSR register contains value 0x3030003.
Then I write the new firmware to SRAM starting from address 0x20000000 (and checking wrote values) in chunck o 512 bytes.
Finally I uptdate:

  • VTOR register value with 0x20000000 (the base address from which I wrote the firmware)
  • PC core register value (having index 15) with the second word of incoming firmware
  • SP core register value (having index 13) with the first word of incoming firmware

and I reset the core simply writing 0xA05F0000 to DHCSR register.

However the RP remains stopped.

I also tried to change VTOR value to 0x20000100 or to reset the RP at the end of the process by writing 0x05FA0004 to AIRCR but the result is the same, in the first case, or the firmware is loaded from FLASH memory, in the second case.

Is it a problem of VTOR, PC or SP addresses?
I already tested separately the functions to stop and restart the core and they works correctly.

Can you help me?

1 Answer 1


There is a function made by the user usedbytes on github that jumps to any address you choose, maybe it could be helpful:

static void jump_to_vtor(uint32_t vtor)
    // Derived from the Leaf Labs Cortex-M3 bootloader.
    // Copyright (c) 2010 LeafLabs LLC.
    // Modified 2021 Brian Starkey <[email protected]>
    // Originally under The MIT License
    uint32_t reset_vector = *(volatile uint32_t *)(vtor + 0x04);

    SCB->VTOR = (volatile uint32_t)(vtor);

    asm volatile("msr msp, %0"::"g"
            (*(volatile uint32_t *)vtor));
    asm volatile("bx %0"::"r" (reset_vector));


I am trying to get the SWD init without any luck, can you give me any suggestions?? I had checked the links you gave, but still have no luck. Thanks.

  • Which probe do you use to establish the SWD connection? Are you using a microcontroller?
    – Luca
    Sep 5, 2022 at 17:23
  • Yes, I am using an RP2040 SPI pins an sending commands to the SWD pins of another cortex M0+ microcontroller, that is ok the problem is the sequence I am sending probably, because I always get and ACK of fault state follow by 32bits+parity.
    – Gabriel F
    Sep 14, 2022 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.