I trying to use freeRTOS, but making very slow progress. Tried to build a process to connect to the WiFi with out success.
This is my code, that I found here, it looks reasonable to me—but–
void keepWiFiAlive(void * parameter){
for(;;){
if(WiFi.status() == WL_CONNECTED){
vTaskDelay(10000 / portTICK_PERIOD_MS);
continue;
}
Serial.println("[WIFI] Connecting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
unsigned long startAttemptTime = millis();
// // Keep looping while we're not connected and haven't reached the timeout
while (WiFi.status() != WL_CONNECTED &&
millis() - startAttemptTime < 1000){}
// When we couldn't make a WiFi connection (or the timeout expired)
// // sleep for a while and then retry.
if(WiFi.status() != WL_CONNECTED){
Serial.println("[WIFI] FAILED");
vTaskDelay(20000 / portTICK_PERIOD_MS);
continue;
}
Serial.println("[WIFI] Connected: " + WiFi.localIP());
}
}
That I run with this statement
xTaskCreatePinnedToCore(
keepWiFiAlive,
"keepWiFiAlive", // Task name
configMINIMAL_STACK_SIZE, // Stack size (bytes)
NULL, // Parameter
1, // Task priority
NULL, // Task handle
CONFIG_ARDUINO_RUNNING_CORE);
It simply circles, effectively tanking my ESP32S3 telling me that there is a stackover flow again and again. I subsequently struggle to reconnect to the stupid ESP32S3 since it looping like mad.
Hi there,
Yea boot loop needs a Boot mode button press procedure sometimes like that.
The ESP32-S3 Arduino uses a modified version of FreeRTOS called IDF FreeRTOS, which is integrated into ESP-IDF:
This version of FreeRTOS is based on Vanilla FreeRTOS, but has been modified to support dual-core symmetric multiprocessing (SMP) for ESP32, ESP32-S3, and ESP32-P4. It can also be configured for single-core use.
This open source real-time operating system (RTOS) kernel is integrated into ESP-IDF and is used by many ESP-IDF applications and components. It’s ported to all ESP chip architectures, including Xtensa and RISC-V.
The ESP32 already uses FreeRTOS in the Arduino environment, and it’s integrated via the esp32 board package.
try this instead.
HTH
GL PJ
PJ,
I got the thing to multitask; I just cannot connect to the WiFi with it; or use the camera come to that. Using Visual Studio with platformIO shows syntax errors where there isn’t and compiles bad code it seems. You say it will work if I go the EDF route?
Hi there,
AFAIK, The PlatformIO isn’t up to snuff with the Latest ESP32C6 yet. Espresiff 's latest change to make the world try and update to the ESP-IDF 5 Lots of old Arduino ESP demo’s don’t work unless you roll back the BSP’s to the older ones. Kinda BS. imo.
HTH
GL PJ
there are some links on here to the Update info on Espreso.
PJ, Do you know which ESP32 I should buy to get the most out of the freeRTOS environment? Obviously it isn’t the ESP32S3 I already got.
Hi there,
So by default the Arduino Stuff runs on Core 0 and that is the core the wifi runs on So I would set the Core affinity to 1 and try again. be sure your code is running on the correct core or NOT blocking the WIFI.
So I don’t think it’s baked for the C6 yet so The multi-core MCU are best for it.
The S3 has a lot of good stuff. It should work the best of all. The Board support though may not be 100%
I have a BLE rtos example demo on here, Well it uses rtos semaphores anyway and the Sleep.
USE Bootloader mode button presses or It’s a quick draw mcgraw style when the XIAO is in a tight loop like that , Hit upload and try to time you plugging in the Xiao into the USB port and it getting ready to write to that port, it takes a few times and try’s but it does work (timing)
or you can load up a factory touch led demo .BIN from the WiKi and send that with RF-test
HTH
GL PJ
I always put a 50 ms delay in the LOOP function even if it’s empty, to allow the bootloader a catch opertunity.