Skip to content

Commit 9d86edf

Browse files
committed
Fix automount on Linux
1 parent b4da16a commit 9d86edf

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

usb_msc/fat_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ static struct fat_filesystem FILESYSTEM = {
77
.boot_sec = {
88
.jmp_cmd = {0xEB, 0x3C, 0x90},
99
.oem_name = {0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30}, // OEM name
10-
.bytes_per_sector = {LE_U16_TO_2U8(DISK_CLUSTER_SIZE)},
10+
.bytes_per_sector = {LE_U16_TO_2U8(DISK_SECTOR_SIZE)},
1111
.sectors_per_cluster = DISK_SECTOR_PER_CLUSTER,
1212
.reserved_sectors = {LE_U16_TO_2U8(0x01)},
1313
.num_fat = NUM_FAT,
1414
.max_root_dir_entries = {LE_U16_TO_2U8(NUM_ROOT_DIR_ENTRIES)},
15-
.total_sectors = {LE_U16_TO_2U8(0xFFFF)},
15+
.total_sectors = {LE_U16_TO_2U8(DISK_REPORT_SECTOR_NUM)},
1616
.media_descriptor = 0xF8,
1717
.sectors_per_fat = {LE_U16_TO_2U8(DISK_SECTOR_PER_FAT)},
1818
.bios_drive_number = 0x80,

usb_msc/fat_util.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313

1414
enum
1515
{
16+
DISK_FULL_SIZE = 32*1024*1024,
1617
DISK_REAL_CLUSTER_NUM = 0x10,
17-
DISK_REPORT_SECTOR_NUM = 0xFFFF,
18-
DISK_SECTOR_PER_CLUSTER = 1, // 0x04
19-
DISK_SECTOR_SIZE = 4096, // 512 // sector size
18+
DISK_SECTOR_PER_CLUSTER = 4, // 0x04
19+
DISK_SECTOR_SIZE = 1024, // 512 // sector size
2020
DISK_CLUSTER_SIZE = DISK_SECTOR_SIZE * DISK_SECTOR_PER_CLUSTER,
21-
DISK_SECTOR_PER_FAT = 0x04, //0x40,
21+
DISK_SECTOR_PER_FAT = (2 * DISK_FULL_SIZE) / (DISK_CLUSTER_SIZE * DISK_SECTOR_SIZE), //0x40,
2222
NUM_FAT = 1,
2323
DISK_REAL_SECTOR_NUM = (1 + NUM_FAT * DISK_SECTOR_PER_FAT + 1 + (DISK_REAL_CLUSTER_NUM * DISK_SECTOR_PER_CLUSTER)),
2424
DISK_BLOCK_NUM = DISK_SECTOR_SIZE + (DISK_SECTOR_PER_FAT * DISK_SECTOR_SIZE) + (DISK_SECTOR_SIZE) + (DISK_SECTOR_SIZE * DISK_SECTOR_PER_CLUSTER * DISK_REAL_CLUSTER_NUM),
2525
NUM_ROOT_DIR_ENTRIES = DISK_SECTOR_SIZE / 32,
26+
DISK_REPORT_SECTOR_NUM = (DISK_FULL_SIZE / DISK_SECTOR_SIZE) + 1 + NUM_FAT * DISK_SECTOR_PER_FAT + 1,
2627
};
2728

2829
#define FAT_NAME_SZ 8

usb_msc/msc_disk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ uint32_t BITSTREAM_CRC32 = 0;
145145

146146
uint32_t BLOCK_COUNTER = 0;
147147

148+
// uint8_t LAST_SECTOR[DISK_CLUSTER_SIZE];
149+
148150
uint32_t flash_calc_crc32(uint32_t addr)
149151
{
150152
spi_flash_read(addr, TEST_RD_BUF, 256);

0 commit comments

Comments
 (0)