pico_set_binary_type(binary blocked_ram) causes link failure #203
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#203
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I want to use Pico's SRAM in unstriped configuration so that I can manage who accesses which bank manually. However, using
pico_set_binary_type(blink blocked_ram)causes linking to fail with the message below (here I modified the blink example with the single additional line for demonstration and easy reproduction).The address range rejected by the linker seems to be exactly the place code should be, so I suspect the linker is just misconfigured.
Do you get the same thing when using the
developbranch of pico-sdk?I switched to
developbranch, created a new build directory, same problem. It just occurred to me that some of the tooling actually comes from the distribution, which in my case is Ubuntu 20.04.2 LTS. That might be an important information. I think I should test this on Raspberry Pi OS, but I don't think I have a board with it available right now.To answer my own question... I get this when using the
masterbranch of pico-sdk:and this when using the
developbranch of pico-sdk:Ahhhh, looks like the error is actually coming from elf2uf2, rather than the linker https://github.com/raspberrypi/pico-sdk/blob/master/tools/elf2uf2/main.cpp#L134
(so I guess elf2uf2 just needs to be taught about blocked_ram builds?)
I'd say the proper solution here would be to not just check that the addresses are in correct range, but also that the different segments don't alias. Having segments in 20xxxxxx is correct, as is having them in 21xxxxxx, but having both at the same time is probably an error unless they use disjoint address ranges.
yes the problem is with elf2uf2, but actually the bootrom doesn't accept blocked RAM binaries eiither - this is OK though as the memory is indeed aliased, so we nee to make elf2uf2 smart enough to re-order a striped binary, and add a small trampoline to the start of striped ram binaries which jumps across aliases
The reordering sounds simple enough for me to whip up a patch. The trampoline would just be a single instruction at an arbitrary unused address jumping to the real start address, right?
cool yes thanks
the trampoline needs to be something like (in the original frame)
which would map to these addresses in unstriped RAM
That would work if the default address range was unstriped, and 0x21xx striped, but it's actually the opposite.
So, considering that we can't load a register and jump in a single word, the only option is to use an immediate jump.
I'm thinking the following "universal" starting sequence (don't know the proper syntax):
this will map to the following in striped mapping
Oh wait, I took a better look at your suggestion and see we actually can load and jump in a single word. I was thinking 32b instructions and forgot about thumb...
also of course I forgot the thumb bit in the jump target, because that's the law!
Note, that I forgot that
blocked_ramis a with flash binary type, so all my talk of entry points are irrelevant in the context of the existing blocked_ram.However, I think RAM layout should be orthogonal to the binary type so this is probably a good time to make that change since the existing blocked_ram is broken anyway
note if you want to workaround for now, i imagine just allowing BSS in
21000000-21040000range inelf2u2should unblock you. There should be no need to reorder the data (which is quite painful) since all the initialized data should be stored in flash and copied to RAM after startup.note the original issue is fixed - blocked_ram and non flash combinations were never supported before, so this was a bit of a tangeny