Coder Social home page Coder Social logo

rhulme / pico-flashloader Goto Github PK

View Code? Open in Web Editor NEW
68.0 68.0 16.0 66 KB

Small (<4k) flashloader for the RP2040 to allow a power-fail safe update in situations where the built-in bootloader is not suitable.

CMake 18.75% C 67.29% Python 13.96%

pico-flashloader's People

Contributors

rhulme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pico-flashloader's Issues

Platformio build support?

Hello! Wonderful code you have, thank you for sharing. It looks like I will be able to use this to update code over CAN bus on my robot.

My project currently builds with platformio. A lot of the stuff that this library does is beyond my skill set.

I am going to try to convert my project to cmake so that I can use this, but I am not presently sure if that will create other problems for me.

I am curious, do you have any experience with platformio, and do you happen to have any idea how this library could be implemented with that build system?

Thanks!

reset through SWD interface

Discussed in #4

Originally posted by erikjonkers January 31, 2022
Hi,
To be able to load the combined application through the SWD interface instead of the usb mount, I used the following command to get a combined HEX file:

srec_cat pico-flashloader.hex app250.hex -o combi.hex

Doing so I noticed that the reset through the SWD interface didn't work but a power reset did and the application was working as expected. I then started the debugger again and issued a reset command. The same problem appeared, it keeps resetting with the following info;

Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
..<snip>..
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Read incorrect DLIPDR f0000001 (possibly CTRL/STAT value) when selecting coreid 0
Could not find MEM-AP to control the core
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target rp2040.core1 failed, trying to reexamine
Could not find MEM-AP to control the core
Examination failed, GDB will be halted. Polling again in 6300ms

During these reboots, the debugger isn't able to connect.
I also flashed the pico with the original FLASH_ME.uf2 file but if I reset through the debugger same problem exists.

What can I do to debug this?

-Erik.

FAILED: pico-flashloader.elf

Thanks for sharing your pico flashloader project. I'm attempting to use it, but get this message about undefined references.

[build] [31/32 93% :: 1.404] Building CXX object CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/pico_standard_link/new_delete.cpp.obj [build] [31/32 96% :: 1.503] Building C object CMakeFiles/pico-flashloader.dir/flashloader.c.obj [build] [32/32 100% :: 1.822] Linking CXX executable pico-flashloader.elf **[build] FAILED: pico-flashloader.elf** [build] cmd.exe /C "cd . && C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE -mcpu=cortex-m0plus -mthumb -Og -g -Wl,--build-id=none -Wl,-Map=pico-flashloader.elf.map -Wl,--script=C:/VSARM/Pico/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld -Wl,-z,max-page-size=4096 -Wl,--gc-sections CMakeFiles/pico-flashloader.dir/flashloader.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_sync/sync.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_claim/claim.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/pico_platform/platform.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_flash/flash.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/pico_bootrom/bootrom.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_watchdog/watchdog.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_xosc/xosc.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_clocks/clocks.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_gpio/gpio.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_irq/irq.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_irq/irq_handler_chain.S.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_sync/sem.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_sync/lock_core.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_time/time.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_time/timeout_helper.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_timer/timer.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_util/datetime.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_util/pheap.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_util/queue.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_sync/mutex.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/common/pico_sync/critical_section.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_pll/pll.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_vreg/vreg.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/hardware_dma/dma.c.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/pico_standard_link/crt0.S.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/pico_standard_link/new_delete.cpp.obj CMakeFiles/pico-flashloader.dir/C_/VSARM/Pico/pico-sdk/src/rp2_common/pico_standard_link/binary_info.c.obj -o pico-flashloader.elf pico-sdk/src/rp2_common/boot_stage2/bs2_default_padded_checksummed.S && cmd.exe /C "cd /D C:\VSARM\Pico\projects\Bootloader\build && C:\VSARM\Pico\projects\Bootloader\build\elf2uf2\elf2uf2 C:/VSARM/Pico/projects/Bootloader/build/pico-flashloader.elf pico-flashloader.uf2"" [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-sbrkr.o): in function _sbrk_r':
[build] sbrkr.c:(.text._sbrk_r+0xc): undefined reference to _sbrk' [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-signalr.o): in function _kill_r':
[build] signalr.c:(.text._kill_r+0xe): undefined reference to _kill' [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-signalr.o): in function _getpid_r':
[build] signalr.c:(.text._getpid_r+0x2): undefined reference to _getpid' [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-writer.o): in function _write_r':
[build] writer.c:(.text._write_r+0x10): undefined reference to _write' [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-closer.o): in function _close_r':
[build] closer.c:(.text._close_r+0xc): undefined reference to _close' [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-fstatr.o): in function _fstat_r':
[build] fstatr.c:(.text._fstat_r+0xe): undefined reference to _fstat' [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-isattyr.o): in function _isatty_r':
[build] isattyr.c:(.text._isatty_r+0xc): undefined reference to _isatty' [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-lseekr.o): in function _lseek_r':
[build] lseekr.c:(.text._lseek_r+0x10): undefined reference to _lseek' [build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg.a(lib_a-readr.o): in function _read_r':
[build] readr.c:(.text._read_r+0x10): undefined reference to _read' [build] collect2.exe: error: ld returned 1 exit status [build] ninja: build stopped: subcommand failed. [build] Build finished with exit code 1

Any suggestions for troubleshooting would be appreciated.

Possibility of adding a license

Hi,

I was wondering if you planned to license this project under an open-source license? Perhaps something like MIT.
This would make it clearer about what circumstances code from this project could be used in.

Thanks,

James

watchdog_reboot delay in flashFirmware

Discussed in #11

Originally posted by websterelec September 1, 2022
I found that with larger programs, the delay in watchdog_reboot (500ms) isn't long enough for the initial flash_range_erase call that erases the target memory area to complete. I measured 730ms for a size of 0x35000. I increased the delay to 2 seconds for my application.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.