fix: disable cache

This commit is contained in:
2024-12-14 14:16:25 +06:00
parent a0072d3d3a
commit 8f5085862a
5 changed files with 27 additions and 66 deletions

View File

@@ -46,7 +46,7 @@ int __attribute__((section(".vectors"))) main(void) {
/* clear block protection */
FLASH_SetStatusBits(0x1c, 0);
printf("[FLASH] Block protection cleared\n");
// uint32_t erase_sector_addr = 0;
Cache_Enable(0);
while (1) {
FLASH_CONTROL->start = 0;
@@ -82,13 +82,6 @@ int __attribute__((section(".vectors"))) main(void) {
for (uint32_t offset = 0; offset < FLASH_CONTROL->len; offset += 4) {
uint32_t write_addr = FLASH_CONTROL->offset + offset;
uint32_t sector_addr1 = write_addr & 0xFFFFF000;
// if (sector_addr1 >=
// erase_sector_addr) { // relate to rtl8710_flasher_auto_erase
// FLASH_Erase(2, sector_addr1);
// erase_sector_addr =
// sector_addr1 + 0x1000; // next sector we should erase
// }
FLASH_TxData12B(write_addr, 4,
(uint8_t *)&FLASH_CONTROL->data[offset]);
}
@@ -97,10 +90,10 @@ int __attribute__((section(".vectors"))) main(void) {
break;
case CMD_VERIFY: {
uint8_t tbuf[4];
printf("Verify: FLASH_CONTROL->data = %p\n", FLASH_CONTROL->data);
printf("Verify: Reading from flash base %p\n", (void *)SPI_FLASH_BASE);
printf("Verify: With offset %x\n", FLASH_CONTROL->offset);
uint8_t tbuf[FLASH_SECTOR_SIZE];
uint32_t start_sector = FLASH_CONTROL->offset / FLASH_SECTOR_SIZE;
uint32_t end_sector = (FLASH_CONTROL->offset + FLASH_CONTROL->len - 1) /
FLASH_SECTOR_SIZE;
for (uint32_t i = 0; i < FLASH_CONTROL->len; i += 4) {
volatile uint32_t *flash_addr =
@@ -109,11 +102,16 @@ int __attribute__((section(".vectors"))) main(void) {
size_t l = MIN(4, FLASH_CONTROL->len - i);
size_t k;
uint32_t current_sector =
(FLASH_CONTROL->offset + i) / FLASH_SECTOR_SIZE;
if (current_sector > end_sector) {
break;
}
for (k = 0; k < l; k++) {
if (tbuf[k] != FLASH_CONTROL->data[i + k]) {
printf("Verify mismatch at offset %x: flash=%02x buf=%02x\n",
printf("[VERIFY] mismatch at offset %x: flash=%02x buf=%02x\n",
i + k, tbuf[k], FLASH_CONTROL->data[i + k]);
break;
}
}