From 5680f00fd3f18508ebcc4b7285e5995a9257a27a Mon Sep 17 00:00:00 2001 From: bsongis Date: Sat, 9 May 2015 08:47:46 +0200 Subject: [PATCH] [Taranis X9E] Variables moved to CCM Memory. Around 45k RAM saved. --- radio/src/Makefile | 9 +- radio/src/audio_arm.cpp | 3 +- radio/src/audio_arm.h | 13 +- radio/src/gui/Taranis/lcd.cpp | 6 +- radio/src/opentx.cpp | 2 +- radio/src/opentx.h | 9 +- radio/src/pulses/pulses_arm.cpp | 4 +- radio/src/{targets/sky9x => }/syscalls.c | 4 +- radio/src/targets/taranis/adc_driver.cpp | 2 +- radio/src/targets/taranis/bootloader/Makefile | 2 +- radio/src/targets/taranis/diskio.cpp | 41 ++-- radio/src/targets/taranis/lcd_driver.cpp | 2 - .../{stm32_ramBoot.ld => stm32_ramboot.ld} | 2 +- .../{stm32_flash_bl.ld => stm32f2_flash.ld} | 18 +- radio/src/targets/taranis/stm32f4_flash.ld | 180 ++++++++++++++++++ 15 files changed, 246 insertions(+), 51 deletions(-) rename radio/src/{targets/sky9x => }/syscalls.c (93%) rename radio/src/targets/taranis/{stm32_ramBoot.ld => stm32_ramboot.ld} (99%) rename radio/src/targets/taranis/{stm32_flash_bl.ld => stm32f2_flash.ld} (87%) create mode 100755 radio/src/targets/taranis/stm32f4_flash.ld diff --git a/radio/src/Makefile b/radio/src/Makefile index ee6e4a72b..4fa3d694e 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -818,7 +818,7 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO)) CPPSRC += targets/sky9x/bluetooth.cpp endif ifeq ($(DEBUG), YES) - SRC += targets/sky9x/syscalls.c + SRC += syscalls.c endif endif @@ -880,7 +880,6 @@ ifeq ($(PCB), TARANIS) ifeq ($(SUPPORT_D16_EU_ONLY), YES) CPPDEFS += -DMODULE_D16_EU_ONLY_SUPPORT endif - LDSCRIPT = targets/taranis/stm32_flash_bl.ld TRGT = arm-none-eabi- OPT = s BITMAPS += $(patsubst %.png,%.lbm,$(wildcard bitmaps/Taranis/*.png)) bitmaps/Taranis/mainmenu.lbm @@ -900,11 +899,13 @@ ifeq ($(PCB), TARANIS) CPPDEFS += -DHSE_VALUE=12000000 ifeq ($(PCBREV), REV9E) STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries - CPPDEFS += -DSTM32F40_41xxx + CPPDEFS += -DSTM32F4 -DSTM32F40_41xxx INCDIRS += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Include $(STM32LIBPATH)/CMSIS/Include $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/inc + LDSCRIPT = targets/taranis/stm32f4_flash.ld else STM32LIBPATH= $(THIRDPARTY)/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries INCDIRS += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/inc $(STM32LIBPATH)/CMSIS/Device/ST/STM32F2xx/Include $(STM32LIBPATH)/CMSIS/include + LDSCRIPT = targets/taranis/stm32f2_flash.ld endif STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries INCDIRS += $(STM32USBPATH)/STM32_USB_OTG_Driver/inc $(STM32USBPATH)/STM32_USB_Device_Library/Core/inc @@ -956,7 +957,7 @@ ifeq ($(PCB), TARANIS) SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_ioreq.c SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_req.c EXTRABOARDSRC += targets/taranis/usbd_usr.cpp - SRC += targets/sky9x/syscalls.c + SRC += syscalls.c ifeq ($(USB), JOYSTICK) CPPDEFS += -DUSB_JOYSTICK SRC += targets/taranis/usbd_hid_joystick.c diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index 0308ea8a1..113542cb3 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -465,10 +465,12 @@ const int16_t alawTable[256] = { -5504, -5248, -6016, -5760, -4480, -4224, -4992 const int16_t ulawTable[256] = { -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764, -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412, -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316, -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140, -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004, -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436, -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, -876, -844, -812, -780, -748, -716, -684, -652, -620, -588, -556, -524, -492, -460, -428, -396, -372, -356, -340, -324, -308, -292, -276, -260, -244, -228, -212, -196, -180, -164, -148, -132, -120, -112, -104, -96, -88, -80, -72, -64, -56, -48, -40, -32, -24, -16, -8, 0, 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, 876, 844, 812, 780, 748, 716, 684, 652, 620, 588, 556, 524, 492, 460, 428, 396, 372, 356, 340, 324, 308, 292, 276, 260, 244, 228, 212, 196, 180, 164, 148, 132, 120, 112, 104, 96, 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0 }; AudioQueue audioQueue; +AudioBuffer audioBuffers[AUDIO_BUFFER_COUNT] _NOCCM; AudioQueue::AudioQueue() { memset(this, 0, sizeof(AudioQueue)); + memset(audioBuffers, 0, sizeof(audioBuffers)); } void AudioQueue::start() @@ -476,7 +478,6 @@ void AudioQueue::start() state = 1; } - #define CODEC_ID_PCM_S16LE 1 #define CODEC_ID_PCM_ALAW 6 #define CODEC_ID_PCM_MULAW 7 diff --git a/radio/src/audio_arm.h b/radio/src/audio_arm.h index 868d441a5..a74648277 100644 --- a/radio/src/audio_arm.h +++ b/radio/src/audio_arm.h @@ -67,6 +67,8 @@ struct AudioBuffer { uint8_t state; }; +extern AudioBuffer audioBuffers[AUDIO_BUFFER_COUNT]; + enum FragmentTypes { FRAGMENT_EMPTY, FRAGMENT_TONE, @@ -197,14 +199,14 @@ class AudioQueue { inline AudioBuffer * getNextFilledBuffer() { - if (buffers[bufferRIdx].state == AUDIO_BUFFER_PLAYING) { - buffers[bufferRIdx].state = AUDIO_BUFFER_FREE; + if (audioBuffers[bufferRIdx].state == AUDIO_BUFFER_PLAYING) { + audioBuffers[bufferRIdx].state = AUDIO_BUFFER_FREE; bufferRIdx = nextBufferIdx(bufferRIdx); } uint8_t idx = bufferRIdx; do { - AudioBuffer * buffer = &buffers[idx]; + AudioBuffer * buffer = &audioBuffers[idx]; if (buffer->state == AUDIO_BUFFER_FILLED) { buffer->state = AUDIO_BUFFER_PLAYING; bufferRIdx = idx; @@ -219,7 +221,7 @@ class AudioQueue { bool filledAtleast(int noBuffers) { int count = 0; for(int n= 0; n= noBuffers) { return true; } @@ -243,7 +245,6 @@ class AudioQueue { ToneContext priorityContext; ToneContext varioContext; - AudioBuffer buffers[AUDIO_BUFFER_COUNT]; uint8_t bufferRIdx; uint8_t bufferWIdx; @@ -254,7 +255,7 @@ class AudioQueue { inline AudioBuffer * getEmptyBuffer() { - AudioBuffer * buffer = &buffers[bufferWIdx]; + AudioBuffer * buffer = &audioBuffers[bufferWIdx]; if (buffer->state == AUDIO_BUFFER_FREE) return buffer; else diff --git a/radio/src/gui/Taranis/lcd.cpp b/radio/src/gui/Taranis/lcd.cpp index 5c2692e28..500a4280c 100755 --- a/radio/src/gui/Taranis/lcd.cpp +++ b/radio/src/gui/Taranis/lcd.cpp @@ -38,11 +38,11 @@ #include "../../timers.h" #if defined(REVPLUS) && defined(LCD_DUAL_BUFFER) - display_t displayBuf1[DISPLAY_BUF_SIZE]; - display_t displayBuf2[DISPLAY_BUF_SIZE]; + display_t displayBuf1[DISPLAY_BUF_SIZE] _NOCCM; + display_t displayBuf2[DISPLAY_BUF_SIZE] _NOCCM; display_t * displayBuf = displayBuf1; #else - display_t displayBuf[DISPLAY_BUF_SIZE]; + display_t displayBuf[DISPLAY_BUF_SIZE] _NOCCM; #endif void lcd_clear() diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 13270eb22..db1421add 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1724,7 +1724,7 @@ void opentxStart() doSplash(); #if defined(DEBUG_TRACE_BUFFER) - trace_event(trace_start, 0x12345678); + trace_event(trace_start, 0x12345678); #endif #if defined(PCBSKY9X) && defined(SDCARD) && !defined(SIMU) diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 7efae5d33..c428680f7 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -212,6 +212,12 @@ #define ROTARY_ENCODER_NAVIGATION #endif +#if defined(STM32F4) + #define _NOCCM __attribute__((section(".ram"))) +#else + #define _NOCCM +#endif + #if defined(SIMU) || defined(CPUARM) || GCC_VERSION < 472 typedef int32_t int24_t; #else @@ -706,7 +712,8 @@ extern uint8_t flightModeTransitionLast; extern int _end; extern int _estack; extern int _main_stack_start; - #define getAvailableMemory() ((unsigned int)((unsigned char *)&_main_stack_start - heap)) + extern int _heap_end; + #define getAvailableMemory() ((unsigned int)((unsigned char *)&_heap_end - heap)) #endif void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms); diff --git a/radio/src/pulses/pulses_arm.cpp b/radio/src/pulses/pulses_arm.cpp index 2cfab5464..1abb76261 100644 --- a/radio/src/pulses/pulses_arm.cpp +++ b/radio/src/pulses/pulses_arm.cpp @@ -41,8 +41,8 @@ uint8_t s_current_protocol[NUM_MODULES] = { MODULES_INIT(255) }; uint16_t failsafeCounter[NUM_MODULES] = { MODULES_INIT(100) }; uint8_t moduleFlag[NUM_MODULES] = { 0 }; -ModulePulsesData modulePulsesData[NUM_MODULES]; -TrainerPulsesData trainerPulsesData; +ModulePulsesData modulePulsesData[NUM_MODULES] _NOCCM; +TrainerPulsesData trainerPulsesData _NOCCM; void setupPulses(unsigned int port) { diff --git a/radio/src/targets/sky9x/syscalls.c b/radio/src/syscalls.c similarity index 93% rename from radio/src/targets/sky9x/syscalls.c rename to radio/src/syscalls.c index 09b70aa81..13480a3ff 100644 --- a/radio/src/targets/sky9x/syscalls.c +++ b/radio/src/syscalls.c @@ -54,7 +54,7 @@ #undef errno extern int errno; extern int _end; -extern int _main_stack_start; +extern int _heap_end; /*---------------------------------------------------------------------------- * Exported functions @@ -66,7 +66,7 @@ extern int _getpid ( void ) ; unsigned char *heap = (unsigned char *)&_end; extern caddr_t _sbrk(int nbytes) { - if (heap + nbytes < (unsigned char *)&_main_stack_start) { + if (heap + nbytes < (unsigned char *)&_heap_end) { unsigned char *prev_heap = heap; heap += nbytes; return (caddr_t) prev_heap; diff --git a/radio/src/targets/taranis/adc_driver.cpp b/radio/src/targets/taranis/adc_driver.cpp index 18df1e8ff..2e815436f 100644 --- a/radio/src/targets/taranis/adc_driver.cpp +++ b/radio/src/targets/taranis/adc_driver.cpp @@ -66,7 +66,7 @@ #define NUMBER_ANALOG_ADC1 10 #endif -uint16_t Analog_values[NUMBER_ANALOG]; +uint16_t Analog_values[NUMBER_ANALOG] _NOCCM; void adcInit() { diff --git a/radio/src/targets/taranis/bootloader/Makefile b/radio/src/targets/taranis/bootloader/Makefile index ed21ef625..7c536c6c5 100755 --- a/radio/src/targets/taranis/bootloader/Makefile +++ b/radio/src/targets/taranis/bootloader/Makefile @@ -91,7 +91,7 @@ STM32USBPATH = ../../../thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries # ifeq ($(PCB), TARANIS) ARCH = ARM - LDSCRIPT = ../stm32_ramBoot.ld + LDSCRIPT = ../stm32_ramboot.ld TRGT = arm-none-eabi- CPPDEFS += -DHSE_VALUE=12000000 CPPDEFS += -DPCBTARANIS -DEEPROM_RLC diff --git a/radio/src/targets/taranis/diskio.cpp b/radio/src/targets/taranis/diskio.cpp index 14928ff05..13e461cb9 100644 --- a/radio/src/targets/taranis/diskio.cpp +++ b/radio/src/targets/taranis/diskio.cpp @@ -230,6 +230,11 @@ void release_spi (void) } #ifdef SD_USE_DMA + +#if defined(STM32F4) +WORD rw_workbyte[1] _NOCCM; +#endif + /*-----------------------------------------------------------------------*/ /* Transmit/Receive Block using DMA (Platform dependent. STM32 here) */ /*-----------------------------------------------------------------------*/ @@ -243,7 +248,11 @@ void stm32_dma_transfer( ) { DMA_InitTypeDef DMA_InitStructure; - WORD dummy[] = { 0xffff }; +#if defined(STM32F4) + rw_workbyte[0] = 0xffff; +#else + WORD rw_workbyte[] = { 0xffff }; +#endif DMA_DeInit(SD_DMA_Stream_SPI_RX); DMA_DeInit(SD_DMA_Stream_SPI_TX); @@ -258,10 +267,10 @@ void stm32_dma_transfer( DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; - DMA_InitStructure.DMA_FIFOMode =DMA_FIFOMode_Enable; - DMA_InitStructure.DMA_FIFOThreshold =DMA_FIFOThreshold_Full; - DMA_InitStructure.DMA_MemoryBurst =DMA_MemoryBurst_Single; - DMA_InitStructure.DMA_PeripheralBurst =DMA_PeripheralBurst_Single; + DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; + DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; + DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; + DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; // separate RX & TX if (receive) { @@ -269,14 +278,14 @@ void stm32_dma_transfer( DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_Init(SD_DMA_Stream_SPI_RX, &DMA_InitStructure); - DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)dummy; + DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)rw_workbyte; DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_Init(SD_DMA_Stream_SPI_TX, &DMA_InitStructure); } else { #if _FS_READONLY == 0 - DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)dummy; + DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)rw_workbyte; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_Init(SD_DMA_Stream_SPI_RX, &DMA_InitStructure); @@ -399,6 +408,10 @@ void power_off (void) /* Receive a data packet from MMC */ /*-----------------------------------------------------------------------*/ +#if defined(SD_USE_DMA) && defined(STM32F4) + uint8_t sd_buff[512] _NOCCM; +#endif + static BOOL rcvr_datablock ( BYTE *buff, /* Data buffer to store received data */ @@ -418,8 +431,11 @@ BOOL rcvr_datablock ( return FALSE; /* If not valid data token, return with error */ } -#ifdef SD_USE_DMA - stm32_dma_transfer( TRUE, buff, btr ); +#if defined(SD_USE_DMA) && defined(STM32F4) + stm32_dma_transfer(TRUE, sd_buff, btr); + memcpy(buff, sd_buff, btr); +#elif defined(SD_USE_DMA) + stm32_dma_transfer(TRUE, buff, btr); #else do { /* Receive the data block into buffer */ rcvr_spi_m(buff++); @@ -463,8 +479,11 @@ BOOL xmit_datablock ( xmit_spi(token); /* transmit data token */ if (token != 0xFD) { /* Is data token */ -#ifdef SD_USE_DMA - stm32_dma_transfer( FALSE, buff, 512 ); +#if defined(SD_USE_DMA) && defined(STM32F4) + memcpy(sd_buff, buff, 512); + stm32_dma_transfer(FALSE, sd_buff, 512); +#elif defined(SD_USE_DMA) + stm32_dma_transfer(FALSE, buff, 512); #else wc = 0; do { /* transmit the 512 byte data block to MMC */ diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index 1c201f52f..b4ef70b11 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -54,7 +54,6 @@ void initLcdSpi() configure_pins( LCD_GPIO_PIN_A0, PIN_OUTPUT | PIN_PORTC | PIN_OS50) ; configure_pins( LCD_GPIO_PIN_MOSI|LCD_GPIO_PIN_CLK, PIN_PORTC | PIN_OS50 | PIN_PER_6 | PIN_PERIPHERAL ) ; - // NVIC_SetPriority( DMA1_Stream7_IRQn, 8 ) ; NVIC_EnableIRQ(DMA1_Stream7_IRQn) ; DMA1->HIFCR |= DMA_HIFCR_CTCIF7; //clear interrupt flag @@ -69,7 +68,6 @@ void initLcdSpi() DMA1_Stream7->NDTR = LCD_W*LCD_H/8*4 ; } - static void LCD_Init() { WriteCommand(0x2F); //Internal pump control diff --git a/radio/src/targets/taranis/stm32_ramBoot.ld b/radio/src/targets/taranis/stm32_ramboot.ld similarity index 99% rename from radio/src/targets/taranis/stm32_ramBoot.ld rename to radio/src/targets/taranis/stm32_ramboot.ld index 697df960b..f2e6e555a 100644 --- a/radio/src/targets/taranis/stm32_ramBoot.ld +++ b/radio/src/targets/taranis/stm32_ramboot.ld @@ -26,7 +26,7 @@ _estack = 0x20020000; /* end of 128K SRAM */ _Min_Heap_Size = 0; /* required amount of heap */ _Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */ -/*Main stack end*/ +/* Main stack end */ _main_stack_start = _estack - _Main_Stack_Size; /* Specify the memory areas */ diff --git a/radio/src/targets/taranis/stm32_flash_bl.ld b/radio/src/targets/taranis/stm32f2_flash.ld similarity index 87% rename from radio/src/targets/taranis/stm32_flash_bl.ld rename to radio/src/targets/taranis/stm32f2_flash.ld index 43f2eeb83..85eec7b88 100644 --- a/radio/src/targets/taranis/stm32_flash_bl.ld +++ b/radio/src/targets/taranis/stm32f2_flash.ld @@ -1,7 +1,7 @@ /* ***************************************************************************** ** -** File : stm32_flash.ld +** File : stm32f2_flash.ld ** ** Abstract : Linker script for STM32F205 Device with ** 0.5MByte FLASH, 128KByte SRAM @@ -13,19 +13,6 @@ ** ** Target : STMicroelectronics STM32 ** -** Environment : Atollic TrueSTUDIO(R) -** -** Distribution: The file is distributed �as is,� without any warranty -** of any kind. -** -** (c)Copyright Atollic AB. -** You may use this file as-is or modify it according to the needs of your -** project. Distribution of this file (unmodified or modified) is not -** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the -** rights to distribute the assembled, compiled & linked contents of this -** file as part of an application binary file, provided that it is built -** using the Atollic TrueSTUDIO(R) toolchain. -** ***************************************************************************** */ @@ -39,8 +26,9 @@ _estack = 0x20020000; /* end of 128K SRAM */ _Min_Heap_Size = 0; /* required amount of heap */ _Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */ -/*Main stack end*/ +/* Main stack end */ _main_stack_start = _estack - _Main_Stack_Size; +_heap_end = _main_stack_start; /* Specify the memory areas */ MEMORY diff --git a/radio/src/targets/taranis/stm32f4_flash.ld b/radio/src/targets/taranis/stm32f4_flash.ld new file mode 100755 index 000000000..c781c89d0 --- /dev/null +++ b/radio/src/targets/taranis/stm32f4_flash.ld @@ -0,0 +1,180 @@ +/* +***************************************************************************** +** +** File : stm32f4_flash.ld +** +** Abstract : Linker script for STM32F407 Device with +** 0.5MByte FLASH, 128KByte SRAM, 64KByte CCM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x10010000; /* end of 64K CCM */ +_heap_end = 0x20020000; /* end of 128K SRAM */ + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0; /* required amount of heap */ +_Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */ + +/* Main stack end */ +_main_stack_start = _estack - _Main_Stack_Size; + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K + CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K + MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + + /* The program code and other data goes into FLASH */ + .text : + { + FILL(0xFFFF) + + CREATE_OBJECT_SYMBOLS + + KEEP(*(.isr_boot_vector)) /* Startup code */ + *(.bootrodata) + *(.bootrodata.*) + + . = 32768; /* Set the start of the main program */ + _stext = .; /* Provide the name for the start of this section */ + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array*)) + KEEP (*(SORT(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = .; + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : AT ( _sidata ) + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >CCM + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + /* __bss_start__ = _sbss; */ + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + /* __bss_end__ = _ebss; */ + } >CCM + + /* collect all uninitialized .ccm sections */ + .ram (NOLOAD) : + { + . = ALIGN(4); + _sram = .; + /* __ccm_start__ = _sccm; */ + *(.ram) + . = ALIGN(4); + _eram = .; + /* __ccm_end__ = _eccm; */ + } >RAM + + PROVIDE ( end = _eram ); + PROVIDE ( _end = _eram ); + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + . = . + _Min_Heap_Size; + . = . + _Main_Stack_Size; + . = ALIGN(4); + } >RAM + + /* MEMORY_bank1 section, code must be located here explicitly */ + /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ + .memory_b1_text : + { + *(.mb1text) /* .mb1text sections (code) */ + *(.mb1text*) /* .mb1text* sections (code) */ + *(.mb1rodata) /* read-only data (constants) */ + *(.mb1rodata*) + } >MEMORY_B1 + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +}