Skip to content

Commit 086461d

Browse files
soburiandreagilardonidani-clogibixhajimef
committed
loader: Incorporate loader source codes
Co-authored-by: Andrea Gilardoni <a.gilardoni@arduino.cc> Co-authored-by: Daniele Cloralio <d.cloralio@arduino.cc> Co-authored-by: Gilberto Conti <g.conti@arduino.cc> Co-authored-by: Hajime Fujimoto <hajime2008x@yahoo.co.jp> Co-authored-by: Kurt Eckhardt <kurte@rockisland.com> Co-authored-by: Leonardo Cavagnis <45899760+leonardocavagnis@users.noreply.github.com> Co-authored-by: Leonardo Cavagnis <l.cavagnis@arduino.cc> Co-authored-by: Luca Burelli <l.burelli@arduino.cc> Co-authored-by: Martino Facchin <m.facchin@arduino.cc> Co-authored-by: Mattia Pennasilico <m.pennasilico@arduino.cc> Co-authored-by: Mike S <CyberMerln@gmail.com> Co-authored-by: Per Tillisch <accounts@perglass.com> Co-authored-by: Ruggero-R <r.rossino@ext.arduino.cc> Co-authored-by: Sebastian Romero <s.romero@arduino.cc> Co-authored-by: Shin Taeha <mirinae3145@g.skku.edu> Co-authored-by: Tamas Jozsi <tamas.jozsi@silabs.com> Co-authored-by: iabdalkader <i.abdalkader@gmail.com> Co-authored-by: maidnl <d.aimo@arduino.cc> Co-authored-by: pennam <m.pennasilico@arduino.cc>
1 parent df50941 commit 086461d

12 files changed

Lines changed: 6328 additions & 0 deletions

File tree

loader/CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
#set(DTC_OVERLAY_FILE ${BOARD}.overlay)
4+
5+
cmake_minimum_required(VERSION 3.20.0)
6+
7+
# get value of NORMALIZED_BOARD_TARGET early
8+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
9+
10+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
11+
set(EXTRA_CONF_FILE ${CMAKE_CURRENT_LIST_DIR}/../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.conf)
12+
13+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
14+
15+
project(app LANGUAGES C CXX)
16+
17+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/blobs)
18+
19+
# Memory region relocation based on Kconfig
20+
# Relocate LLEXT heap if region specified
21+
if(NOT "${CONFIG_LLEXT_HEAP_REGION}" STREQUAL "")
22+
zephyr_code_relocate(FILES ${ZEPHYR_BASE}/subsys/llext/llext_mem.c
23+
LOCATION ${CONFIG_LLEXT_HEAP_REGION}_BSS_NOINIT)
24+
endif()
25+
26+
# Relocate main stack if region specified
27+
if(NOT "${CONFIG_MAIN_STACK_REGION}" STREQUAL "")
28+
zephyr_code_relocate(FILES ${ZEPHYR_BASE}/kernel/init.c
29+
LOCATION ${CONFIG_MAIN_STACK_REGION}_BSS_NOINIT)
30+
endif()
31+
32+
33+
# for USB device stack NEXT
34+
target_sources_ifdef(CONFIG_USB_DEVICE_STACK_NEXT app PRIVATE
35+
${CMAKE_CURRENT_LIST_DIR}/../cores/arduino/usb_device_descriptor.c
36+
)
37+
38+
FILE(GLOB app_sources *.c)
39+
target_sources(app PRIVATE ${app_sources})
40+
target_compile_definitions(app PUBLIC _XOPEN_SOURCE=700)
41+
target_compile_definitions(app PUBLIC _GNU_SOURCE)
42+
43+
target_link_libraries(app PUBLIC blobs)

loader/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) Arduino s.r.l. and/or its affiliated companies
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
source "Kconfig.zephyr"
8+
9+
config LLEXT_HEAP_REGION
10+
string "LLEXT heap memory region"
11+
depends on CODE_DATA_RELOCATION
12+
help
13+
Specify the memory region for LLEXT heap.
14+
15+
config MAIN_STACK_REGION
16+
string "Main stack memory region"
17+
depends on CODE_DATA_RELOCATION
18+
help
19+
Specify the memory region for main stack.

loader/blobs/4343WA1_bin_qspi.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) Arduino s.r.l. and/or its affiliated companies
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/devicetree.h>
7+
#include "wiced_resource.h"
8+
9+
#define QUADSPI_MMAP_BASE DT_REG_ADDR_BY_IDX(DT_NODELABEL(quadspi), 1)
10+
#define FLASH_CHIP_OFFSET DT_REG_ADDR(DT_NODELABEL(qspi_flash))
11+
#define AIROC_PART_OFS DT_REG_ADDR(DT_NODELABEL(airoc_firmware))
12+
13+
#define FW_ADDR (QUADSPI_MMAP_BASE + FLASH_CHIP_OFFSET + AIROC_PART_OFS)
14+
#define FW_SIZE 421098 /* same as the _bin.c file */
15+
16+
const resource_hnd_t wifi_firmware_image = {
17+
RESOURCE_IN_MEMORY,
18+
FW_SIZE,
19+
{ .mem = { (const char *) FW_ADDR } }
20+
};

loader/blobs/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_interface_library_named(blobs)
4+
5+
if (CONFIG_BOARD_ARDUINO_PORTENTA_C33)
6+
set(gen_inc_dir ${ZEPHYR_BINARY_DIR}/misc/generated)
7+
zephyr_include_directories(${gen_inc_dir})
8+
set(gen_dir ${gen_inc_dir}/c33_bl_patch)
9+
generate_inc_file_for_target(
10+
${ZEPHYR_CURRENT_LIBRARY}
11+
${CMAKE_CURRENT_SOURCE_DIR}/c33_bl.bin
12+
${gen_dir}/c33_bl.bin.inc
13+
)
14+
endif()
15+
16+
if(CONFIG_AIROC_WIFI_CUSTOM)
17+
zephyr_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/airoc-firmware) # for wifi_nvram_image.h
18+
zephyr_library_sources(${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/airoc-firmware/4343WA1_clm_blob.c)
19+
zephyr_library_sources(${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/airoc-firmware/4343WA1_bin_qspi.c) # use _bin.c for a static build
20+
endif()

loader/blobs/c33_bl.bin

17.3 KB
Binary file not shown.

loader/blobs/c33_bl.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Zephyr-specific Portenta C33 bootloader
2+
3+
The `c33_bl.bin` file is the Zephyr-specific Portenta C33 bootloader. It is a
4+
binary file that can be flashed to the Portenta C33 to enable it to boot Zephyr
5+
applications.
6+
7+
Compared to the default C33 bootloader, the Zephyr-specific bootloader supports
8+
an additional `alt` section for the sketch to be loaded.
9+
10+
### Sources and compilation instructions
11+
12+
The source code for the Zephyr-specific C33 bootloader can be found in the
13+
[`arduino-renesas-bootloader` repository](https://github.com/arduino/arduino-renesas-bootloader/tree/zephyr_alt/)
14+
on GitHub. The Zephyr-specific bootloader uses the `zephyr_alt` branch.
15+
16+
This binary can be regenerated with the following commands:
17+
18+
```bash
19+
git clone https://github.com/arduino/arduino-renesas-bootloader
20+
git clone https://github.com/hathach/tinyusb
21+
cd tinyusb
22+
patch -p1 < ../arduino-renesas-bootloader/0001-fix-arduino-bootloaders.patch
23+
python tools/get_deps.py ra
24+
cd ..
25+
cd arduino-renesas-bootloader
26+
git checkout zephyr_alt
27+
TINYUSB_ROOT=$PWD/../tinyusb make -f Makefile.c33
28+
```
29+
30+
### License
31+
32+
The Zephyr-specific Portenta C33 bootloader is licensed under the MIT license.

0 commit comments

Comments
 (0)