Skip to content

[feature request] Add direct memory access like machine.mem in Micropython #1268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
uhrheber opened this issue Oct 12, 2018 · 6 comments
Closed

Comments

@uhrheber
Copy link

Please add a simple method for direct memory access to circuitpython.

Micropython has the machine.mem8/16/32 object, to access the memory directly.
Example: machine.mem32[0x50000748]=0x703

There are many situation where you want to access the memory, especially the registers, directly.
May it be speed, or because you need a special feature, that the driver/hal doesn't support.

It is possible to use @micropython.viper, and use pointers to access the memory, but I don't know what the status of the viper emitter is in circuitpython, and whether it will be supported in the future.

@tannewt
Copy link
Member

tannewt commented Oct 12, 2018

The Adafruit sponsored development of CircuitPython is very beginner focused so myself or @dhalbert will not get to this anytime soon. I do agree that it'd be useful for advanced users. I'd be happy to help someone else implement this.

I think we'd actually want two different modules:

  1. A memory module that gives direct access to RAM which is generic across all CircuitPython ports.
  2. A <port>_memory module that gives access to the full memory space. Having this as a platform specific module will make it easy to recognize when python code is used on an incompatible platform. For example, if a driver uses the nrf52_memory module but is used on a samd21 then it will fail with an import error because it provides samd21_memory instead.

@siddacious
Copy link

With a lot of guidance I might be able to work on this however I'm pretty busy at the moment. If someone else is interested by all means take it on.

@uhrheber
Copy link
Author

I just received my DK. Give me some time to get used to it and wade through the circuitpython code.

@siddacious: I'd be happy to collaborate.

@tannewt: Would it be OK to share our progress here, or should we set up a thread in the forum, or somewhere else?

@tannewt
Copy link
Member

tannewt commented Oct 15, 2018

@uhrheber Here is great! Let me know if you have questions about CircuitPython code. Thanks!

@uhrheber
Copy link
Author

You might have seen this: #1248
Using @micropython.viper or @micropython.asm_thumb is already a usable way to access the memory and registers.

@dhalbert
Copy link
Collaborator

dhalbert commented Nov 1, 2020

Superseded by #3234, but seeing how MicroPython does is worth looking at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants