diff options
Diffstat (limited to 'projects/cli-test')
-rw-r--r-- | projects/cli-test/mgmt-fpga.c | 16 | ||||
-rw-r--r-- | projects/cli-test/mgmt-keystore.c | 6 | ||||
-rw-r--r-- | projects/cli-test/mgmt-misc.c | 6 | ||||
-rw-r--r-- | projects/cli-test/mgmt-misc.h | 2 | ||||
-rw-r--r-- | projects/cli-test/mgmt-show.c | 14 | ||||
-rw-r--r-- | projects/cli-test/test-mkmif.c | 32 |
6 files changed, 39 insertions, 37 deletions
diff --git a/projects/cli-test/mgmt-fpga.c b/projects/cli-test/mgmt-fpga.c index da539f1..a307436 100644 --- a/projects/cli-test/mgmt-fpga.c +++ b/projects/cli-test/mgmt-fpga.c @@ -47,14 +47,16 @@ static volatile uint32_t dfu_offset = 0; -static int _flash_write_callback(uint8_t *buf, size_t len) +static HAL_StatusTypeDef _flash_write_callback(uint8_t *buf, size_t len) { + HAL_StatusTypeDef res; + if ((dfu_offset % FPGACFG_SECTOR_SIZE) == 0) /* first page in sector, need to erase sector */ - if (fpgacfg_erase_sector(dfu_offset / FPGACFG_SECTOR_SIZE) != 1) - return CLI_ERROR; + if ((res = fpgacfg_erase_sector(dfu_offset / FPGACFG_SECTOR_SIZE)) != HAL_OK) + return res; - int res = fpgacfg_write_data(dfu_offset, buf, len) == 1; + res = fpgacfg_write_data(dfu_offset, buf, len); dfu_offset += len; return res; } @@ -72,7 +74,7 @@ static int cmd_fpga_bitstream_upload(struct cli_def *cli, const char *command, c fpgacfg_access_control(ALLOW_ARM); cli_print(cli, "Checking if FPGA config memory is accessible"); - if (fpgacfg_check_id() != 1) { + if (fpgacfg_check_id() != HAL_OK) { cli_print(cli, "ERROR: FPGA config memory not accessible. Check that jumpers JP7 and JP8 are installed."); return CLI_ERROR; } @@ -94,7 +96,7 @@ static int cmd_fpga_bitstream_erase(struct cli_def *cli, const char *command, ch fpgacfg_access_control(ALLOW_ARM); cli_print(cli, "Checking if FPGA config memory is accessible"); - if (fpgacfg_check_id() != 1) { + if (fpgacfg_check_id() != HAL_OK) { cli_print(cli, "ERROR: FPGA config memory not accessible. Check that jumpers JP7 and JP8 are installed."); return CLI_ERROR; } @@ -105,7 +107,7 @@ static int cmd_fpga_bitstream_erase(struct cli_def *cli, const char *command, ch * * This command could be made to accept an argument indicating the whole memory should be erased. */ - if (fpgacfg_erase_sector(0) != 0) { + if (fpgacfg_erase_sector(0) != HAL_OK) { cli_print(cli, "Erasing first sector in FPGA config memory failed"); return CLI_ERROR; } diff --git a/projects/cli-test/mgmt-keystore.c b/projects/cli-test/mgmt-keystore.c index ea1f263..8c16f35 100644 --- a/projects/cli-test/mgmt-keystore.c +++ b/projects/cli-test/mgmt-keystore.c @@ -228,12 +228,12 @@ static int cmd_keystore_show_data(struct cli_def *cli, const char *command, char argv = argv; argc = argc; - if (keystore_check_id() != 1) { + if (keystore_check_id() != CMSIS_HAL_OK) { cli_print(cli, "ERROR: The keystore memory is not accessible."); } memset(buf, 0, sizeof(buf)); - if ((i = keystore_read_data(0, buf, sizeof(buf))) != 1) { + if ((i = keystore_read_data(0, buf, sizeof(buf))) != CMSIS_HAL_OK) { cli_print(cli, "Failed reading first page from keystore memory: %li", i); return CLI_ERROR; } @@ -355,7 +355,7 @@ static int cmd_keystore_erase(struct cli_def *cli, const char *command, char *ar } cli_print(cli, "OK, erasing keystore, this might take a while..."); - if ((status = keystore_erase_bulk()) != 1) { + if ((status = keystore_erase_bulk()) != CMSIS_HAL_OK) { cli_print(cli, "Failed erasing token keystore: %i", status); return CLI_ERROR; } diff --git a/projects/cli-test/mgmt-misc.c b/projects/cli-test/mgmt-misc.c index 4be9a4b..1216bd5 100644 --- a/projects/cli-test/mgmt-misc.c +++ b/projects/cli-test/mgmt-misc.c @@ -49,9 +49,9 @@ static volatile hal_crc32_t demo_crc; -static int _count_bytes_callback(uint8_t *buf, size_t len) { +static HAL_StatusTypeDef _count_bytes_callback(uint8_t *buf, size_t len) { demo_crc = hal_crc32_update(demo_crc, buf, len); - return 1; + return CMSIS_HAL_OK; } int cli_receive_data(struct cli_def *cli, uint8_t *buf, size_t len, cli_data_callback data_callback) @@ -92,7 +92,7 @@ int cli_receive_data(struct cli_def *cli, uint8_t *buf, size_t len, cli_data_cal /* After reception of a chunk but before ACKing we have "all" the time in the world to * calculate CRC and invoke the data_callback. */ - if (data_callback != NULL && ! data_callback(buf, (size_t) n)) { + if (data_callback != NULL && data_callback(buf, n) != CMSIS_HAL_OK) { cli_print(cli, "Data processing failed"); goto fail; } diff --git a/projects/cli-test/mgmt-misc.h b/projects/cli-test/mgmt-misc.h index c549f63..c0581c9 100644 --- a/projects/cli-test/mgmt-misc.h +++ b/projects/cli-test/mgmt-misc.h @@ -39,7 +39,7 @@ #define FILETRANSFER_UPLOAD_CHUNK_SIZE 256 -typedef int (*cli_data_callback)(uint8_t *, size_t); +typedef HAL_StatusTypeDef (*cli_data_callback)(uint8_t *, size_t); extern int cli_receive_data(struct cli_def *cli, uint8_t *buf, size_t len, cli_data_callback data_callback); diff --git a/projects/cli-test/mgmt-show.c b/projects/cli-test/mgmt-show.c index e829744..e276b15 100644 --- a/projects/cli-test/mgmt-show.c +++ b/projects/cli-test/mgmt-show.c @@ -73,7 +73,7 @@ static int cmd_show_fpga_status(struct cli_def *cli, const char *command, char * argv = argv; argc = argc; - cli_print(cli, "FPGA has %sloaded a bitstream", fpgacfg_check_done() ? "":"NOT "); + cli_print(cli, "FPGA has %sloaded a bitstream", (fpgacfg_check_done() == CMSIS_HAL_OK) ? "":"NOT "); return CLI_OK; } @@ -86,7 +86,7 @@ static int cmd_show_fpga_cores(struct cli_def *cli, const char *command, char *a argv = argv; argc = argc; - if (! fpgacfg_check_done()) { + if (fpgacfg_check_done() != CMSIS_HAL_OK) { cli_print(cli, "FPGA has not loaded a bitstream"); return CLI_OK; } @@ -106,7 +106,7 @@ static int cmd_show_keystore_status(struct cli_def *cli, const char *command, ch argv = argv; argc = argc; - cli_print(cli, "Keystore memory is %sonline", (keystore_check_id() != 1) ? "NOT ":""); + cli_print(cli, "Keystore memory is %sonline", (keystore_check_id() == CMSIS_HAL_OK) ? "":"NOT "); return CLI_OK; } @@ -119,12 +119,12 @@ static int cmd_show_keystore_data(struct cli_def *cli, const char *command, char argv = argv; argc = argc; - if (keystore_check_id() != 1) { + if (keystore_check_id() != CMSIS_HAL_OK) { cli_print(cli, "ERROR: The keystore memory is not accessible."); } memset(buf, 0, sizeof(buf)); - if ((i = keystore_read_data(0, buf, sizeof(buf))) != 1) { + if ((i = keystore_read_data(0, buf, sizeof(buf))) != CMSIS_HAL_OK) { cli_print(cli, "Failed reading first page from keystore memory: %li", i); return CLI_ERROR; } @@ -145,14 +145,14 @@ static int cmd_show_keystore_data(struct cli_def *cli, const char *command, char if (buf[i] == 0xff) { cli_print(cli, "Tombstoning byte %li", i); buf[i] = 0x55; - if ((i = keystore_write_data(0, buf, sizeof(buf))) != 1) { + if ((i = keystore_write_data(0, buf, sizeof(buf))) != CMSIS_HAL_OK) { cli_print(cli, "Failed writing data at offset 0: %li", i); return CLI_ERROR; } } } else { cli_print(cli, "Erasing first sector since all the first 8 bytes are tombstones"); - if ((i = keystore_erase_sector(0)) != 1) { + if ((i = keystore_erase_sector(0)) != CMSIS_HAL_OK) { cli_print(cli, "Failed erasing the first sector: %li", i); return CLI_ERROR; } diff --git a/projects/cli-test/test-mkmif.c b/projects/cli-test/test-mkmif.c index 6321dde..cd71040 100644 --- a/projects/cli-test/test-mkmif.c +++ b/projects/cli-test/test-mkmif.c @@ -32,18 +32,18 @@ static hal_error_t sclk_test(struct cli_def *cli, hal_core_t *core, const uint32 uint32_t readback; hal_error_t err; - cli_print(cli, "Trying to adjust the clockspeed (divisor %x).\n", (unsigned int) divisor); + cli_print(cli, "Trying to adjust the clockspeed (divisor %x).", (unsigned int) divisor); if ((err = hal_mkmif_set_clockspeed(core, divisor)) != LIBHAL_OK) { - cli_print(cli, "hal_mkmif_set_clockspeed: %s\n", hal_error_string(err)); + cli_print(cli, "hal_mkmif_set_clockspeed: %s", hal_error_string(err)); return err; } if ((err = hal_mkmif_get_clockspeed(core, &readback)) != LIBHAL_OK) { - cli_print(cli, "hal_mkmif_get_clockspeed: %s\n", hal_error_string(err)); + cli_print(cli, "hal_mkmif_get_clockspeed: %s", hal_error_string(err)); return err; } if (readback != divisor) { - cli_print(cli, "expected %x, got %x\n", (unsigned int)divisor, (unsigned int)readback); + cli_print(cli, "expected %x, got %x", (unsigned int)divisor, (unsigned int)readback); return HAL_ERROR_IO_UNEXPECTED; } return LIBHAL_OK; @@ -53,10 +53,10 @@ static hal_error_t init_test(struct cli_def *cli, hal_core_t *core) { hal_error_t err; - cli_print(cli, "Trying to init to the memory in continuous mode.\n"); + cli_print(cli, "Trying to init to the memory in continuous mode."); if ((err = hal_mkmif_init(core)) != LIBHAL_OK) { - cli_print(cli, "hal_mkmif_init: %s\n", hal_error_string(err)); + cli_print(cli, "hal_mkmif_init: %s", hal_error_string(err)); return err; } @@ -74,11 +74,11 @@ static hal_error_t write_test(struct cli_def *cli, hal_core_t *core) i < 0x10; write_data += 0x01010101, write_address += 4, ++i) { - cli_print(cli, "Trying to write 0x%08x to memory address 0x%08x.\n", + cli_print(cli, "Trying to write 0x%08x to memory address 0x%08x.", (unsigned int)write_data, (unsigned int)write_address); if ((err = hal_mkmif_write_word(core, write_address, write_data)) != LIBHAL_OK) { - cli_print(cli, "hal_mkmif_write: %s\n", hal_error_string(err)); + cli_print(cli, "hal_mkmif_write: %s", hal_error_string(err)); return err; } } @@ -97,13 +97,13 @@ static hal_error_t read_test(struct cli_def *cli, hal_core_t *core) i < 0x10; read_address += 4, ++i) { - cli_print(cli, "Trying to read from memory address 0x%08x.\n", (unsigned int)read_address); + cli_print(cli, "Trying to read from memory address 0x%08x.", (unsigned int)read_address); if ((err = hal_mkmif_read_word(core, read_address, &read_data)) != LIBHAL_OK) { - cli_print(cli, "hal_mkmif_read: %s\n", hal_error_string(err)); + cli_print(cli, "hal_mkmif_read: %s", hal_error_string(err)); return err; } - cli_print(cli, "Data read: 0x%08x\n", (unsigned int)read_data); + cli_print(cli, "Data read: 0x%08x", (unsigned int)read_data); } return LIBHAL_OK; @@ -115,22 +115,22 @@ static hal_error_t write_read_test(struct cli_def *cli, hal_core_t *core) uint32_t readback; hal_error_t err; - cli_print(cli, "Trying to write 0xdeadbeef to the memory and then read back.\n"); + cli_print(cli, "Trying to write 0xdeadbeef to the memory and then read back."); data = 0xdeadbeef; if ((err = hal_mkmif_write_word(core, 0x00000000, data)) != LIBHAL_OK) { - cli_print(cli, "write error: %s\n", hal_error_string(err)); + cli_print(cli, "write error: %s", hal_error_string(err)); return err; } if ((err = hal_mkmif_read_word(core, 0x00000000, &readback)) != LIBHAL_OK) { - cli_print(cli, "read error: %s\n", hal_error_string(err)); + cli_print(cli, "read error: %s", hal_error_string(err)); return err; } if (readback != data) { - cli_print(cli, "read %08x, expected %08x\n", (unsigned int)readback, (unsigned int)data); + cli_print(cli, "read %08x, expected %08x", (unsigned int)readback, (unsigned int)data); return HAL_ERROR_IO_UNEXPECTED; } @@ -147,7 +147,7 @@ int cmd_test_mkmif(struct cli_def *cli, const char *command, char *argv[], int a argc = argc; if (core == NULL) { - cli_print(cli, "MKMIF core not present, not testing.\n"); + cli_print(cli, "MKMIF core not present, not testing."); return HAL_ERROR_CORE_NOT_FOUND; } |