Skip to content

Commit

Permalink
tests/psoc6: Enabling working MPY VFS tests for our port.
Browse files Browse the repository at this point in the history
Signed-off-by: NikhitaR-IFX <[email protected]>
  • Loading branch information
NikhitaR-IFX committed Jan 15, 2024
1 parent 1b4a5ed commit 9fa22a4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ports_psoc6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ jobs:
devs=($(python tools/psoc6/get-devs.py port -b ${{ matrix.board }} -y tools/psoc6/${{ runner.name }}-devs.yml))
cd tests
./psoc6/run_psoc6_tests.sh --psoc6-multi --dev0 ${devs[0]} --dev1 ${devs[1]}
- name: Run psoc6 filesystem test
run: |
devs=($(python tools/psoc6/get-devs.py port -b ${{ matrix.board }} -y tools/psoc6/${{ runner.name }}-devs.yml))
cd tests
./psoc6/run_psoc6_tests.sh -v --dev0 ${devs[0]} --dev1 ${devs[1]}
- name: Run psoc6 tests
run: |
devs=($(python tools/psoc6/get-devs.py port -b ${{ matrix.board }} -y tools/psoc6/${{ runner.name }}-devs.yml))
Expand Down
20 changes: 6 additions & 14 deletions ports/psoc6/modules/psoc6/psoc6_qspi_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ STATIC mp_obj_t psoc6_qspi_flash_readblocks(size_t n_args, const mp_obj_t *args)
}
mplogger_print("Address in hex:%04X, Length:%u\n", self->flash_base + offset, bufinfo.len);

mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); // begin atomic section
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION();
cy_rslt_t result = cy_serial_flash_qspi_read(self->flash_base + offset, bufinfo.len, bufinfo.buf);

if (CY_RSLT_SUCCESS != result) {
mplogger_print("psoc6_qspi_flash_readblocks() failed while reading the flash with error code: %u\n", CY_RSLT_GET_CODE(result));
mp_raise_ValueError(MP_ERROR_TEXT("psoc6_qspi_flash_readblocks() - QSPI Flash Read failed !"));
}
MICROPY_END_ATOMIC_SECTION(atomic_state); // end atomic section
MICROPY_END_ATOMIC_SECTION(atomic_state);
;
return mp_const_none;
}
Expand All @@ -178,12 +178,7 @@ STATIC mp_obj_t psoc6_qspi_flash_writeblocks(size_t n_args, const mp_obj_t *args
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ);

if (n_args == 3) {
// Flash erase/program must run in an atomic section.
// TODO: replace with implemented machine.disable_irq() in machine module.
// TODO: that function implements the atomic_state hash logic.
// TODO: that function must be made non-static first.
// TODO: or, reimplement MICROPY_BEGIN_ATOMIC_SECTION() as a simple macro
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); // begin atomic section
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION();
uint32_t numSectors = bufinfo.len / EXT_FLASH_SECTOR_SIZE;

for (uint32_t i = 0; i <= numSectors; ++i) {
Expand All @@ -197,14 +192,12 @@ STATIC mp_obj_t psoc6_qspi_flash_writeblocks(size_t n_args, const mp_obj_t *args
}
}

MICROPY_END_ATOMIC_SECTION(atomic_state); // end atomic section
MICROPY_END_ATOMIC_SECTION(atomic_state);
} else {
offset += mp_obj_get_int(args[3]);
}

// Flash erase/program must run in an atomic section.
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION();
// uint32_t numPages = bufinfo.len / EXT_FLASH_PAGE_SIZE;

cy_rslt_t result = cy_serial_flash_qspi_write(self->flash_base + offset, bufinfo.len, bufinfo.buf);
if (CY_RSLT_SUCCESS != result) {
Expand Down Expand Up @@ -246,15 +239,14 @@ STATIC mp_obj_t psoc6_qspi_flash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj
return MP_OBJ_NEW_SMALL_INT(EXT_FLASH_BLOCK_SIZE_BYTES);
case MP_BLOCKDEV_IOCTL_BLOCK_ERASE: {
uint32_t offset = mp_obj_get_int(arg_in) * EXT_FLASH_BLOCK_SIZE_BYTES;
// Flash erase/program must run in an atomic section.
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); // begin atomic section
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION();
cy_rslt_t result = cy_serial_flash_qspi_erase(self->flash_base + offset, cy_serial_flash_qspi_get_erase_size(self->flash_base + offset));

if (CY_RSLT_SUCCESS != result) {
mplogger_print("psoc6_qspi_flash_ioctl() failed while erasing block with error code: %u\n", CY_RSLT_GET_CODE(result));
mp_raise_ValueError(MP_ERROR_TEXT("psoc6_qspi_flash_ioctl() - QSPI Flash erase failed !"));
}
MICROPY_END_ATOMIC_SECTION(atomic_state); // end atomic section
MICROPY_END_ATOMIC_SECTION(atomic_state);
return MP_OBJ_NEW_SMALL_INT(0);
}
default:
Expand Down
32 changes: 29 additions & 3 deletions tests/psoc6/run_psoc6_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ usage() {
echo " -i run implemented tests only and exclude known failing tests"
echo " -n run not yet implemented tests only"
echo " -w run wifi tests => needs secrets.py key file>"
echo " -v run virtual filesystem related tests"
echo " --dev0 device to be used"
echo " --dev1 second device to be used (for multi test)"
echo " --psco6 run only psoc6 port related tests"
echo " --psoc6 run only psoc6 port related tests"
echo " --psoc6-multi run only psoc6 port multi tests (requires 2 instances)"
exit 1;
}
Expand All @@ -36,7 +37,7 @@ for arg in "$@"; do
esac
done

while getopts "acd:e:fhimnpw" o; do
while getopts "acd:e:fhimnpwv" o; do
case "${o}" in
a)
all=1
Expand Down Expand Up @@ -71,6 +72,9 @@ while getopts "acd:e:fhimnpw" o; do
w)
wifi=1
;;
v)
fs=1
;;
*)
usage
;;
Expand Down Expand Up @@ -115,6 +119,10 @@ if [ -z "${wifi}" ]; then
wifi=0
fi

if [ -z "${fs}" ]; then
fs=0
fi

if [ -z "${psoc6OnlyMulti}" ]; then
psoc6OnlyMulti=0
fi
Expand Down Expand Up @@ -229,6 +237,24 @@ if [ ${wifi} -eq 1 ]; then

fi

if [ ${fs} -eq 1 ]; then

echo " running filesystem tests ..."
echo

./run-tests.py --target psoc6 --device ${device0} \
\
extmod/vfs_basic.py \
extmod/vfs_lfs_superblock.py \
extmod/vfs_userfs.py \
| tee -a ${resultsFile}

echo
echo " done."
echo

fi


if [ ${implemented} -eq 1 ]; then

Expand Down Expand Up @@ -268,7 +294,7 @@ if [ ${implemented} -eq 1 ]; then
\
-e extmod/re_stack_overflow.py \
-e extmod/socket_udp_nonblock.py \
-e extmod/vfs_lfs_mtime.py \

\
-e feature_check/async_check.py \
-e feature_check/bytearray.py \
Expand Down

0 comments on commit 9fa22a4

Please sign in to comment.