From ed7a23256c25ff855e4cb360c3e3e93f80bd5dea Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Fri, 16 May 2025 21:55:25 +0200 Subject: [PATCH] Let the SEGFAULTS begin! Signed-off-by: Peter Siegmund --- .gitignore | 5 +++ .vscode/c_cpp_properties.json | 23 +++++++++++ .vscode/launch.json | 15 +++++++ CMakeLists.txt | 6 +++ components/led_matrix/CMakeLists.txt | 5 +++ components/led_matrix/idf_component.yml | 17 ++++++++ components/led_matrix/include/led_matrix.h | 3 ++ components/led_matrix/led_matrix.c | 39 +++++++++++++++++++ components/remote_control/CMakeLists.txt | 2 + .../remote_control/include/remote_control.h | 1 + components/remote_control/remote_control.c | 7 ++++ dependencies.lock | 21 ++++++++++ main/CMakeLists.txt | 6 +++ main/idf_component.yml | 16 ++++++++ main/main.c | 6 +++ partitions.csv | 7 ++++ sdkconfig.defaults | 19 +++++++++ sdkconfig.defaults.esp32s3 | 2 + 18 files changed, 200 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 CMakeLists.txt create mode 100644 components/led_matrix/CMakeLists.txt create mode 100644 components/led_matrix/idf_component.yml create mode 100644 components/led_matrix/include/led_matrix.h create mode 100644 components/led_matrix/led_matrix.c create mode 100644 components/remote_control/CMakeLists.txt create mode 100644 components/remote_control/include/remote_control.h create mode 100644 components/remote_control/remote_control.c create mode 100644 dependencies.lock create mode 100644 main/CMakeLists.txt create mode 100644 main/idf_component.yml create mode 100644 main/main.c create mode 100644 partitions.csv create mode 100755 sdkconfig.defaults create mode 100644 sdkconfig.defaults.esp32s3 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef616 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build/** +managed_components/** +sdkconfig +sdkconfig.old +.vscode/settings.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..7a61e51 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,23 @@ +{ + "configurations": [ + { + "name": "ESP-IDF", + "compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc", + "compileCommands": "${config:idf.buildPath}/compile_commands.json", + "includePath": [ + "${config:idf.espIdfPath}/components/**", + "${config:idf.espIdfPathWin}/components/**", + "${workspaceFolder}/**" + ], + "browse": { + "path": [ + "${config:idf.espIdfPath}/components", + "${config:idf.espIdfPathWin}/components", + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true + } + } + ], + "version": 4 +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2511a38 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "gdbtarget", + "request": "attach", + "name": "Eclipse CDT GDB Adapter" + }, + { + "type": "espidf", + "name": "Launch", + "request": "launch" + } + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..edb5f67 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +# 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) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(miniature_town) diff --git a/components/led_matrix/CMakeLists.txt b/components/led_matrix/CMakeLists.txt new file mode 100644 index 0000000..8f3915b --- /dev/null +++ b/components/led_matrix/CMakeLists.txt @@ -0,0 +1,5 @@ +idf_component_register(SRCS "led_matrix.c" + INCLUDE_DIRS "include" + PRIV_REQUIRES + led_strip +) diff --git a/components/led_matrix/idf_component.yml b/components/led_matrix/idf_component.yml new file mode 100644 index 0000000..75a6942 --- /dev/null +++ b/components/led_matrix/idf_component.yml @@ -0,0 +1,17 @@ +## IDF Component Manager Manifest File +dependencies: + ## Required IDF version + idf: + version: '>=4.1.0' + # # Put list of dependencies here + # # For components maintained by Espressif: + # component: "~1.0.0" + # # For 3rd party components: + # username/component: ">=1.0.0,<2.0.0" + # username2/component2: + # version: "~1.0.0" + # # For transient dependencies `public` flag can be set. + # # `public` flag doesn't have an effect dependencies of the `main` component. + # # All dependencies of `main` are public by default. + # public: true + espressif/led_strip: '~3.0.0' diff --git a/components/led_matrix/include/led_matrix.h b/components/led_matrix/include/led_matrix.h new file mode 100644 index 0000000..abe0efc --- /dev/null +++ b/components/led_matrix/include/led_matrix.h @@ -0,0 +1,3 @@ +#pragma once + +void init_led(void); diff --git a/components/led_matrix/led_matrix.c b/components/led_matrix/led_matrix.c new file mode 100644 index 0000000..5a4d57c --- /dev/null +++ b/components/led_matrix/led_matrix.c @@ -0,0 +1,39 @@ +#include +#include "led_matrix.h" + +#include "led_strip.h" + +#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000) + +led_strip_handle_t led_strip_init(uint8_t gpio_pin, uint32_t width, uint32_t height) +{ + led_strip_config_t strip_config = { + .strip_gpio_num = gpio_pin, + .max_leds = width * height, + .led_model = LED_MODEL_WS2812, + .color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_RGB, + .flags = { + .invert_out = false, + }}; + + led_strip_rmt_config_t rmt_config = { + .clk_src = RMT_CLK_SRC_DEFAULT, + .resolution_hz = LED_STRIP_RMT_RES_HZ, + .mem_block_symbols = 64, + .flags = { + .with_dma = true, + }}; + + led_strip_handle_t led_strip; + ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip)); + return led_strip; +} + +void init_led(void) +{ + led_strip_handle_t led = led_strip_init(14, 8, 8); + // led_strip_set_pixel(led, 0, 255, 0, 0); + // led_strip_set_pixel(led, 1, 0, 255, 0); + // led_strip_set_pixel(led, 2, 0, 0, 255); + led_strip_refresh(led); +} diff --git a/components/remote_control/CMakeLists.txt b/components/remote_control/CMakeLists.txt new file mode 100644 index 0000000..ad8a575 --- /dev/null +++ b/components/remote_control/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "remote_control.c" + INCLUDE_DIRS "include") diff --git a/components/remote_control/include/remote_control.h b/components/remote_control/include/remote_control.h new file mode 100644 index 0000000..f6f3a61 --- /dev/null +++ b/components/remote_control/include/remote_control.h @@ -0,0 +1 @@ +void func(void); diff --git a/components/remote_control/remote_control.c b/components/remote_control/remote_control.c new file mode 100644 index 0000000..1e6d1b5 --- /dev/null +++ b/components/remote_control/remote_control.c @@ -0,0 +1,7 @@ +#include +#include "remote_control.h" + +void func(void) +{ + +} diff --git a/dependencies.lock b/dependencies.lock new file mode 100644 index 0000000..aa9a469 --- /dev/null +++ b/dependencies.lock @@ -0,0 +1,21 @@ +dependencies: + espressif/led_strip: + component_hash: b578eb926d9f6402fd45398b53c9bd5d1b7a15c1b2974d25aa3088e6c79b0b4c + dependencies: + - name: idf + require: private + version: '>=5.0' + source: + registry_url: https://components.espressif.com/ + type: service + version: 3.0.1 + idf: + source: + type: idf + version: 5.4.1 +direct_dependencies: +- espressif/led_strip +- idf +manifest_hash: f4b6d767929ac18eaac7f04ecb838dbd4eeadcf88f73554cdf3fb35996942f18 +target: esp32s3 +version: 2.0.0 diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 0000000..6dbaa17 --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,6 @@ +idf_component_register(SRCS "main.c" + INCLUDE_DIRS "." + PRIV_REQUIRES + led_matrix + remote_control +) diff --git a/main/idf_component.yml b/main/idf_component.yml new file mode 100644 index 0000000..343c26f --- /dev/null +++ b/main/idf_component.yml @@ -0,0 +1,16 @@ +## IDF Component Manager Manifest File +dependencies: + ## Required IDF version + idf: + version: '>=5.4.0' + # # Put list of dependencies here + # # For components maintained by Espressif: + # component: "~1.0.0" + # # For 3rd party components: + # username/component: ">=1.0.0,<2.0.0" + # username2/component2: + # version: "~1.0.0" + # # For transient dependencies `public` flag can be set. + # # `public` flag doesn't have an effect dependencies of the `main` component. + # # All dependencies of `main` are public by default. + # public: true diff --git a/main/main.c b/main/main.c new file mode 100644 index 0000000..ca664b3 --- /dev/null +++ b/main/main.c @@ -0,0 +1,6 @@ +#include "led_matrix.h" + +void app_main(void) +{ + init_led(); +} diff --git a/partitions.csv b/partitions.csv new file mode 100644 index 0000000..be9a670 --- /dev/null +++ b/partitions.csv @@ -0,0 +1,7 @@ +# Name , Type , SubType , Offset , Size , Flags +nvs , data , nvs , 0x9000 , 20k , +otadata , data , ota , 0xe000 , 8k , +app0 , app , ota_0 , 0x10000 , 1024k , +app1 , app , ota_1 , , 1024k , +spiffs , data , spiffs , , 1536k , +coredump , data , coredump , , 64k , diff --git a/sdkconfig.defaults b/sdkconfig.defaults new file mode 100755 index 0000000..c60e329 --- /dev/null +++ b/sdkconfig.defaults @@ -0,0 +1,19 @@ +# activate Bluetooth Low Energy (BLE) +CONFIG_BT_ENABLED=y +CONFIG_BT_NIMBLE_ENABLED=y + +# nimble options +CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="miniature" + +# Logging +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_MAXIMUM_LEVEL=3 + +# Flash Size +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Partitions +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" diff --git a/sdkconfig.defaults.esp32s3 b/sdkconfig.defaults.esp32s3 new file mode 100644 index 0000000..7c2cf11 --- /dev/null +++ b/sdkconfig.defaults.esp32s3 @@ -0,0 +1,2 @@ +# default ESP target +CONFIG_IDF_TARGET="esp32s3"