mirror of https://github.com/ARMmbed/mbed-os.git
STM32H7 FLASH and DEVICE_KEY
- Enable FLASHIAP for all H7 boards - Use "TDB_INTERNAL" for all H7 boards - Define specific internal_base_address only for DISCO_H747I_CM7 (default address is the end of FLASH which is correct for other H7 boards) - Correct GetSectorBase function with Dual Bank informationpull/11789/head
parent
cbf9f0650b
commit
d7d0d0b8cb
|
@ -20,9 +20,18 @@
|
|||
"NUCLEO_F429ZI": {
|
||||
"storage_type": "TDB_INTERNAL"
|
||||
},
|
||||
"NUCLEO_H743ZI": {
|
||||
"storage_type": "TDB_INTERNAL"
|
||||
},
|
||||
"NUCLEO_H743ZI2": {
|
||||
"storage_type": "TDB_INTERNAL"
|
||||
},
|
||||
"DISCO_H747I": {
|
||||
"storage_type": "TDB_INTERNAL"
|
||||
},
|
||||
"DISCO_H747I_CM4": {
|
||||
"storage_type": "TDB_INTERNAL"
|
||||
},
|
||||
"UBLOX_EVK_ODIN_W2": {
|
||||
"storage_type": "TDB_INTERNAL"
|
||||
},
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
"internal_base_address": "0x00028000"
|
||||
},
|
||||
"DISCO_H747I": {
|
||||
"internal_size": "256*1024",
|
||||
"internal_size": "2*FLASH_SECTOR_SIZE",
|
||||
"internal_base_address": "0x080C0000"
|
||||
},
|
||||
"ARM_MUSCA_A1_S": {
|
||||
"ARM_MUSCA_A1_S": {
|
||||
"internal_size": "0x8000",
|
||||
"internal_base_address": "0x00420000"
|
||||
},
|
||||
|
|
|
@ -1,49 +1,21 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2016, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016-2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef MBED_FLASH_DATA_H
|
||||
#define MBED_FLASH_DATA_H
|
||||
|
||||
#include "device.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#if DEVICE_FLASH
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
|
||||
/* Flash size */
|
||||
#ifndef FLASH_SIZE
|
||||
#define FLASH_SIZE (uint32_t) 0x200000 // 2Mb
|
||||
#endif
|
||||
|
||||
#define ADDR_FLASH_SECTOR_0_BANK1 ((uint32_t)0x08000000) /* Base @ of Sector 0, Bank1, 128 Kbyte */
|
||||
#define ADDR_FLASH_SECTOR_1_BANK1 ((uint32_t)0x08020000) /* Base @ of Sector 1, Bank1, 128 Kbyte */
|
||||
#define ADDR_FLASH_SECTOR_2_BANK1 ((uint32_t)0x08040000) /* Base @ of Sector 2, Bank1, 128 Kbyte */
|
||||
|
@ -62,6 +34,4 @@
|
|||
#define ADDR_FLASH_SECTOR_6_BANK2 ((uint32_t)0x081C0000) /* Base @ of Sector 6, Bank2, 128 Kbyte */
|
||||
#define ADDR_FLASH_SECTOR_7_BANK2 ((uint32_t)0x081E0000) /* Base @ of Sector 7, Bank2, 128 Kbyte */
|
||||
|
||||
#endif // DEVICE_FLASH
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* <h2><center>© Copyright (c) 2018-2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
|
@ -16,20 +16,6 @@
|
|||
#ifndef MBED_FLASH_DATA_H
|
||||
#define MBED_FLASH_DATA_H
|
||||
|
||||
#include "device.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#if DEVICE_FLASH
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
|
||||
/* Flash size */
|
||||
#ifndef FLASH_SIZE
|
||||
#define FLASH_SIZE (uint32_t) 0x200000 // 2Mb
|
||||
#endif
|
||||
|
||||
#define ADDR_FLASH_SECTOR_0_BANK1 ((uint32_t)0x08000000) /* Base @ of Sector 0, Bank1, 128 Kbyte */
|
||||
#define ADDR_FLASH_SECTOR_1_BANK1 ((uint32_t)0x08020000) /* Base @ of Sector 1, Bank1, 128 Kbyte */
|
||||
#define ADDR_FLASH_SECTOR_2_BANK1 ((uint32_t)0x08040000) /* Base @ of Sector 2, Bank1, 128 Kbyte */
|
||||
|
@ -48,6 +34,4 @@
|
|||
#define ADDR_FLASH_SECTOR_6_BANK2 ((uint32_t)0x081C0000) /* Base @ of Sector 6, Bank2, 128 Kbyte */
|
||||
#define ADDR_FLASH_SECTOR_7_BANK2 ((uint32_t)0x081E0000) /* Base @ of Sector 7, Bank2, 128 Kbyte */
|
||||
|
||||
#endif // DEVICE_FLASH
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
* Copyright (c) 2017 STMicroelectronics
|
||||
* Copyright (c) 2017-2019 ARM Limited
|
||||
* Copyright (c) 2017-2019 STMicroelectronics
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
static uint32_t GetSector(uint32_t Address);
|
||||
static uint32_t GetSectorSize(uint32_t Sector);
|
||||
static uint32_t GetSectorBase(uint32_t SectorId);
|
||||
static uint32_t GetSectorBase(uint32_t SectorId, uint32_t BanksId);
|
||||
|
||||
int32_t flash_init(flash_t *obj)
|
||||
{
|
||||
|
@ -50,7 +50,6 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
|||
{
|
||||
/* Variable used for Erase procedure */
|
||||
FLASH_EraseInitTypeDef EraseInitStruct;
|
||||
uint32_t SectorId;
|
||||
uint32_t SectorError = 0;
|
||||
int32_t status = 0;
|
||||
|
||||
|
@ -70,29 +69,23 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* Get the 1st sector to erase */
|
||||
SectorId = GetSector(address);
|
||||
|
||||
/* Fill EraseInit structure */
|
||||
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
|
||||
EraseInitStruct.Sector = SectorId;
|
||||
EraseInitStruct.Sector = GetSector(address);
|
||||
EraseInitStruct.NbSectors = 1;
|
||||
|
||||
if (address < ADDR_FLASH_SECTOR_0_BANK2) {
|
||||
EraseInitStruct.Banks = FLASH_BANK_1;
|
||||
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK) {
|
||||
status = -1;
|
||||
}
|
||||
} else {
|
||||
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||
EraseInitStruct.Banks = FLASH_BANK_2;
|
||||
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK) {
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
|
||||
SCB_CleanInvalidateDCache_by_Addr((uint32_t *)GetSectorBase(SectorId), GetSectorSize(SectorId));
|
||||
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK) {
|
||||
status = -1;
|
||||
}
|
||||
|
||||
SCB_CleanInvalidateDCache_by_Addr((uint32_t *)GetSectorBase(EraseInitStruct.Sector, EraseInitStruct.Banks), GetSectorSize(EraseInitStruct.Sector));
|
||||
SCB_InvalidateICache();
|
||||
|
||||
HAL_FLASH_Lock();
|
||||
|
@ -218,18 +211,25 @@ static uint32_t GetSector(uint32_t Address)
|
|||
*/
|
||||
static uint32_t GetSectorSize(uint32_t Sector)
|
||||
{
|
||||
return (uint32_t)(128 * 1024); // 128 KB
|
||||
return FLASH_SECTOR_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets sector base address
|
||||
* @param SectorId
|
||||
* @param BanksId
|
||||
* @retval base address of a given sector
|
||||
*/
|
||||
static uint32_t GetSectorBase(uint32_t SectorId)
|
||||
static uint32_t GetSectorBase(uint32_t SectorId, uint32_t BanksId)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
uint32_t address_sector = FLASH_BASE;
|
||||
uint32_t address_sector;
|
||||
|
||||
if (BanksId == FLASH_BANK_1) {
|
||||
address_sector = FLASH_BANK1_BASE;
|
||||
} else {
|
||||
address_sector = FLASH_BANK2_BASE;
|
||||
}
|
||||
|
||||
for (i = 0; i < SectorId; i++) {
|
||||
address_sector += GetSectorSize(i);
|
||||
|
|
|
@ -3236,6 +3236,7 @@
|
|||
"macro_name": "HSE_VALUE"
|
||||
}
|
||||
},
|
||||
"components_add": ["FLASHIAP"],
|
||||
"macros_add": [
|
||||
"STM32H743xx",
|
||||
"EXTRA_IDLE_STACK_REQUIRED",
|
||||
|
@ -3288,6 +3289,7 @@
|
|||
"macro_name": "HSE_VALUE"
|
||||
}
|
||||
},
|
||||
"components_add": ["FLASHIAP"],
|
||||
"macros_add": [
|
||||
"STM32H743xx",
|
||||
"EXTRA_IDLE_STACK_REQUIRED",
|
||||
|
@ -3359,6 +3361,7 @@
|
|||
"STM32H747xI",
|
||||
"DISCO_H747I"
|
||||
],
|
||||
"components_add": ["FLASHIAP"],
|
||||
"config": {
|
||||
"lpticker_lptim": {
|
||||
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
|
||||
|
|
Loading…
Reference in New Issue