0

I'm working on an embedded linux project using PetaLinux and running on kernel 5.4.0-xilinx-v2020.1. We have multiple apps that needs to write their ~200 bytes config in a file every second for years at a time so we chose to include an 8kB FRAM on the board. The number of apps running isn't fixed, nor is the size of the data each will need to write so a filesystem seems like the easiest, user-friendliest and most transparent solution.

I've found the littlefs-fuse project and I've tested it on my workstation with a 8k loop device, everything is working as expected.

I'm currently in the integration phase and I'm having some issues creating the littlefs filesystem on the FRAM, here's how I'm hoping things would work:

  1. The FRAM is setup in the device-tree as a 24c64-eeprom-compatible i2c device
  2. Linux loads the at24 as expected and create the /sys/bus/i2c/devices/x-xxxx/ folder
  3. I can read and write using bash commands to the /sys/bus/i2c/devices/x-xxxx/eeprom file
  4. I create a loop device using the eeprom file
  5. I use the littlefs-fuse project to create my file system and mount it

I'm currently stuck at the end of part 4, I created a loop device with the eeprom file using losetup -fP /sys/bus/i2c/devices/x-xxxx/eeprom and it works fine without any error but I can't access any data on it.

Here's the error message I get when I try to cat the file

# cat /dev/loop0
cat: read error: Input/output error

And here's what I can find with dmesg concerning the error:

[11950.780699] print_req_error: 5 callbacks suppressed
[11950.780706] blk_update_request: I/O error, dev loop0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 2 prio class 0
[11950.795985] blk_update_request: I/O error, dev loop0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[11950.805985] buffer_io_error: 3 callbacks suppressed
[11950.805990] Buffer I/O error on dev loop0, logical block 0, async page read
[11950.817854] blk_update_request: I/O error, dev loop0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[11950.827846] Buffer I/O error on dev loop0, logical block 0, async page read

It's completly possible I'm try to fit a square peg in a round hole here but as far as I know, any file is supposed to work with a loop device so I'm confused as to why it's not working as I expect

Tzig
  • 726
  • 5
  • 20
  • 1
    8k == 8192 __bits__ or __bytes__? Even for the later it's a bit too small for any filesystem to begin with. To the loop device issue I believe that it tries IOCTLs for __block__ device, while *eeprom* is basically a __char-like__ device in this sense. – 0andriy Jul 06 '21 at 15:10
  • 8k bytes, sorry for the confusion, I agree it's on the small side but I've validated that littlefs works fine on a 8kbyte device. As for the block vs char device, isn't the point of the loop driver to create block device using plain files? Are "plain files" different from "char device file" to the kernel even though they act exactly the same from user-space? – Tzig Jul 06 '21 at 16:03
  • Regular file access is covered by VFS. NVMEM subsystem does not have IOCTLs: https://www.kernel.org/doc/html/latest/driver-api/nvmem.html#userspace-binary-interface. And in the code via https://elixir.bootlin.com/linux/latest/source/drivers/nvmem/core.c#L313 (of sysfs): https://elixir.bootlin.com/linux/latest/source/fs/sysfs/file.c#L245. – 0andriy Jul 06 '21 at 16:52
  • I have got it, you need something in user space that will parse *littlefs* directly from the file that has only `read()`/`write()` capabilities. – 0andriy Jul 06 '21 at 17:02
  • Something that will parse a filesystem? I'm sorry I don't know anything about it and I can't find any resources on it, do you have a link about this? – Tzig Jul 07 '21 at 09:59
  • You already provided a link to source code, now you need to take that library and write the code which will use a file instead of any other layer. There is also a python code, it may be helpful as well. – 0andriy Jul 07 '21 at 12:01

0 Answers0