Skip to content

fix(coap): declare coap_resource_zlet_coap_service iterable section in the infra#44

Merged
rodrigopex merged 1 commit into
mainfrom
fix/42-coap-iterable-section
May 26, 2026
Merged

fix(coap): declare coap_resource_zlet_coap_service iterable section in the infra#44
rodrigopex merged 1 commit into
mainfrom
fix/42-coap-iterable-section

Conversation

@rodrigopex
Copy link
Copy Markdown
Owner

Summary

  • Move the coap_resource_zlet_coap_service iterable-section declaration into frontends/coap/ so apps that enable CONFIG_ZEPHLETS_COAP just work — no per-app linker boilerplate.
  • Drop the now-redundant local copy from tests/coap_functional/.

Why

COAP_SERVICE_DEFINE(zlet_coap_service, ...) in zephlet_coap_frontend.c produces references to _coap_resource_zlet_coap_service_list_{start,end}. Those symbols are only emitted when the consumer registers ITERABLE_SECTION_RAM(coap_resource_zlet_coap_service, ...) via the Zephyr linker glue. The test app did this locally; the infra never did, so every other consumer hit:

undefined reference to `_coap_resource_zlet_coap_service_list_start`
undefined reference to `_coap_resource_zlet_coap_service_list_end`

Discovered while wiring the ui zephlet's CoAP frontend into the ports_adapters_zbus example app. After this PR merges, the app gets a companion commit on main that opts UI into CoAP without any CMake glue.

Test plan

  • just docker-test on native_sim/native/64: 35/35 cases pass (coap_functional/{smoke,rpc} plus the rest).
  • Consuming app (ports_adapters_zbus, feat(ui,coap) queued locally) links and serves CoAP RPCs end-to-end from macOS via aiocoap and libcoap coap-client.

Note

The infra-side declaration is single-source. An app that also adds its own zephyr_iterable_section(...) for this name ends up with two adjacent section ranges and broken resource lookup at runtime — verified during development. So once this lands, consumers must rely solely on the infra-side registration.

Closes #42

`COAP_SERVICE_DEFINE(zlet_coap_service, ...)` in
zephlet_coap_frontend.c plus each codegen-emitted
`COAP_RESOURCE_DEFINE(<type>_coap_resource, zlet_coap_service, ...)`
produces references to `_coap_resource_zlet_coap_service_list_{start,end}`.
The infra never declared the matching ITERABLE_SECTION_RAM, so every
app that flips CONFIG_ZEPHLETS_COAP=y hit an undefined-reference link
error and had to replicate the test app's local linker glue.

Move the registration into `frontends/coap/CMakeLists.txt` under the
existing `if(CONFIG_ZEPHLETS_COAP)` block, plus a sibling
`sections-ram.ld` that declares the iterable section. Drop the now-
redundant local copies from tests/coap_functional/.

The infra-side declaration is single-source: an app that also adds
its own `zephyr_iterable_section(...)` for this name ends up with two
adjacent section ranges and broken resource lookup at runtime, so
consumers must rely solely on the infra-side registration.

Verified:
- `just docker-test` on native_sim/native/64: 35/35 cases pass.
- Consuming app (ports_adapters_zbus) links cleanly with no local
  linker workaround and serves CoAP RPCs end-to-end via aiocoap and
  libcoap coap-client.

Closes #42
@rodrigopex rodrigopex self-assigned this May 26, 2026
@rodrigopex rodrigopex added the enhancement New feature or request label May 26, 2026
@rodrigopex rodrigopex merged commit 1adb329 into main May 26, 2026
4 checks passed
@rodrigopex rodrigopex deleted the fix/42-coap-iterable-section branch May 26, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(coap): declare coap_resource_zlet_coap_service iterable section in the infra

1 participant