Writing to ESP32-S2 IRAM at runtime [solved]
Posted: Mon Jul 11, 2022 8:05 pm
I am currently trying to further develop a fast-design-code-compile-iterate system for the ESP32-S2. I have a proof of concept working here: https://twitter.com/cnlohr/status/1546445702636584960
There is a big snag/question, though. In order to accomplish this, the IRAM must be writable at runtime. But the ESP32-S2 IDF pretty aggressively seals the IRAM via `memprot_ll_iram0_set_lock()` / `esp_memprot_set_lock()`. And it seems? there is no way to unseal it?
From Section 14.3.1.1 of the TRM: "At the same time, the value of the PMS_PRO_IRAM0_LOCK signal will also remain at 1 and cannot be changed. The value of the PMS_PRO_IRAM0_LOCK signal is reset to 0 only when the CPU is reset."
For the time being I've modified things to _never_ log the IRAM and keep it wide open for writes.
https://github.com/cnlohr/esp32-c3-play ... e5eR28-R37
I can understand for final products the desire to lock the IRAM memory region, but while developing, I am curious:
1) Is there any technical reason IRAM must be locked, and/or writing to IRAM would be bad?
2) Are there any performance implications of not locking IRAM? Of leaving it in read/write mode?
3) What is the ideal way to be able to write into IRAM after boot?
4) Is the proper way to handle this to set CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK = n?
There is a big snag/question, though. In order to accomplish this, the IRAM must be writable at runtime. But the ESP32-S2 IDF pretty aggressively seals the IRAM via `memprot_ll_iram0_set_lock()` / `esp_memprot_set_lock()`. And it seems? there is no way to unseal it?
From Section 14.3.1.1 of the TRM: "At the same time, the value of the PMS_PRO_IRAM0_LOCK signal will also remain at 1 and cannot be changed. The value of the PMS_PRO_IRAM0_LOCK signal is reset to 0 only when the CPU is reset."
For the time being I've modified things to _never_ log the IRAM and keep it wide open for writes.
https://github.com/cnlohr/esp32-c3-play ... e5eR28-R37
I can understand for final products the desire to lock the IRAM memory region, but while developing, I am curious:
1) Is there any technical reason IRAM must be locked, and/or writing to IRAM would be bad?
2) Are there any performance implications of not locking IRAM? Of leaving it in read/write mode?
3) What is the ideal way to be able to write into IRAM after boot?
4) Is the proper way to handle this to set CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK = n?