ataradov / usb-sniffer-lite

A simple USB sniffer based on Raspberry Pi RP2040
BSD 3-Clause "New" or "Revised" License
547 stars 49 forks source link

Linker error #3

Closed szoshi closed 1 year ago

szoshi commented 1 year ago

Hello, I keep getting the following error when I try to build the project as is. I have made no changes to any of the source or linker files yet.

"/usb-sniffer-lite-main/firmware/linker/rp2040.ld:21 cannot move location counter backwards (from 000000001000014c to 00000000100000fc)"

I have read up a bit and this hints at an application that is too large(?) to fit in memory. I cannot figure out why though. Any help here would be greatly appreciated. I am also unable to understand the purpose of linking to the address 0x10000000. Could you explain that as well?

Thanks.

szoshi commented 1 year ago

I have made some progress. On viewing my listing file, I see that the boot_entry function binary exceeds the 256 byte limit reserved for it. On raising this limit to 512 bytes, it seems to link, I have a feeling though that I am missing something due to the CRC etc.

ataradov commented 1 year ago

What version of the compiler is used? The function must fit into the 256 byte block, this is all ROM code loads. I'm not sure why it is so big in your case.

Address 0x10000000 is where RP2040 flash is located.

szoshi commented 1 year ago

Hi, I am using a version bundled with Embedded Studio. Which version should I ideally be using?

ataradov commented 1 year ago

Anything recent should work. Are you using the provided Makefile or some newly created project? If later, then make sure to set optimization settings as in the supplied Makefile.

szoshi commented 1 year ago

I will try using a newer version and post my results here. Please keep this open till then. I did not understand the purpose of the CRC at the end of the first 256 bytes. Can you explain what that is about? Do you use a debug probe in your setup by chance? Ideally I would like to use a JLink to step through my Pico project. I think that should be possible.

ataradov commented 1 year ago

This is a requirement for the RP2040 boot. You need to run bin2uf tool on the compiled binary to place the correct CRC in that location. Default makefile does this, but if you are making a custom project, then you need to take care of that.

No, I don't use debuggers.

szoshi commented 1 year ago

Hi, with a newer gcc, it compiles correctly. Thanks.