[M487] Support flash

pull/4608/head
ccli8 2017-03-21 16:54:31 +08:00
parent dae0a4c30c
commit bced49325a
2 changed files with 89 additions and 2 deletions

View File

@ -0,0 +1,87 @@
/* mbed Microcontroller Library
* Copyright (c) 2015-2016 Nuvoton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "flash_api.h"
#include "flash_data.h"
#include "mbed_critical.h"
// This is a flash algo binary blob. It is PIC (position independent code) that should be stored in RAM
// NOTE: On ARMv7-M/ARMv8-M, instruction fetches are always little-endian.
static uint32_t FLASH_ALGO[] = {
// FIXME
0x4603b530, 0x2164460c, 0x4df82059, 0x20166028, 0xf8c5070d, 0x20880100, 0x0100f8c5, 0xf8d006c0,
0xf0000100, 0xb9080001, 0xbd302001, 0x680048f0, 0x0004f040, 0x4580f04f, 0x0200f8c5, 0xf8d04628,
0xf0400204, 0xf8c50004, 0xbf000204, 0xf1a11e08, 0xd1fb0101, 0x680048e7, 0x0021f040, 0x60284de5,
0x69c04628, 0x0001f040, 0x462861e8, 0xf0006800, 0xb9080001, 0xe7d82001, 0x680048de, 0x0040f040,
0x60284ddc, 0xe7d02000, 0xbf004601, 0x690048d9, 0x0001f000, 0xd1f92800, 0x680048d6, 0x0021f020,
0x60104ad4, 0x69c04610, 0x0001f020, 0x200061d0, 0x60104ace, 0x46014770, 0x48cebf00, 0xf0006900,
0x28000001, 0x48cbd1f9, 0xf0406800, 0x4ac90040, 0x20226010, 0xf02160d0, 0x60500003, 0x1f00f5b1,
0x48c5d101, 0x20016090, 0x61104ac2, 0x8f60f3bf, 0x48c0bf00, 0xf0006900, 0x28000001, 0x48bdd1f9,
0xf0006800, 0xb1380040, 0x680048ba, 0x0040f040, 0x60104ab8, 0x47702001, 0xe7fc2000, 0x4603b570,
0x2500460c, 0x4629e009, 0xf8531c6d, 0xf7ff0021, 0x1e06ffc2, 0x4630d001, 0x42a5bd70, 0x2000d3f3,
0xb570e7fa, 0x460b4604, 0x22004615, 0xf1034629, 0xf020000f, 0xbf00030f, 0x690048a6, 0x0001f000,
0xd1f92800, 0x680048a3, 0x0040f040, 0x60304ea1, 0x000ff024, 0x20276070, 0x461060f0, 0xf8511c52,
0x4e9c0020, 0x60303680, 0x1c524610, 0x0020f851, 0xf8c64e98, 0x46100084, 0xf8511c52, 0x4e950020,
0x60303688, 0x1c524610, 0x0020f851, 0x60301d36, 0x4e902001, 0x3b106130, 0xbf00e02c, 0x30c0488d,
0xf0006800, 0x28000030, 0x4610d1f8, 0xf8511c52, 0x4e880020, 0x60303680, 0x1c524610, 0x0020f851,
0xf8c64e84, 0xbf000084, 0x30c04882, 0xf0006800, 0x280000c0, 0x4610d1f8, 0xf8511c52, 0x4e7d0020,
0x60303688, 0x1c524610, 0x0020f851, 0xf8c64e79, 0x3b10008c, 0xd1d02b00, 0x4876bf00, 0xf0006900,
0x28000001, 0xbd70d1f9, 0x4603b510, 0xf0201cc8, 0xbf000103, 0x6900486f, 0x0001f000, 0xd1f92800,
0x6800486c, 0x0040f040, 0x60204c6a, 0x60e02021, 0xf023e020, 0x4c670003, 0x68106060, 0x200160a0,
0xf3bf6120, 0xbf008f60, 0x69004862, 0x0001f000, 0xd1f92800, 0x6800485f, 0x0040f000, 0x485db138,
0xf0406800, 0x4c5b0040, 0x20016020, 0x1d1bbd10, 0x1f091d12, 0xd1dc2900, 0xe7f72000, 0x47f0e92d,
0x460c4605, 0xf04f4616, 0x46c20800, 0x4851bf00, 0xf0006900, 0x28000001, 0x484ed1f9, 0xf0406800,
0x494c0040, 0x1ce06008, 0x0403f020, 0xf3c5e02f, 0xb9600008, 0x7f00f5b4, 0xf44fd309, 0xeb067700,
0x46390208, 0xf7ff4628, 0x4682ff2c, 0xf3c5e016, 0xb9580008, 0xd3092c10, 0x070ff024, 0x0208eb06,
0x46284639, 0xff1df7ff, 0xe0074682, 0xeb064627, 0x46390208, 0xf7ff4628, 0x4682ff87, 0x44b8443d,
0xf1ba1be4, 0xd0020f00, 0xe8bd2001, 0x2c0087f0, 0x2000d1cd, 0xb510e7f9, 0xf0231ccb, 0xbf000103,
0x691b4b2c, 0x0301f003, 0xd1f92b00, 0x681b4b29, 0x0340f043, 0x60234c27, 0x60e32300, 0xf020e025,
0x4c240303, 0x23006063, 0x230160a3, 0xf3bf6123, 0xbf008f60, 0x691b4b1f, 0x0301f003, 0xd1f92b00,
0x681b4b1c, 0x0340f003, 0x4b1ab133, 0xf043681b, 0x4c180340, 0xbd106023, 0x689b4b16, 0x42a36814,
0xe7f8d000, 0x1d121d00, 0x29001f09, 0xbf00d1d7, 0xb510e7f1, 0x480f4603, 0xf0006e00, 0xb1680002,
0x6503480c, 0x65826541, 0x4c0a2001, 0xbf0065e0, 0x6e004808, 0x0001f000, 0xd1f92800, 0x6e004805,
0x0004f000, 0x2002b950, 0x0000bd10, 0x40000100, 0x40000200, 0x4000c000, 0x0055aa03, 0x6e004804,
0x0002f000, 0x2001b108, 0x2000e7ee, 0x0000e7ec, 0x4000c000, 0x00000000,
};
static const flash_algo_t flash_algo_config = {
// FIXME
.init = 0x00000001,
.uninit = 0x00000089,
.erase_sector = 0x000000b7,
.program_page = 0x0000029d,
.static_base = 0x00000414,
.algo_blob = FLASH_ALGO
};
static const sector_info_t sectors_info[] = {
{0x0, 0x1000}, // (start, sector size)
};
static const flash_target_config_t flash_target_config = {
// FIXME
.page_size = 0x200, // 512 bytes
.flash_start = 0x0,
.flash_size = 0x80000, // 512 KB
.sectors = sectors_info,
.sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t)
};
void flash_set_target_config(flash_t *obj)
{
obj->flash_algo = &flash_algo_config;
obj->target_config = &flash_target_config;
}

View File

@ -3260,11 +3260,11 @@
"NUMAKER_PFM_M487": {
"core": "Cortex-M4F",
"default_toolchain": "ARM",
"extra_labels": ["NUVOTON", "M480", "NUMAKER_PFM_M487"],
"extra_labels": ["NUVOTON", "M480", "FLASH_CMSIS_ALGO"],
"is_disk_virtual": true,
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"],
"inherits": ["Target"],
"device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "TRNG", "CAN"],
"device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "TRNG", "CAN", "FLASH"],
"features": ["LWIP"],
"release_versions": ["5"],
"device_name": "M487JIDAE"