summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
index 71e8342595..737ee36e00 100644
--- a/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
@@ -147,9 +147,17 @@ void usb_drv_int_enable(bool enable)
147void usb_fix_mbr(unsigned char *mbr) 147void usb_fix_mbr(unsigned char *mbr)
148{ 148{
149 unsigned char* p = mbr + 0x1be; 149 unsigned char* p = mbr + 0x1be;
150 char tmp[16];
151 150
152 /* The Gigabeat S factory partition table contains invalid values for the 151 /* Windows ignores the partition flags and mounts the first partition it
152 sees when the device reports itself as removable. Swap the partitions
153 so the data partition appears to be partition 0. Mark the boot
154 partition 0 as hidden and make it partition 1.
155
156 Update 2018-01-14: Windows shows it if exists, so long as it can mount
157 it. Resort to not exposing entries that we want hidden.
158 */
159
160 /* The Gigabeat S factory partition table contains invalid values for the
153 "active" flag in the MBR. This prevents at least the Linux kernel 161 "active" flag in the MBR. This prevents at least the Linux kernel
154 from accepting the partition table, so we fix it on-the-fly. */ 162 from accepting the partition table, so we fix it on-the-fly. */
155 p[0x00] &= 0x80; 163 p[0x00] &= 0x80;
@@ -158,18 +166,12 @@ void usb_fix_mbr(unsigned char *mbr)
158 p[0x30] &= 0x80; 166 p[0x30] &= 0x80;
159 167
160 if (bootloader_install_mode) 168 if (bootloader_install_mode)
161 return; 169 {
162 170 memset(&p[0x10], 0x00, 0x30); /* Hide non-boot partitions */
163 /* Windows ignores the partition flags and mounts the first partition it 171 }
164 sees when the device reports itself as removable. Swap the partitions 172 else
165 so the data partition appears to be partition 0. Mark the boot 173 {
166 partition 0 as hidden and make it partition 1. */ 174 memmove(&p[0x00], &p[0x10], 0x30); /* Hide boot partition */
167 175 memset(&p[0x30], 0x00, 0x10);
168 /* Mark the first partition as hidden */ 176 }
169 p[0x04] |= 0x10;
170
171 /* Swap first and second partitions */
172 memcpy(tmp, &p[0x00], 16);
173 memcpy(&p[0x00], &p[0x10], 16);
174 memcpy(&p[0x10], tmp, 16);
175} 177}