Coder Social home page Coder Social logo

rp2040-serial-bootloader's Introduction

rp2040-serial-bootloader's People

Contributors

usedbytes 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

Watchers

 avatar  avatar  avatar  avatar

rp2040-serial-bootloader's Issues

Usage of the bootloader with picoprobe

Hi Brian,
I am currently using your bootloader with my custom applications. I am also trying to debug my application with the Picoprobe.uf2 provided by Raspberry pi. What changes do I need to make the bootloader and the app be recogonized by openocd on the picoprobe?
I am also trying to flash the target pico with your pico-blink-noboot2 as a sample.
Ubuntu 20.04
VSCode extension

This is the output on the Debug console.

Cortex-Debug: VSCode debugger extension version 1.12.0 git(d7a405a). Usage info: https://github.com/Marus/cortex-debug#usage
Reading symbols from objdump-multiarch --syms -C -h -w /home/amrith/github_projects/RP2040-serial-bootloader/build/bootloader.elf
Reading symbols from nm-multiarch --defined-only -S -l -C -p /home/amrith/github_projects/RP2040-serial-bootloader/build/bootloader.elf
Launching GDB: gdb-multiarch -q --interpreter=mi2
    IMPORTANT: Set "showDevDebugOutput": "raw" in "launch.json" to see verbose GDB transactions here. Very helpful to debug issues or report problems
Error: nm-multiarch failed! statics/global/functions may not be properly classified: Error: spawn nm-multiarch ENOENT
    Expecting `nm` next to `objdump`. If that is not the problem please report this.
Error: objdump failed! statics/globals/functions may not be properly classified: Error: spawn objdump-multiarch ENOENT    ENOENT means program not found. If that is not the issue, please report this problem.Launching gdb-server: openocd -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s /home/amrith/pico/openocd/tcl -f /home/amrith/.vscode/extensions/marus25.cortex-debug-1.12.0/support/openocd-helpers.tcl -f interface/picoprobe.cfg -f target/rp2040.cfg
    Please check TERMINAL tab (gdb-server) for output from openocd
Finished reading symbols from objdump: Time: 23 ms
Finished reading symbols from nm: Time: 19 ms
Output radix now set to decimal 10, hex a, octal 12.
Input radix now set to decimal 10, hex a, octal 12.
0x200002ca in uart_read_blocking.constprop ()
Program stopped, probably due to a reset and/or halt issued by debugger
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00

Thread
1 stopped.
0x000000ea in ?? ()

Thanks in advance.
Regards,
Amrith

bootloader_build_combined - Dependencies

I am currently having issues with using bootloader_build_combined function.
I had added the following:

  1. A simple blinky program application for testing purpose.
  2. Modified CMakeLists.txt and added
    add_executable(test"app.c")
    target_link_libraries(test pico_stdlib)
    bootloader_build_combined(test)

The build process results in an error upon trying to build the executable

Error : "No rule to make target '../test.bin', needed by 'test_app.bin'. Stop."

Any help please?

Over flow error when I compiled this

I have the pico development board and I ran this code. I am getting the error as shown below:

[build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: bootloader.elf section `.text' will not fit in region `FLASH'
[build] c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 9244 bytes

What am I missing?

RS-485 or Half-duplex support?

Hi there!

I was reading your blog and was very much impressed with your work, thanks for sharing your project! Since your blog's comments section was disabled, I thought I'd ask here a question I had about the project (without looking at the actual code first, sorry!).

I'm interested to find a way to use a shared bus to both transmit and receive commands and data between the host and the MCU. Of course, since UART is a full-duplex protocol with separate RX and TX lines, it's a common approach to use the same OPcodes on both ends for different operations, and sometimes it's needed for both devices to communicate with each other simultaneously (akin to SPI transactions).

I'm in the middle of transitioning from AVR to another chip, such as the RP2040, for added functionality, and was wondering if it would be possible to use your project but somehow modify it to use a single RS-485 bus for the transportation layer. Currently, I was limited to using two separate RS-485 buses for the Optiboot bootloader, since it wouldn't work on a shared bus in my case.

This setup will allow RP2040 chips to be updated remotely from longer distances than wireless protocols will allow for, and also more reliably.

Anyways, thanks again for your project, and I was just wondering what would happen if the commands (such as CMD_SYNC, CMD_READ, CMD_WRITE, etc) are sent to the wrong end, or what happens if any bytes that a party writes to the bus is also read by the unintended party as well. Do you think it would be somehow easy to account for this, so your bootloader could be used in such projects?

Thanks again, and sorry for bothering you with this.
Have a great day!

๐Ÿ‘‹๐Ÿป

FLASH overflow ld error

Hi, I'm gettingthe following error when trying to compile the bootloader:

samsmith94@DESKTOP-CB1NOEN:~/pico/rp2040-serial-bootloader/build$ make bootloader -j8
[ 4%] Performing build step for 'ELF2UF2Build'
[ 4%] Built target bs2_default
[ 8%] Built target bs2_default_padded_checksummed_asm
[100%] Built target elf2uf2
[ 9%] No install step for 'ELF2UF2Build'
[ 11%] Completed 'ELF2UF2Build'
[ 19%] Built target ELF2UF2Build
[ 20%] Linking CXX executable bootloader.elf
/usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld: bootloader.elf section .text' will not fit in region FLASH'
/usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld: region `FLASH' overflowed by 5816 bytes
collect2: error: ld returned 1 exit status
CMakeFiles/bootloader.dir/build.make:855: recipe for target 'bootloader.elf' failed
make[3]: *** [bootloader.elf] Error 1
CMakeFiles/Makefile2:1492: recipe for target 'CMakeFiles/bootloader.dir/all' failed
make[2]: *** [CMakeFiles/bootloader.dir/all] Error 2
CMakeFiles/Makefile2:1499: recipe for target 'CMakeFiles/bootloader.dir/rule' failed
make[1]: *** [CMakeFiles/bootloader.dir/rule] Error 2
Makefile:124: recipe for target 'bootloader' failed
make: *** [bootloader] Error 2

Do you happen to know the reason why this might be?

license

Hi! Thanks for the great project and writeup. Would you consider adding some open-source license to make it easy to reuse this in other projects ?

Wrong CRC calculation

First of all, thank you for your project.
I had an issue with the CRC calculation. RP2040 CRC was wrong.
First i had to remove the final XOR on the read of 'dw_dma-> sniff_data' (in method calc_crc32(...)).
Finally look like this :


static uint32_t calc_crc32(void *ptr, uint32_t len)
{
	uint32_t dummy_dest, crc;
	int channel = dma_claim_unused_channel(true);
	dma_channel_config c = dma_channel_get_default_config(channel);
	channel_config_set_transfer_data_size(&c, DMA_SIZE_32);
	channel_config_set_read_increment(&c, true);
	channel_config_set_write_increment(&c, false);
	channel_config_set_sniff_enable(&c, true);

	// Seed the CRC calculation
	dma_hw->sniff_data = 0xFFFFFFFF;

	// Mode 1, then bit-reverse the result gives the same result as
	// golang's IEEE802.3 implementation
	dma_sniffer_enable(channel, DMA_MODE, true);

	dma_channel_configure(channel, &c, &dummy_dest, ptr , (len) / 4, true);

	dma_channel_wait_for_finish_blocking(channel);

	// Read the result before resetting
	crc = dma_hw->sniff_data;

	dma_sniffer_disable();
	dma_channel_unclaim(channel);

	return crc;
}

Second thing i had to change is in the python script (gen_imghdr.py). I had a lot of trubble but the biggest one was that the methode binascii.crc32() do not compute CRC the same as RP2040 DMA controller. I finally found that the correct CRC that RP2040 compute is the type CRC/MPEG-2.
To do this i had to used the following function to compute CRC in python script:


def crc32mpeg2(buf, crc=0xffffffff):
    for val in buf:
        crc ^= val << 24
        for _ in range(8):
            crc = crc << 1 if (crc & 0x80000000) == 0 else (crc << 1) ^ 0x104c11db7
    return crc`

I was also able to debug with vscode/openocd. If you want more information feel free to contact me.

A Thank You Message

Hello, I know this is not an issue, but I wanted to thank you for your great bootloader + serial flashing application (I could not find a comment section in your blog post, or an email address to send it to).

It has saved us loads of headaches, and we are happily using the C bootloader application!
Since we usually don't have GoLang as dependency in our deployment systems, I have rewritten your GoLang app in Python.

For now, we only needed the UART part of your implementation, so no TCP OTA updates (yet) unfortunately. It can be found here: https://github.com/ConfedSolutions/pico-py-serial-flash.

Anyways, massive thank you for the insightful blog post and helpful repositories :)

Bootloader not jumping to program?

Hi,

I am trying to get this working with blink_noboot (https://github.com/usedbytes/pico-blink-noboot2) and the RP2040 serial bootloader (https://github.com/usedbytes/rp2040-serial-bootloader).

I have read through the previous issue thread and changed the bootloader size to 28k.
Are the following memories now correct?
bootloader.ld:
MEMORY { FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 24k RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k }

combined.ld:
MEMORY { FLASH_BL(rx) : ORIGIN = 0x10000000, LENGTH = 24k FLASH_IMGHDR(rx) : ORIGIN = 0x10000000 + 24k, LENGTH = 4k FLASH_APP(rx) : ORIGIN = 0x10000000 + 28k, LENGTH = 2048k - 28k RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k }

blink_noboot2.ld:
MEMORY { FLASH(rx) : ORIGIN = 0x10000000 + 28k, LENGTH = 2048k - 28k RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k }

main.c (bootloader):
'#define IMAGE_HEADER_OFFSET (24 * 1024)'

I have also added the following to the end of the while(1) in the bootloader main.c, I believe this should make the bootloader jump to blink_noboot2 when i disconnect BOOTLOADER_ENTRY_PIN?

if (!should_stay_in_bootloader()) { uint32_t vtor = XIP_BASE + (1024 * 28); disable_interrupts(); reset_peripherals(); jump_to_vtor(vtor); }

I am doing the following steps:
1)Build bootloader
2) Copy the .uf2 to the Pi Pico using the mass storage USB bootloader
3) Build blink_noboot2 and copy the .uf2 to desktop
4) Open the command terminal (windows) and run serial-flash COM9 blink_noboot2.uf2 0x10007000
5) I get the following output:
Opened COM9 Synchronising: 1 / 5 [==========>--------------------------------------------] 20.00% 29/s 0s Querying device info: 1 / 1 [======================================================] 100.00% 101/s 0s Erasing: 40960 / 40960 [===========================================] 100.00% 122346/s 0s Writing: 40960 / 40960 [============================================] 100.00% 64226/s 0s Finalising: 1 / 1 [=======================================================] 100.00% 67/s 0s
Error: seal: received error response`
6) RP2040 LED is on. If I disconnect the BOOTLOADER_ENTRY_PIN, the LED stays on, indicating I am not jumping to program?
7) If I power cycle the RP2040 with the BOOTLOADER_ENTRY_PIN disconnected (high), I get a brief flash, then nothing.

Any guidance you can give on this would be much appreciated.

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.