Skip to content

Calculate FlashIAPBlockDevice start address and size automatically for test only #9268

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 1 commit into from
Jan 8, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

//#include "mbed.h"
#include "FlashIAP.h"
#include "LittleFileSystem.h"
#include "fslittle_debug.h"
#include "fslittle_test.h"
Expand All @@ -48,6 +49,15 @@ using namespace utest::v1;
#endif
/// @endcond

// Align a value to a specified size.
// Parameters :
// val - [IN] Value.
// size - [IN] Size.
// Return : Aligned value.
static inline uint32_t align_up(uint32_t val, uint32_t size)
{
return (((val - 1) / size) + 1) * size;
}

/* DEVICE_SPI
* This symbol is defined in targets.json if the target has a SPI interface, which is required for SDCard support.
Expand Down Expand Up @@ -1247,7 +1257,29 @@ control_t fslittle_fopen_test_00(const size_t call_count)
(void) call_count;
int32_t ret = -1;

#if (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE == 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS == 0xFFFFFFFF)

size_t flash_size;
uint32_t start_address;
uint32_t bottom_address;
mbed::FlashIAP flash_driver;

ret = flash_driver.init();
TEST_ASSERT_EQUAL(0, ret);
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this work? assert equal and the condition below returns to the next test case (does it reach line 1273?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the remark. The code will get to 1273 if the ret value is 0. The only problem is that the if after the ASSERT is redundant. I have removed it and updated the commit message.


//Find the start of first sector after text area
bottom_address = align_up(FLASHIAP_APP_ROM_END_ADDR, flash_driver.get_sector_size(FLASHIAP_APP_ROM_END_ADDR));
start_address = flash_driver.get_flash_start();
flash_size = flash_driver.get_flash_size();
ret = flash_driver.deinit();
flash = new FlashIAPBlockDevice(bottom_address, start_address + flash_size - bottom_address);

#else

flash = new FlashIAPBlockDevice();

#endif

ret = flash->init();
TEST_ASSERT_EQUAL(0, ret);

Expand Down