mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
test_apps: Test multicore app can be run by unicore bootloader
This commit is contained in:
parent
975c138fad
commit
444c27e4e6
@ -182,3 +182,8 @@ tools/test_apps/system/startup:
|
||||
tools/test_apps/system/test_watchpoint:
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32", "esp32c3"] # Just one test per architecture
|
||||
|
||||
tools/test_apps/system/unicore_bootloader:
|
||||
enable:
|
||||
- if: SOC_CPU_CORES_NUM > 1
|
||||
reason: the test should be run on multicore chips
|
||||
|
6
tools/test_apps/system/unicore_bootloader/CMakeLists.txt
Normal file
6
tools/test_apps/system/unicore_bootloader/CMakeLists.txt
Normal file
@ -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)
|
2
tools/test_apps/system/unicore_bootloader/README.md
Normal file
2
tools/test_apps/system/unicore_bootloader/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- |
|
4
tools/test_apps/system/unicore_bootloader/README.txt
Normal file
4
tools/test_apps/system/unicore_bootloader/README.txt
Normal file
@ -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.
|
52
tools/test_apps/system/unicore_bootloader/conftest.py
Normal file
52
tools/test_apps/system/unicore_bootloader/conftest.py
Normal file
@ -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)
|
@ -0,0 +1 @@
|
||||
idf_component_register(SRCS "main.c")
|
12
tools/test_apps/system/unicore_bootloader/main/main.c
Normal file
12
tools/test_apps/system/unicore_bootloader/main/main.c
Normal file
@ -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");
|
||||
}
|
@ -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')
|
@ -0,0 +1 @@
|
||||
CONFIG_FREERTOS_UNICORE=y
|
Loading…
Reference in New Issue
Block a user