Skip to content

Commit e18e0f1

Browse files
committed
MXRT1050_EVK: Ensure certain low power function are linked to internal memory
Low power functions related to powering off FLEXSPI and SDRAM needs to be copied to internal memory Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent a1d8298 commit e18e0f1

File tree

5 files changed

+63
-37
lines changed

5 files changed

+63
-37
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/mbed_overrides.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* limitations under the License.
1515
*/
1616
#include "pinmap.h"
17-
1817
#include "fsl_clock_config.h"
1918
#include "fsl_clock.h"
19+
#include "lpm.h"
2020

2121
#define LPSPI_CLOCK_SOURCE_DIVIDER (7U)
2222
#define LPI2C_CLOCK_SOURCE_DIVIDER (5U)
@@ -124,11 +124,39 @@ void BOARD_ConfigMPU(void)
124124
SCB_EnableICache();
125125
}
126126

127+
#if defined(TOOLCHAIN_GCC_ARM)
128+
extern uint32_t __ram_function_flash_start[];
129+
#define __RAM_FUNCTION_FLASH_START __ram_function_flash_start
130+
extern uint32_t __ram_function_ram_start[];
131+
#define __RAM_FUNCTION_RAM_START __ram_function_ram_start
132+
extern uint32_t __ram_function_size[];
133+
#define __RAM_FUNCTION_SIZE __ram_function_size
134+
void Board_CopyToRam()
135+
{
136+
unsigned char *source;
137+
unsigned char *destiny;
138+
unsigned int size;
139+
140+
source = (unsigned char *)(__RAM_FUNCTION_FLASH_START);
141+
destiny = (unsigned char *)(__RAM_FUNCTION_RAM_START);
142+
size = (unsigned long)(__RAM_FUNCTION_SIZE);
143+
144+
while (size--)
145+
{
146+
*destiny++ = *source++;
147+
}
148+
}
149+
#endif
150+
127151
// called before main
128152
void mbed_sdk_init()
129153
{
130154
BOARD_ConfigMPU();
131155
BOARD_BootClockRUN();
156+
#if defined(TOOLCHAIN_GCC_ARM)
157+
Board_CopyToRam();
158+
#endif
159+
LPM_Init();
132160
}
133161

134162
void spi_setup_clock()

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/device/TOOLCHAIN_ARM_STD/MIMXRT1052xxxxx.sct

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
#define m_text_start 0x60002400
7878
#define m_text_size 0x03FFDC00
7979

80+
#define m_text2_start 0x00000000
81+
#define m_text2_size 0x00020000
82+
8083
#define m_data_start 0x80000000
8184
#define m_data_size 0x01E00000
8285

@@ -139,6 +142,9 @@ LR_IROM1 m_flash_config_start m_text_start+m_text_size-m_flash_config_start {
139142
}
140143
ARM_LIB_STACK m_data_start+m_data_size EMPTY -Stack_Size { ; Stack region growing down
141144
}
145+
RW_m_ram_text m_text2_start UNINIT m_text2_size { ; load address = execution address
146+
* (RamFunction)
147+
}
142148
RW_m_ncache m_ncache_start m_ncache_size { ; ncache RW data
143149
* (NonCacheable.init)
144150
* (NonCacheable)

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/device/TOOLCHAIN_GCC_ARM/MIMXRT1052xxxxx.ld

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ MEMORY
7272
m_ivt (RX) : ORIGIN = 0x60001000, LENGTH = 0x00001000
7373
m_interrupts (RX) : ORIGIN = 0x60002000, LENGTH = 0x00000400
7474
m_text (RX) : ORIGIN = 0x60002400, LENGTH = 0x03FFDC00
75+
m_text2 (RX) : ORIGIN = 0x00000000, LENGTH = 0x00020000
7576
m_data (RW) : ORIGIN = 0x80000000, LENGTH = 0x01E00000
7677
m_ncache (RW) : ORIGIN = 0x81E00000, LENGTH = 0x00200000
7778
m_data2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00020000
@@ -225,7 +226,21 @@ SECTIONS
225226
__data_end__ = .; /* define a global symbol at data end */
226227
} > m_data
227228

228-
__NDATA_ROM = __DATA_ROM + (__data_end__ - __data_start__);
229+
__ram_function_flash_start = __DATA_ROM + (__data_end__ - __data_start__); /* Symbol is used by startup for TCM data initialization */
230+
231+
.ram_function : AT(__ram_function_flash_start)
232+
{
233+
. = ALIGN(32);
234+
__ram_function_ram_start = .;
235+
*(RamFunction)
236+
. = ALIGN(128);
237+
__ram_function_ram_end = .;
238+
} > m_text2
239+
240+
__ram_function_size = SIZEOF(.ram_function);
241+
242+
__NDATA_ROM = __ram_function_flash_start + SIZEOF(.ram_function);
243+
229244
.ncache.init : AT(__NDATA_ROM)
230245
{
231246
__noncachedata_start__ = .; /* create a global symbol at ncache data start */

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/device/TOOLCHAIN_IAR/MIMXRT1052xxxxx.icf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ define symbol m_interrupts_end = 0x600023FF;
6767
define symbol m_text_start = 0x60002400;
6868
define symbol m_text_end = 0x63FFFFFF;
6969

70+
define symbol m_text2_start = 0x00000000;
71+
define symbol m_text2_end = 0x0001FFFF;
72+
7073
define symbol m_interrupts_ram_start = 0x20000000;
7174
define symbol m_interrupts_ram_end = 0x20000000 + __ram_vector_table_offset__;
7275

@@ -108,6 +111,8 @@ define memory mem with size = 4G;
108111
define region TEXT_region = mem:[from m_interrupts_start to m_interrupts_end]
109112
| mem:[from m_text_start to m_text_end];
110113

114+
define region TEXT2_region = mem:[from m_text2_start to m_text2_end];
115+
111116
define region DATA_region = mem:[from m_data_start to m_data_end];
112117
define region DATA2_region = mem:[from m_data2_start to m_data2_end];
113118
define region DATA3_region = mem:[from m_data3_start to m_data3_end-__size_cstack__];
@@ -139,4 +144,5 @@ place in DATA3_region { block ZI };
139144
place in DATA3_region { last block HEAP };
140145
place in CSTACK_region { block CSTACK };
141146
place in NCACHE_region { block NCACHE_VAR };
147+
place in TEXT2_region { section .textrw};
142148
place in m_interrupts_ram_region { section m_interrupts_ram };

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/drivers/fsl_common.h

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
44
* Copyright 2016-2017 NXP
55
* All rights reserved.
6-
*
6+
*
77
* Redistribution and use in source and binary forms, with or without modification,
88
* are permitted (subject to the limitations in the disclaimer below) provided
99
* that the following conditions are met:
@@ -149,7 +149,7 @@ enum _status_groups
149149
kStatusGroup_LPC_MINISPI = 76, /*!< Group number for LPC_MINISPI status codes. */
150150
kStatusGroup_NOTIFIER = 98, /*!< Group number for NOTIFIER status codes. */
151151
kStatusGroup_DebugConsole = 99, /*!< Group number for debug console status codes. */
152-
kStatusGroup_SEMC = 100, /*!< Group number for SEMC status codes. */
152+
kStatusGroup_SEMC = 100, /*!< Group number for SEMC status codes. */
153153
kStatusGroup_ApplicationRangeStart = 101, /*!< Starting number for application groups. */
154154
};
155155

@@ -347,35 +347,6 @@ _Pragma("diag_suppress=Pm120")
347347
/* @} */
348348

349349
/*! @name Time sensitive region */
350-
/* @{ */
351-
#if defined(FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE) && FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE
352-
#if (defined(__ICCARM__))
353-
#define AT_QUICKACCESS_SECTION_CODE(func) func @"CodeQuickAccess"
354-
#define AT_QUICKACCESS_SECTION_DATA(func) func @"DataQuickAccess"
355-
#elif(defined(__ARMCC_VERSION))
356-
#define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("CodeQuickAccess"))) func
357-
#define AT_QUICKACCESS_SECTION_DATA(func) __attribute__((section("DataQuickAccess"))) func
358-
#elif(defined(__GNUC__))
359-
#define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("CodeQuickAccess"))) func
360-
#define AT_QUICKACCESS_SECTION_DATA(func) __attribute__((section("DataQuickAccess"))) func
361-
#else
362-
#error Toolchain not supported.
363-
#endif /* defined(__ICCARM__) */
364-
#else
365-
#if (defined(__ICCARM__))
366-
#define AT_QUICKACCESS_SECTION_CODE(func) func
367-
#define AT_QUICKACCESS_SECTION_DATA(func) func
368-
#elif(defined(__ARMCC_VERSION))
369-
#define AT_QUICKACCESS_SECTION_CODE(func) func
370-
#define AT_QUICKACCESS_SECTION_DATA(func) func
371-
#elif(defined(__GNUC__))
372-
#define AT_QUICKACCESS_SECTION_CODE(func) func
373-
#define AT_QUICKACCESS_SECTION_DATA(func) func
374-
#else
375-
#error Toolchain not supported.
376-
#endif
377-
#endif /* __FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE */
378-
/* @} */
379350

380351
/*******************************************************************************
381352
* API
@@ -557,15 +528,15 @@ _Pragma("diag_suppress=Pm120")
557528
* @param size The length required to malloc.
558529
* @param alignbytes The alignment size.
559530
* @retval The allocated memory.
560-
*/
531+
*/
561532
void *SDK_Malloc(size_t size, size_t alignbytes);
562-
533+
563534
/*!
564535
* @brief Free memory.
565536
*
566537
* @param ptr The memory to be release.
567-
*/
568-
void SDK_Free(void *ptr);
538+
*/
539+
void SDK_Free(void *ptr);
569540

570541
#if defined(__cplusplus)
571542
}

0 commit comments

Comments
 (0)