Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 committed Oct 2, 2023
1 parent cebe060 commit 5d94517
Show file tree
Hide file tree
Showing 15 changed files with 470 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/espidf-arduino-littlefs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.pio
.vscode
4 changes: 4 additions & 0 deletions examples/espidf-arduino-littlefs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
list(APPEND EXTRA_COMPONENT_DIRS managed_components)
project(espidf-arduino-littlefs)
1 change: 1 addition & 0 deletions examples/espidf-arduino-littlefs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Arduino_IDF_LittleFS
1 change: 1 addition & 0 deletions examples/espidf-arduino-littlefs/data/file1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aaa
1 change: 1 addition & 0 deletions examples/espidf-arduino-littlefs/data/testfolder/test2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bbb
39 changes: 39 additions & 0 deletions examples/espidf-arduino-littlefs/include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
46 changes: 46 additions & 0 deletions examples/espidf-arduino-littlefs/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
3 changes: 3 additions & 0 deletions examples/espidf-arduino-littlefs/littlefsbuilder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Import("env")
platform = env.PioPlatform()
env.Replace( MKSPIFFSTOOL=platform.get_package_dir("tool-mklittlefs") + '/mklittlefs' ) # PlatformIO now believes it has actually created a SPIFFS
Empty file.
6 changes: 6 additions & 0 deletions examples/espidf-arduino-littlefs/partitions_custom.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x80000,
app1, app, ota_1, 0x90000, 0x110000,
spiffs, data, spiffs, 0x1A0000,0x260000,
19 changes: 19 additions & 0 deletions examples/espidf-arduino-littlefs/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env]
platform = espressif32
framework = arduino, espidf
monitor_speed = 115200

[env:esp32-s3]
board = esp32-s3-devkitc-1
extra_scripts = ./littlefsbuilder.py
board_build.partitions = partitions_custom.csv
9 changes: 9 additions & 0 deletions examples/espidf-arduino-littlefs/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_AUTOSTART_ARDUINO=y
# CONFIG_WS2812_LED_ENABLE is not set
CONFIG_FREERTOS_HZ=1000
CONFIG_MBEDTLS_PSK_MODES=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
6 changes: 6 additions & 0 deletions examples/espidf-arduino-littlefs/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file was automatically generated for projects
# without default 'CMakeLists.txt' file.

FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)

idf_component_register(SRCS ${app_sources})
51 changes: 51 additions & 0 deletions examples/espidf-arduino-littlefs/src/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
dependencies:
# Required IDF version
idf: ">=4.4"

esp_littlefs:
git: https://github.com/joltwallet/esp_littlefs.git
version: lfs2.8

mdns: "^1.2.1"
# nghttp: "^1.50.0"
# esp_jpeg: "^1.0.4"
# esp-dsp: "^1.2.0"
# esp-sr: "^1.0.3"
# esp32-camera: "^2.0.3"
# esp-dl:
# git: https://github.com/espressif/esp-dl.git
# arduino:
# path: components/arduino

# # Defining a dependency from the registry:
# # https://components.espressif.com/component/example/cmp
# example/cmp: "^3.3.3" # Automatically update minor releases
#
# # Other ways to define dependencies
#
# # For components maintained by Espressif only name can be used.
# # Same as `espressif/cmp`
# component: "~1.0.0" # Automatically update bugfix releases
#
# # Or in a longer form with extra parameters
# component2:
# version: ">=2.0.0"
#
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect for the `main` component.
# # All dependencies of `main` are public by default.
# public: true
#
# # For components hosted on non-default registry:
# service_url: "https://componentregistry.company.com"
#
# # For components in git repository:
# test_component:
# path: test_component
# git: ssh://[email protected]/user/components.git
#
# # For test projects during component development
# # components can be used from a local directory
# # with relative or absolute path
# some_local_component:
# path: ../../projects/component
Loading

0 comments on commit 5d94517

Please sign in to comment.