From a60efa323935111d668684827de6e8ac41c5b1e4 Mon Sep 17 00:00:00 2001 From: NikhitaR-IFX Date: Tue, 20 Feb 2024 15:24:50 +0530 Subject: [PATCH] ports/psoc6: Refactored internal flash code. Signed-off-by: NikhitaR-IFX --- ports/psoc6/freeze/vfs_lfs2.py | 2 +- ports/psoc6/psoc6_flash.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ports/psoc6/freeze/vfs_lfs2.py b/ports/psoc6/freeze/vfs_lfs2.py index ca4ecf66b706e..77eaa23e2bb61 100644 --- a/ports/psoc6/freeze/vfs_lfs2.py +++ b/ports/psoc6/freeze/vfs_lfs2.py @@ -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 diff --git a/ports/psoc6/psoc6_flash.c b/ports/psoc6/psoc6_flash.c index f95c457a8b06d..9488de821c7c9 100644 --- a/ports/psoc6/psoc6_flash.c +++ b/ports/psoc6/psoc6_flash.c @@ -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);