1

I'm using a raspberry Pi Pico and I'm struggling to find if it's possible to update my script remotely (I cannot use neither SWD or USB). Currently my new firmware (can be .uf2, .bin or .hex file) is stocked in my Pico in the form of an array that I remotely sent, I would like to know if there is any way for me to update the Pico just by rebooting it on the new firmware.

I guess I will have to write my own bootloader but I have no idea where to start and there might be a simplier option (maybe partitionning the flash memory ?).

I'm open to any kind of idea since I don't really know how to start.

Thanks !

UPDATE

Thanks to Jon Durrant answer, I managed to use a custom second stage bootloader and to boot on it but I'm still facing an issue.

On my current setup, I have a connected device that acts as a gateway for my pico. My gateway is connected to the internet and connected to Pico thanks to a CAN bus.

Thanks to this setup, I can upload firmware on the gateway and send it in CAN to the pico. It receives it well and reboots on the new firmware. My issue now is that when it reboots, nothing happens. My pico is dead and I have to flash it again in the classic way (SWD or USB) to make it work again.

Here is my serial output : enter image description here

And here is my corresponding code :

if(END == 3){
                        printf("endOK\n");
                        if(len_msg_frame >= 3) memcpy(msg_to_flash+DATALEN*cnt_loop, data_send, len_msg_frame-eof);
                        printf("Flash received %d!!!!!\n", cnt_loop);
                        sleep_ms(10);
                        watchdog_update();
                        printf("Commiting...");
                        pfb_firmware_commit();
                        printf("Downloading...");
                        watchdog_update();
                        pfb_initialize_download_slot();
                        printf("Downloaded...");
                        watchdog_update();
                        int size = (DATALEN*(cnt_loop))/256;
                        for (int i = 0; i < size; i++){
                            if(pfb_write_to_flash_aligned_256_bytes(msg_to_flash, i*256, 256)) printf("err writing\n");
                        } 
                        printf("written %d bytes\n", DATALEN*cnt_loop);
                        watchdog_update();
                        int test = 0;
                        if(test = pfb_firmware_sha256_check(DATALEN*(cnt_loop))) printf("sha256 error %d\n", test);
                        else printf("Flash written\n");
                        watchdog_update();
                        pfb_mark_download_slot_as_valid();
                        printf("Flash valid\n");
                        sleep_ms(100);
                        watchdog_update();
                        pfb_perform_update();
                    }  

I don't know if there is any link but I disabled any kind of encryption in my CMakeLists.tkt :

set(PFB_WITH_IMAGE_ENCRYPTION OFF)
set(PFB_WITH_SHA256_HASHING OFF)

I also work on a raspberry pi pico instead of a pico W.

2
  • Googled "Pico OTA" (other the air) and got this result. Have not tried it, but its what you are looking for I think. github.com/usedbytes/picowota
    – Chad G
    Commented Aug 1, 2023 at 18:46
  • @ChadG Thanks ! I'm gonna have a look at it
    – Bibibou
    Commented Aug 2, 2023 at 7:20

1 Answer 1

1

Thanks to the work of Jakub Zimnol (https://github.com/JZimnol) I have got OTA (Over the Air) Updates for the Pico W firmware working. I've posted a video about this on YouTube: https://youtu.be/Go58qyJpz8Q

My example firmware which switches between Blue and Green releases is at: https://github.com/jondurrant/RPIPicoW-OTA-Exp The bootloader from Jakub can be found here: https://github.com/JZimnol/pico_fota_bootloader

1
  • Thank you for your reply, Your work is exciting for my application case, but I still have some issues. I have updated my post according to your answer.
    – Bibibou
    Commented Jul 23 at 14:14

Your Answer

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

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