-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/mmu_page_size_from_app_bin_v5.4' into 'release/…
…v5.4' feat(bootloader): add support to use MMU page size from app binary (v5.4) See merge request espressif/esp-idf!35070
- Loading branch information
Showing
17 changed files
with
238 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The following lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
set(COMPONENTS main) | ||
project(test_mmu_page_size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
| Supported Targets | ESP32-C6 | ESP32-H2 | | ||
| ----------------- | -------- | -------- | | ||
|
||
This test app ensures that bootloader can support configurable MMU page size as per the application binary header. | ||
This test tries to boot the application with different MMU page sizes and checks if the application is able to boot successfully. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import logging | ||
import os | ||
|
||
import pytest | ||
from _pytest.fixtures import FixtureRequest | ||
from _pytest.monkeypatch import MonkeyPatch | ||
from pytest_embedded_idf.app import FlashFile | ||
from pytest_embedded_idf.serial import IdfSerial | ||
|
||
|
||
# This is a custom IdfSerial class to support custom functionality | ||
# which is required only for this test | ||
class FlashBootloader(IdfSerial): | ||
def bootloader_flash(self, binary_path: str) -> None: | ||
""" | ||
Flash bootloader. | ||
:return: None | ||
""" | ||
logging.info('Flashing bootloader') | ||
bootloader_path = os.path.join(binary_path, 'bootloader', 'bootloader.bin') | ||
logging.info(bootloader_path) | ||
offs = int(self.app.sdkconfig.get('BOOTLOADER_OFFSET_IN_FLASH', 0)) | ||
logging.info('bootloader offset is {0}'.format(hex(offs))) | ||
prev_flash_files = self.app.flash_files | ||
flash_files = [] | ||
flash_files.append( | ||
FlashFile( | ||
offs, | ||
bootloader_path, | ||
False, | ||
) | ||
) | ||
self.app.flash_files = flash_files | ||
self.flash() | ||
# Restore self.app.flash files to original value | ||
self.app.flash_files = prev_flash_files | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def monkeypatch_module(request: FixtureRequest) -> MonkeyPatch: | ||
mp = MonkeyPatch() | ||
request.addfinalizer(mp.undo) | ||
return mp | ||
|
||
|
||
@pytest.fixture(scope='module', autouse=True) | ||
def replace_dut_class(monkeypatch_module: MonkeyPatch) -> None: | ||
monkeypatch_module.setattr('pytest_embedded_idf.IdfSerial', FlashBootloader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
idf_component_register(SRCS "main.c" | ||
PRIV_REQUIRES unity esp_partition) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <inttypes.h> | ||
|
||
#include "unity.h" | ||
#include "esp_partition.h" | ||
|
||
#define SZ 4096 | ||
|
||
void app_main(void) | ||
{ | ||
printf("App is running\n"); | ||
|
||
// Perform some partition and memory map related operations | ||
char src_p_1[32] = "Test data pattern 123456789"; | ||
char buf[32]; | ||
|
||
// Find storage partition | ||
const esp_partition_t* partition = esp_partition_find_first( | ||
ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, NULL); | ||
TEST_ASSERT_NOT_NULL(partition); | ||
|
||
esp_partition_mmap_handle_t handle1; | ||
const void *ptr1; | ||
TEST_ESP_OK(esp_partition_mmap(partition, 0, SZ, ESP_PARTITION_MMAP_DATA, &ptr1, &handle1)); | ||
TEST_ESP_OK(esp_partition_erase_range(partition, 0, SZ)); | ||
TEST_ESP_OK(esp_partition_write(partition, 0, src_p_1, sizeof(src_p_1))); | ||
memcpy(buf, ptr1, sizeof(buf)); | ||
|
||
TEST_ASSERT_EQUAL(0, memcmp(buf, src_p_1, sizeof(buf))); | ||
esp_partition_munmap(handle1); | ||
|
||
printf("Partition test done\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Name, Type, SubType, Offset, Size, Flags | ||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap | ||
nvs, data, nvs, , 0x6000, | ||
phy_init, data, phy, , 0x1000, | ||
factory, app, factory, , 1M, | ||
storage, data, fat, , 64K, |
Oops, something went wrong.