Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot reliably mount emulated storage under Linux #980

Open
JakubVanek opened this issue Mar 15, 2020 · 6 comments
Open

Cannot reliably mount emulated storage under Linux #980

JakubVanek opened this issue Mar 15, 2020 · 6 comments

Comments

@JakubVanek
Copy link

Describe the bug
Linux-based OSes cannot reliably mount the emulated FAT32 volume. The underlying block device is accessible, but the FAT32 format cannot be parsed without errors.

To Reproduce

  1. Boot Xubuntu 18.04.4 Live USB
  2. Plug in EV3 with firmware 1.10E
  3. Open the device in Thunar/File browser
  4. Run dmesg in terminal

Expected behavior
Kernel mounts the filesystem successfully and is able to read and write files on it without errors.

Screenshots
dmesg on PC:

[46037.916480] usb 1-9: new high-speed USB device number 59 using xhci_hcd
[46038.104311] usb 1-9: New USB device found, idVendor=0694, idProduct=0005, bcdDevice= 2.16
[46038.104315] usb 1-9: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[46038.104317] usb 1-9: Product: EV3
[46038.104319] usb 1-9: Manufacturer: LEGO Group
[46038.104320] usb 1-9: SerialNumber: 00165344cf21
[46038.149724] hid-generic 0003:0694:0005.002E: hiddev1,hidraw0: USB HID v1.10 Device [LEGO Group EV3] on usb-0000:00:14.0-9/input0
[46038.157223] usb-storage 1-9:1.1: USB Mass Storage device detected
[46038.157599] scsi host6: usb-storage 1-9:1.1
[46049.321161] scsi 6:0:0:0: Direct-Access     Linux    File-CD Gadget   0316 PQ: 0 ANSI: 2
[46049.321848] sd 6:0:0:0: Attached scsi generic sg2 type 0
[46049.322918] sd 6:0:0:0: Power-on or device reset occurred
[46049.323847] sd 6:0:0:0: [sdb] 65000 512-byte logical blocks: (33.3 MB/31.7 MiB)
[46049.324376] sd 6:0:0:0: [sdb] Write Protect is off
[46049.324383] sd 6:0:0:0: [sdb] Mode Sense: 0f 00 00 00
[46049.324989] sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[46049.350182]  sdb:
[46049.353691] sd 6:0:0:0: [sdb] Attached SCSI removable disk
[46056.286985] FAT-fs (sdb): error, corrupted directory (invalid entries)
[46056.286989] FAT-fs (sdb): Filesystem has been set read-only
[46088.069243] FAT-fs (sdb): error, fat_get_cluster: invalid cluster chain (i_pos 0)

If needed, I can scrape the kernel dmesg from the brick as well (via telnet).

Desktop (please complete the following information):

  • OS: Xubuntu 18.04.4
  • Version 5.3.0-40-generic #32~18.04.1-Ubuntu

Additional context
I can force the kernel into ignoring the errors. After that, the files can be listed and application upload succeeds, but it is not a very good experience.

$ sudo mount -t vfat -o rw,errors=continue /dev/sdb /mnt
$ LC_ALL=C ls
ls: cannot access 'projects': Input/output error
dmesg.txt  index.htm  info_uf2.txt  projects
$ sudo cp lego-Untitled.uf2 /mnt/
$ sync

However I cannot access the projects directory at all, the result is always an I/O error. On Windows, I can browser the Projects directory and the UF2 files show up.

@JakubVanek
Copy link
Author

Snapshot of the raw contents of the emulated USB drive: ev3fs.zip

@JakubVanek
Copy link
Author

This seems to be a problem with the Projects folder only. If I remove all files from the BrkProg_SAVE directory, the folder disappears and there are no more errors while mounting.

@JakubVanek
Copy link
Author

The issue can be reproduced with https://github.com/microsoft/uf2-linux/, so it is not specific to EV3.
With the following directory map, the same errors occur via NBD.

struct DirMap dirMaps[] = { //
    {"Uf2Dir", "/home/kuba/uf2", F_UF2},
    {NULL, NULL, 0}};

@luukp
Copy link

luukp commented Jun 29, 2021

I am also having this issue. Possibly the documentation should be updated to state that drag and drop isn't supported on Linux? I'm assuming that this will affect chromebooks as well, which kind of seems like the primary use case.

As this is likely to be a bug with the EV3 firmware, rather than a problem with makecode itself, should it be raised with Lego to be resolved?

@erwroth
Copy link

erwroth commented Jul 17, 2021

Same problem here on a Raspberry Pi 400 with Raspbian GNU/Linux 10.Would be great for teaching if this problem could be fixed soon!

Doing a fsck file system-check after rebooting the EV3 shows the following:

root@raspberrypi:/# fsck.fat  /dev/sda
fsck.fat 4.1 (2017-01-24)
0x25: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
1) Remove dirty bit
2) No action
? 1
/EV3
  Contains a free cluster (782). Assuming EOF.
/dmesg.txt
  File size is 131072 bytes, cluster chain length is > 131072 bytes.
  Truncating file to 131072 bytes.
/Projects
  "." is missing. Can't fix this yet.
/Projects
  ".." is missing. Can't fix this yet.

@tentator
Copy link

tentator commented Dec 28, 2021

same here :(

lots of kernel: FAT-fs errors, first this:

    error, corrupted directory (invalid entries)  
    Filesystem has been set read-only

and then lots of these at each access:

    error, fat_get_cluster: invalid cluster chain (i_pos 0)

but it seems I cannot see the drive in windows as well and do not see the ev3 in the firmware upgrade tool anymore (otherwise I'd try to downgrade it for instance)..

I also found this alternative explanation/root cause so far: https://serverfault.com/questions/331779/how-do-i-debug-this-fs-error-on-a-flash-device

anyone has some progress on this?

fengguang pushed a commit to 0day-ci/linux that referenced this issue Feb 4, 2022
This reverts commit a3082d5.

The reverted commit adds check for FAT images. However, the tools used
for creating images for the Lego Mindstrom EV3 are not adding '.' and
'..' entry in the 'Projects' directory.
Without this fix, the kernel can not fill the inode structure for
'Projects' directory.

See microsoft/pxt-ev3#980
And microsoft/uf2-linux#6

With the patch reverted, we can mount an image copied from the EV3

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
joelagnel pushed a commit to joelagnel/linux-kernel that referenced this issue Jun 19, 2022
This reverts commit a3082d5.

The reverted commit adds check for FAT images. However, the tools used
for creating images for the Lego Mindstrom EV3 are not adding '.' and
'..' entry in the 'Projects' directory.
Without this fix, the kernel can not fill the inode structure for
'Projects' directory.

See microsoft/pxt-ev3#980
And microsoft/uf2-linux#6

With the patch reverted, we can mount an image copied from the EV3

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
(am from https://lore.kernel.org/r/20220204062232.3410036-1-gwendal@chromium.org)

BUG=b:205899437
TEST=With the patch reverted, we can mount an image copied from
the EV3

Change-Id: I731be37a6305e4d5378ac4d31817adcbd43e9c62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3430762
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Daniil Lunev <dlunev@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
(cherry picked from commit f67697eb16412d5a1b5a633b619e129425afcec0)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3498707
joelagnel pushed a commit to joelagnel/linux-kernel that referenced this issue Aug 9, 2022
This reverts commit a3082d5.

The reverted commit adds check for FAT images. However, the tools used
for creating images for the Lego Mindstrom EV3 are not adding '.' and
'..' entry in the 'Projects' directory.
Without this fix, the kernel can not fill the inode structure for
'Projects' directory.

See microsoft/pxt-ev3#980
And microsoft/uf2-linux#6

With the patch reverted, we can mount an image copied from the EV3

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
(am from https://lore.kernel.org/r/20220204062232.3410036-1-gwendal@chromium.org)

BUG=b:205899437
TEST=With the patch reverted, we can mount an image copied from
the EV3

Change-Id: I731be37a6305e4d5378ac4d31817adcbd43e9c62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3430762
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Daniil Lunev <dlunev@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
(cherry picked from commit f67697eb16412d5a1b5a633b619e129425afcec0)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3498707
disantkumar pushed a commit to disantkumar/intel-mainline-tracking that referenced this issue Oct 16, 2023
This reverts commit a3082d5.

The reverted commit adds check for FAT images. However, the tools used
for creating images for the Lego Mindstrom EV3 are not adding '.' and
'..' entry in the 'Projects' directory.
Without this fix, the kernel can not fill the inode structure for
'Projects' directory.

See microsoft/pxt-ev3#980
And microsoft/uf2-linux#6

With the patch reverted, we can mount an image copied from the EV3

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
(am from https://lore.kernel.org/r/20220204062232.3410036-1-gwendal@chromium.org)

BUG=b:205899437
TEST=With the patch reverted, we can mount an image copied from
the EV3

Change-Id: I731be37a6305e4d5378ac4d31817adcbd43e9c62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3430762
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Daniil Lunev <dlunev@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
(cherry picked from commit f67697eb16412d5a1b5a633b619e129425afcec0)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3498707
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants