Skip to content

Conversation

@usbalbin
Copy link
Owner

@usbalbin usbalbin commented Oct 12, 2025

I have exposed this as two macros(to be renamed).

  • make_foo requires the addresses to be known at proc_macro time, as in literals. This could be made to be zero cost since the value of the static itself is not needed, by moving it into some wonky linker section.
  • make_bar requires the name of a symbol to use as addressing base and a offset. Also this could be made zero cost as above.

As yet another alternative it might also be possible to to put the address in the value of the static. This way we could either at const eval time or at runtime, put in the address as the value of the static. However this would cause a memory cost of 4 bytes per metric.

// Hardcoded address
make_metric_from_address!(DWT_CYCCNT: i8 @ 0xE0001004, "DWT_CYCCNT");

let some_address: *const u8 = *const 0x1234;
let mut my_ptr_metric = make_ptr(MY_PTR_METRIC).unwrap();
my_ptr_metric.set(some_address);
make_metric_from_address_with_offset(root.path.child: u8 @ MY_PTR_METRIC + 42, "3 * root.path.child");

@usbalbin
Copy link
Owner Author

usbalbin commented Dec 29, 2025

TODO

  • make_ptr
  • make_metric_from_address which is a metric with hardcoded address
  • make_metric_from_base_with_offset which is a metric at base address in matric_ptr with a const address offset.
  • Make root.path.child work as identifiers for all metrics and settings. (currently only works for make_metric_from_base_with_offset)
  • Fix all warnings
  • Remove loads of unwraps

@usbalbin
Copy link
Owner Author

@denenilsson, I have not tested it on real hardware yet, but I think this might be quite close now

@usbalbin
Copy link
Owner Author

image

@usbalbin usbalbin marked this pull request as ready for review January 5, 2026 14:51
@usbalbin usbalbin force-pushed the manually-add-symbols branch from b15e5cb to 3562727 Compare January 5, 2026 15:05
@usbalbin
Copy link
Owner Author

usbalbin commented Jan 5, 2026

@denenilsson, I'll merge this now since this refactors a lot of things which pretty much blocks everything else

@usbalbin usbalbin force-pushed the manually-add-symbols branch from 2d9f3e0 to 66031a6 Compare January 5, 2026 15:17
@usbalbin usbalbin merged commit d4fab29 into main Jan 5, 2026
4 checks passed
@usbalbin usbalbin deleted the manually-add-symbols branch January 5, 2026 15:28
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.

2 participants