Skip to content

Conversation

@multiplemonomials
Copy link
Collaborator

Summary of changes

This MR adds support for linking libraries outside of the core libmbed-os.a in PlatformIO projects. It does this via a new mbed_app.json option, link_libraries, which automatically adds libraries as a dependency of libmbed-os. It also adds some new logic in the PlatformIO integration code to track what libraries the user application depends on and add them to the link line.

I was worried this might be complicated, but it actually seems to be pretty simple. It helps, though, that we only have to worry about static libraries, not shared or object, so CMake will already give us a link line containing all the libraries. All we have to do is convert it to the format that SCons expects, add dependencies, and bam! Things start working.

Impact of changes

Migration actions required

Documentation

TODO


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[X] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[X] Tests / results supplied as part of this PR

Now able to compile and run code for Raspberry Pi Pico via PlatformIO:

Retrieving maximum program size .pio\build\rpipico\firmware.elf
Checking size .pio\build\rpipico\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.3% (used 11144 bytes from 262144 bytes)

This used to not work because, when building for this target, mbed-os depends on mbed-usb to implement usb-serial functionality.


@multiplemonomials multiplemonomials merged commit 1e8f63f into master Jan 8, 2026
50 checks passed
@multiplemonomials multiplemonomials deleted the dev/pio-optional-libraries branch January 8, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants