For starting my MQTT task:
Code: Select all
void Mqtt_Start_Task( void )
{
ESP_LOGI(TAG, "Initializing MQTT task");
g_mqtt_update_queue = xQueueCreate( 10, sizeof(mqtt_update_cmd_t) );
BaseType_t res = xTaskCreate(&Mqtt_Task, "Mqtt_Task", 1024 * 50, NULL, 5, NULL);
if (res != pdPASS)
{
ESP_LOGE(TAG, "Error creating Mqtt task, %d", res);
abort();
}
ESP_LOGI(TAG, "Remaining free space : %u", heap_caps_get_free_size(MALLOC_CAP_INTERNAL));
ESP_LOGI(TAG, "Largest available block: %u", heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL));
}
After the task starts, the following is printed:
Once I receive that 40kB message, I'll need to move it to flash for long term, but not permanent storage. Another task will need to read that data back out of flash for continual processing. I feel dangerously close to being out of RAM. My first thought was to switch to the WROVER module, but after looking into it, it appears that the external RAM cannot be utilized for task stack space. Could I still declare a 40kB variable in external RAM for the task to use? The data is largely a simple look up table. Processing the data does not need to be very efficient, but does need to occur at least once per second.I (650) mqtt: Remaining free space : 117300
I (660) mqtt: Largest available block: 62600
I feel like this is a dumb question, but this project is my first experience with an embedded RTOS. I'm just not really sure what the use case is for the external PSRAM. If I could create my heap in it and have each task's space come from that, that would be ideal. However, I do see issues with it. Second best seems like the external RAM would be used for storing idle tasks and the entire internal RAM could be used for active tasks. Third best, which I THINK is the case, is that I access the external RAM pretty much like it is a peripheral (though I think FreeRTOS hides the complexity of it and I just basically map a variable to an address somehow).