#add: 完成基础的项目结构搭建
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
ARG DOCKER_TAG=latest
|
||||
FROM espressif/idf:${DOCKER_TAG}
|
||||
|
||||
ENV LC_ALL=C.UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
RUN apt-get update -y && apt-get install udev -y
|
||||
|
||||
RUN echo "source /opt/esp/idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
|
||||
|
||||
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
|
||||
|
||||
CMD ["/bin/bash", "-c"]
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "ESP-IDF QEMU",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {
|
||||
"terminal.integrated.defaultProfile.linux": "bash",
|
||||
"idf.gitPath": "/usr/bin/git"
|
||||
},
|
||||
"extensions": [
|
||||
"espressif.esp-idf-extension",
|
||||
"espressif.esp-idf-web"
|
||||
]
|
||||
}
|
||||
},
|
||||
"runArgs": ["--privileged"]
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
# macOS
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Directory metadata
|
||||
.directory
|
||||
|
||||
# Temporary files
|
||||
*~
|
||||
*.swp
|
||||
*.swo
|
||||
*.bak
|
||||
*.tmp
|
||||
|
||||
# Log files
|
||||
*.log
|
||||
|
||||
# Build artifacts and directories
|
||||
**/build/
|
||||
build/
|
||||
/.build/
|
||||
*.o
|
||||
*.a
|
||||
*.out
|
||||
*.exe # For any host-side utilities compiled on Windows
|
||||
|
||||
# ESP-IDF specific build outputs
|
||||
*.bin
|
||||
*.elf
|
||||
*.map
|
||||
flasher_args.json # Generated in build directory
|
||||
sdkconfig.old
|
||||
sdkconfig
|
||||
|
||||
# ESP-IDF dependencies
|
||||
# For older versions or manual component management
|
||||
/components/.idf/
|
||||
**/components/.idf/
|
||||
# For modern ESP-IDF component manager
|
||||
managed_components/
|
||||
# If ESP-IDF tools are installed/referenced locally to the project
|
||||
.espressif/
|
||||
|
||||
# CMake generated files
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
CTestTestfile.cmake
|
||||
|
||||
# Python environment files
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
__pycache__/
|
||||
*.egg-info/
|
||||
dist/
|
||||
|
||||
# Virtual environment folders
|
||||
venv/
|
||||
.venv/
|
||||
env/
|
||||
|
||||
# Language Servers
|
||||
.clangd/
|
||||
.ccls-cache/
|
||||
compile_commands.json
|
||||
|
||||
# Windows specific
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
Desktop.ini
|
||||
|
||||
# User-specific configuration files
|
||||
/CMakeUserPresets.json
|
||||
*.user
|
||||
*.workspace # General workspace files, can be from various tools
|
||||
*.suo # Visual Studio Solution User Options
|
||||
*.sln.docstates # Visual Studio
|
||||
|
||||
.build
|
||||
|
||||
.cache
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "ESP-IDF",
|
||||
"compilerPath": "/home/lain/.espressif/tools/xtensa-esp-elf/esp-15.2.0_20251204/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc",
|
||||
"compileCommands": "/home/lain/Projects/esp_study/esp_study/.build/dev/compile_commands.json",
|
||||
"intelliSenseMode": "gcc-x86",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "gdbtarget",
|
||||
"request": "attach",
|
||||
"name": "Eclipse CDT GDB Adapter"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"C_Cpp.intelliSenseEngine": "disabled",
|
||||
"idf.extensionActivationMode": "always",
|
||||
"cmake.configureOnOpen": false,
|
||||
"cmake.configureOnEdit": false,
|
||||
"cmake.automaticReconfigure": false,
|
||||
"cmake.autoSelectActiveFolder": false,
|
||||
"cmake.options.advanced": {
|
||||
"build": {
|
||||
"statusBarVisibility": "inherit",
|
||||
"inheritDefault": "hidden"
|
||||
},
|
||||
"launch": {
|
||||
"statusBarVisibility": "inherit",
|
||||
"inheritDefault": "hidden"
|
||||
},
|
||||
"debug": {
|
||||
"statusBarVisibility": "inherit",
|
||||
"inheritDefault": "hidden"
|
||||
}
|
||||
},
|
||||
"idf.openOcdConfigs": [
|
||||
"board/esp32s3-builtin.cfg"
|
||||
],
|
||||
"idf.port": "/dev/ttyACM0",
|
||||
"idf.currentSetup": "/home/lain/.espressif/v6.0.2/esp-idf",
|
||||
"clangd.path": "/home/lain/.espressif/tools/esp-clang/esp-20.1.1_20250829/esp-clang/bin/clangd",
|
||||
"clangd.arguments": [
|
||||
"--background-index",
|
||||
"--query-driver=**",
|
||||
"--compile-commands-dir=/home/lain/Projects/esp_study/esp_study/.build/dev"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.25)
|
||||
|
||||
if(NOT DEFINED IDF_TARGET)
|
||||
set(IDF_TARGET "esp32s3" CACHE STRING "ESP-IDF target")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED SDKCONFIG)
|
||||
set(SDKCONFIG "${CMAKE_BINARY_DIR}/sdkconfig")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED SDKCONFIG_DEFAULTS)
|
||||
set(SDKCONFIG_DEFAULTS
|
||||
"${CMAKE_SOURCE_DIR}/sdkconfig.defaults;${CMAKE_SOURCE_DIR}/sdkconfig.defaults.dev")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 26)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(esp_study)
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"version": 3,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 25,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "idf-base",
|
||||
"hidden": true,
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/.build/${presetName}",
|
||||
"cacheVariables": {
|
||||
"IDF_TARGET": "esp32s3",
|
||||
"SDKCONFIG": "${sourceDir}/.build/${presetName}/sdkconfig"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dev",
|
||||
"inherits": "idf-base",
|
||||
"displayName": "Default (development)",
|
||||
"description": "Development configuration",
|
||||
"cacheVariables": {
|
||||
"SDKCONFIG_DEFAULTS": "${sourceDir}/sdkconfig.defaults;${sourceDir}/sdkconfig.defaults.dev"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "prod",
|
||||
"inherits": "idf-base",
|
||||
"displayName": "Production",
|
||||
"description": "Production configuration",
|
||||
"cacheVariables": {
|
||||
"SDKCONFIG_DEFAULTS": "${sourceDir}/sdkconfig.defaults;${sourceDir}/sdkconfig.defaults.prod"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "dev",
|
||||
"configurePreset": "dev"
|
||||
},
|
||||
{
|
||||
"name": "prod",
|
||||
"configurePreset": "prod"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(SRCS
|
||||
"application.cc"
|
||||
"context.cc"
|
||||
"loader.cc"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "application.hh"
|
||||
|
||||
#include <new> // For std::nothrow
|
||||
#include <stop_token> // For std::stop_source, std::stop_token, std::nostopstate
|
||||
#include <thread> // For std::jthread
|
||||
|
||||
#include "context.hh" // For context
|
||||
#include "loader.hh" // For loader::ui, loader::service
|
||||
|
||||
class impl {
|
||||
public:
|
||||
impl()
|
||||
: ui_thread_(&impl::ui_thread_function, this),
|
||||
service_thread_(&impl::service_thread_function, this),
|
||||
context_() {};
|
||||
~impl() noexcept = default;
|
||||
|
||||
void run() {
|
||||
context_.run();
|
||||
}
|
||||
|
||||
private:
|
||||
void ui_thread_function(std::stop_token token) {
|
||||
// Implementation of the UI thread function
|
||||
loader::ui ui_instance;
|
||||
ui_instance.set_context(&context_);
|
||||
}
|
||||
|
||||
void service_thread_function(std::stop_token token) {
|
||||
// Implementation of the service thread function
|
||||
loader::service service_instance;
|
||||
service_instance.set_context(&context_);
|
||||
}
|
||||
|
||||
private:
|
||||
std::jthread ui_thread_;
|
||||
std::jthread service_thread_;
|
||||
context context_;
|
||||
};
|
||||
|
||||
application::application() : pimpl_(new(std::nothrow) impl()) {}
|
||||
|
||||
application::~application() noexcept { delete pimpl_; }
|
||||
|
||||
void application::run() { pimpl_->run(); }
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef APPLICATION_HH
|
||||
#define APPLICATION_HH
|
||||
#pragma once
|
||||
|
||||
class impl;
|
||||
|
||||
class application {
|
||||
public:
|
||||
application();
|
||||
~application() noexcept;
|
||||
|
||||
void run();
|
||||
|
||||
private:
|
||||
impl *pimpl_;
|
||||
};
|
||||
|
||||
#endif // APPLICATION_HH
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef CONTEXT_HH
|
||||
#define CONTEXT_HH
|
||||
#pragma once
|
||||
// 事件循环上下文
|
||||
class context {
|
||||
public:
|
||||
context() = default;
|
||||
~context() noexcept = default;
|
||||
|
||||
void run() noexcept;
|
||||
};
|
||||
#endif // CONTEXT_HH
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef LOADER_HH
|
||||
#define LOADER_HH
|
||||
#pragma once
|
||||
|
||||
class context;
|
||||
|
||||
namespace loader {
|
||||
class ui {
|
||||
public:
|
||||
ui() = default;
|
||||
~ui() noexcept = default;
|
||||
|
||||
void set_context(context *ctx);
|
||||
};
|
||||
|
||||
class service {
|
||||
public:
|
||||
service() = default;
|
||||
~service() noexcept = default;
|
||||
|
||||
void set_context(context *ctx);
|
||||
};
|
||||
} // namespace loader
|
||||
|
||||
#endif // LOADER_HH
|
||||
@@ -0,0 +1 @@
|
||||
idf_component_register()
|
||||
@@ -0,0 +1 @@
|
||||
idf_component_register()
|
||||
@@ -0,0 +1 @@
|
||||
idf_component_register()
|
||||
@@ -0,0 +1 @@
|
||||
idf_component_register()
|
||||
@@ -0,0 +1,3 @@
|
||||
idf_component_register(REQUIRES littlefs)
|
||||
|
||||
littlefs_create_partition_image(assets_fs "../../assets" FLASH_IN_PROJECT)
|
||||
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
idf: ">=6.0.0,<6.1.0"
|
||||
joltwallet/littlefs: "~=1.22.3"
|
||||
@@ -0,0 +1,21 @@
|
||||
dependencies:
|
||||
idf:
|
||||
source:
|
||||
type: idf
|
||||
version: 6.0.2
|
||||
joltwallet/littlefs:
|
||||
component_hash: 3af20a3d75c49db9dc2286fd50862c34055c9f578419ad1f2bf7ed3ed01391fe
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.0'
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.22.3
|
||||
direct_dependencies:
|
||||
- idf
|
||||
- joltwallet/littlefs
|
||||
manifest_hash: 25f711fa39d438b5d864dd7aeb4896a3f989485a893f69e56fc846156a31272a
|
||||
target: esp32s3
|
||||
version: 3.0.0
|
||||
@@ -0,0 +1,9 @@
|
||||
idf_component_register(SRCS "main.cc"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES
|
||||
app_framework
|
||||
startup_ui
|
||||
display_service
|
||||
network_service
|
||||
storage_service
|
||||
ota_service)
|
||||
@@ -0,0 +1,7 @@
|
||||
// #include "application.hh"
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
// application app;
|
||||
// app.run();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x15000,
|
||||
otadata, data, ota, 0x1E000, 0x2000,
|
||||
coredump, data, coredump,0x20000, 0x20000,
|
||||
ota_0, app, ota_0, 0x40000, 0x500000,
|
||||
ota_1, app, ota_1, 0x540000, 0x500000,
|
||||
plugin_fs, data, littlefs,0xA40000, 0x200000,
|
||||
assets_fs, data, littlefs,0xC40000, 0x3C0000,
|
||||
|
@@ -0,0 +1,17 @@
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
|
||||
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_TYPE_AUTO=y
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
CONFIG_SPIRAM_USE_MALLOC=y
|
||||
# CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM is not set
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||
|
||||
CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=y
|
||||
CONFIG_ESP_COREDUMP_CHECK_BOOT=y
|
||||
CONFIG_ESP_COREDUMP_STACK_SIZE=2048
|
||||
@@ -0,0 +1,4 @@
|
||||
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_DEBUG=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
|
||||
CONFIG_ESP_COREDUMP_LOGS=y
|
||||
@@ -0,0 +1,4 @@
|
||||
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
|
||||
# CONFIG_ESP_COREDUMP_LOGS is not set
|
||||
Reference in New Issue
Block a user