Skip to content

FlashIAP & NVStore tests: Skip test if overwriting code in flash #7212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions TESTS/mbed_drivers/flashiap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
#include "utest/utest_serial.h"
#include "unity/unity.h"
#include "greentea-client/test_env.h"
#include "FlashIAP.h"
#include "unity.h"
#include <algorithm>

#include "mbed.h"

using namespace utest::v1;


void flashiap_init_test()
{
FlashIAP flash_device;
Expand Down Expand Up @@ -59,6 +62,9 @@ void flashiap_program_test()
// the one before the last sector in the system
uint32_t address = (flash_device.get_flash_start() + flash_device.get_flash_size()) - (sector_size);
TEST_ASSERT_TRUE(address != 0UL);
utest_printf("ROM ends at 0x%lx, test starts at 0x%lx\n", FLASHIAP_ROM_END, address);
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");

ret = flash_device.erase(address, sector_size);
TEST_ASSERT_EQUAL_INT32(0, ret);

Expand Down Expand Up @@ -93,6 +99,7 @@ void flashiap_program_test()
TEST_ASSERT_EQUAL_INT32(0, ret);
}


void flashiap_cross_sector_program_test()
{
FlashIAP flash_device;
Expand All @@ -111,6 +118,7 @@ void flashiap_cross_sector_program_test()
agg_size += sector_size;
address -= sector_size;
}
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
ret = flash_device.erase(address, agg_size);
TEST_ASSERT_EQUAL_INT32(0, ret);

Expand Down Expand Up @@ -166,6 +174,7 @@ void flashiap_program_error_test()
TEST_ASSERT_TRUE(address != 0UL);

// unaligned address
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
ret = flash_device.erase(address + 1, sector_size);
TEST_ASSERT_EQUAL_INT32(-1, ret);
if (flash_device.get_page_size() > 1) {
Expand All @@ -185,7 +194,7 @@ void flashiap_timing_test()
uint32_t ret = flash_device.init();
TEST_ASSERT_EQUAL_INT32(0, ret);
mbed::Timer timer;
int num_write_sizes;
unsigned int num_write_sizes;
unsigned int curr_time, byte_usec_ratio;
unsigned int avg_erase_time = 0;
unsigned int max_erase_time = 0, min_erase_time = (unsigned int) -1;
Expand Down Expand Up @@ -222,7 +231,7 @@ void flashiap_timing_test()
uint32_t address = base_address;
unsigned int avg_write_time = 0;
unsigned int max_write_time = 0, min_write_time = (unsigned int) -1;
int num_writes;
unsigned int num_writes;
for (num_writes = 0; num_writes < max_writes; num_writes++) {
if ((address + write_size) > end_address) {
break;
Expand Down
10 changes: 10 additions & 0 deletions features/nvstore/TESTS/nvstore/functionality/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ static const int race_test_data_size = 128;
static const int race_test_min_stack_size = 768;
static const int race_test_max_stack_size = 1024;

static bool nvstore_overlaps_code = false;

static void gen_random(uint8_t *s, int len)
{
for (int i = 0; i < len; ++i) {
Expand All @@ -91,6 +93,10 @@ static void nvstore_basic_functionality_test()
size_t area_size;
nvstore.get_area_params(area, area_address, area_size);
printf("Area %d: address 0x%08lx, size %d (0x%x)\n", area, area_address, area_size, area_size);
if (area_address < FLASHIAP_ROM_END) {
nvstore_overlaps_code = true;
}
TEST_SKIP_UNLESS_MESSAGE(!nvstore_overlaps_code, "Test skipped. NVStore region overlaps code.");
}

gen_random(nvstore_testing_buf_set, basic_func_max_data_size);
Expand Down Expand Up @@ -485,6 +491,8 @@ static void nvstore_multi_thread_test()

NVStore &nvstore = NVStore::get_instance();

TEST_SKIP_UNLESS_MESSAGE(!nvstore_overlaps_code, "Test skipped. NVStore region overlaps code.");

ret = nvstore.reset();
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, ret);

Expand Down Expand Up @@ -574,6 +582,8 @@ static void nvstore_race_test()
int num_threads = race_test_num_threads;
uint16_t actual_len_bytes;

TEST_SKIP_UNLESS_MESSAGE(!nvstore_overlaps_code, "Test skipped. NVStore region overlaps code.");

NVStore &nvstore = NVStore::get_instance();

ret = nvstore.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFED
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };

define block FLASH_CODE_ROM {section FLASH_ROM_init object flash_api.o, section .text_init object tmpm46b_fc.o};
define block FLASH_CODE_RAM {section FLASH_ROM object flash_api.o, section .text object tmpm46b_fc.o};
define block FLASH_CODE_ROM {section FLASH_ROM_init object flash_api.o};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this change about? removing some temporary object that should not be there? Separate commit for this change with reason for removing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was modified after a the previous link failure in this board. Consulted with Toshiba engineers, and they said that this object file wasn't required there. Now, I can move this change to another PR, but it would only make sense in this one, as the link error was the only reason for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xc0170 Is this explanation satisfactory? If not, I will need to open another PR (with the reasoning behind it being the resolving of the link error in this one).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidsaada I would recommend backing out this change and moving it to another PR since it's not really related to the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK Done. Now depending on #7791.

define block FLASH_CODE_RAM {section FLASH_ROM object flash_api.o};

initialize by copy { readwrite };
initialize manually { section FLASH_ROM object flash_api.o, section .text object tmpm46b_fc.o};
initialize manually { section FLASH_ROM object flash_api.o };
do not initialize { section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
Expand Down