Skip to content

Commit a208fa2

Browse files
committed
Upgrade to LFS 2.0; see MGOS_LFS1_COMPAT for upgrade options
MGOS_LFS1_COMPAT - LFSv1 compatibility mode: * 0 - none: No LFSv1 code in the firmware, attempts to mount LFSv1 filesystem results in an error. * 1 - full: Existing LFSv1 filesystems can be mounted rw and used with no restrictions. Firmware contains full LFSv1 code, data is not migrated, mkfs always creates LFSv2. * 2 - stomp: LFSv1 filesystems are stomped and reformatted as LFSv2 without preserving the data. No LFSv1 code, no data migration, mkfs creates LFSv2. This option is suitable for cases where LFS is only used as scratch space. CL: vfs-fs-lfs: Upgrade to LFS 2.0; see MGOS_LFS1_COMPAT for upgrade options
1 parent d465901 commit a208fa2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+16295
-3070
lines changed

.clang-format

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BasedOnStyle: Google
2+
AllowShortFunctionsOnASingleLine: false
3+
SpaceAfterCStyleCast: true
4+
PointerBindsToType: false
5+
DerivePointerBinding: false

littlefs/.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DisableFormat: true
File renamed without changes.

littlefs/.travis.yml

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
# Environment variables
2+
env:
3+
global:
4+
- CFLAGS=-Werror
5+
6+
# Common test script
7+
script:
8+
# make sure example can at least compile
9+
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
10+
make all CFLAGS+="
11+
-Duser_provided_block_device_read=NULL
12+
-Duser_provided_block_device_prog=NULL
13+
-Duser_provided_block_device_erase=NULL
14+
-Duser_provided_block_device_sync=NULL
15+
-include stdio.h"
16+
17+
# run tests
18+
- make test QUIET=1
19+
20+
# run tests with a few different configurations
21+
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_CACHE_SIZE=4"
22+
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_CACHE_SIZE=512 -DLFS_BLOCK_CYCLES=16"
23+
- make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD_SIZE=256"
24+
25+
- make clean test QUIET=1 CFLAGS+="-DLFS_INLINE_MAX=0"
26+
- make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"
27+
28+
# compile and find the code size with the smallest configuration
29+
- make clean size
30+
OBJ="$(ls lfs*.o | tr '\n' ' ')"
31+
CFLAGS+="-DLFS_NO_ASSERT -DLFS_NO_DEBUG -DLFS_NO_WARN -DLFS_NO_ERROR"
32+
| tee sizes
33+
34+
# update status if we succeeded, compare with master if possible
35+
- |
36+
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
37+
then
38+
CURR=$(tail -n1 sizes | awk '{print $1}')
39+
PREV=$(curl -u "$GEKY_BOT_STATUSES" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
40+
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
41+
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
42+
| capture(\"code size is (?<size>[0-9]+)\").size" \
43+
|| echo 0)
44+
45+
STATUS="Passed, code size is ${CURR}B"
46+
if [ "$PREV" -ne 0 ]
47+
then
48+
STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
49+
fi
50+
fi
51+
52+
# CI matrix
53+
jobs:
54+
include:
55+
# native testing
56+
- stage: test
57+
env:
58+
- STAGE=test
59+
- NAME=littlefs-x86
60+
61+
# cross-compile with ARM (thumb mode)
62+
- stage: test
63+
env:
64+
- STAGE=test
65+
- NAME=littlefs-arm
66+
- CC="arm-linux-gnueabi-gcc --static -mthumb"
67+
- EXEC="qemu-arm"
68+
install:
69+
- sudo apt-get install gcc-arm-linux-gnueabi qemu-user
70+
- arm-linux-gnueabi-gcc --version
71+
- qemu-arm -version
72+
73+
# cross-compile with PowerPC
74+
- stage: test
75+
env:
76+
- STAGE=test
77+
- NAME=littlefs-powerpc
78+
- CC="powerpc-linux-gnu-gcc --static"
79+
- EXEC="qemu-ppc"
80+
install:
81+
- sudo apt-get install gcc-powerpc-linux-gnu qemu-user
82+
- powerpc-linux-gnu-gcc --version
83+
- qemu-ppc -version
84+
85+
# cross-compile with MIPS
86+
- stage: test
87+
env:
88+
- STAGE=test
89+
- NAME=littlefs-mips
90+
- CC="mips-linux-gnu-gcc --static"
91+
- EXEC="qemu-mips"
92+
install:
93+
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
94+
- sudo apt-get -qq update
95+
- sudo apt-get install gcc-mips-linux-gnu qemu-user
96+
- mips-linux-gnu-gcc --version
97+
- qemu-mips -version
98+
99+
# self-host with littlefs-fuse for fuzz test
100+
- stage: test
101+
env:
102+
- STAGE=test
103+
- NAME=littlefs-fuse
104+
if: branch !~ -prefix$
105+
install:
106+
- sudo apt-get install libfuse-dev
107+
- git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha
108+
- fusermount -V
109+
- gcc --version
110+
before_script:
111+
# setup disk for littlefs-fuse
112+
- rm -rf littlefs-fuse/littlefs/*
113+
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
114+
115+
- mkdir mount
116+
- sudo chmod a+rw /dev/loop0
117+
- dd if=/dev/zero bs=512 count=4096 of=disk
118+
- losetup /dev/loop0 disk
119+
script:
120+
# self-host test
121+
- make -C littlefs-fuse
122+
123+
- littlefs-fuse/lfs --format /dev/loop0
124+
- littlefs-fuse/lfs /dev/loop0 mount
125+
126+
- ls mount
127+
- mkdir mount/littlefs
128+
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
129+
- cd mount/littlefs
130+
- stat .
131+
- ls -flh
132+
- make -B test_dirs test_files QUIET=1
133+
134+
# self-host with littlefs-fuse for fuzz test
135+
- stage: test
136+
env:
137+
- STAGE=test
138+
- NAME=littlefs-migration
139+
if: branch !~ -prefix$
140+
install:
141+
- sudo apt-get install libfuse-dev
142+
- git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha v2
143+
- git clone --depth 1 https://github.com/geky/littlefs-fuse -b v1 v1
144+
- fusermount -V
145+
- gcc --version
146+
before_script:
147+
# setup disk for littlefs-fuse
148+
- rm -rf v2/littlefs/*
149+
- cp -r $(git ls-tree --name-only HEAD) v2/littlefs
150+
151+
- mkdir mount
152+
- sudo chmod a+rw /dev/loop0
153+
- dd if=/dev/zero bs=512 count=4096 of=disk
154+
- losetup /dev/loop0 disk
155+
script:
156+
# compile v1 and v2
157+
- make -C v1
158+
- make -C v2
159+
160+
# run self-host test with v1
161+
- v1/lfs --format /dev/loop0
162+
- v1/lfs /dev/loop0 mount
163+
164+
- ls mount
165+
- mkdir mount/littlefs
166+
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
167+
- cd mount/littlefs
168+
- stat .
169+
- ls -flh
170+
- make -B test_dirs test_files QUIET=1
171+
172+
# attempt to migrate
173+
- cd ../..
174+
- fusermount -u mount
175+
176+
- v2/lfs --migrate /dev/loop0
177+
- v2/lfs /dev/loop0 mount
178+
179+
# run self-host test with v2 right where we left off
180+
- ls mount
181+
- cd mount/littlefs
182+
- stat .
183+
- ls -flh
184+
- make -B test_dirs test_files QUIET=1
185+
186+
# Automatically create releases
187+
- stage: deploy
188+
env:
189+
- STAGE=deploy
190+
- NAME=deploy
191+
script:
192+
- |
193+
bash << 'SCRIPT'
194+
set -ev
195+
# Find version defined in lfs.h
196+
LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
197+
LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
198+
LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
199+
# Grab latests patch from repo tags, default to 0, needs finagling
200+
# to get past github's pagination api
201+
PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
202+
PREV_URL=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I \
203+
| sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1' \
204+
|| echo $PREV_URL)
205+
LFS_VERSION_PATCH=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" \
206+
| jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
207+
.captures[].string | tonumber) | max + 1' \
208+
|| echo 0)
209+
# We have our new version
210+
LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
211+
echo "VERSION $LFS_VERSION"
212+
# Check that we're the most recent commit
213+
CURRENT_COMMIT=$(curl -f -u "$GEKY_BOT_RELEASES" \
214+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/commits/master \
215+
| jq -re '.sha')
216+
[ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ] || exit 0
217+
# Create major branch
218+
git branch v$LFS_VERSION_MAJOR HEAD
219+
# Create major prefix branch
220+
git config user.name "geky bot"
221+
git config user.email "bot@geky.net"
222+
git fetch https://github.com/$TRAVIS_REPO_SLUG.git \
223+
--depth=50 v$LFS_VERSION_MAJOR-prefix || true
224+
./scripts/prefix.py lfs$LFS_VERSION_MAJOR
225+
git branch v$LFS_VERSION_MAJOR-prefix $( \
226+
git commit-tree $(git write-tree) \
227+
$(git rev-parse --verify -q FETCH_HEAD | sed -e 's/^/-p /') \
228+
-p HEAD \
229+
-m "Generated v$LFS_VERSION_MAJOR prefixes")
230+
git reset --hard
231+
# Update major version branches (vN and vN-prefix)
232+
git push https://$GEKY_BOT_RELEASES@github.com/$TRAVIS_REPO_SLUG.git \
233+
v$LFS_VERSION_MAJOR \
234+
v$LFS_VERSION_MAJOR-prefix
235+
# Create patch version tag (vN.N.N)
236+
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
237+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
238+
-d "{
239+
\"ref\": \"refs/tags/$LFS_VERSION\",
240+
\"sha\": \"$TRAVIS_COMMIT\"
241+
}"
242+
# Create minor release?
243+
[[ "$LFS_VERSION" == *.0 ]] || exit 0
244+
# Build release notes
245+
PREV=$(git tag --sort=-v:refname -l "v*.0" | head -1)
246+
if [ ! -z "$PREV" ]
247+
then
248+
echo "PREV $PREV"
249+
CHANGES=$'### Changes\n\n'$( \
250+
git log --oneline $PREV.. --grep='^Merge' --invert-grep)
251+
printf "CHANGES\n%s\n\n" "$CHANGES"
252+
fi
253+
# Create the release
254+
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
255+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
256+
-d "{
257+
\"tag_name\": \"$LFS_VERSION\",
258+
\"name\": \"${LFS_VERSION%.0}\",
259+
\"draft\": true,
260+
\"body\": $(jq -sR '.' <<< "$CHANGES")
261+
}" #"
262+
SCRIPT
263+
264+
# Manage statuses
265+
before_install:
266+
- |
267+
curl -u "$GEKY_BOT_STATUSES" -X POST \
268+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
269+
-d "{
270+
\"context\": \"$STAGE/$NAME\",
271+
\"state\": \"pending\",
272+
\"description\": \"${STATUS:-In progress}\",
273+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
274+
}"
275+
276+
after_failure:
277+
- |
278+
curl -u "$GEKY_BOT_STATUSES" -X POST \
279+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
280+
-d "{
281+
\"context\": \"$STAGE/$NAME\",
282+
\"state\": \"failure\",
283+
\"description\": \"${STATUS:-Failed}\",
284+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
285+
}"
286+
287+
after_success:
288+
- |
289+
curl -u "$GEKY_BOT_STATUSES" -X POST \
290+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
291+
-d "{
292+
\"context\": \"$STAGE/$NAME\",
293+
\"state\": \"success\",
294+
\"description\": \"${STATUS:-Passed}\",
295+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
296+
}"
297+
298+
# Job control
299+
stages:
300+
- name: test
301+
- name: deploy
302+
if: branch = master AND type = push

0 commit comments

Comments
 (0)