Skip to content

Commit

Permalink
Merge pull request #143 from joltwallet/littlefs-python2
Browse files Browse the repository at this point in the history
Replace mklittlefs with littlefs-python
  • Loading branch information
BrianPugh authored Sep 20, 2023
2 parents e23c0c6 + 8eab104 commit 9b4438e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 51 deletions.
48 changes: 12 additions & 36 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,36 @@ on:
schedule:
- cron: "0 1 * * 6" # Every Saturday at 1AM

# Based on https://github.com/igrr/libnmea-esp32/blob/main/.github/workflows/build.yml
jobs:
build-component:
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
idf_ver: ["release-v4.3", "release-v4.4", "release-v5.0", "latest"]
idf_ver: ["v4.4", "v5.0", "v5.1", "latest"]
idf_target: ["esp32"]
include:
- idf_ver: "release-v4.4"
- idf_ver: "v4.4"
idf_target: esp32s2
- idf_ver: "release-v4.4"
- idf_ver: "v4.4"
idf_target: esp32c3
- idf_ver: "release-v4.4"
- idf_ver: "v4.4"
idf_target: esp32s3
runs-on: ubuntu-latest
container: espressif/idf:${{ matrix.idf_ver }}
steps:
- name: Update git
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y software-properties-common g++
add-apt-repository -y ppa:git-core/ppa
apt-get update
apt-get install -y git
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Build for ESP32
env:
IDF_TARGET: ${{ matrix.idf_target }}
shell: bash
run: |
. ${IDF_PATH}/export.sh
cd example
idf.py build

build-tests:
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
idf_ver: ["v4.3.3", "v4.4.1", "latest"]

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: esp-idf build library
uses: espressif/esp-idf-ci-action@main
with:
submodules: recursive
- name: esp-idf build
esp_idf_version: ${{ matrix.idf_ver }}
target: ${{ matrix.idf_target }}
path: "example/"
command: apt update && apt install -y python3-venv && idf.py build

- name: esp-idf build tests
uses: espressif/esp-idf-ci-action@main
with:
esp_idf_version: ${{ matrix.idf_ver }}
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "main/littlefs"]
path = src/littlefs
url = https://github.com/littlefs-project/littlefs.git
[submodule "mklittlefs"]
path = mklittlefs
url = https://github.com/BrianPugh/mklittlefs.git
1 change: 1 addition & 0 deletions image-building-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
littlefs-python>=0.7.1
1 change: 0 additions & 1 deletion mklittlefs
Submodule mklittlefs deleted from 311ae7
35 changes: 24 additions & 11 deletions project_include.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#
# Create a littlefs image of the specified directory on the host during build and optionally
# have the created image flashed using `idf.py flash`
set(MKLITTLEFS_DIR "${CMAKE_CURRENT_LIST_DIR}/mklittlefs")
set(MKLITTLEFS "${MKLITTLEFS_DIR}/mklittlefs")

set(littlefs_py_venv "${CMAKE_CURRENT_BINARY_DIR}/littlefs_py_venv")
set(littlefs_py_requirements "${CMAKE_CURRENT_LIST_DIR}/image-building-requirements.txt")

function(littlefs_create_partition_image partition base_dir)
set(options FLASH_IN_PROJECT)
Expand All @@ -18,21 +19,33 @@ function(littlefs_create_partition_image partition base_dir)
partition_table_get_partition_info(size "--partition-name ${partition}" "size")
partition_table_get_partition_info(offset "--partition-name ${partition}" "offset")

add_custom_command(
OUTPUT ${MKLITTLEFS}
COMMAND make clean && make dist LFS_NAME_MAX=${CONFIG_LITTLEFS_OBJ_NAME_LEN}
WORKING_DIRECTORY ${MKLITTLEFS_DIR}
DEPENDS ${SDKCONFIG}
)

if("${size}" AND "${offset}")
set(image_file ${CMAKE_BINARY_DIR}/${partition}.bin)

if(CMAKE_HOST_WIN32)
set(littlefs_py "${littlefs_py_venv}/Scripts/littlefs-python.exe")
add_custom_command(
OUTPUT ${littlefs_py_venv}
COMMAND ${PYTHON} -m venv ${littlefs_py_venv} && ${littlefs_py_venv}/Scripts/pip.exe install -r ${littlefs_py_requirements}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${littlefs_py_requirements}
)
else()
set(littlefs_py "${littlefs_py_venv}/bin/littlefs-python")
add_custom_command(
OUTPUT ${littlefs_py_venv}
COMMAND ${PYTHON} -m venv ${littlefs_py_venv} && ${littlefs_py_venv}/bin/pip install -r ${littlefs_py_requirements}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${littlefs_py_requirements}
)
endif()

# Execute LittleFS image generation; this always executes as there is no way to specify for CMake to watch for
# contents of the base dir changing.

add_custom_target(littlefs_${partition}_bin ALL
COMMAND ${MKLITTLEFS} -d 0 -c ${base_dir_full_path} -s ${size} -p ${CONFIG_LITTLEFS_PAGE_SIZE} -b 4096 ${image_file}
DEPENDS ${arg_DEPENDS} ${MKLITTLEFS}
COMMAND ${littlefs_py} create ${base_dir_full_path} -v --image=${image_file} --fs-size=${size} --name-max=${CONFIG_LITTLEFS_OBJ_NAME_LEN} --block-size=4096
DEPENDS ${arg_DEPENDS} ${littlefs_py_venv}
)

set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
Expand Down

0 comments on commit 9b4438e

Please sign in to comment.