Skip to content
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

Problem with UART, if UART is placed in IRAM [problem found] (IDFGH-7646) #9198

Closed
vavroa opened this issue Jun 21, 2022 · 5 comments
Closed
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@vavroa
Copy link

vavroa commented Jun 21, 2022

Problem found in IDF 4.4.1

If the SPI function that accesses the external flash is being executed and the ISR is called from the UART at this point, the entire program will crash.

The problem is that the ISR from UART uses RINGBUFFER, which has some functions located in external memory.

I am attaching a patch that I applied to this problem.

0001-Ringbuffer-to-iram.zip
.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jun 21, 2022
@github-actions github-actions bot changed the title Problem with UART, if UART is placed in IRAM [problem found] Problem with UART, if UART is placed in IRAM [problem found] (IDFGH-7646) Jun 21, 2022
@meltdown03
Copy link

You should make a Pull Request instead of attaching the patch here. That way it can be tested and edited by the Espressif team

@igrr
Copy link
Member

igrr commented Jun 27, 2022

Hi @vavroa,

Could you please attach your sdkconfig file?

In v4.4.1 release, FreeRTOS and ringbuffer functions are already placed into IRAM, unless CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH configuration option is enabled. I'd like to check if you are seeing this issue with this option is enabled or not.

@vavroa
Copy link
Author

vavroa commented Jun 27, 2022

Indeed, this option was enabled, probably for this reason, the ringbuffer functions were placed in FLASH, which caused problems in their access from ISR.

Now I've tested it with option CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH turned off and it looks like it works.

@igrr
Copy link
Member

igrr commented Jun 27, 2022

Thanks for confirming!

Looks like the action on our side would be to either prevent CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH from being used together with UART-ISR-in-IRAM, or somehow automatically move ringbuffer functions back to IRAM in that case. Another option would be to create a new option just for ringbuffers, CONFIG_ESP_RINGBUFFER_PLACE_FUNCTIONS_INTO_FLASH, and make sure it is disabled when UART IRAM interrupts are enabled.

@vavroa
Copy link
Author

vavroa commented Jun 27, 2022

Both options are a good idea.

In our case, we are at the limit of IRAM capacity, so we tried these different options.

@espressif-bot espressif-bot added Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new Status: In Progress Work is in progress labels Jun 30, 2022
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Reviewing Issue is being reviewed Resolution: NA Issue resolution is unavailable labels Jul 12, 2022
espressif-bot pushed a commit that referenced this issue Aug 9, 2022
…ERTOS_PLACE_FUNCTIONS_INTO_FLASH

esp-ringbuf funtion placement is now controlled by its own configs:
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH and CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH

Closes #9198
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

5 participants