Skip to content

Add FLASHIAP component to DISCO_H747 #11619

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 4 commits into from
Oct 30, 2019
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
3 changes: 3 additions & 0 deletions features/storage/kvstore/conf/global/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"NUCLEO_F429ZI": {
"storage_type": "TDB_INTERNAL"
},
"DISCO_H747I": {
"storage_type": "TDB_INTERNAL"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it will be easier to set the default value to TDB_INTERNAL ?
instead of overriding each target one by one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SeppoTakalo - we should consider this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, apparently many modules are assuming that KVStore "just works", so we need to probably default to TDB_INTERNAL and silently steal some flash away from the app.

But of course it needs to be configurable, so that location can be overwritten.

},
"UBLOX_EVK_ODIN_W2": {
"storage_type": "TDB_INTERNAL"
},
Expand Down
4 changes: 4 additions & 0 deletions features/storage/kvstore/conf/tdb_internal/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"internal_size": "0x8000",
"internal_base_address": "0x00028000"
},
"DISCO_H747I": {
"internal_size": "256*1024",
"internal_base_address": "0x080C0000"
Copy link
Contributor

@LMESTM LMESTM Oct 30, 2019

Choose a reason for hiding this comment

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

I don't like so much having this value HARD CODED.
Couldn't this be an address like
" MBED_APP_START + MBED_APP_SIZE - 256*1024 + 1 "
?
Note: I'm okay to move on wit this first implementation and try to make a later modification that makes it more dynamic ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder wha the MBED_APP_SIZE is actually here? If it's 1024-(2*128), then it would be OK. We can do that change for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But at least the offsets for example, you can't give as computed things - they had to be in real numbers.

Copy link
Contributor

Choose a reason for hiding this comment

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

The offset you're referring should be "internal_size" right ? Basically we're allocating a region of size "internal_size" at the end of application flash memory, isn't it ? so if we get the end address, we can deduce the rest of it at least for default value. Of course application can overload to somewhere else in memory and over-write the 2 parameters.

},
"ARM_MUSCA_A1_S": {
"internal_size": "0x8000",
"internal_base_address": "0x00420000"
Expand Down
24 changes: 24 additions & 0 deletions targets/TARGET_STM/TARGET_STM32H7/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

static uint32_t GetSector(uint32_t Address);
static uint32_t GetSectorSize(uint32_t Sector);
static uint32_t GetSectorBase(uint32_t SectorId);

int32_t flash_init(flash_t *obj)
{
Expand Down Expand Up @@ -91,6 +92,9 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
}
}

SCB_CleanInvalidateDCache_by_Addr((uint32_t *)GetSectorBase(SectorId), GetSectorSize(SectorId));
SCB_InvalidateICache();

HAL_FLASH_Lock();
#if defined(DUAL_CORE)
LL_HSEM_ReleaseLock(HSEM, CFG_HW_FLASH_SEMID, HSEM_CR_COREID_CURRENT);
Expand All @@ -103,6 +107,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
{
uint32_t StartAddress = 0;
int32_t status = 0;
uint32_t FullSize = size;

if ((address >= (FLASH_BASE + FLASH_SIZE)) || (address < FLASH_BASE)) {
return -1;
Expand Down Expand Up @@ -135,6 +140,9 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
}
}

SCB_CleanInvalidateDCache_by_Addr((uint32_t *)StartAddress, FullSize);
SCB_InvalidateICache();

HAL_FLASH_Lock();
#if defined(DUAL_CORE)
LL_HSEM_ReleaseLock(HSEM, CFG_HW_FLASH_SEMID, HSEM_CR_COREID_CURRENT);
Expand Down Expand Up @@ -213,6 +221,22 @@ static uint32_t GetSectorSize(uint32_t Sector)
return (uint32_t)(128 * 1024); // 128 KB
}

/**
* @brief Gets sector base address
* @param SectorId
* @retval base address of a given sector
*/
static uint32_t GetSectorBase(uint32_t SectorId)
{
uint32_t i = 0;
uint32_t address_sector = FLASH_BASE;

for (i = 0; i < SectorId; i++) {
address_sector += GetSectorSize(i);
}
return address_sector;
}

uint8_t flash_get_erase_value(const flash_t *obj)
{
(void)obj;
Expand Down
1 change: 1 addition & 0 deletions targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3315,6 +3315,7 @@
"DISCO_H747I": {
"inherits": ["FAMILY_STM32"],
"core": "Cortex-M7FD",
"components_add": ["FLASHIAP"],
"extra_labels_add": [
"STM32H7",
"STM32H747xI",
Expand Down