Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2fb2ef5

Browse filesBrowse files
committed
Calculate properly Firmware MSC fat table sectors
1 parent 7a7bd37 commit 2fb2ef5
Copy full SHA for 2fb2ef5

File tree

2 files changed

+4
-3
lines changed
Filter options

2 files changed

+4
-3
lines changed

‎cores/esp32/FirmwareMSC.cpp

Copy file name to clipboardExpand all lines: cores/esp32/FirmwareMSC.cpp
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static size_t msc_update_get_required_disk_sectors(){
113113
log_d("USING FAT12");
114114
mcs_is_fat16 = false;
115115
}
116+
log_d("FAT sector size: %u", DISK_SECTOR_SIZE);
116117
log_d("FAT data sectors: %u", data_sectors);
117118
log_d("FAT table sectors: %u", msc_table_sectors);
118119
log_d("FAT total sectors: %u (%uKB)", total_sectors, (total_sectors * DISK_SECTOR_SIZE) / 1024);

‎cores/esp32/firmware_msc_fat.c

Copy file name to clipboardExpand all lines: cores/esp32/firmware_msc_fat.c
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static const char * FAT12_FILE_SYSTEM_TYPE = "FAT12";
3939

4040
static uint16_t fat12_sectors_per_alloc_table(uint32_t sector_num){
4141
uint32_t required_bytes = (((sector_num * 3)+1)/2);
42-
return (required_bytes / DISK_SECTOR_SIZE) + ((required_bytes & DISK_SECTOR_SIZE)?1:0);
42+
return (required_bytes / DISK_SECTOR_SIZE) + ((required_bytes & (DISK_SECTOR_SIZE - 1))?1:0);
4343
}
4444

4545
static uint8_t * fat12_add_table(uint8_t * dst, fat_boot_sector_t * boot){
@@ -68,7 +68,7 @@ static const char * FAT16_FILE_SYSTEM_TYPE = "FAT16";
6868

6969
static uint16_t fat16_sectors_per_alloc_table(uint32_t sector_num){
7070
uint32_t required_bytes = sector_num * 2;
71-
return (required_bytes / DISK_SECTOR_SIZE) + ((required_bytes & DISK_SECTOR_SIZE)?1:0);
71+
return (required_bytes / DISK_SECTOR_SIZE) + ((required_bytes & (DISK_SECTOR_SIZE - 1))?1:0);
7272
}
7373

7474
static uint8_t * fat16_add_table(uint8_t * dst, fat_boot_sector_t * boot){
@@ -129,7 +129,7 @@ fat_boot_sector_t * fat_add_boot_sector(uint8_t * dst, uint16_t sector_num, uint
129129
boot->num_heads = 1;
130130
boot->hidden_sectors_count = 0;
131131
boot->total_sectors_32 = 0;
132-
boot->physical_drive_number = 0x00;
132+
boot->physical_drive_number = 0x80;
133133
boot->reserved0 = 0x00;
134134
boot->extended_boot_signature = 0x29;
135135
boot->serial_number = serial_number;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.