Skip to content

[NXP LPC176X] flash_api.c implementation #4169

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 12 commits into from
May 4, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LR_IROM1 0x00000000 0x80000 { ; load region size_region
.ANY (+RO)
}
; 8_byte_aligned(49 vect * 4 bytes) = 8_byte_aligned(0xC4) = 0xC8
; 32KB - 0xC8 = 0x7F38
RW_IRAM1 0x100000C8 0x7F38 {
; 32KB (RAM size) - 0xC8 (NIVT) - 32 (topmost 32 bytes used by IAP functions) = 0x7F18
RW_IRAM1 0x100000C8 0x7F18 {
.ANY (+RW +ZI)
}
RW_IRAM2 0x2007C000 0x4000 { ; RW data, USB RAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LR_IROM1 0x00000000 0x80000 { ; load region size_region
.ANY (+RO)
}
; 8_byte_aligned(49 vect * 4 bytes) = 8_byte_aligned(0xC4) = 0xC8
; 32KB - 0xC8 = 0x7F38
RW_IRAM1 0x100000C8 0x7F38 {
; 32KB (RAM size) - 0xC8 (NIVT) - 32 (topmost 32 bytes used by IAP functions) = 0x7F18
RW_IRAM1 0x100000C8 0x7F18 {
.ANY (+RW +ZI)
}
RW_IRAM2 0x2007C000 0x4000 { ; RW data, ETH RAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8)
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8 - 32) /* topmost 32 bytes used by IAP functions */

USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MEMORY
{
FLASH (rx) : ORIGIN = 0x00002000, LENGTH = 504K
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8)
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8 - 32) /* topmost 32 bytes used by IAP functions */

USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MEMORY
{
/* Define each memory region */
MFlash512 (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512k */
RamLoc32 (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F38 /* 32k */
RamLoc32 (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F18 /* 32k (topmost 32 bytes used by IAP functions) */
RamAHB_USB (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x4000 /* 16k */
RamAHB_Eth (rwx) : ORIGIN = 0x20080000, LENGTH = 0x4000 /* 16k */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ SEARCH_DIR(.)

/*
ram ORIGIN: 8_byte_aligned(49 vect * 4 bytes) = 8_byte_aligned(0xC4) = 0xC8
ram LENGTH: 32KB - 0xC8 = 0x7F38
ram LENGTH: 32KB (RAM size) - 0xC8 (NIVT) - 32 (topmost 32 bytes used by IAP functions) = 0x7F18
*/
MEMORY
{
rom (rx) : ORIGIN = 0x00000000, LENGTH = 512K

ram (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F38
ram (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F18

ram1(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
ram2(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
Expand Down
66 changes: 66 additions & 0 deletions targets/TARGET_NXP/TARGET_LPC176X/device/flash_api.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* mbed Microcontroller Library
* Copyright (c) 2017 ARM Limited
*
* 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 "platform/mbed_critical.h"

// This file is automatically generated

#if DEVICE_FLASH

// This is a flash algo binary blob. It is PIC (position independent code) that should be stored in RAM
static uint32_t FLASH_ALGO[] = {
0x28100b00, 0x210ed302, 0x00d0eb01, 0xf44f4770, 0xfbb1707a, 0x4933f0f0, 0x60084449, 0x20014932,
0x20006408, 0x20004770, 0xe92d4770, 0xf7ff41f0, 0x4d2effe7, 0x444d4604, 0xe9c52032, 0xf1050400,
0x4e2b0114, 0x4628460f, 0x47b060ac, 0xb9686968, 0xe9c52034, 0x48230400, 0x444860ac, 0x68004639,
0x462860e8, 0x696847b0, 0xd0002800, 0xe8bd2001, 0xe92d81f0, 0x461441f0, 0xd10e0006, 0x0100e9d4,
0xe9d44408, 0x44111202, 0x69214408, 0x69614408, 0x69a14408, 0x42404408, 0x463061e0, 0xffb0f7ff,
0x21324d12, 0x4f12444d, 0x1000e9c5, 0x0114f105, 0x468860a8, 0x47b84628, 0xb9806968, 0xe9c52033,
0xf44f0600, 0xe9c56080, 0x48064002, 0x44484641, 0x61286800, 0x47b84628, 0x28006968, 0x2001d0c7,
0x0000e7c5, 0x00000004, 0x400fc000, 0x00000008, 0x1fff1ff1, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
};

static const flash_algo_t flash_algo_config = {
.init = 0xf,
.uninit = 0x27,
.erase_sector = 0x2b,
.program_page = 0x73,
.static_base = 0xf4,
.algo_blob = FLASH_ALGO
};

static const sector_info_t sectors_info[] = {
{0x0, 0x1000},
{0x10000, 0x8000},
};

static const flash_target_config_t flash_target_config = {
.page_size = 0x400,
.flash_start = 0x0,
.flash_size = 0x80000,
.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;
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#include "flash_api.h"
#include "flash_data.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

// This file is automagically generated
// This file is automatically generated

#if DEVICE_FLASH

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#include "flash_api.h"
#include "flash_data.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"

// This file is automagically generated
// This file is automatically generated

#if DEVICE_FLASH

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "flash_data.h"
#include "mbed_critical.h"

// This file is automagically generated
// This file is automatically generated

#if DEVICE_FLASH

Expand Down
16 changes: 8 additions & 8 deletions targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@
"LPC1768": {
"inherits": ["LPCTarget"],
"core": "Cortex-M3",
"extra_labels": ["NXP", "LPC176X", "MBED_LPC1768"],
"extra_labels": ["NXP", "LPC176X", "MBED_LPC1768", "FLASH_CMSIS_ALGO"],
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"],
"detect_code": ["1010"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ERROR_PATTERN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "LOCALFILESYSTEM", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SEMIHOST", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ERROR_PATTERN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "LOCALFILESYSTEM", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SEMIHOST", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"],
"release_versions": ["2", "5"],
"features": ["LWIP"],
"device_name": "LPC1768"
Expand All @@ -244,10 +244,10 @@
"supported_form_factors": ["ARDUINO"],
"core": "Cortex-M3",
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"],
"extra_labels": ["NXP", "LPC176X"],
"extra_labels": ["NXP", "LPC176X", "FLASH_CMSIS_ALGO"],
"macros": ["TARGET_LPC1768"],
"inherits": ["LPCTarget"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ERROR_PATTERN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ERROR_PATTERN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"],
"release_versions": ["2", "5"],
"features": ["LWIP"],
"device_name": "LPC1768"
Expand All @@ -256,10 +256,10 @@
"supported_form_factors": ["ARDUINO"],
"core": "Cortex-M3",
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"],
"extra_labels": ["NXP", "LPC176X"],
"extra_labels": ["NXP", "LPC176X", "FLASH_CMSIS_ALGO"],
"macros": ["TARGET_LPC1768"],
"inherits": ["LPCTarget"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ERROR_RED", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ERROR_RED", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"],
"release_versions": ["2", "5"],
"features": ["LWIP"],
"device_name": "LPC1768"
Expand All @@ -268,10 +268,10 @@
"inherits": ["LPCTarget"],
"core": "Cortex-M3",
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"],
"extra_labels": ["NXP", "LPC176X", "XBED_LPC1768"],
"extra_labels": ["NXP", "LPC176X", "XBED_LPC1768", "FLASH_CMSIS_ALGO"],
"macros": ["TARGET_LPC1768"],
"detect_code": ["1010"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ERROR_PATTERN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "LOCALFILESYSTEM", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SEMIHOST", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ERROR_PATTERN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "LOCALFILESYSTEM", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SEMIHOST", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"],
"device_name": "LPC1768"
},
"LPC2368": {
Expand Down