diff options
Diffstat (limited to 'projects')
-rw-r--r-- | projects/board-test/keystore-perf.c | 4 | ||||
-rw-r--r-- | projects/board-test/spiflash-perf.c | 23 | ||||
-rw-r--r-- | projects/cli-test/mgmt-dfu.c | 4 | ||||
-rw-r--r-- | projects/cli-test/mgmt-fpga.c | 10 | ||||
-rw-r--r-- | projects/cli-test/mgmt-keystore.c | 2 | ||||
-rw-r--r-- | projects/cli-test/mgmt-show.c | 2 | ||||
-rw-r--r-- | projects/hsm/mgmt-fpga.c | 12 |
7 files changed, 44 insertions, 13 deletions
diff --git a/projects/board-test/keystore-perf.c b/projects/board-test/keystore-perf.c index 75b4e3f..09528a2 100644 --- a/projects/board-test/keystore-perf.c +++ b/projects/board-test/keystore-perf.c @@ -64,7 +64,7 @@ static void test_erase_sector(void) int err; for (i = 0; i < KEYSTORE_NUM_SECTORS; ++i) { - err = keystore_erase_sectors(i, i); + err = keystore_erase_sector(i); if (err != 1) { uart_send_string("ERROR: keystore_erase_sector returned "); uart_send_integer(err, 0); @@ -83,7 +83,7 @@ static void test_erase_subsector(void) int err; for (i = 0; i < KEYSTORE_NUM_SUBSECTORS; ++i) { - err = keystore_erase_subsectors(i, i); + err = keystore_erase_subsector(i); if (err != 1) { uart_send_string("ERROR: keystore_erase_subsector returned "); uart_send_integer(err, 0); diff --git a/projects/board-test/spiflash-perf.c b/projects/board-test/spiflash-perf.c index 1abcd7b..53f29cb 100644 --- a/projects/board-test/spiflash-perf.c +++ b/projects/board-test/spiflash-perf.c @@ -23,7 +23,7 @@ extern struct spiflash_ctx keystore_ctx; static struct spiflash_ctx *ctx = &keystore_ctx; /* - * 1. Read the entire flash by pages, ignoring data. + * 1a. Read the entire flash by pages, ignoring data. */ static void test_read_page(void) { @@ -43,6 +43,26 @@ static void test_read_page(void) } /* + * 1b. Read the entire flash by subsectors, ignoring data. + */ +static void test_read_subsector(void) +{ + uint8_t read_buf[N25Q128_SUBSECTOR_SIZE]; + uint32_t i; + int err; + + for (i = 0; i < N25Q128_NUM_SUBSECTORS; ++i) { + err = n25q128_read_subsector(ctx, i, read_buf); + if (err != 1) { + uart_send_string("ERROR: n25q128_read_subsector returned "); + uart_send_integer(err, 0); + uart_send_string("\r\n"); + break; + } + } +} + +/* * Read the flash data and verify it against a known pattern. * It turns out that verification doesn't slow us down in any measurable * way, because memcmp on 256 bytes is pretty inconsequential. @@ -217,6 +237,7 @@ int main(void) uart_send_string("Starting...\r\n"); time_check("read page ", test_read_page(), N25Q128_NUM_PAGES); + time_check("read subsector ", test_read_subsector(), N25Q128_NUM_SUBSECTORS); time_check("erase subsector ", test_erase_subsector(), N25Q128_NUM_SUBSECTORS); time_check("erase sector ", test_erase_sector(), N25Q128_NUM_SECTORS); time_check("erase bulk ", test_erase_bulk(), 1); diff --git a/projects/cli-test/mgmt-dfu.c b/projects/cli-test/mgmt-dfu.c index 8f258ea..851c8ea 100644 --- a/projects/cli-test/mgmt-dfu.c +++ b/projects/cli-test/mgmt-dfu.c @@ -72,9 +72,7 @@ static int cmd_dfu_erase(struct cli_def *cli, const char *command, char *argv[], { int status; - cli_print(cli, "Erasing flash sectors %i to %i (address %p to %p) - expect the CLI to crash now", - stm_flash_sector_num((uint32_t) dfu_firmware), - stm_flash_sector_num((uint32_t) dfu_firmware_end), + cli_print(cli, "Erasing flash address %p to %p - expect the CLI to crash now", dfu_firmware, dfu_firmware_end); diff --git a/projects/cli-test/mgmt-fpga.c b/projects/cli-test/mgmt-fpga.c index 31a6e27..b1b0973 100644 --- a/projects/cli-test/mgmt-fpga.c +++ b/projects/cli-test/mgmt-fpga.c @@ -47,7 +47,13 @@ static volatile uint32_t dfu_offset = 0; -static int _flash_write_callback(uint8_t *buf, size_t len) { +static int _flash_write_callback(uint8_t *buf, size_t len) +{ + 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; + int res = fpgacfg_write_data(dfu_offset, buf, BITSTREAM_UPLOAD_CHUNK_SIZE) == 1; dfu_offset += BITSTREAM_UPLOAD_CHUNK_SIZE; return res; @@ -91,7 +97,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_sectors(1)) { + if (fpgacfg_erase_sector(0) != 0) { 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 457abc2..09d512e 100644 --- a/projects/cli-test/mgmt-keystore.c +++ b/projects/cli-test/mgmt-keystore.c @@ -334,7 +334,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_sectors(0, KEYSTORE_NUM_SECTORS - 1)) != 1) { + if ((status = keystore_erase_bulk()) != 1) { cli_print(cli, "Failed erasing token keystore: %i", status); return CLI_ERROR; } diff --git a/projects/cli-test/mgmt-show.c b/projects/cli-test/mgmt-show.c index 5cca8b7..f124830 100644 --- a/projects/cli-test/mgmt-show.c +++ b/projects/cli-test/mgmt-show.c @@ -132,7 +132,7 @@ static int cmd_show_keystore_data(struct cli_def *cli, const char *command, char } } else { cli_print(cli, "Erasing first sector since all the first 8 bytes are tombstones"); - if ((i = keystore_erase_sectors(1, 1)) != 1) { + if ((i = keystore_erase_sector(0)) != 1) { cli_print(cli, "Failed erasing the first sector: %li", i); return CLI_ERROR; } diff --git a/projects/hsm/mgmt-fpga.c b/projects/hsm/mgmt-fpga.c index d76315e..06f2a26 100644 --- a/projects/hsm/mgmt-fpga.c +++ b/projects/hsm/mgmt-fpga.c @@ -3,7 +3,7 @@ * ----------- * CLI code to manage the FPGA configuration etc. * - * Copyright (c) 2016, NORDUnet A/S All rights reserved. + * Copyright (c) 2016-2017, NORDUnet A/S All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -55,7 +55,13 @@ extern hal_user_t user; static volatile uint32_t dfu_offset = 0; -static int _flash_write_callback(uint8_t *buf, size_t len) { +static int _flash_write_callback(uint8_t *buf, size_t len) +{ + 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; + int res = fpgacfg_write_data(dfu_offset, buf, BITSTREAM_UPLOAD_CHUNK_SIZE) == 1; dfu_offset += BITSTREAM_UPLOAD_CHUNK_SIZE; return res; @@ -104,7 +110,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_sectors(1)) { + if (fpgacfg_erase_sector(0) != 0) { cli_print(cli, "Erasing first sector in FPGA config memory failed"); return CLI_ERROR; } |