Skip to content

Commit 70aa179

Browse files
authored
Merge pull request #16 from ARMmbed/v2.2-alpha
Bring in v2.2
2 parents 19da65b + c9a6b88 commit 70aa179

Some content is hidden

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

59 files changed

+14957
-5792
lines changed

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ script:
1818

1919
# Run littlefs functional tests with different configurations
2020
# Note: r/w size of 64 is default in mbed
21-
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=64 -DLFS_PROG_SIZE=64"
22-
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1"
23-
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512"
24-
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023"
25-
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS_LOOKAHEAD=2048"
21+
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS2_READ_SIZE=64 -DLFS2_CACHE_SIZE=64"
22+
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS2_READ_SIZE=1 -DLFS2_CACHE_SIZE=1"
23+
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS2_READ_SIZE=512 -DLFS2_CACHE_SIZE=512 -DLFS2_BLOCK_CYCLES=16"
24+
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS2_READ_SIZE=8 -DLFS2_CACHE_SIZE=16 -DLFS2_BLOCK_CYCLES=2"
25+
- make -Clittlefs test QUIET=1 CFLAGS+="-DLFS2_BLOCK_COUNT=1023 -DLFS2_LOOKAHEAD_SIZE=256"
2626

2727
install:
2828
# Get arm-none-eabi-gcc
@@ -33,7 +33,8 @@ install:
3333
- git clone https://github.com/armmbed/mbed-os.git
3434
# Install python dependencies
3535
- pip install -r mbed-os/requirements.txt
36+
- sudo apt-get install python3 python3-pip
37+
- sudo pip3 install toml
3638
# Check versions
3739
- arm-none-eabi-gcc --version
38-
- python --version
3940
- gcc --version

LittleFileSystem2.cpp

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ namespace mbed {
2424

2525
extern "C" uint32_t lfs2_crc(uint32_t crc, const void *buffer, size_t size)
2626
{
27-
uint32_t initial_xor = crc;
28-
MbedCRC<POLY_32BIT_REV_ANSI, 32> ct(initial_xor, 0x0, true, false);
27+
uint32_t initial_xor = lfs2_rbit(crc);
28+
MbedCRC<POLY_32BIT_ANSI, 32, CrcMode::TABLE> ct(initial_xor, 0x0, true, true);
29+
2930
ct.compute((void *)buffer, size, &crc);
3031
return crc;
3132
}
@@ -166,12 +167,10 @@ LittleFileSystem2::~LittleFileSystem2()
166167
int LittleFileSystem2::mount(BlockDevice *bd)
167168
{
168169
_mutex.lock();
169-
LFS2_INFO("mount(%p)", bd);
170170
_bd = bd;
171171
int err = _bd->init();
172172
if (err) {
173173
_bd = NULL;
174-
LFS2_INFO("mount -> %d", err);
175174
_mutex.unlock();
176175
return err;
177176
}
@@ -192,20 +191,17 @@ int LittleFileSystem2::mount(BlockDevice *bd)
192191
err = lfs2_mount(&_lfs, &_config);
193192
if (err) {
194193
_bd = NULL;
195-
LFS2_INFO("mount -> %d", lfs2_toerror(err));
196194
_mutex.unlock();
197195
return lfs2_toerror(err);
198196
}
199197

200198
_mutex.unlock();
201-
LFS2_INFO("mount -> %d", 0);
202199
return 0;
203200
}
204201

205202
int LittleFileSystem2::unmount()
206203
{
207204
_mutex.lock();
208-
LFS2_INFO("unmount(%s)", "");
209205
int res = 0;
210206
if (_bd) {
211207
int err = lfs2_unmount(&_lfs);
@@ -221,7 +217,6 @@ int LittleFileSystem2::unmount()
221217
_bd = NULL;
222218
}
223219

224-
LFS2_INFO("unmount -> %d", res);
225220
_mutex.unlock();
226221
return res;
227222
}
@@ -230,11 +225,8 @@ int LittleFileSystem2::format(BlockDevice *bd,
230225
lfs2_size_t block_size, uint32_t block_cycles,
231226
lfs2_size_t cache_size, lfs2_size_t lookahead_size)
232227
{
233-
LFS2_INFO("format(%p, %ld, %ld, %ld, %ld)",
234-
bd, block_size, block_cycles, cache_size, lookahead_size);
235228
int err = bd->init();
236229
if (err) {
237-
LFS2_INFO("format -> %d", err);
238230
return err;
239231
}
240232

@@ -257,39 +249,33 @@ int LittleFileSystem2::format(BlockDevice *bd,
257249

258250
err = lfs2_format(&_lfs, &_config);
259251
if (err) {
260-
LFS2_INFO("format -> %d", lfs2_toerror(err));
261252
return lfs2_toerror(err);
262253
}
263254

264255
err = bd->deinit();
265256
if (err) {
266-
LFS2_INFO("format -> %d", err);
267257
return err;
268258
}
269259

270-
LFS2_INFO("format -> %d", 0);
271260
return 0;
272261
}
273262

274263
int LittleFileSystem2::reformat(BlockDevice *bd)
275264
{
276265
_mutex.lock();
277-
LFS2_INFO("reformat(%p)", bd);
278266
if (_bd) {
279267
if (!bd) {
280268
bd = _bd;
281269
}
282270

283271
int err = unmount();
284272
if (err) {
285-
LFS2_INFO("reformat -> %d", err);
286273
_mutex.unlock();
287274
return err;
288275
}
289276
}
290277

291278
if (!bd) {
292-
LFS2_INFO("reformat -> %d", -ENODEV);
293279
_mutex.unlock();
294280
return -ENODEV;
295281
}
@@ -300,49 +286,40 @@ int LittleFileSystem2::reformat(BlockDevice *bd)
300286
_config.cache_size,
301287
_config.lookahead_size);
302288
if (err) {
303-
LFS2_INFO("reformat -> %d", err);
304289
_mutex.unlock();
305290
return err;
306291
}
307292

308293
err = mount(bd);
309294
if (err) {
310-
LFS2_INFO("reformat -> %d", err);
311295
_mutex.unlock();
312296
return err;
313297
}
314298

315-
LFS2_INFO("reformat -> %d", 0);
316299
_mutex.unlock();
317300
return 0;
318301
}
319302

320303
int LittleFileSystem2::remove(const char *filename)
321304
{
322305
_mutex.lock();
323-
LFS2_INFO("remove(\"%s\")", filename);
324306
int err = lfs2_remove(&_lfs, filename);
325-
LFS2_INFO("remove -> %d", lfs2_toerror(err));
326307
_mutex.unlock();
327308
return lfs2_toerror(err);
328309
}
329310

330311
int LittleFileSystem2::rename(const char *oldname, const char *newname)
331312
{
332313
_mutex.lock();
333-
LFS2_INFO("rename(\"%s\", \"%s\")", oldname, newname);
334314
int err = lfs2_rename(&_lfs, oldname, newname);
335-
LFS2_INFO("rename -> %d", lfs2_toerror(err));
336315
_mutex.unlock();
337316
return lfs2_toerror(err);
338317
}
339318

340319
int LittleFileSystem2::mkdir(const char *name, mode_t mode)
341320
{
342321
_mutex.lock();
343-
LFS2_INFO("mkdir(\"%s\", 0x%lx)", name, mode);
344322
int err = lfs2_mkdir(&_lfs, name);
345-
LFS2_INFO("mkdir -> %d", lfs2_toerror(err));
346323
_mutex.unlock();
347324
return lfs2_toerror(err);
348325
}
@@ -351,9 +328,7 @@ int LittleFileSystem2::stat(const char *name, struct stat *st)
351328
{
352329
struct lfs2_info info;
353330
_mutex.lock();
354-
LFS2_INFO("stat(\"%s\", %p)", name, st);
355331
int err = lfs2_stat(&_lfs, name, &info);
356-
LFS2_INFO("stat -> %d", lfs2_toerror(err));
357332
_mutex.unlock();
358333
st->st_size = info.size;
359334
st->st_mode = lfs2_tomode(info.type);
@@ -366,9 +341,7 @@ int LittleFileSystem2::statvfs(const char *name, struct statvfs *st)
366341

367342
lfs2_ssize_t in_use = 0;
368343
_mutex.lock();
369-
LFS2_INFO("statvfs(\"%s\", %p)", name, st);
370344
in_use = lfs2_fs_size(&_lfs);
371-
LFS2_INFO("statvfs -> %d", lfs2_toerror(in_use));
372345
_mutex.unlock();
373346
if (in_use < 0) {
374347
return in_use;
@@ -388,9 +361,7 @@ int LittleFileSystem2::file_open(fs_file_t *file, const char *path, int flags)
388361
{
389362
lfs2_file_t *f = new lfs2_file_t;
390363
_mutex.lock();
391-
LFS2_INFO("file_open(%p, \"%s\", 0x%x)", *file, path, flags);
392364
int err = lfs2_file_open(&_lfs, f, path, lfs2_fromflags(flags));
393-
LFS2_INFO("file_open -> %d", lfs2_toerror(err));
394365
_mutex.unlock();
395366
if (!err) {
396367
*file = f;
@@ -404,9 +375,7 @@ int LittleFileSystem2::file_close(fs_file_t file)
404375
{
405376
lfs2_file_t *f = (lfs2_file_t *)file;
406377
_mutex.lock();
407-
LFS2_INFO("file_close(%p)", file);
408378
int err = lfs2_file_close(&_lfs, f);
409-
LFS2_INFO("file_close -> %d", lfs2_toerror(err));
410379
_mutex.unlock();
411380
delete f;
412381
return lfs2_toerror(err);
@@ -416,9 +385,7 @@ ssize_t LittleFileSystem2::file_read(fs_file_t file, void *buffer, size_t len)
416385
{
417386
lfs2_file_t *f = (lfs2_file_t *)file;
418387
_mutex.lock();
419-
LFS2_INFO("file_read(%p, %p, %d)", file, buffer, len);
420388
lfs2_ssize_t res = lfs2_file_read(&_lfs, f, buffer, len);
421-
LFS2_INFO("file_read -> %d", lfs2_toerror(res));
422389
_mutex.unlock();
423390
return lfs2_toerror(res);
424391
}
@@ -427,9 +394,7 @@ ssize_t LittleFileSystem2::file_write(fs_file_t file, const void *buffer, size_t
427394
{
428395
lfs2_file_t *f = (lfs2_file_t *)file;
429396
_mutex.lock();
430-
LFS2_INFO("file_write(%p, %p, %d)", file, buffer, len);
431397
lfs2_ssize_t res = lfs2_file_write(&_lfs, f, buffer, len);
432-
LFS2_INFO("file_write -> %d", lfs2_toerror(res));
433398
_mutex.unlock();
434399
return lfs2_toerror(res);
435400
}
@@ -438,9 +403,7 @@ int LittleFileSystem2::file_sync(fs_file_t file)
438403
{
439404
lfs2_file_t *f = (lfs2_file_t *)file;
440405
_mutex.lock();
441-
LFS2_INFO("file_sync(%p)", file);
442406
int err = lfs2_file_sync(&_lfs, f);
443-
LFS2_INFO("file_sync -> %d", lfs2_toerror(err));
444407
_mutex.unlock();
445408
return lfs2_toerror(err);
446409
}
@@ -449,9 +412,7 @@ off_t LittleFileSystem2::file_seek(fs_file_t file, off_t offset, int whence)
449412
{
450413
lfs2_file_t *f = (lfs2_file_t *)file;
451414
_mutex.lock();
452-
LFS2_INFO("file_seek(%p, %ld, %d)", file, offset, whence);
453415
off_t res = lfs2_file_seek(&_lfs, f, offset, lfs2_fromwhence(whence));
454-
LFS2_INFO("file_seek -> %d", lfs2_toerror(res));
455416
_mutex.unlock();
456417
return lfs2_toerror(res);
457418
}
@@ -460,9 +421,7 @@ off_t LittleFileSystem2::file_tell(fs_file_t file)
460421
{
461422
lfs2_file_t *f = (lfs2_file_t *)file;
462423
_mutex.lock();
463-
LFS2_INFO("file_tell(%p)", file);
464424
off_t res = lfs2_file_tell(&_lfs, f);
465-
LFS2_INFO("file_tell -> %d", lfs2_toerror(res));
466425
_mutex.unlock();
467426
return lfs2_toerror(res);
468427
}
@@ -471,9 +430,7 @@ off_t LittleFileSystem2::file_size(fs_file_t file)
471430
{
472431
lfs2_file_t *f = (lfs2_file_t *)file;
473432
_mutex.lock();
474-
LFS2_INFO("file_size(%p)", file);
475433
off_t res = lfs2_file_size(&_lfs, f);
476-
LFS2_INFO("file_size -> %d", lfs2_toerror(res));
477434
_mutex.unlock();
478435
return lfs2_toerror(res);
479436
}
@@ -482,9 +439,7 @@ int LittleFileSystem2::file_truncate(fs_file_t file, off_t length)
482439
{
483440
lfs2_file_t *f = (lfs2_file_t *)file;
484441
_mutex.lock();
485-
LFS2_INFO("file_truncate(%p)", file);
486442
int err = lfs2_file_truncate(&_lfs, f, length);
487-
LFS2_INFO("file_truncate -> %d", lfs2_toerror(err));
488443
_mutex.unlock();
489444
return lfs2_toerror(err);
490445
}
@@ -495,9 +450,7 @@ int LittleFileSystem2::dir_open(fs_dir_t *dir, const char *path)
495450
{
496451
lfs2_dir_t *d = new lfs2_dir_t;
497452
_mutex.lock();
498-
LFS2_INFO("dir_open(%p, \"%s\")", *dir, path);
499453
int err = lfs2_dir_open(&_lfs, d, path);
500-
LFS2_INFO("dir_open -> %d", lfs2_toerror(err));
501454
_mutex.unlock();
502455
if (!err) {
503456
*dir = d;
@@ -511,9 +464,7 @@ int LittleFileSystem2::dir_close(fs_dir_t dir)
511464
{
512465
lfs2_dir_t *d = (lfs2_dir_t *)dir;
513466
_mutex.lock();
514-
LFS2_INFO("dir_close(%p)", dir);
515467
int err = lfs2_dir_close(&_lfs, d);
516-
LFS2_INFO("dir_close -> %d", lfs2_toerror(err));
517468
_mutex.unlock();
518469
delete d;
519470
return lfs2_toerror(err);
@@ -524,9 +475,7 @@ ssize_t LittleFileSystem2::dir_read(fs_dir_t dir, struct dirent *ent)
524475
lfs2_dir_t *d = (lfs2_dir_t *)dir;
525476
struct lfs2_info info;
526477
_mutex.lock();
527-
LFS2_INFO("dir_read(%p, %p)", dir, ent);
528478
int res = lfs2_dir_read(&_lfs, d, &info);
529-
LFS2_INFO("dir_read -> %d", lfs2_toerror(res));
530479
_mutex.unlock();
531480
if (res == 1) {
532481
ent->d_type = lfs2_totype(info.type);
@@ -539,19 +488,15 @@ void LittleFileSystem2::dir_seek(fs_dir_t dir, off_t offset)
539488
{
540489
lfs2_dir_t *d = (lfs2_dir_t *)dir;
541490
_mutex.lock();
542-
LFS2_INFO("dir_seek(%p, %ld)", dir, offset);
543491
lfs2_dir_seek(&_lfs, d, offset);
544-
LFS2_INFO("dir_seek -> %s", "void");
545492
_mutex.unlock();
546493
}
547494

548495
off_t LittleFileSystem2::dir_tell(fs_dir_t dir)
549496
{
550497
lfs2_dir_t *d = (lfs2_dir_t *)dir;
551498
_mutex.lock();
552-
LFS2_INFO("dir_tell(%p)", dir);
553499
lfs2_soff_t res = lfs2_dir_tell(&_lfs, d);
554-
LFS2_INFO("dir_tell -> %d", lfs2_toerror(res));
555500
_mutex.unlock();
556501
return lfs2_toerror(res);
557502
}
@@ -560,9 +505,7 @@ void LittleFileSystem2::dir_rewind(fs_dir_t dir)
560505
{
561506
lfs2_dir_t *d = (lfs2_dir_t *)dir;
562507
_mutex.lock();
563-
LFS2_INFO("dir_rewind(%p)", dir);
564508
lfs2_dir_rewind(&_lfs, d);
565-
LFS2_INFO("dir_rewind -> %s", "void");
566509
_mutex.unlock();
567510
}
568511

littlefs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
blocks/
88
lfs2
99
test.c
10+
tests/*.toml.*
11+
scripts/__pycache__
12+
.gdb_history

0 commit comments

Comments
 (0)