-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
ledc_set_fade_time_and_start causes "Cache disabled but cached memory region accessed" if used while accessing flash via SPIFFS (IDFGH-12743) #13725
Comments
@MrSurly Are you calling |
@suda-morris I'm not using a callback. |
@MrSurly Could you please also run the same test with IDF Monitor, so that the backtrace gets decoded into function names?
If you are using PlatformIO, there is a similar feature ( |
For context:
|
It looks like the most "interesting" part (i.e. the last frame) didn't get translated for some reason. Could you please check the .map file (located in the build directory) and see which function contains this address (0x4202c187)? Or upload the .map file here if you are unsure. |
|
Looks like this is related to PlatformIO build system generating different object file names from IDF build system. This results in linker script rules not having desired effect. It seems like this was resolved in IDF via this PR: #13039. But we didn't understand the impact and so didn't backport the fix to older release branches. Could you please try making that change locally to your copy of IDF and see if that resolves the issue? We'll backport that PR then. |
Post change:
After clean/rebuild with above:
|
It looks like that change didn't have effect, ledc_hal_get_duty was still placed into Flash instead of IRAM. I have tried reproducing the issue, with the following platformio.ini:
and
After calling a bunch of LEDC driver functions from main.c, I got the following in the map file:
so ledc_hal_get_duty got correctly placed into IRAM... Could you please try narrowing the issue down to a simpler project you could share with us? |
Here ya go: |
Thank you for the reproducer! The issue is that PlatformIO doesn't make use of all the linker fragment files. Here is an excerpt from the verbose build log:
Here at least one of the linker fragment files is missing: components/driver/ledc/linker.lf. Since this file is not passed to the linker script generator, the rule to place ledc_hal_iram.o into IRAM isn't there and all the functions get placed into Flash instead. Looking at platformio/platform-esp32 repo, I'm guessing this is the code responsible for getting the list of linker fragment files. Since the list of linker fragment files is hardcoded, it is prone to such issues: when new files are added or when existing files are renamed, this code needs to be updated on PlatformIO side so that the list stays in sync. There are probably a few ways to improve this, here is one option which might be the easiest to implement. PlatformIO already generates a custom component called idf_build_get_property(ldgen_fragment_files __LDGEN_FRAGMENT_FILES GENERATOR_EXPRESSION)
idf_build_get_property(build_dir BUILD_DIR)
file(GENERATE OUTPUT ${build_dir}/ldgen_fragment_files.txt CONTENT "${ldgen_fragment_files}") then (cc @valeros) @MrSurly as a workaround for this issue, you can find espidf.py under .platformio directory, and edit the |
hi @MrSurly,
No need, I'm working on a fix, it will be available in the next stable release. |
Answers checklist.
IDF version.
5.2.1
Espressif SoC revision.
ESP32-S3
Operating System used.
Linux
How did you build your project?
Other (please specify in More Information)
If you are using Windows, please specify command line type.
None
Development Kit.
Generic ESP32-S3 dev board
Power Supply used.
USB
What is the expected behavior?
When using
ledc_set_fade_time_and_start
in one task while another task is doingfread
of a file stored in SPIFFS, that it runs without crashingWhat is the actual behavior?
Crashes when I do that:
Steps to reproduce.
[LEDC](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/ledc.html)
API to do LED fading in one task vialedc_set_fade_time_and_start
(called repeatedly every few seconds)Cache disabled but cached memory region accessed
The code is large and complicated, and not yet public. If necessary I can generate something that can reliably reproduce.
Debug Logs.
More Information.
ledc_set_fade_time_and_start
for the timed fade effect. If I useledc_set_duty
,ledc_update_duty
, this does not occur.ledc_fade_func_install(ESP_INTR_FLAG_IRAM)
). This does not help. In fact the source forledc_fade_func_install
shows that it adds this flag anyway.The text was updated successfully, but these errors were encountered: