Skip to content

Add machine.mem64 support #19719

Description

@nickovs

Description

Currently the machine module offers mem8, mem16 and mem32 objects for accessing memory of those widths, but it does not provide a mem64 even on machines whose native memory size is 64 bit.

With the increasing availability and use of controller chips such as the PIC64, the (misleadingly named) STM32MP2, and TI C29 series, 64 bit memory is now first class on some "micro"-controllers. The MicroPython struct and uctypes libraries already support 64 bit operations (q and Q types). In the event that the device has 64-bit wide IO registers (for example fast, high-resolution counters) being able to read all 64 bits in one operations is valuable. Zephyr has 64-bit targets and the MicroPython unix port also runs on many platforms with natively 64-bit wide memory.

For all these reasons I suggest that we add mem64 support into machine.

I propose that this is gated on a new configuration macro MICROPY_PY_MACHINE_MEM64 and that this defaults to on for machines that have 64 bit pointer types and long int support, and defaults off elsewhere.

Code Size

The implementation looks to be about 50 lines of C and it will likely add a couple of hundred bytes of code and static class definition. Since this would be off by default for machines without 64-bit memory busses this will have no impact on historically memory-constrained machines.

Implementation

I intend to implement this feature and would submit a Pull Request if desirable

Code of Conduct

Yes, I agree

Activity

  1. added
    enhancementFeature requests, new feature implementations
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, new feature implementations

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions