Typical MCUs (STM32, ESP32-C3, NXP Kinetis, etc.) have limited resources and need an RTOS to manage tasks.
void vTaskBlink(void *pv){
for(;;){
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
vTaskDelay(pdMS_TO_TICKS(500));
}
}
xTaskCreate(vTaskBlink, "blink", 128, NULL, 1, NULL);
vTaskStartScheduler();
The resulting bin file is usually < 64 KB and can be flashed directly.
When using an MPU (i.MX6/8, RK3566, Allwinner V3s) Linux flows like a "small PC".
pthread still works, but you can also run Docker, Python, Node.js when resources allow.git clone https://github.com/buildroot/buildroot.git
cd buildroot
make menuconfig # choose board & packages
make -j$(nproc) # generates sdcard.img
Burn the image to an SD card and boot; final size 50-200 MB.