GithubHelp home page GithubHelp logo

Comments (6)

JakubVanek avatar JakubVanek commented on May 13, 2024

I think I have finally found it. Comparing the dumped file to the description on Wikipedia, there are multiple problems:

  1. Volume label directory entry (EV3) does not have cluster number set to zero.
  2. The cluster corresponding to the Projects directory table has the next cluster == 0x0000 (FREE), instead it should be 0xFFFF (EOF). (however see below, this may be caused by Linux).
  3. Linux requires a directory table to have at least two directory entries (https://github.com/torvalds/linux/blob/aeb542a1b5c507ea117d21c3e3e012ba16f065ac/fs/fat/inode.c#L497), which is not fulfilled there. The directory table contains only the DEMO.UF2 directory entry, which is not enough. There should be also the . and .. directories present. I think this may cause the issue above - when Linux detects this, it sets the next cluster pointer to zero.
  4. The dmesg.txt file has 512 blocks allocated in the FAT, but its directory entry lists it as only 256 blocks long.

from uf2-linux.

JakubVanek avatar JakubVanek commented on May 13, 2024

Fixing just (2) and (3) in the dumped image is enough to make the drive mountable without problems. The solution is to add valid . and .. directory entries to the Projects directory table.
dirents

from uf2-linux.

JakubVanek avatar JakubVanek commented on May 13, 2024

Problem no. 4 found:

c->numclusters = (c->st.st_size + 255) / 256;
(I think this should be 511/512).

EDIT: I am likely wrong with this, as it seems that the block size is supposed to be 256 bytes for passthrough files:

uf2-linux/uf2daemon/fat.c

Lines 334 to 337 in c003d65

if (c->flags & F_RAW)
c->numclusters = (c->st.st_size + 511) / 512;
else
c->numclusters = (c->st.st_size + 255) / 256;

from uf2-linux.

JakubVanek avatar JakubVanek commented on May 13, 2024

Problem no. 1 maybe spotted:

It would seem to me that startCluster is what can be seen in the generated directory entry. Currently, it is set to the "current cluster", not to 0x0000.

It seems that UF2Daemon generates this correctly, but as soon as the Linux kernel mounts the FS, it sets the FAT entries to zero.

from uf2-linux.

lfrie avatar lfrie commented on May 13, 2024

when is this fixed? i have the same issue

from uf2-linux.

JakubVanek avatar JakubVanek commented on May 13, 2024

I'm sorry but I currently don't have much time to work on this. Also, fixing this here would fix the problem only for new releases of uf2d (which is the first step though); it would then have to be fixed with a firmware update for the problematic device (if your device is not fully under your control like with Raspberry Pi).

from uf2-linux.

Related Issues (7)

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.