[Taranis X9E] Variables moved to CCM Memory. Around 45k RAM saved.

This commit is contained in:
bsongis
2015-06-29 18:25:25 +02:00
parent 1086ae85e5
commit 5680f00fd3
15 changed files with 246 additions and 51 deletions
-162
View File
@@ -1,162 +0,0 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/**
* \file syscalls.c
*
* Implementation of newlib syscall.
*
*/
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
// #include "board.h"
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
/*----------------------------------------------------------------------------
* Exported variables
*----------------------------------------------------------------------------*/
#undef errno
extern int errno;
extern int _end;
extern int _main_stack_start;
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern void _exit( int status ) ;
extern void _kill( int pid, int sig ) ;
extern int _getpid ( void ) ;
unsigned char *heap = (unsigned char *)&_end;
extern caddr_t _sbrk(int nbytes)
{
if (heap + nbytes < (unsigned char *)&_main_stack_start) {
unsigned char *prev_heap = heap;
heap += nbytes;
return (caddr_t) prev_heap;
}
else {
errno = ENOMEM;
return ((void*)-1);
}
}
extern int _gettimeofday(void *p1, void *p2)
{
return 0 ;
}
extern int _link( char *old, char *nw )
{
return -1 ;
}
extern int _unlink (const char *path)
{
return -1 ;
}
extern int _open(const char *name, int flags, int mode)
{
return -1 ;
}
extern int _close( int file )
{
return -1 ;
}
extern int _fstat( int file, struct stat *st )
{
st->st_mode = S_IFCHR ;
return 0 ;
}
extern int _isatty( int file )
{
return 1 ;
}
extern int _lseek( int file, int ptr, int dir )
{
return 0 ;
}
extern int _read(int file, char *ptr, int len)
{
return 0 ;
}
extern int _write( int file, char *ptr, int len )
{
int iIndex ;
// for ( ; *ptr != 0 ; ptr++ )
for ( iIndex=0 ; iIndex < len ; iIndex++, ptr++ )
{
// TODO UART_PutChar( *ptr ) ;
}
return iIndex ;
}
extern void _exit( int status )
{
#if defined(SIMU)
printf( "Exiting with status %d.\n", status ) ;
#endif
for ( ; ; ) ;
}
extern void _kill( int pid, int sig )
{
return ;
}
extern int _getpid ( void )
{
return -1 ;
}
void _init (void)
{
}
+1 -1
View File
@@ -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()
{
@@ -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
+30 -11
View File
@@ -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 */
-2
View File
@@ -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
@@ -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 */
@@ -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
+180
View File
@@ -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) }
}