Skip to content

Commit

Permalink
ports/psoc6: Refactored internal flash code.
Browse files Browse the repository at this point in the history
Signed-off-by: NikhitaR-IFX <Nikhita.Rajasekhar@infineon.com>
  • Loading branch information
NikhitaR-IFX committed Feb 20, 2024
1 parent 97c631f commit a60efa3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ports/psoc6/freeze/vfs_lfs2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
vfs = os.VfsLfs2(bdev, progsize=write_size, readsize=read_size)
os.mount(vfs, "/")

print("LFS2 filesystem mounted at /\n")
print("Internal LFS2 filesystem mounted at /\n")

del machine, os, psoc6, bdev, vfs, read_size, write_size
12 changes: 4 additions & 8 deletions ports/psoc6/psoc6_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,10 @@ STATIC mp_obj_t psoc6_flash_writeblocks(size_t n_args, const mp_obj_t *args) {
// Flash erase/program must run in an atomic section.
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION();

uint32_t numPages = bufinfo.len / FLASH_SECTOR_SIZE; // TODO: should be page size
for (uint32_t i = 0; i <= numPages; ++i) {
cy_rslt_t result = cyhal_flash_program(&cyhal_flash_obj, self->flash_base + offset + i * FLASH_SECTOR_SIZE, bufinfo.buf + i * FLASH_SECTOR_SIZE);

if (CY_RSLT_SUCCESS != result) {
mplogger_print("\npsoc6_flash_writeblocks() failed while writing with error code: %u\n", CY_RSLT_GET_CODE(result));
mp_raise_ValueError(MP_ERROR_TEXT("\npsoc6_flash_writeblocks() - Flash Program failed!"));
}
cy_rslt_t result = cyhal_flash_write(&cyhal_flash_obj, self->flash_base + offset, bufinfo.buf);
if (CY_RSLT_SUCCESS != result) {
mplogger_print("psoc6_qspi_flash_writeblocks() failed while writing with error code: %u\n", CY_RSLT_GET_CODE(result));
mp_raise_ValueError(MP_ERROR_TEXT("psoc6_qspi_flash_writeblocks() - QSPI Flash Write failed!"));
}

MICROPY_END_ATOMIC_SECTION(atomic_state);
Expand Down

0 comments on commit a60efa3

Please sign in to comment.