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
This commit is contained in:
James Buren 2021-06-21 09:36:54 +00:00
parent fc92081080
commit 581081a3df
8 changed files with 6 additions and 147 deletions

View file

@ -44,7 +44,6 @@
#include "storage.h"
#include "button.h"
#include "disk.h"
#include "crc32-mi4.h"
#include <string.h>
#include "i2c.h"
#include "backlight-target.h"

View file

@ -35,7 +35,7 @@
#include "file.h"
#include "button.h"
#include "disk.h"
#include "crc32-mi4.h"
#include "crc32.h"
#include <string.h>
#include "i2c.h"
#include "backlight-target.h"
@ -138,7 +138,7 @@ void* main(void)
storage_read_sectors(pinfo.start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK,
1 , sector);
crc32 = chksum_crc32 (sector, 512);
crc32 = crc_32r (sector, 512, 0);
#if 0 /* not needed in release builds */
printf("--- Hack Status ---");

View file

@ -37,7 +37,7 @@
#include "adc.h"
#include "button.h"
#include "disk.h"
#include "crc32-mi4.h"
#include "crc32.h"
#include "mi4-loader.h"
#include "loader_strerror.h"
#include <string.h>
@ -169,7 +169,7 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo,
(mi4header.mi4size-MI4_HEADER_SIZE)/512, buf);
/* Check CRC32 to see if we have a valid file */
sum = chksum_crc32 (buf,mi4header.mi4size-MI4_HEADER_SIZE);
sum = crc_32r (buf,mi4header.mi4size-MI4_HEADER_SIZE,0);
printf("Calculated CRC32: %x", sum);