mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
secure boot: Fix bootloader image verification failure
* Failure prevented secure boot from enabling. * Also adds unit test cases for esp_image_basic_verify() Ref https://esp32.com/viewtopic.php?f=2&t=1602 TW11878
This commit is contained in:

committed by
Angus Gratton

parent
b540322dc1
commit
e2479b46f7
4
components/bootloader_support/test/component.mk
Normal file
4
components/bootloader_support/test/component.mk
Normal file
@@ -0,0 +1,4 @@
|
||||
#
|
||||
#Component Makefile
|
||||
#
|
||||
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
|
37
components/bootloader_support/test/test_verify_image.c
Normal file
37
components/bootloader_support/test/test_verify_image.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Tests for bootloader_support esp_image_basic_verify()
|
||||
*/
|
||||
|
||||
#include <esp_types.h>
|
||||
#include <stdio.h>
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "unity.h"
|
||||
|
||||
#include "esp_partition.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_image_format.h"
|
||||
|
||||
TEST_CASE("Verify bootloader image in flash", "[bootloader_support]")
|
||||
{
|
||||
uint32_t image_len = 0;
|
||||
TEST_ASSERT_EQUAL_HEX(ESP_OK, esp_image_basic_verify(0x1000, true, &image_len));
|
||||
TEST_ASSERT_NOT_EQUAL(0, image_len);
|
||||
}
|
||||
|
||||
TEST_CASE("Verify unit test app image", "[bootloader_support]")
|
||||
{
|
||||
uint32_t image_len = 0;
|
||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||
TEST_ASSERT_NOT_EQUAL(NULL, running);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX(ESP_OK, esp_image_basic_verify(running->address, true, &image_len));
|
||||
TEST_ASSERT_NOT_EQUAL(0, image_len);
|
||||
TEST_ASSERT_TRUE(image_len <= running->size);
|
||||
}
|
||||
|
Reference in New Issue
Block a user