Commit c30a7477 authored by Sergei Miroshnichenko's avatar Sergei Miroshnichenko

RM#1047 stm32: Add support for 2MiB embedded flash

- Replace local macros for flash base size with generic ones (from
  include/configs/*.h);
- Add four banks 256KiB each in according with RM0410 "3.3.1 Flash
  memory organization".
parent a181eb3b
......@@ -25,15 +25,6 @@
#include <errno.h>
#include "envm.h"
/*
* Flash data area definitions
*/
#define STM32_FLASH_BASE 0x08000000
#if defined(CONFIG_SYS_STM32F43X)
#define STM32_FLASH_SIZE (1024 * 1024 * 2)
#else
#define STM32_FLASH_SIZE (1024 * 1024 * 1)
#endif
/*
* This array defines the layout of the Embedded Flash on the STM32 chips
*/
......@@ -42,6 +33,9 @@ static u32 flash_bsize[] = {
[0 ... 3] = 32 * 1024,
[4] = 128 * 1024,
[5 ... 7] = 256 * 1024,
#if defined(CONFIG_SYS_STM32F76xxx) || defined(CONFIG_SYS_STM32F77xxx)
[8 ... 11] = 256 * 1024,
#endif
#else
[0 ... 3] = 16 * 1024,
[4] = 64 * 1024,
......@@ -152,7 +146,7 @@ stm32_flash_cr_lock(void)
static s32 stm32_flash_get_block(u8 *addr)
{
s32 i = 0;
u8 *base = (u8 *)STM32_FLASH_BASE;
u8 *base = (u8 *)CONFIG_MEM_NVM_BASE;
while (i < STM32_FLASH_BLOCKS) {
if (addr == base)
......@@ -322,8 +316,8 @@ envm_write(u32 offset, void * buf, u32 size)
stm32f7_envm_as_dev();
#endif
/* Basic sanity check. More checking in the "get_block" routine */
if ((offset < STM32_FLASH_BASE) ||
((offset + size) > (STM32_FLASH_BASE + STM32_FLASH_SIZE))) {
if ((offset < CONFIG_MEM_NVM_BASE) ||
((offset + size) > (CONFIG_MEM_NVM_BASE + CONFIG_MEM_NVM_LEN))) {
printf("%s: Address %#x is not in flash"
" or size %d is too big\n",
__func__, offset, size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment