-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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/unicore_bootloader_can_run_multicore_app' into …
…'master' esp_system: Fix case when multicore app can not be run if bootloader is unicore Closes IDFGH-9336 See merge request espressif/esp-idf!22664
- Loading branch information
Showing
14 changed files
with
237 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# 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) | ||
project(test_unicore_bootloader) |
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 @@ | ||
| Supported Targets | ESP32 | ESP32-S3 | | ||
| ----------------- | ----- | -------- | |
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,4 @@ | ||
This project tests if the app can start up in a certain configuration. | ||
Multicore app can start up even if the bootloader is unicore. | ||
|
||
The test is only for Multicore chips. |
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,52 @@ | ||
# SPDX-FileCopyrightText: 2023 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 @@ | ||
idf_component_register(SRCS "main.c") |
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,12 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
void app_main(void) | ||
{ | ||
printf("App is running\n"); | ||
} |
39 changes: 39 additions & 0 deletions
39
tools/test_apps/system/unicore_bootloader/pytest_unicore_bootloader.py
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,39 @@ | ||
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
import os | ||
|
||
import pytest | ||
from pytest_embedded import Dut | ||
|
||
|
||
@pytest.mark.esp32 | ||
@pytest.mark.esp32s3 | ||
@pytest.mark.generic | ||
@pytest.mark.parametrize('config', ['multicore'], indirect=True) | ||
def test_multicore_app_and_unicore_bootloader(dut: Dut) -> None: | ||
dut.expect('Multicore bootloader') | ||
dut.expect('Multicore app') | ||
dut.expect('App is running') | ||
|
||
path_to_unicore_build = os.path.join(dut.app.app_path, f'build_{dut.target}_unicore') | ||
dut.serial.bootloader_flash(path_to_unicore_build) | ||
dut.expect('Unicore bootloader') | ||
dut.expect('Multicore app') | ||
dut.expect('App is running') | ||
|
||
|
||
@pytest.mark.esp32 | ||
@pytest.mark.esp32s3 | ||
@pytest.mark.generic | ||
@pytest.mark.parametrize('config', ['unicore'], indirect=True) | ||
def test_unicore_app_and_multicore_bootloader(dut: Dut) -> None: | ||
dut.expect('Unicore bootloader') | ||
dut.expect('Unicore app') | ||
dut.expect('App is running') | ||
|
||
path_to_unicore_build = os.path.join(dut.app.app_path, f'build_{dut.target}_multicore') | ||
dut.serial.bootloader_flash(path_to_unicore_build) | ||
dut.expect('Multicore bootloader') | ||
dut.expect('Unicore app') | ||
dut.expect('App is running') |
Empty file.
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 @@ | ||
CONFIG_FREERTOS_UNICORE=y |