X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/blobdiff_plain/90ff396e7d83b2ae713535226633feea6ed604da..refs/heads/testing:/updater/updater.c diff --git a/updater/updater.c b/updater/updater.c index f61b345..479df80 100644 --- a/updater/updater.c +++ b/updater/updater.c @@ -271,15 +271,38 @@ size_t mypgm_WRITEpage(const mypgm_addr_t byteaddress,const void* buffer, const } #endif +#if defined(UPDATECRC32) +#include "crccheck.c" +#endif + // #pragma GCC diagnostic ignored "-Wno-pointer-to-int-cast" int main(void) { +#if defined(UPDATECRC32) + uint32_t crcval; +#endif size_t i; uint8_t buffer[SPM_PAGESIZE]; wdt_disable(); cli(); +#if defined(UPDATECRC32) + // check if new firmware-image is corrupted + crcval = D_32; + for (i=0;i 65535) + crcval = update_crc_32(crcval, pgm_read_byte_far(FULLCORRECTFLASHADDRESS(&new_firmware[i]))); +#else + crcval = update_crc_32(crcval, pgm_read_byte(FULLCORRECTFLASHADDRESS(&new_firmware[i]))); +#endif + } + crcval ^= D_32; + + // allow to change the firmware + if (crcval == ((uint32_t)UPDATECRC32)) { +#endif + // check if firmware would change... buffer[0]=0; for (i=0;i