]> granicus.if.org Git - esp-idf/commitdiff
Merge branch 'bugfix/flash_op_unpinned_task' into 'master'
authorIvan Grokhotkov <ivan@espressif.com>
Thu, 19 Jan 2017 02:14:34 +0000 (10:14 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 19 Jan 2017 02:14:34 +0000 (10:14 +0800)
fixes for issues observed when using spi_flash

This MR fixes three unrelated issues:

- Race condition in spi_flash_enable_interrupts_caches_and_other_cpu
  when operations on unpinned tasks are performed.
  The issue is reported in https://github.com/espressif/esp-idf/pull/258

- esp_intr_noniram_disable doesn’t disable interrupts when compiled in
  release mode. This issue manifested itself with an illegal instruction
  exception when task WDT ISR was called at the time when flash was
  disabled.
  Fixes https://github.com/espressif/esp-idf/issues/263.

- Tick hooks on CPU1 were not called if CPU0 scheduler was disabled for
  significant amount of time (which could happen when doing flash erase).
  The issue manifested itself as “INT WDT timeout on core 1” error.
  Fixes https://github.com/espressif/esp-idf/issues/219.

See merge request !441

1  2 
components/spi_flash/test/test_spi_flash.c

index bf05b64db431841f8521650c8947cdca21ce797c,4f3171049e8592e15af9cbf33d465bc5b0cffabb..ecc472ac0e4da54e87ca4fcc2f270d75d5241ab7
@@@ -62,31 -61,25 +61,25 @@@ static void flash_test_task(void *arg
      vTaskDelete(NULL);
  }
  
 -TEST_CASE("flash write and erase work both on PRO CPU and on APP CPU", "[spi_flash]")
 +TEST_CASE("flash write and erase work both on PRO CPU and on APP CPU", "[spi_flash][ignore]")
  {
-     TaskHandle_t procpu_task;
-     TaskHandle_t appcpu_task;
-     struct flash_test_ctx ctx;
+     SemaphoreHandle_t done = xSemaphoreCreateCounting(4, 0);
+     struct flash_test_ctx ctx[4] = {
+             { .offset = 0x100 + 6, .done = done },
+             { .offset = 0x100 + 7, .done = done },
+             { .offset = 0x100 + 8, .done = done },
+             { .offset = 0x100 + 9, .done = done }
+     };
  
-     ctx.offset[0] = 6;
-     ctx.offset[1] = 7;
-     ctx.fail[0] = 0;
-     ctx.fail[1] = 0;
-     ctx.done = xSemaphoreCreateBinary();
+     xTaskCreatePinnedToCore(flash_test_task, "1", 2048, &ctx[0], 3, NULL, 0);
+     xTaskCreatePinnedToCore(flash_test_task, "2", 2048, &ctx[1], 3, NULL, 1);
+     xTaskCreatePinnedToCore(flash_test_task, "3", 2048, &ctx[2], 3, NULL, tskNO_AFFINITY);
+     xTaskCreatePinnedToCore(flash_test_task, "4", 2048, &ctx[3], 3, NULL, tskNO_AFFINITY);
  
-     xTaskCreatePinnedToCore(flash_test_task, "1", 2048, &ctx, 3, &procpu_task, 0);
-     if (portNUM_PROCESSORS == 2) {
-         xTaskCreatePinnedToCore(flash_test_task, "2", 2048, &ctx, 3, &appcpu_task, 1);
-     }
-     xSemaphoreTake(ctx.done, portMAX_DELAY);
-     if (portNUM_PROCESSORS == 2) {
-         xSemaphoreTake(ctx.done, portMAX_DELAY);
-     }
-     TEST_ASSERT_EQUAL(false, ctx.fail[0]);
-     if (portNUM_PROCESSORS == 2) {
-         TEST_ASSERT_EQUAL(false, ctx.fail[1]);
+     for (int i = 0; i < 4; ++i) {
+         xSemaphoreTake(done, portMAX_DELAY);
+         TEST_ASSERT_FALSE(ctx[i].fail);
      }
+     vSemaphoreDelete(done);
  }