Code Monkey home page Code Monkey logo

tinyfs's Introduction

TinyFS

Build

TinyFS contains Go implementations of embedded filesystems. The packages in this module require CGo support and are TinyGo compatible.

Supported hardware

You can use TinyFS with the following embedded hardware configurations:

Onboard Flash memory

You can use TinyFS on processors that have onboard Flash memory in the area above where the compiled TinyGo program is running.

External Flash memory

You can use TinyFS on an external Flash memory chip connected via SPI/QSPI hardware interface.

See https://github.com/tinygo-org/drivers/tree/release/flash

SD card connected via SPI/QPI

You can use TinyFS on an SD card connected via SPI/QSPI hardware interface.

See https://github.com/tinygo-org/drivers/tree/release/sdcard

LittleFS

The LittleFS file system is specifically designed for embedded applications.

See https://github.com/littlefs-project/littlefs for more information.

Example

This example runs on the RP2040 using the on-board flash in the available memory above where the program code itself is running:

$ tinygo flash -target pico -monitor ./examples/console/littlefs/machine/
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
SPI Configured. Reading flash info
==> lsblk

-------------------------------------
 Device Information:  
-------------------------------------
 flash data start: 10017000
 flash data end:  10200000
-------------------------------------

==> format
Successfully formatted LittleFS filesystem.

==> mount
Successfully mounted LittleFS filesystem.

==> ls
==> samples
wrote 90 bytes to file0.txt
wrote 90 bytes to file1.txt
wrote 90 bytes to file2.txt
wrote 90 bytes to file3.txt
wrote 90 bytes to file4.txt
==> ls
-rwxrwxrwx    90 file0.txt
-rwxrwxrwx    90 file1.txt
-rwxrwxrwx    90 file2.txt
-rwxrwxrwx    90 file3.txt
-rwxrwxrwx    90 file4.txt
==> cat file3.txt
00000000: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f     !"#$%&'()*+,-./
00000010: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f    0123456789:;<=>?
00000020: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f    @ABCDEFGHIJKLMNO
00000030: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f    PQRSTUVWXYZ[\]^_
00000040: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f    `abcdefghijklmno
00000050: 70 71 72 73 74 75 76 77 78 79                      pqrstuvwxy

After unplugging and reconnecting the RP2040 device (a hard restart):

$ tinygo monitor
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
SPI Configured. Reading flash info
==> mount
Successfully mounted LittleFS filesystem.

==> ls
-rwxrwxrwx    90 file0.txt
-rwxrwxrwx    90 file1.txt
-rwxrwxrwx    90 file2.txt
-rwxrwxrwx    90 file3.txt
-rwxrwxrwx    90 file4.txt
==> cat file3.txt
00000000: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f     !"#$%&'()*+,-./
00000010: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f    0123456789:;<=>?
00000020: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f    @ABCDEFGHIJKLMNO
00000030: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f    PQRSTUVWXYZ[\]^_
00000040: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f    `abcdefghijklmno
00000050: 70 71 72 73 74 75 76 77 78 79                      pqrstuvwxy

FAT FS

The FAT file system is not currently working, due to tinygo-org/tinygo#3460.

tinyfs's People

Contributors

bgould avatar deadprogram avatar sago35 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tinyfs's Issues

What if there is a problem with the import path?

What if there is a problem with the import path?
Can I just rewrite all the imports in the code to github.com/tinygo-org/tinyfs?

$ go mod tidy
go: finding module for package github.com/tinygo-org/tinyfs/fatfs
go: finding module for package github.com/tinygo-org/tinyfs
go: found github.com/tinygo-org/tinyfs/fatfs in github.com/tinygo-org/tinyfs v0.0.0-20200908023903-7edd7c8b7150
go: found github.com/tinygo-org/tinyfs in github.com/tinygo-org/tinyfs v0.0.0-20200908023903-7edd7c8b7150
go: tinygo.org/x/drivers/examples/sdcard/tinyfs imports
        github.com/tinygo-org/tinyfs/fatfs: github.com/tinygo-org/[email protected]: parsing go.mod:
        module declares its path as: github.com/bgould/tinyfs
                but was required as: github.com/tinygo-org/tinyfs

littlefs disk version 2.1

Currently the littelfs implemention provided by tinyfs is built for littlefs disk version 2.0.
See here: https://github.com/tinygo-org/tinyfs/blob/release/littlefs/lfs.h#L31

The latest version though is disk version 2.1: https://github.com/littlefs-project/littlefs/blob/master/lfs.h#L31

This leads to the problem that devices are only mountable with extra hurdles on a desktop machine.
To be precise, one needs to build https://github.com/littlefs-project/littlefs-fuse/tree/v2.0.0 . Newer versions seem to be problematic.

The goal would be to update the vendor-ed version here.

The fuse driver just refuses to work:

littlefs/lfs.c:4323:debug: Found older minor version v2.0 < v2.1
littlefs/lfs.c:4369:error: Invalid block count (62520320 != 62521344)
lfs_fuse.c:514:error: Invalid argument

Looking at the code, it seems the C files from https://github.com/littlefs-project/littlefs were copied one-to-one. Maybe
updating them would be enough?

Not able to build console/fatfs/spi example

I was just trying to run the following, and ran into a build problem:

$ tinygo flash -target pyportal ./examples/console/fatfs/spi/                                                          
# github.com/tinygo-org/tinyfs/fatfs                                                                                   
fatfs/go_fatfs.go:163:11: ModeDir not declared by package os

@sago35 do you know anything to get around this?

FatFS not working

The FatFS is not working correctly, apparently ever since tinygo-org/tinygo#3460

$ tinygo flash -target nano-rp2040 -stack-size 8kb -monitor ./examples/console/fatfs/machine/
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
SPI Configured. Reading flash info
==> lsblk

-------------------------------------
 Device Information:  
-------------------------------------
 flash data start: 10026000
 flash data end:  11000000
-------------------------------------

==> mount
Could not mount filesystem: fatfs: (13) There is no valid FAT volume

==> format
Successfully formatted filesystem.

==> mount
Could not mount filesystem: fatfs: (13) There is no valid FAT volume

Change import path to tinygo.org/x/tinyfs

The sdcard example from the drivers repository references tinyfs using the import path github.com/tinygo-org/tinyfs - https://github.com/tinygo-org/drivers/blob/24dfd8795aba54ae489b140cd7e467db8233e0d9/examples/sdcard/tinyfs/main.go#L8 - since that example has not made it into a release yet, it might be a good time to make the naming of the import consistent.

I propose that prior to the next release of the drivers, the import path of this repository should be updated to be tinygo.org/x/tinyfs`, and an initial release tag should be created and referenced from the drivers repository. I'm not sure what needs to be done in order to make that import path work, I assume there is some edit to the tinygo.org site that may be necessary.

@deadprogram what is your opinion about this?

align tinyfs with Go 1.16+ io/fs package

Go 1.16 adds a new package io/fs with interfaces that function as an abstraction layer for filesystems. The analogous interfaces in TinyGo/tinyfs are very close to the ones in the io/fs package, so we should implement those "natively" where possible, at least for Go 1.16 users.

It may be worth considering to require Go 1.16 for using tinyfs going forward so that we can avoid cluttering up the codebase with build tags, etc., to account for the missing io/fs package for Go 1.15 and below.

not able to run simple-fatfs

Unable to build simple-fatfs example here.

panic: runtime error: type assert failed

What is the minimal example to simply:
1)write "hello world" to a Pico's flash using TinyGo
2)read the string from flash and print to the terminal

This is essential for any persistence if we are to use TinyGo.

Needs implementation of `Seek()` added to tinyfs.File

I need to add the io.Seeker interface to tinyfs.File so I can read some data directly from littlefs storage instead of copying into memory first for some code that has to backtrack in the processing of the file.

I noticed that the littlefs implementation does support Seek() but since the fatfs implementation does not, it is not part of that interface.

So, seems like the options are to either try to add to the current fatfs implementation, or to try swapping to @soypat pure go fatfs?

I really need this quickly so any feedback and/or help I can get will be appreciated! ๐Ÿ˜ธ

tinyfs issues on Adafruit Gran Central M4 board

I'm testing the tinyfs on an Adafruit Gran Central M4 board, but the changes are not stored on the SPI Flash device.

I'm using the QSPI example

Device is detected JEDEC ID: C84017, and the default file systems works properly

==> ls
drwxrwxrwx     0 .fseventsd
-rwxrwxrwx     0 .metadata_never_index
-rwxrwxrwx     0 .Trashes
-rwxrwxrwx   102 boot_out.txt

but "samples", mkdir, create does not create the expected items.

format works removing all the default files

All the details are attached on the console capture tiosync-20221016T181113.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.