has 16 small 4k sectors and two big 32k sectors).
--> Need to change parts definition format.
-Prevent unwanted writting of Code Read Protection values.
-
Add the definition of all LPC parts ?
#ifndef ISP_UTILS_H
#define ISP_UTILS_H
+
+/* ---- CRP Protection values ---------------------------------------------------*/
+#define CRP_OFFSET 0x000002FC
+#define CRP_NO_ISP 0x4E697370
+#define CRP_CRP1 0x12345678
+#define CRP_CRP2 0x87654321
+#define CRP_CRP3 0x43218765
+
+
void isp_dump(const unsigned char* buf, unsigned int buf_size);
uint32_t uuencode = part->uuencode;
uint32_t* v = NULL; /* Used for checksum computing */
uint32_t cksum = 0;
+ uint32_t crp = 0;
/** Sanity checks *********************************/
/* RAM buffer address within RAM */
}
printf("Checksum check OK\n");
+ crp = v[(CRP_OFFSET / 4)];
+ if ((crp == CRP_NO_ISP) || (crp == CRP_CRP1) || (crp == CRP_CRP2) || (crp == CRP_CRP3)) {
+ printf("CRP : 0x%08x\n", crp);
+ printf("The binary has CRP protection ativated, which violates GPLv3.\n");
+ printf("Check the licence for the software you are using, and if this is allowed,\n");
+ printf(" then modify this software to allow flashing of code with CRP protection\n");
+ printf(" activated. (Or use another software).\n");
+ return -6;
+ }
+
blocks = (size / write_size) + ((size % write_size) ? 1 : 0);
/* Gonna write out of flash ? */
if ((blocks * write_size) > part->flash_size) {
printf("Flash size : %d, trying to flash %d blocks of %d bytes : %d\n",
part->flash_size, blocks, write_size, (blocks * write_size));
free(data);
- return -6;
+ return -7;
}
printf("Flash size : %d, trying to flash %d blocks of %d bytes : %d\n",
part->flash_size, blocks, write_size, (blocks * write_size));