diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-07-06 10:45:42 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-07-06 10:45:42 -0700 |
| commit | 0c4b273f24d9d4291770a20d392ba3275e29e518 (patch) | |
| tree | e56c15fda072f38c3de8d3bd2ea2419fc96c924f /lib | |
| parent | 32cad8c0f8ee14f2c656bb908becb94d0b910451 (diff) | |
atmel-samd: Give the on board flash filesystem a unique volume ID. This is useful for identifying filesystem mounts and matching them up to hardware.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/fatfs/ff.c | 7 | ||||
| -rw-r--r-- | lib/fatfs/ff.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/fatfs/ff.c b/lib/fatfs/ff.c index 68c529a28..f4a7c7d8f 100644 --- a/lib/fatfs/ff.c +++ b/lib/fatfs/ff.c @@ -4054,7 +4054,8 @@ FRESULT f_forward ( FRESULT f_mkfs (
const TCHAR* path, /* Logical drive number */
BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */
- UINT au /* Size of allocation unit in unit of byte or sector */
+ UINT au, /* Size of allocation unit in unit of byte or sector */
+ DWORD volume_id
)
{
static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0};
@@ -4218,7 +4219,7 @@ FRESULT f_mkfs ( ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */
n = GET_FATTIME(); /* Use current time as VSN */
if (fmt == FS_FAT32) {
- ST_DWORD(tbl + BS_VolID32, n); /* VSN */
+ ST_DWORD(tbl + BS_VolID32, volume_id); /* VSN */
ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */
ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */
ST_WORD(tbl + BPB_FSInfo, 1); /* FSINFO record offset (VBR + 1) */
@@ -4227,7 +4228,7 @@ FRESULT f_mkfs ( tbl[BS_BootSig32] = 0x29; /* Extended boot signature */
mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */
} else {
- ST_DWORD(tbl + BS_VolID, n); /* VSN */
+ ST_DWORD(tbl + BS_VolID, volume_id); /* VSN */
ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */
tbl[BS_DrvNum] = 0x80; /* Drive number */
tbl[BS_BootSig] = 0x29; /* Extended boot signature */
diff --git a/lib/fatfs/ff.h b/lib/fatfs/ff.h index 31d58b442..21f01188c 100644 --- a/lib/fatfs/ff.h +++ b/lib/fatfs/ff.h @@ -236,7 +236,7 @@ FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get numbe FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
-FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
+FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au, DWORD volume_id); /* Create a file system on the volume */
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
