Skip to content

Commit 2d22db2

Browse files
authored
Merge pull request #4169 from 0x6d61726b/master
[NXP LPC176X] flash_api.c implementation
2 parents aa80b55 + 7d9e1d4 commit 2d22db2

File tree

11 files changed

+88
-22
lines changed

11 files changed

+88
-22
lines changed

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ LR_IROM1 0x00000000 0x80000 { ; load region size_region
66
.ANY (+RO)
77
}
88
; 8_byte_aligned(49 vect * 4 bytes) = 8_byte_aligned(0xC4) = 0xC8
9-
; 32KB - 0xC8 = 0x7F38
10-
RW_IRAM1 0x100000C8 0x7F38 {
9+
; 32KB (RAM size) - 0xC8 (NIVT) - 32 (topmost 32 bytes used by IAP functions) = 0x7F18
10+
RW_IRAM1 0x100000C8 0x7F18 {
1111
.ANY (+RW +ZI)
1212
}
1313
RW_IRAM2 0x2007C000 0x4000 { ; RW data, USB RAM

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ LR_IROM1 0x00000000 0x80000 { ; load region size_region
66
.ANY (+RO)
77
}
88
; 8_byte_aligned(49 vect * 4 bytes) = 8_byte_aligned(0xC4) = 0xC8
9-
; 32KB - 0xC8 = 0x7F38
10-
RW_IRAM1 0x100000C8 0x7F38 {
9+
; 32KB (RAM size) - 0xC8 (NIVT) - 32 (topmost 32 bytes used by IAP functions) = 0x7F18
10+
RW_IRAM1 0x100000C8 0x7F18 {
1111
.ANY (+RW +ZI)
1212
}
1313
RW_IRAM2 0x2007C000 0x4000 { ; RW data, ETH RAM

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
MEMORY
55
{
66
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K
7-
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8)
7+
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8 - 32) /* topmost 32 bytes used by IAP functions */
88

99
USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
1010
ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/TARGET_XBED_LPC1768/XBED_LPC1768.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
MEMORY
55
{
66
FLASH (rx) : ORIGIN = 0x00002000, LENGTH = 504K
7-
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8)
7+
RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8 - 32) /* topmost 32 bytes used by IAP functions */
88

99
USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
1010
ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_CR/LPC1768.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MEMORY
77
{
88
/* Define each memory region */
99
MFlash512 (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512k */
10-
RamLoc32 (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F38 /* 32k */
10+
RamLoc32 (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F18 /* 32k (topmost 32 bytes used by IAP functions) */
1111
RamAHB_USB (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x4000 /* 16k */
1212
RamAHB_Eth (rwx) : ORIGIN = 0x20080000, LENGTH = 0x4000 /* 16k */
1313

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_CS/LPC1768.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ SEARCH_DIR(.)
2020

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

29-
ram (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F38
29+
ram (rwx) : ORIGIN = 0x100000C8, LENGTH = 0x7F18
3030

3131
ram1(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
3232
ram2(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "flash_api.h"
18+
#include "flash_data.h"
19+
#include "platform/mbed_critical.h"
20+
21+
// This file is automatically generated
22+
23+
#if DEVICE_FLASH
24+
25+
// This is a flash algo binary blob. It is PIC (position independent code) that should be stored in RAM
26+
static uint32_t FLASH_ALGO[] = {
27+
0x28100b00, 0x210ed302, 0x00d0eb01, 0xf44f4770, 0xfbb1707a, 0x4933f0f0, 0x60084449, 0x20014932,
28+
0x20006408, 0x20004770, 0xe92d4770, 0xf7ff41f0, 0x4d2effe7, 0x444d4604, 0xe9c52032, 0xf1050400,
29+
0x4e2b0114, 0x4628460f, 0x47b060ac, 0xb9686968, 0xe9c52034, 0x48230400, 0x444860ac, 0x68004639,
30+
0x462860e8, 0x696847b0, 0xd0002800, 0xe8bd2001, 0xe92d81f0, 0x461441f0, 0xd10e0006, 0x0100e9d4,
31+
0xe9d44408, 0x44111202, 0x69214408, 0x69614408, 0x69a14408, 0x42404408, 0x463061e0, 0xffb0f7ff,
32+
0x21324d12, 0x4f12444d, 0x1000e9c5, 0x0114f105, 0x468860a8, 0x47b84628, 0xb9806968, 0xe9c52033,
33+
0xf44f0600, 0xe9c56080, 0x48064002, 0x44484641, 0x61286800, 0x47b84628, 0x28006968, 0x2001d0c7,
34+
0x0000e7c5, 0x00000004, 0x400fc000, 0x00000008, 0x1fff1ff1, 0x00000000, 0x00000000, 0x00000000,
35+
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
36+
};
37+
38+
static const flash_algo_t flash_algo_config = {
39+
.init = 0xf,
40+
.uninit = 0x27,
41+
.erase_sector = 0x2b,
42+
.program_page = 0x73,
43+
.static_base = 0xf4,
44+
.algo_blob = FLASH_ALGO
45+
};
46+
47+
static const sector_info_t sectors_info[] = {
48+
{0x0, 0x1000},
49+
{0x10000, 0x8000},
50+
};
51+
52+
static const flash_target_config_t flash_target_config = {
53+
.page_size = 0x400,
54+
.flash_start = 0x0,
55+
.flash_size = 0x80000,
56+
.sectors = sectors_info,
57+
.sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t)
58+
};
59+
60+
void flash_set_target_config(flash_t *obj)
61+
{
62+
obj->flash_algo = &flash_algo_config;
63+
obj->target_config = &flash_target_config;
64+
}
65+
66+
#endif

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xI/device/flash_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
#include "flash_api.h"
1818
#include "flash_data.h"
19-
#include "mbed_critical.h"
19+
#include "platform/mbed_critical.h"
2020

21-
// This file is automagically generated
21+
// This file is automatically generated
2222

2323
#if DEVICE_FLASH
2424

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/device/flash_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
#include "flash_api.h"
1818
#include "flash_data.h"
19-
#include "mbed_critical.h"
19+
#include "platform/mbed_critical.h"
2020

21-
// This file is automagically generated
21+
// This file is automatically generated
2222

2323
#if DEVICE_FLASH
2424

targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/flash_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "flash_data.h"
1919
#include "mbed_critical.h"
2020

21-
// This file is automagically generated
21+
// This file is automatically generated
2222

2323
#if DEVICE_FLASH
2424

targets/targets.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@
224224
"LPC1768": {
225225
"inherits": ["LPCTarget"],
226226
"core": "Cortex-M3",
227-
"extra_labels": ["NXP", "LPC176X", "MBED_LPC1768"],
227+
"extra_labels": ["NXP", "LPC176X", "MBED_LPC1768", "FLASH_CMSIS_ALGO"],
228228
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"],
229229
"detect_code": ["1010"],
230-
"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"],
230+
"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"],
231231
"release_versions": ["2", "5"],
232232
"features": ["LWIP"],
233233
"device_name": "LPC1768"
@@ -236,10 +236,10 @@
236236
"supported_form_factors": ["ARDUINO"],
237237
"core": "Cortex-M3",
238238
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"],
239-
"extra_labels": ["NXP", "LPC176X"],
239+
"extra_labels": ["NXP", "LPC176X", "FLASH_CMSIS_ALGO"],
240240
"macros": ["TARGET_LPC1768"],
241241
"inherits": ["LPCTarget"],
242-
"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"],
242+
"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"],
243243
"release_versions": ["2", "5"],
244244
"features": ["LWIP"],
245245
"device_name": "LPC1768"
@@ -248,10 +248,10 @@
248248
"supported_form_factors": ["ARDUINO"],
249249
"core": "Cortex-M3",
250250
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"],
251-
"extra_labels": ["NXP", "LPC176X"],
251+
"extra_labels": ["NXP", "LPC176X", "FLASH_CMSIS_ALGO"],
252252
"macros": ["TARGET_LPC1768"],
253253
"inherits": ["LPCTarget"],
254-
"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"],
254+
"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"],
255255
"release_versions": ["2", "5"],
256256
"features": ["LWIP"],
257257
"device_name": "LPC1768"
@@ -260,10 +260,10 @@
260260
"inherits": ["LPCTarget"],
261261
"core": "Cortex-M3",
262262
"supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"],
263-
"extra_labels": ["NXP", "LPC176X", "XBED_LPC1768"],
263+
"extra_labels": ["NXP", "LPC176X", "XBED_LPC1768", "FLASH_CMSIS_ALGO"],
264264
"macros": ["TARGET_LPC1768"],
265265
"detect_code": ["1010"],
266-
"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"],
266+
"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"],
267267
"device_name": "LPC1768"
268268
},
269269
"LPC2368": {

0 commit comments

Comments
 (0)