Skip to content

Commit 581081a

Browse files
author
James Buren
committed
mi4: replace chksum_crc32 with crc_32r
This uses an equivalent algorithm but with a different initial value than we normally use (all bits off vs all bits on). Use the new crc_32r to replace the original MI4 crc32 implementation. This frees up some extra space on mi4 targets which gives us more room on a few very space constrained targets (sansa c200/e200, etc). Change-Id: Iaaac3ae353b30566156b1404cbf31ca32926203d
1 parent fc92081 commit 581081a

File tree

8 files changed

+6
-147
lines changed

8 files changed

+6
-147
lines changed

bootloader/fat32format.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "storage.h"
4545
#include "button.h"
4646
#include "disk.h"
47-
#include "crc32-mi4.h"
4847
#include <string.h>
4948
#include "i2c.h"
5049
#include "backlight-target.h"

bootloader/main-e200r-installer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "file.h"
3636
#include "button.h"
3737
#include "disk.h"
38-
#include "crc32-mi4.h"
38+
#include "crc32.h"
3939
#include <string.h>
4040
#include "i2c.h"
4141
#include "backlight-target.h"
@@ -138,7 +138,7 @@ void* main(void)
138138

139139
storage_read_sectors(pinfo.start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK,
140140
1 , sector);
141-
crc32 = chksum_crc32 (sector, 512);
141+
crc32 = crc_32r (sector, 512, 0);
142142

143143
#if 0 /* not needed in release builds */
144144
printf("--- Hack Status ---");

bootloader/main-pp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "adc.h"
3838
#include "button.h"
3939
#include "disk.h"
40-
#include "crc32-mi4.h"
40+
#include "crc32.h"
4141
#include "mi4-loader.h"
4242
#include "loader_strerror.h"
4343
#include <string.h>
@@ -169,7 +169,7 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo,
169169
(mi4header.mi4size-MI4_HEADER_SIZE)/512, buf);
170170

171171
/* Check CRC32 to see if we have a valid file */
172-
sum = chksum_crc32 (buf,mi4header.mi4size-MI4_HEADER_SIZE);
172+
sum = crc_32r (buf,mi4header.mi4size-MI4_HEADER_SIZE,0);
173173

174174
printf("Calculated CRC32: %x", sum);
175175

firmware/SOURCES

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ common/crc32.c
242242
#ifdef MODEL_NUMBER
243243
common/loader_strerror.c
244244
#endif
245-
#ifdef MI4_FORMAT
246-
common/crc32-mi4.c
247-
#endif
248245
#ifdef RKW_FORMAT
249246
common/crc32-rkw.c
250247
#endif

firmware/common/crc32-mi4.c

Lines changed: 0 additions & 110 deletions
This file was deleted.

firmware/include/crc32-mi4.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

firmware/rolo.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
#include "loader_strerror.h"
4242
#if defined(MI4_FORMAT)
43-
#include "crc32-mi4.h"
4443
#include "mi4-loader.h"
4544
#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR)
4645
#include "bootdata.h"

firmware/target/arm/pp/mi4-loader.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
#include "config.h"
2828
#include "mi4-loader.h"
2929
#include "loader_strerror.h"
30-
#include "crc32-mi4.h"
30+
#include "crc32.h"
3131
#include "file.h"
3232
#if defined(HAVE_BOOTDATA)
3333
#include "system.h"
3434
#include "bootdata.h"
35-
#include "crc32.h"
3635

3736
/* Write bootdata into location in FIRMWARE marked by magic header
3837
* Assumes buffer is already loaded with the firmware image
@@ -293,7 +292,7 @@ static int load_mi4_filename(unsigned char* buf,
293292
return EREAD_IMAGE_FAILED;
294293

295294
/* Check CRC32 to see if we have a valid file */
296-
sum = chksum_crc32 (buf, mi4header.mi4size - MI4_HEADER_SIZE);
295+
sum = crc_32r (buf, mi4header.mi4size - MI4_HEADER_SIZE, 0);
297296

298297
if(sum != mi4header.crc32)
299298
return EBAD_CHKSUM;

0 commit comments

Comments
 (0)