-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
355c8d2
commit c6f8017
Showing
11 changed files
with
264 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# For more information about build system see | ||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html | ||
# The following five 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) | ||
|
||
set(PROJECT_VER "0.0.1") | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(why2025-firmware-esp32p4) |
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,119 @@ | ||
PORT ?= /dev/ttyACM0 | ||
|
||
IDF_PATH ?= $(shell cat .IDF_PATH 2>/dev/null || echo `pwd`/esp-idf) | ||
IDF_TOOLS_PATH ?= $(shell cat .IDF_TOOLS_PATH 2>/dev/null || echo `pwd`/esp-idf-tools) | ||
#IDF_BRANCH ?= v5.3.1 | ||
IDF_BRANCH ?= release/v5.4 | ||
#IDF_COMMIT ?= c57b352725ab36f007850d42578d2c7bc858ed47 | ||
IDF_EXPORT_QUIET ?= 1 | ||
IDF_GITHUB_ASSETS ?= dl.espressif.com/github_assets | ||
MAKEFLAGS += --silent | ||
|
||
SHELL := /usr/bin/env bash | ||
|
||
export IDF_TOOLS_PATH | ||
export IDF_GITHUB_ASSETS | ||
|
||
# General targets | ||
|
||
.PHONY: all | ||
all: build flash | ||
|
||
.PHONY: install | ||
install: flash | ||
|
||
# Preparation | ||
|
||
.PHONY: prepare | ||
prepare: submodules sdk | ||
|
||
.PHONY: submodules | ||
submodules: | ||
git submodule update --init --recursive | ||
|
||
.PHONY: sdk | ||
sdk: | ||
if test -d "$(IDF_PATH)"; then echo -e "ESP-IDF target folder exists!\r\nPlease remove the folder or un-set the environment variable."; exit 1; fi | ||
if test -d "$(IDF_TOOLS_PATH)"; then echo -e "ESP-IDF tools target folder exists!\r\nPlease remove the folder or un-set the environment variable."; exit 1; fi | ||
git clone --recursive --branch "$(IDF_BRANCH)" https://github.com/espressif/esp-idf.git "$(IDF_PATH)" --depth=1 --shallow-submodules | ||
#cd "$(IDF_PATH)"; git checkout "$(IDF_COMMIT)" | ||
cd "$(IDF_PATH)"; git submodule update --init --recursive | ||
cd "$(IDF_PATH)"; bash install.sh all | ||
source "$(IDF_PATH)/export.sh" && idf.py --preview set-target esp32p4 | ||
git checkout sdkconfig | ||
|
||
.PHONY: menuconfig | ||
menuconfig: | ||
source "$(IDF_PATH)/export.sh" && idf.py menuconfig | ||
|
||
# Cleaning | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf "build" | ||
|
||
.PHONY: fullclean | ||
fullclean: | ||
source "$(IDF_PATH)/export.sh" && idf.py fullclean | ||
|
||
# Building | ||
|
||
.PHONY: build | ||
build: | ||
source "$(IDF_PATH)/export.sh" >/dev/null && idf.py build | ||
|
||
# Hardware | ||
|
||
.PHONY: flash | ||
flash: build | ||
source "$(IDF_PATH)/export.sh" && \ | ||
idf.py flash -p $(PORT) | ||
|
||
.PHONY: flashmonitor | ||
flashmonitor: build | ||
source "$(IDF_PATH)/export.sh" && \ | ||
idf.py flash -p $(PORT) monitor | ||
|
||
.PHONY: appfs | ||
appfs: | ||
source "$(IDF_PATH)/export.sh" && \ | ||
esptool.py \ | ||
-b 921600 --port $(PORT) \ | ||
write_flash --flash_mode dio --flash_freq 80m --flash_size 16MB \ | ||
0x110000 appfs.bin | ||
|
||
.PHONY: erase | ||
erase: | ||
source "$(IDF_PATH)/export.sh" && idf.py erase-flash -p $(PORT) | ||
|
||
.PHONY: monitor | ||
monitor: | ||
source "$(IDF_PATH)/export.sh" && idf.py monitor -p $(PORT) | ||
|
||
.PHONY: openocd | ||
openocd: | ||
source "$(IDF_PATH)/export.sh" && idf.py openocd | ||
|
||
.PHONY: gdb | ||
gdb: | ||
source "$(IDF_PATH)/export.sh" && idf.py gdb | ||
|
||
# Tools | ||
|
||
.PHONY: size | ||
size: | ||
source "$(IDF_PATH)/export.sh" && idf.py size | ||
|
||
.PHONY: size-components | ||
size-components: | ||
source "$(IDF_PATH)/export.sh" && idf.py size-components | ||
|
||
.PHONY: size-files | ||
size-files: | ||
source "$(IDF_PATH)/export.sh" && idf.py size-files | ||
|
||
# Formatting | ||
|
||
.PHONY: format | ||
format: | ||
find main/ -iname '*.h' -o -iname '*.c' -o -iname '*.cpp' | xargs clang-format -i |
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,10 @@ | ||
# RVSWD programmer example | ||
|
||
An example showing how to use the RVSWD component. | ||
|
||
Tested on the official ESP32-P4 devkit. | ||
|
||
## Usage | ||
|
||
Connect a CH32V203 to pins 22 (swdio, PA13) and 23 (swclk, PA14) to program it. The included firmware binary blinks a LED attached to PB5 of the CH32V203. | ||
|
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,35 @@ | ||
dependencies: | ||
espressif/cmake_utilities: | ||
component_hash: 351350613ceafba240b761b4ea991e0f231ac7a9f59a9ee901f751bddc0bb18f | ||
dependencies: | ||
- name: idf | ||
require: private | ||
version: '>=4.1' | ||
source: | ||
registry_url: https://components.espressif.com | ||
type: service | ||
version: 0.5.3 | ||
idf: | ||
source: | ||
type: idf | ||
version: 5.4.0 | ||
nicolaielectronics/rvswd: | ||
component_hash: 02ddf180e334afba2822b3474f318e8f13ec6626b565107ac0660c1f0cbc7e30 | ||
dependencies: | ||
- name: espressif/cmake_utilities | ||
registry_url: https://components.espressif.com | ||
require: private | ||
version: 0.* | ||
- name: idf | ||
require: private | ||
version: '>=5.3' | ||
source: | ||
registry_url: https://components.espressif.com/ | ||
type: service | ||
version: 0.1.0 | ||
direct_dependencies: | ||
- idf | ||
- nicolaielectronics/rvswd | ||
manifest_hash: 33d3568bd3ae7225fee460ca35818f3dcc7e4f99626318c87789aacc5e359b64 | ||
target: esp32p4 | ||
version: 2.0.0 |
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 @@ | ||
export IDF_PATH=$(pwd)/esp-idf | ||
export IDF_TOOLS_PATH=$(pwd)/esp-idf-tools | ||
|
||
echo "ESP-IDF: $IDF_PATH" | ||
echo "TOOLS: $IDF_TOOLS_PATH" | ||
|
||
source esp-idf/export.sh |
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,8 @@ | ||
idf_component_register( | ||
SRCS | ||
"main.c" | ||
INCLUDE_DIRS | ||
"." | ||
EMBED_FILES | ||
"coprocessor.bin" | ||
) |
Binary file not shown.
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 @@ | ||
## IDF Component Manager Manifest File | ||
dependencies: | ||
## Required IDF version | ||
idf: | ||
version: '>=5.3.1' | ||
nicolaielectronics/rvswd: '*' |
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: 2025 Nicolai Electronics | ||
* | ||
* SPDX-License-Identifier: CC0-1.0 | ||
*/ | ||
|
||
#include <inttypes.h> | ||
#include <stdio.h> | ||
#include "rvswd_ch32v203.h" | ||
#include "esp_err.h" | ||
#include "esp_log.h" | ||
|
||
static const char* TAG = "example"; | ||
|
||
extern uint8_t const coprocessor_firmware_start[] asm("_binary_coprocessor_bin_start"); | ||
extern uint8_t const coprocessor_firmware_end[] asm("_binary_coprocessor_bin_end"); | ||
|
||
static void flash_coprocessor(void) { | ||
rvswd_handle_t handle = { | ||
.swdio = 22, | ||
.swclk = 23, | ||
}; | ||
|
||
bool success = ch32_program(&handle, coprocessor_firmware_start, coprocessor_firmware_end - coprocessor_firmware_start); | ||
|
||
if (success) { | ||
ESP_LOGI(TAG, "Succesfully flashed the CH32V203 microcontroller"); | ||
} else { | ||
ESP_LOGE(TAG, "Failed to flash the CH32V203 microcontroller"); | ||
} | ||
|
||
// vTaskDelay(pdMS_TO_TICKS(5000)); | ||
// esp_restart(); | ||
} | ||
|
||
void app_main(void) { | ||
flash_coprocessor(); | ||
return; | ||
} |
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 @@ | ||
# ESP-IDF Partition Table | ||
# Name, Type, SubType, Offset, Size, Flags | ||
nvs, data, nvs, 0x9000, 16K | ||
otadata, data, ota, 0xD000, 8K, | ||
phy_init, data, phy, 0xF000, 4K, | ||
factory, app, factory, 0x10000, 2M, | ||
fat, data, fat, 0x220000, 2M, |
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,23 @@ | ||
# This file was generated using idf.py save-defconfig. It can be edited manually. | ||
# Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration | ||
# | ||
CONFIG_IDF_TARGET="esp32p4" | ||
CONFIG_BOOTLOADER_LOG_COLORS=y | ||
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y | ||
CONFIG_PARTITION_TABLE_CUSTOM=y | ||
CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y | ||
CONFIG_SPIRAM=y | ||
CONFIG_SPIRAM_SPEED_200M=y | ||
CONFIG_SPIRAM_XIP_FROM_PSRAM=y | ||
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y | ||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 | ||
CONFIG_ESP_INT_WDT=n | ||
CONFIG_ESP_TASK_WDT_EN=n | ||
CONFIG_LOG_COLORS=y | ||
CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4 | ||
CONFIG_LWIP_PPP_SUPPORT=y | ||
CONFIG_LWIP_PPP_SERVER_SUPPORT=y | ||
CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y | ||
CONFIG_MBEDTLS_CMAC_C=y | ||
CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y | ||
CONFIG_IDF_EXPERIMENTAL_FEATURES=y |