ESP32 DPORT access mitigation without IDF funtions
Daniel wrote 01/03/2021 at 14:56 • 0 pointsHi everyone,
I wanted to implement a dynamically loaded module for micropython on ESP32, that requires access to the DPORT registers which control the clock gating for the peripherals. Since there is no atomic bit set / clear instruction, this requires mutual exclusion. Problem with these modules is that I don't have access to the IDF / OS, therefore I can't just call the appropriate function. I want to avoid doing this without any mitigation, since it could cause undesired side effects. The usual workaround would be to disable the interrupts for this, but since its a dual-core its not that easy.
Does anyone have a solution for this?
Thanks,
Daniel
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
For DPORT access, you suposed to use DPORT_STALL_OTHER_CPU_START() to stall the other Core on chip rev < v3.
Sorry never used micropython so this is probably not useful :S
Are you sure? yes | no
The problem when building a dynamically loaded module is, that it is not linked against the IDF / FreeRTOS. So its impossible to call arbitrary functions from these modules.
Sadly DPORT_STALL_OTHER_CPU_START() is also based on the underlying FreeRTOS, so I cant use it.
Are you sure? yes | no
If you check my project, I'm using the zephyr implementation of the atomic function within esp-idf:
https://github.com/darthcloud/BlueRetro/blob/master/main/zephyr/atomic.h
This use the xtensa s32c1i opcode to implement the atomic set, clear, test functions.
Can't you just call C function within micropython?
Are you sure? yes | no