Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolban committed Aug 6, 2018
1 parent db78095 commit f50bcb0
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Documentation/ideas/FastFlash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# FastFlash
As we build ESP32 applications, we typically perform a compile, flash, test loop cycle. We compile an app, we flash the ESP32 with that app and then we test whether it works. We perform these actions over and over again. When we look at the time taken in each step, we see there is compile time on our PC and then the time taken to flash the PC. This story talks about the time taken to flash the PC.

The ESP32 is typically configured to flash at 115200 kbps. This is 115200 bits per second. If we think that a typical ESP32 application is 800KBytes then this requires a transmission of:

800000 * 9 = 7.2 million bits = 62.5 seconds

we can increase our baud rate up to 921600 = 7.8 seconds
2 changes: 1 addition & 1 deletion tasks/watchdogs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Watchdogs
# Watchdogs
This is a sample application that illustrates the capabilities of watchdogs and watchdog processing.

A related YouTube video is available here:
Expand Down
155 changes: 155 additions & 0 deletions tasks/watchdogs/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
#include <esp_task_wdt.h>

esp_err_t event_handler(void *ctx, system_event_t *event)
{
return ESP_OK;
}

extern "C"
{
void app_main(void);
}

void highPriorityTask(void *myData)
{
printf("High priority task started and now looping for 10 seconds. Our priority is %d.\n", uxTaskPriorityGet(nullptr));
TickType_t startTicks = xTaskGetTickCount();
while (xTaskGetTickCount() - startTicks < (10 * 1000 / portTICK_PERIOD_MS))
{
// Do nothing but loop
}
printf("High priority task ended\n");
vTaskDelete(nullptr);
}

void hardLoopTask(void *myData)
{
printf("Hard loop task started ...\n");
while (1)
{
// do nothing but burn CPU
}
}

void hardLoopTaskNoInterrupts(void *myData)
{
printf("Hard loop task disabling interrupts started ...\n");
taskDISABLE_INTERRUPTS();
while (1)
{
// do nothing but burn CPU
}
}

void myTask(void *myData)
{
printf("# Running in myTask\n");
printf("# Registering our new task with the task watchdog.\n");
esp_task_wdt_add(nullptr);

printf("# Looping 5 times with a delay of 1 second and not feeding the watchdog.\n");
for (int i = 0; i < 5; i++)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("Tick\n");
}

printf("# Looping 5 times with a delay of 1 second and positively feeding the watchdog.\n");
esp_task_wdt_reset();
for (int i = 0; i < 5; i++)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("Tick\n");
esp_task_wdt_reset();
}

printf("# Removing our watchdog registration so we can do something expensive.\n");
esp_task_wdt_delete(nullptr);

printf("# Looping 5 times with a delay of 1 second and not feeding the watchdog.\n");
for (int i = 0; i < 5; i++)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("Tick\n");
}

printf("# Re-registering our task with the task watchdog.\n");
esp_task_wdt_add(nullptr);
printf("# Looping 5 times with a delay of 1 second and not feeding the watchdog.\n");
for (int i = 0; i < 5; i++)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("Tick\n");
}

printf("# Our current task priority is %d.\n", uxTaskPriorityGet(nullptr));
printf("# Spwaning a higher priority task\n");
xTaskCreate(highPriorityTask, // Task code
"Priority task", // Name of task
16 * 1024, // Stack size
nullptr, // Task data
5, // Priority
nullptr // task handle
);

printf("# Looping 5 times with a delay of 1 second and positively feeding the watchdog.\n");
esp_task_wdt_reset();
for (int i = 0; i < 5; i++)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("Tick\n");
esp_task_wdt_reset();
}

printf("Spawning a hard-loop function!\n");
xTaskCreate(hardLoopTaskNoInterrupts, // Task code
"Hard Loop", // Name of task
16 * 1024, // Stack size
nullptr, // Task data
5, // Priority
nullptr // task handle
);

printf("# Looping 5 times with a delay of 1 second and positively feeding the watchdog.\n");
esp_task_wdt_reset();
for (int i = 0; i < 5; i++)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("Tick\n");
esp_task_wdt_reset();
}


printf("# Removing our watchdog registration before we end the task.\n");
esp_task_wdt_delete(nullptr);

printf("# Ending myTask\n");
vTaskDelete(nullptr);
} // myTask

void app_main(void)
{
xTaskHandle handle;
printf("App starting\n");
printf("Initializing the task watchdog subsystem with an interval of 2 seconds.\n");
esp_task_wdt_init(2, false);

printf("Creatign a new task.\n");
// Now let us create a new task.
xTaskCreate(myTask, // Task code
"My Task", // Name of task
16 * 1024, // Stack size
nullptr, // Task data
0, // Priority
&handle // task handle
);

//printf("App Ended!\n");
} // app_main

0 comments on commit f50bcb0

Please sign in to comment.