Closed acheronfail closed 5 months ago
I got it somewhat working using this:
function makeFileSystem(ff: FatFsTypes.FatFs) {
const work = ff.malloc(FatFs.FF_MAX_SS);
const fmt = (FatFs.FM_SFD | FatFs.FM_ANY) & 0xff;
const n_fat = (1 & 0xff) << 8;
const align = (0 & 0xffff) << 16;
const n_root = (0 & 0xffff) << 32;
const au_size = (0 & 0xffffffff) << 48;
const flags = ff.malloc(8);
console.log(fmt | n_fat | align | n_root | au_size);
ff.setValue(flags, fmt | n_fat | align | n_root | au_size, "*");
ff.f_mkfs("", flags, work, FatFs.FF_MAX_SS);
ff.free(work);
}
In v0.2.0, f_mkfs()
accepts opt
parameter of type MkfsParams, like this:
const ff = await FatFs.create({ ... });
const opts = { fmt: FatFs.FM_FAT, n_fat: 1, align: 0, n_root: 0, au_size: 4096 };
ff.f_mkfs('', opts, work, FatFs.FF_MAX_SS);
Absolutely phenomenal work @irori thank you so much!
I'm trying to use
f_mkfs
as documented here: http://elm-chan.org/fsw/ff/doc/mkfs.htmlI need to set some specific options with
MKFS_PARM
(namely thefmt
,n_fat
andau_size
fields). As far as I can tell,fs-fatfs
doesn't expose theMKFS_PARM
struct? It does expose thef_mkfs
function though.