|
2 | 2 |
|
3 | 3 | [](https://github.com/tinygo-org/tinyfs/actions/workflows/build.yml) |
4 | 4 |
|
5 | | -TinyFS contains Go implementations of embedded filesystems. The packages in |
| 5 | +TinyFS contains Go implementations of embedded filesystems. The packages in |
6 | 6 | this module require CGo support and are [TinyGo](https://tinygo.org/) compatible. |
| 7 | + |
| 8 | +## Supported hardware |
| 9 | + |
| 10 | +You can use TinyFS with the following embedded hardware configurations: |
| 11 | + |
| 12 | +### Onboard Flash memory |
| 13 | + |
| 14 | +You can use TinyFS on processors that have onboard Flash memory in the area above where the compiled TinyGo program is running. |
| 15 | + |
| 16 | +### External Flash memory |
| 17 | + |
| 18 | +You can use TinyFS on an external Flash memory chip connected via SPI/QSPI hardware interface. |
| 19 | + |
| 20 | +See https://github.com/tinygo-org/drivers/tree/release/flash |
| 21 | + |
| 22 | +### SD card connected via SPI/QPI |
| 23 | + |
| 24 | +You can use TinyFS on an SD card connected via SPI/QSPI hardware interface. |
| 25 | + |
| 26 | +See https://github.com/tinygo-org/drivers/tree/release/sdcard |
| 27 | + |
| 28 | +## LittleFS |
| 29 | + |
| 30 | +The LittleFS file system is specifically designed for embedded applications. |
| 31 | + |
| 32 | +See https://github.com/littlefs-project/littlefs for more information. |
| 33 | + |
| 34 | +### Example |
| 35 | + |
| 36 | +This example runs on the RP2040 using the on-board flash in the available memory above where the program code itself is running: |
| 37 | + |
| 38 | +``` |
| 39 | +$ tinygo flash -target pico -monitor ./examples/console/littlefs/machine/ |
| 40 | +Connected to /dev/ttyACM0. Press Ctrl-C to exit. |
| 41 | +SPI Configured. Reading flash info |
| 42 | +==> lsblk |
| 43 | +
|
| 44 | +------------------------------------- |
| 45 | + Device Information: |
| 46 | +------------------------------------- |
| 47 | + flash data start: 10017000 |
| 48 | + flash data end: 10200000 |
| 49 | +------------------------------------- |
| 50 | +
|
| 51 | +==> format |
| 52 | +Successfully formatted LittleFS filesystem. |
| 53 | +
|
| 54 | +==> mount |
| 55 | +Successfully mounted LittleFS filesystem. |
| 56 | +
|
| 57 | +==> ls |
| 58 | +==> samples |
| 59 | +wrote 90 bytes to file0.txt |
| 60 | +wrote 90 bytes to file1.txt |
| 61 | +wrote 90 bytes to file2.txt |
| 62 | +wrote 90 bytes to file3.txt |
| 63 | +wrote 90 bytes to file4.txt |
| 64 | +==> ls |
| 65 | +-rwxrwxrwx 90 file0.txt |
| 66 | +-rwxrwxrwx 90 file1.txt |
| 67 | +-rwxrwxrwx 90 file2.txt |
| 68 | +-rwxrwxrwx 90 file3.txt |
| 69 | +-rwxrwxrwx 90 file4.txt |
| 70 | +==> cat file3.txt |
| 71 | +00000000: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !"#$%&'()*+,-./ |
| 72 | +00000010: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 0123456789:;<=>? |
| 73 | +00000020: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO |
| 74 | +00000030: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f PQRSTUVWXYZ[\]^_ |
| 75 | +00000040: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f `abcdefghijklmno |
| 76 | +00000050: 70 71 72 73 74 75 76 77 78 79 pqrstuvwxy |
| 77 | +``` |
| 78 | + |
| 79 | +After unplugging and reconnecting the RP2040 device (a hard restart): |
| 80 | + |
| 81 | +``` |
| 82 | +$ tinygo monitor |
| 83 | +Connected to /dev/ttyACM0. Press Ctrl-C to exit. |
| 84 | +SPI Configured. Reading flash info |
| 85 | +==> mount |
| 86 | +Successfully mounted LittleFS filesystem. |
| 87 | +
|
| 88 | +==> ls |
| 89 | +-rwxrwxrwx 90 file0.txt |
| 90 | +-rwxrwxrwx 90 file1.txt |
| 91 | +-rwxrwxrwx 90 file2.txt |
| 92 | +-rwxrwxrwx 90 file3.txt |
| 93 | +-rwxrwxrwx 90 file4.txt |
| 94 | +==> cat file3.txt |
| 95 | +00000000: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !"#$%&'()*+,-./ |
| 96 | +00000010: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 0123456789:;<=>? |
| 97 | +00000020: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO |
| 98 | +00000030: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f PQRSTUVWXYZ[\]^_ |
| 99 | +00000040: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f `abcdefghijklmno |
| 100 | +00000050: 70 71 72 73 74 75 76 77 78 79 pqrstuvwxy |
| 101 | +``` |
| 102 | + |
| 103 | +## FAT FS |
| 104 | + |
| 105 | +The FAT file system is not currently working, due to https://github.com/tinygo-org/tinygo/issues/3460. |
| 106 | + |
0 commit comments