I'm using an ESP32S3 chip and trying to implement OTA through a cellular modem. The size of the bin file is 1250KB. The cellular modem has an AT command that downloads all the content in one go. Since there is no option to read it in chunks and there is not enough RAM to hold that 1250 KB of data. So I have decided to read the data in chunks from the RX FIFO buffer.
Now when I'm reading the data from UART and printing it, I'm receiving all the data properly. But when I'm trying to store the downloaded content into a local file in the file system. Data is being missed. I understood that this UART task should be performed uninterrupted.
For this, I tried running file writing tasks separately using xSemaphoreCreateMutex() but still the data is missing.
Now I'm trying to use software flow control by sending XON and XOFF values. But still, the data is missing.
I'm sending XON before reading data and I'm sending XOFF immediately after data reading. Is this the correct way of using this? or Do I have to initialize something for software flow control?
Also please let me know if there is any alternative solution for downloading the file using the cellular modem and saving it in the partition.
Thanks.
UART software flow control in ESP32S3
-
- Posts: 1734
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: UART software flow control in ESP32S3
You can let the UART handle XON/XOFF for you in hardware: uart_set_sw_flow_ctrl(...).
If so: Writing to flash memory takes some time (easily tens of ms or more) and blocks most other tasks during the write operation, including "normal", non-IRAM interrupts (UART,...).
To avoid this blocking, you can try and put the UART ISR (+ring buffer code) into IRAM.
Using a file system may also involve significant overhead when writing, so using a "raw" partition to store the data may be faster.
You can also try to reconfigure the UART to use a larger block of HW FIFO. Or, of course, reduce the baud rate to slow down the incoming data.
What "local" file system? A file system in flash?trying to store the downloaded content into a local file in the file system
If so: Writing to flash memory takes some time (easily tens of ms or more) and blocks most other tasks during the write operation, including "normal", non-IRAM interrupts (UART,...).
To avoid this blocking, you can try and put the UART ISR (+ring buffer code) into IRAM.
Using a file system may also involve significant overhead when writing, so using a "raw" partition to store the data may be faster.
You can also try to reconfigure the UART to use a larger block of HW FIFO. Or, of course, reduce the baud rate to slow down the incoming data.
-
- Posts: 20
- Joined: Wed Mar 02, 2022 2:39 pm
Re: UART software flow control in ESP32S3
Yes, local file system here means file system developed on the internal flash memory of ESP32S3.
Thanks for the idea, I will try using the raw partition and reduce the baud rate. My primary application is to write in the raw partition but I want to check the data integrity first by downloading the file into the file system and validating its SHA256 hash and then proceed ahead with writing into the raw partition. Seems like that is not going to work, so I will directly write it into the raw partition.
Thanks for the idea, I will try using the raw partition and reduce the baud rate. My primary application is to write in the raw partition but I want to check the data integrity first by downloading the file into the file system and validating its SHA256 hash and then proceed ahead with writing into the raw partition. Seems like that is not going to work, so I will directly write it into the raw partition.
Who is online
Users browsing this forum: No registered users and 140 guests