Skip to content

pico_multicore breaks BTstack TLV persistence #2725

@diegoparrilla

Description

@diegoparrilla

I think I’ve found a reproducible combination that breaks TLV persistence in BTstack on RP2040 when using pico-sdk 2.2.0.
This can make developers struggle to locate the root cause, so I’m documenting it here.

The key point: just linking pico_multicore is enough to break TLV persistence, even if no multicore functions are called.

How to reproduce

In CMakeLists.txt:

# Link libraries required for the project
target_link_libraries(${PROJECT_NAME} PRIVATE
    ${LINK_LIBRARIES}
    pico_multicore
    <other libraries...>
)

To ensure the TLV does not overlap with other flash sections (only BT_TLV matters here):

MEMORY
{
    FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 1152k
    RAM(rwx) : ORIGIN =  0x20000000, LENGTH = 256k
    SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
    SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
    CONFIG_FLASH(rwx): ORIGIN = 0x101DE000, LENGTH = 120K
    GLOBAL_LOOKUP_FLASH(rwx): ORIGIN = 0x101FC000, LENGTH = 4K
    GLOBAL_CONFIG_FLASH(rwx): ORIGIN = 0x101FD000, LENGTH = 4K
    BT_TLV(rwx): ORIGIN = 0x101FE000, LENGTH = 8K
}

I’m using the Bluepad32 library, but the issue is reproducible using the BTstack included in pico-sdk.

Observed behavior

With this setup, any BTstack API call that must persist data in the TLV fails silently.
Nothing is stored.

A clear symptom: link keys are not persisted after pairing a Bluetooth keyboard/mouse, so the device cannot reconnect after a power cycle.

Key findings

  • If I remove pico_multicore, TLV persistence works as expected.
  • If I add pico_multicore but also launch code on Core 1 using multicore_launch_core1(), TLV persistence also works.

So the failure only occurs in the specific situation where:

pico_multicore is linked
AND core1 is NOT launched

This suggests initialization side effects in pico_multicore that interfere with flash operations BTstack depends on.

My project (still WIP): https://github.com/sidecartridge/rp2-atarist-rpikb

Hope this helps identify the root cause, or at least warns other developers about this combination.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions