Flash bank customisation #1293
No reviewers
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 assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!1293
Loading…
Reference in a new issue
No description provided.
Delete branch "bt_flash_bank_dynamic"
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?
Defaults to true. Can be set to false if the flash bank offset is dynamically generated, e.g. to be inside the binary itself.
Fixes #1278
Frankly, i'd just be tempted to use
__builtin_constant_p()in an ifdef around the static assertionsNice. I literally didn't know that existed
I've used __builtin_constant_p()
Not sure what you meant by using it in a ifdef as it's a compiler not preprocessor thing?
uh yeah, duh, good point ;-) too little sleep!
Unless I'm mistaken this still isn't going to work without modifying files in the sdk?
They want to define the flash bank storage offset with pointer arithmetic. Which means the variable has to be defined in the btstack_flash_bank.h file. It can't go in pico_w.h because that's included in assembler.
Maybe we just need to make it possible to use an alternate version of pico_flash_bank_instance maybe via a #define specifying the function name or a cmake variable specifying a different source file. @kilograham are there any other examples for enabling customisation like this?
I've fixed this differently. Now if you define pico_flash_bank_get_offset_func you can change the function used to get the offset.
Some example code here
github.com/peterharperuk/pico-examples@4f26716e75@earlephilhower you better tell me if you're happy with this.
@peterharperuk, first thanks a bunch for your support. That's a neat solution
, but is it safe to assume the size in the SDK when this is called? (I assume you'll need to adjust the SDK to call this as well?)--edit-- I see it's still a `#define, ignore this question --edit--I'm also thinking, maybe this and https://github.com/raspberrypi/pico-sdk/issues/1278 can also be dropped. The reason is that the current TVL flash bank implementation isn't multicore safe, and I think lots of folks are going to use that 2nd core. The SDK can't really cater to all use cases, but it can be a simple example for folks to build off of for their own TLV implementations, maybe?
I don't think you should be using sizeof to set the size of the flash area. I can't see the need. Just set PICO_FLASH_BANK_TOTAL_SIZE to the number of sectors you want to reserve.
Are you saying you don't need this change? If the flash bank implementation isn't multicore safe (you're probably right) we can just fix that.
Agreed, I edited afterwards which probably wasn't obvious once I realized the same thing. Sorry, it was pre-coffee in the morning for me!
Well, this is necessary but not sufficient for my use case. The multicore safety needs to be there, too, but then I think I could use the stock version, yes.
But, my comment was more that you're moving into the application-side of things here, while most of the SDK is low-level tools. TLV could be in a fixed flash sector, it could be in a dynamic one like this patch, it could be a file (if you have a FS you could spread out flash wear), etc. So you've shown how to do it already, and since BT is really an app-level thing it's up to the end user to implement the right TLV store for their app.
Understood. I agree we're straying into the app side of things. We just want to provide the minimum necessary for the users who just want their code to work. And we don't want to get in the way of "power users" like yourself. I'll look into the multicore safety issue as that was an open issue that needs to be resolved.
seems like this should be documented somewhere (either PICO_CONFIG, or perhaps in the header)
you can't put a comma in the description; it breaks the doc tooling
I think you were looking at an old version of the change? PICO_FLASH_BANK_FIXED_OFFSET doesn't exist anymore. Instead I use pico_flash_bank_get_offset_func
just marking this as a draft so i don't merge it yet... will likely add some help for multicore in 1.5.1 too
now dependent on #1412 (with some merge fun)
Needs to be rebased on top of https://github.com/raspberrypi/pico-sdk/pull/1412
Seems to be working okay
Rebase done!