On 6/4/19 4:05 AM, Gene Cumm via Syslinux wrote:> On Sat, May 25, 2019 at 8:33 AM Johann Obermayr via Syslinux > <syslinux at syslinux.org> wrote: >> >> Hello, >> >> Is there a function to check a bzImage CRC ? >> >> If (ImageCRC("/bzImage") == -1) >> Load_kernel("/BACKUP/bzImage") or what else >> >> Thanks >> >> Regards >> Johann > > It doesn't appear so. I'm assuming you're referring to the CRC32 > present in Linux x86 boot protocol 2.08+ found in Linux versions > 2.6.26+ ? libupload has a CRC-16 function. zlib has a CRC-32 > function but looks like it's initialized with different > polynomial/remainder. >Writing a generic CRC generator is not very hard; for a boot loader it makes sense to compute the tables at runtime anyway, so it isn't a hard thing to do. However, the CRC polynomial for zlib and the Linux kernel should both be the same: 0x04c11db7. -hpa
On 6/7/19 10:19 PM, H. Peter Anvin via Syslinux wrote:>> >> It doesn't appear so. I'm assuming you're referring to the CRC32 >> present in Linux x86 boot protocol 2.08+ found in Linux versions >> 2.6.26+ ? libupload has a CRC-16 function. zlib has a CRC-32 >> function but looks like it's initialized with different >> polynomial/remainder. >> > > Writing a generic CRC generator is not very hard; for a boot loader it makes > sense to compute the tables at runtime anyway, so it isn't a hard thing to do. > > However, the CRC polynomial for zlib and the Linux kernel should both be the > same: 0x04c11db7. >I just double-checked, and the CRC tables are indeed identical. I was pretty sure, because I wrote that code a long time ago... -hpa
On 6/7/19 10:25 PM, H. Peter Anvin via Syslinux wrote:>> >> However, the CRC polynomial for zlib and the Linux kernel should both be the >> same: 0x04c11db7. > > I just double-checked, and the CRC tables are indeed identical. I was pretty > sure, because I wrote that code a long time ago... >Ah, it seems that zlib's CRC32 returns the binary inverse of the CRC32 (i.e. crc32 ^ 0xffffffff); so unless the Linux code is broken (and the spec needs to be corrected, since that error would go back many years) using the zlib code one would have to look for 0xffffffff == UINT32_MAX instead of 0. -hpa