Skip to content

Commit

Permalink
Bugfix not correctly moving to the next erase address and program pag…
Browse files Browse the repository at this point in the history
…e rework
  • Loading branch information
itzandroidtab authored Oct 4, 2023
1 parent 9297f60 commit 6a72d98
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions flash/flash_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,16 @@ int __attribute__ ((noinline)) SEGGER_OPEN_Program(uint32_t address, uint32_t si

for (uint32_t i = 0; i < pages; i++) {
// program a page
int r = ProgramPage(address + (i * PAGE_SIZE_SHIFT), (0x1 << PAGE_SIZE_SHIFT), &data[i * PAGE_SIZE_SHIFT]);
int r = ProgramPage(address, (0x1 << PAGE_SIZE_SHIFT), data);

// check if something went wrong
if (r) {
// return a error
return 1;
}

address += (0x1 << PAGE_SIZE_SHIFT);
data += (0x1 << PAGE_SIZE_SHIFT);
}

// return everything went oke
Expand Down Expand Up @@ -267,6 +270,9 @@ int __attribute__ ((noinline)) SEGGER_OPEN_Program(uint32_t address, uint32_t si
// return we have a error
return 1;
}

// go to the next sector address
SectorAddr += (1 << SECTOR_SIZE_SHIFT);
}

// return everything went oke
Expand All @@ -284,7 +290,7 @@ int __attribute__ ((noinline)) SEGGER_OPEN_Program(uint32_t address, uint32_t si

#if !NATIVE_READ
int __attribute__ ((noinline, __used__)) BlankCheck(const uint32_t address, const uint32_t size, const uint8_t blank_value) {
uint8_t buffer[256];
static uint8_t buffer[256];

// read all the memory and compare it with the blank value
for (uint32_t i = 0; i < size; /* do not update i here */) {
Expand Down Expand Up @@ -314,4 +320,4 @@ int __attribute__ ((noinline)) SEGGER_OPEN_Program(uint32_t address, uint32_t si

return size;
}
#endif
#endif

0 comments on commit 6a72d98

Please sign in to comment.