Eclipse and Codesourcery for ARM generate very large binary - eclipse

I'm writing firmware for TM4C1231H6PZ now. Some time ago I was helped to set-up IDE and toolchain, that were generating neat and working binaries for my project, ~8 kB large. After that, I did some directory moving and so on, and now the same IDE, working with the same project (I have restored whole project directory from archive) generates binary 520 Mb large, which is obviously wrong.
Looking into new binary, I see that there is code from 00000000 to 0000079b, after that there are only NULLs, and then some code from 20000000 to 2000002b. I believe that it has to be some code intended for SRAM, but I don't know what to do with it. I tried to just delete code starting from 20000000, but the resulting binary doesn't work on MCU.
May somebody help me to repair my IDE+toolchain to generate normal binaries as before?
I use Eclipse Kepler 2.0.2, Codesourcery Lite for ARM Toolchain (arm-2013.11-24-arm-none-eabi.exe installer) and TivaWare (SW-TM4C-2.1.0.12573.exe).
Here's my linker script file:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 16K
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
}
SECTIONS
{
.text :
{
_text = .;
KEEP(*(.isr_vector))
*(.text*)
*(.rodata)
*(.rodata*)
_etext = .;
} > FLASH
/* C++ initialization and finalization data */
.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
.data : AT(ADDR(.text) + SIZEOF(.text) + SIZEOF(.preinit_array) + SIZEOF(.init_array) + SIZEOF(.fini_array))
{
. = ALIGN(4);
_data = .;
*(.data)
*(.data*)
. = ALIGN(4);
_edata = .;
} > SRAM
. = ALIGN(4);
.bss :
{
_bss = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
} > SRAM
}

Somewhere your code contains initial values or program code to be placed in RAM. You need to check your linker map file to figure out the name of this segment.
Let's say, you'll find
.ramfunc 0x123
0x20000000
In this case you need to add this section to your .data segment by adding
*(.data)
*(.data*)
*(.ramfunc) <-- this line
to your linker script.
The data segment will be placed in flash and copied to RAM by the initialization code before main() is called.

Related

Transmitting 255 bytes of data using stm32 i2c dma lower level driver example

I am currently using STM32L0538 Discovery board. In my project i have to use lower level drivers to interface i2c with slave device (ST25DV) using DMA.
I ported LL example to STM32L0538 DISCO board by referring the LL example project available for NUCLEO-L073RZ in the firmware repo (STM32Cube_FW_L0_V1.12.1).
The issue with example is i am only able to transmit 4-bytes of data (slave addr. + 3bytes of 8bit data), afterwards i2c generates stop condition although the number of data to be transmitted is more than 4 bytes both in DMA and I2C register. I think the issue is with DMA, as it accepts uint32_t type source memory addr. but my data is of uint8_t type. I have tried typecasting as shown in the demo LL example but it doesn't work.
**Can anyone please tell me how can i transmit more than just 4bytes of data or where i am going wrong. ** Thanks in advance.
Here is the sample code ported from STM32L0 Firmware repo which only send 4 bytes of data:
uint8_t aLedOn[5] = {0x12,0x34,0x56,0x77,88};
__IO uint8_t ubNbDataToTransmit = sizeof(aLedOn);
uint8_t* pTransmitBuffer = (uint8_t*)aLedOn;
__IO uint8_t ubTransferComplete = 0;
#define SLAVE_OWN_ADDRESS 0xAE
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
/* Configure the system clock */
SystemClock_Config();
MX_GPIO_Init();
/* USER CODE BEGIN 2 */
Configure_DMA();
Configure_I2C_Master();
LL_mDelay(1000);
Handle_I2C_Master();
/* USER CODE END 2 */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
}
void Configure_DMA(void)
{
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1);
NVIC_SetPriority(DMA1_Channel4_5_6_7_IRQn, 0);
NVIC_EnableIRQ(DMA1_Channel4_5_6_7_IRQn);
LL_DMA_ConfigTransfer(DMA1, LL_DMA_CHANNEL_4, LL_DMA_DIRECTION_MEMORY_TO_PERIPH | \
LL_DMA_PRIORITY_HIGH | \
LL_DMA_MODE_NORMAL | \
LL_DMA_PERIPH_NOINCREMENT | \
LL_DMA_MEMORY_INCREMENT | \
LL_DMA_PDATAALIGN_BYTE | \
LL_DMA_MDATAALIGN_BYTE);
LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_4, ubNbDataToTransmit);
LL_DMA_ConfigAddresses(DMA1, LL_DMA_CHANNEL_4, (uint32_t)pTransmitBuffer, (uint32_t)LL_I2C_DMA_GetRegAddr(I2C2, LL_I2C_DMA_REG_DATA_TRANSMIT), LL_DMA_GetDataTransferDirection(DMA1, LL_DMA_CHANNEL_4));
LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_4, LL_DMA_REQUEST_7);
LL_DMA_EnableIT_TC(DMA1, LL_DMA_CHANNEL_4);
LL_DMA_EnableIT_TE(DMA1, LL_DMA_CHANNEL_4);
}
void Configure_I2C_Master(void)
{
LL_I2C_InitTypeDef I2C_InitStruct = {0};
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
/* Enable the peripheral clock of GPIOC */
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
GPIO_InitStruct.Pin = LL_GPIO_PIN_13;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
GPIO_InitStruct.Alternate = LL_GPIO_AF_5;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LL_GPIO_PIN_14;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
GPIO_InitStruct.Alternate = LL_GPIO_AF_5;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C2);
LL_I2C_SetTiming(I2C2, 0x00100E16);
LL_I2C_SetOwnAddress1(I2C2, 0x00, LL_I2C_OWNADDRESS1_7BIT);
LL_I2C_DisableOwnAddress1(I2C2);
LL_I2C_EnableClockStretching(I2C2);
LL_I2C_SetDigitalFilter(I2C2, 0x00);
LL_I2C_EnableAnalogFilter(I2C2);
LL_I2C_EnableGeneralCall(I2C2);
LL_I2C_SetOwnAddress2(I2C2, 0x00, LL_I2C_OWNADDRESS2_NOMASK);
LL_I2C_DisableOwnAddress2(I2C2);
LL_I2C_SetMasterAddressingMode(I2C2, LL_I2C_ADDRESSING_MODE_7BIT);
LL_I2C_SetMode(I2C2, LL_I2C_MODE_I2C);
// (4) Enable DMA transmission requests a
LL_I2C_EnableDMAReq_TX(I2C2);
LL_I2C_Enable(I2C2);
}
void Handle_I2C_Master(void)
{
ubTransferComplete = 0;
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_4);
LL_I2C_HandleTransfer(I2C2, SLAVE_OWN_ADDRESS, LL_I2C_ADDRSLAVE_7BIT, ubNbDataToTransmit, LL_I2C_MODE_AUTOEND, LL_I2C_GENERATE_START_WRITE);
/* Loop until DMA transfer complete event */
while(!ubTransferComplete)
{
}
/* Loop until STOP flag is raised */
while(!LL_I2C_IsActiveFlag_STOP(I2C2))
{
}
LL_I2C_ClearFlag_STOP(I2C2);
}

How to clear linker error? cross-compiling stm32 on windows

I am trying to cross-compile a simple c/cpp file the target is an stm32f030F4P, I was successfully able to setup the CMake files, and cmake successfully build the build.ninja file for ninja.
When I execute ninja I get the following error
PS C:\Users\varun\Desktop\Projects\stm32f030f4p\Firmware\Blinky\build>
ninja.exe [1/1] Linking CXX executable .elf FAILED: .elf cmd.exe /C
"cd . && C:\DEV-TO~1\TOOLCH~1\GCC-AR~1\102020~1\bin\AR10B2~1.EXE
-march=armv6-m -mcpu=cortex-m0 -mthumb -DSTM32F030x4 -Og -ggdb -Wall -Wextra -ffunction-sections -fdata-sections -ffreestanding -fno-builtin --specs=nano.specs -fno-rtti -fno-exceptions -Wno-volatile -std=c++1z -g CMakeFiles/.elf.dir/src/main.cpp.obj -o .elf && cd ."
c:/dev-to~1/toolch~1/gcc-ar~1/102020~1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe:
c:/dev-to~1/toolch~1/gcc-ar~1/102020~1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libg_nano.a(lib_a-exit.o):
in function exit': exit.c:(.text.exit+0x1e): undefined reference to _exit' collect2.exe: error: ld returned 1 exit status ninja: build
stopped: subcommand failed. PS
Please find my CMakeLists.txt.
CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
INCLUDE("CMake/arm-none-eabi.cmake")
SET(CMAKE_C_STANDARD 11)
SET(CMAKE_CXX_STANDARD 17)
PROJECT(BLINKY VERSION 1.0.1 DESCRIPTION "Blinky Example")
FILE(GLOB_RECURSE
LDSCRIPTS
"ldscripts/*.ld"
)
FOREACH(file ${LDSCRIPTS})
SET(CMAKE_CAMKE_LINKER_FLAGS "${CAMKE_LINKER_FLAGS} -T \"${file}\" ")
ENDFOREACH()
#Setup project headers
INCLUDE_DIRECTORIES(
)
#Setup porject sources
FILE(GLOB_RECURSE
APPLICATION_SOURCE
"src/*.c"
"src/*.cpp"
)
ADD_EXECUTABLE(${PROJECT}.elf ${APPLICATION_SOURCE})
Please find my arm-none-eabi.cmake(excuse the copy paste toolchain name, had no clue what to name it)
MESSAGE("Running : arm-none-eabi.cmake")
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_C_COMPILER_WORKS TRUE)
SET(CMAKE_CXX_COMPILER_WORKS TRUE)
SET(CMAKE_TRY_COMPILE_TARGTE_TYPE STATIC_LIBRARY)
SET(TARGET STM32F030x4)
SET(ARCH armv6-m)
SET(CPU cortex-m0)
SET(ARM_ISA mthumb)
SET(CMAKE_C_COMPILER arm-none-eabi-gcc)
SET(CMAKE_CXX_COMPILER arm-none-eabi-g++)
SET(CMAKE_ASM_COMPILER arm-none-eabi-g++)
SET(CMAKE_SIZE arm-none-eabi-size)
SET(CMAKE_OBJDUMP arm-none-eabi-objdump)
SET(CMAKE_OBJCOPY arm-none-eabi-objcopy)
SET(OPTIMISATION Og)
SET(DEBUG "ggdb")
SET(CMAKE_COMMON_FLAGS "-march=${ARCH} -mcpu=${CPU} -${ARM_ISA} -D${TARGET} -${OPTIMISATION} -${DEBUG} -Wall -Wextra -ffunction-sections -fdata-sections -ffreestanding -fno-builtin --specs=nano.specs")
SET(CMAKE_ASM_FLAGS "${CMAKE_COMMON_FLAGS} ")
SET(CMAKE_C_FLAGS "${CMAKE_COMMON_FLAGS} -std=gnull")
SET(CMAKE_CXX_FLAGS "${CMAKE_COMMON_FLAGS} -fno-rtti -fno-exceptions -Wno-volatile -std=c++1z")
SET(CAMKE_LINKER_FLAGS "${CMAKE_COMMON_FLAGS} -nostartfiles -Wl, -Map, \"${TARGET}.map\" --specs-nano.specs")
My linker script is a copy paste from STM32CubeIDE
> /* Entry Point */ ENTRY(Reset_Handler)
>
> /* Highest address of the user mode stack */
> _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
>
> _Min_Heap_Size = 0x200 ; /* required amount of heap */
> _Min_Stack_Size = 0x400 ; /* required amount of stack */
>
> /* Memories definition */ MEMORY { RAM (xrw) : ORIGIN =
> 0x20000000, LENGTH = 4K FLASH (rx) : ORIGIN = 0x8000000,
> LENGTH = 16K }
>
> /* Sections */ SECTIONS { /* The startup code into "FLASH" Rom type
> memory */ .isr_vector : {
> . = ALIGN(4);
> KEEP(*(.isr_vector)) /* Startup code */
> . = ALIGN(4); } >FLASH
>
> /* The program code and other data into "FLASH" Rom type memory */
> .text : {
> . = ALIGN(4);
> *(.text) /* .text sections (code) */
> *(.text*) /* .text* sections (code) */
> *(.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
>
> /* Constant data into "FLASH" Rom type memory */ .rodata : {
> . = ALIGN(4);
> *(.rodata) /* .rodata sections (constants, strings, etc.) */
> *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
> . = ALIGN(4); } >FLASH
>
> .ARM.extab : {
> . = ALIGN(4);
> *(.ARM.extab* .gnu.linkonce.armextab.*)
> . = ALIGN(4); } >FLASH
>
> .ARM : {
> . = ALIGN(4);
> __exidx_start = .;
> *(.ARM.exidx*)
> __exidx_end = .;
> . = ALIGN(4); } >FLASH
>
> .preinit_array : {
> . = ALIGN(4);
> PROVIDE_HIDDEN (__preinit_array_start = .);
> KEEP (*(.preinit_array*))
> PROVIDE_HIDDEN (__preinit_array_end = .);
> . = ALIGN(4); } >FLASH
>
> .init_array : {
> . = ALIGN(4);
> PROVIDE_HIDDEN (__init_array_start = .);
> KEEP (*(SORT(.init_array.*)))
> KEEP (*(.init_array*))
> PROVIDE_HIDDEN (__init_array_end = .);
> . = ALIGN(4); } >FLASH
>
> .fini_array : {
> . = ALIGN(4);
> PROVIDE_HIDDEN (__fini_array_start = .);
> KEEP (*(SORT(.fini_array.*)))
> KEEP (*(.fini_array*))
> PROVIDE_HIDDEN (__fini_array_end = .);
> . = ALIGN(4); } >FLASH
>
> /* Used by the startup to initialize data */ _sidata =
> LOADADDR(.data);
>
> /* Initialized data sections into "RAM" Ram type memory */ .data :
> {
> . = ALIGN(4);
> _sdata = .; /* create a global symbol at data start */
> *(.data) /* .data sections */
> *(.data*) /* .data* sections */
> *(.RamFunc) /* .RamFunc sections */
> *(.RamFunc*) /* .RamFunc* sections */
>
> . = ALIGN(4);
> _edata = .; /* define a global symbol at data end */
>
> } >RAM AT> FLASH
>
> /* Uninitialized data section into "RAM" Ram type memory */ . =
> ALIGN(4); .bss : {
> /* This is used by the startup in order to initialize the .bss section */
> _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; } >RAM
>
> /* User_heap_stack section, used to check that there is enough "RAM"
> Ram type memory left */ ._user_heap_stack : {
> . = ALIGN(8);
> PROVIDE ( end = . );
> PROVIDE ( _end = . );
> . = . + _Min_Heap_Size;
> . = . + _Min_Stack_Size;
> . = ALIGN(8); } >RAM
>
> /* Remove information from the compiler libraries */ /DISCARD/ :
> {
> libc.a ( * )
> libm.a ( * )
> libgcc.a ( * ) }
>
> .ARM.attributes 0 : { *(.ARM.attributes) } }
And finally c file is simple
unsigned int counter;
int main(void)
{
for(;;)
{
counter++;
}
}

How to define platform_data in a Linux 3.8 device tree structure (DTS) file

I'm trying to get the at86rf230 kernel driver running on a BeagleBone Black to communicate with my radio. I have confirmed that I am able to interact with the device using some userspace SPI code. Here's the fragment of the DTS file I'm working with:
fragment#0 {
target = <&am33xx_pinmux>;
__overlay__ {
spi1_pins_s0: spi1_pins_s0 {
pinctrl-single,pins = <
0x040 0x37 /* DIG2 GPIO_9.15 I_PULLUP | MODE7-GPIO1_16 */
0x044 0x17 /* SLPTR GPIO_9.23 O_PULLUP | MODE7-GPIO1_17 */
0x1AC 0x17 /* RSTN GPIO_9.25 O_PULLUP | MODE7-GPIO3_21 */
0x1A4 0x37 /* IRQ GPIO_9.26 I_PULLUP | MODE7-GPIO3_19 */
0x190 0x33 /* SCLK mcasp0_aclkx.spi1_sclk, INPUT_PULLUP | MODE3 */
0x194 0x33 /* MISO mcasp0_fsx.spi1_d0, INPUT_PULLUP | MODE3 */
0x198 0x13 /* MOSI mcasp0_axr0.spi1_d1, OUTPUT_PULLUP | MODE3 */
0x19c 0x13 /* SCS0 mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */
>;
};
};
};
fragment#3 {
target = <&spi1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins_s0>;
at86rf230#0 {
spi-max-frequency = <1000000>;
reg = <0>;
compatible = "at86rf230";
interrupts = <19>;
interrupt-parent = <&gpio3>;
};
};
};
On loading the module I get the following error in dmesg:
[ 352.668833] at86rf230 spi1.0: no platform_data
[ 352.668945] at86rf230: probe of spi1.0 failed with error -22
I am trying to work out the right way to attach platform_data to the SPI overlay. Here's what I'd like to attach:
platform_data {
rstn = <&gpio3 21 0>;
slp_tr = <&gpio1 17 0>;
dig2 = <&gpio1 16 0>;
};
Unfortunately, just sticking it in as-is doesn't work so well when I use dtc to compile the DTS. I get the following error:
syntax error: properties must precede subnodes
FATAL ERROR: Unable to parse input tree
I feel that I'm ridiculously close to solving this, and I just need a little shove in the right direction ;)
First of all, the GPIO names in your excerpt are wrong. Accordingly to the latest code in linux-next there are
pdata->rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
pdata->slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
There are only two of them.
Second, you have to adjust the DTS for your exact board. The entire DTS has to be considered as a platform data for all devices found on the board (some supported, some might be not). The section for the specific device should be described as device node.
So, the good start point is to check what is in upstream already exists, namely in arch/arm/boot/dts/am335x-boneblack.dts, don't forget to check included files as well.
And the example for this specific driver is in Documentation/devicetree/bindings/net/ieee802154/at86rf230.txt.

Eclipse Arduino Linker trouble

I have been trying to get my Arduino/Eclipse environment setup. For some reason I keep having trouble with the linker.
Here is the error I receive when trying to build.
So there is a conflict between libgcc and libc?
I have followed these instructions pretty close, but there are some nuances.
**** Build of configuration Debug for project CustomLEDPoi ****
make all
Building target: CustomLEDPoi.elf
Invoking: AVR C++ Linker
avr-gcc -Wl,-Map,CustomLEDPoi.map,--cref -Wl,--gc-sections -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino" -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src" -Xlinker -verbose -mmcu=atmega328p -o "CustomLEDPoi.elf" ./src/glowstick2.o ./lib/CShiftPWM.o ./lib/MeetAndroid.o ./lib/hsv2rgb.o ./arduinolib/HardwareSerial.o ./arduinolib/SPI.o -lArduinoCore
GNU ld (WinAVR 20081205) 2.19
Supported emulations:
avr2
avr1
avr25
avr3
avr31
avr35
avr4
avr5
avr51
avr6
avrxmega1
avrxmega2
avrxmega3
avrxmega4
avrxmega5
avrxmega6
avrxmega7
cannot find script file ldscripts/avr5.x
opened script file c:\users\justin\arduino\arduino-1.0\hardware\tools\avr\avr\bin\../lib\ldscripts/avr5.x
using external linker script:
==================================================
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:5)
MEMORY
{
text (rx) : ORIGIN = 0, LENGTH = 128K
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K
lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K
signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K
}
SECTIONS
{
/* Read-only sections, merged into text segment: */
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
/* Internal text space or external memory. */
.text :
{
*(.vectors)
KEEP(*(.vectors))
/* For data that needs to reside in the lower 64k of progmem. */
*(.progmem.gcc*)
*(.progmem*)
. = ALIGN(2);
__trampolines_start = . ;
/* The jump trampolines for the 16-bit limited relocs will reside here. */
*(.trampolines)
*(.trampolines*)
__trampolines_end = . ;
/* For future tablejump instruction arrays for 3 byte pc devices.
We don't relax jump/call instructions within these sections. */
*(.jumptables)
*(.jumptables*)
/* For code that needs to reside in the lower 128k progmem. */
*(.lowtext)
*(.lowtext*)
__ctors_start = . ;
*(.ctors)
__ctors_end = . ;
__dtors_start = . ;
*(.dtors)
__dtors_end = . ;
KEEP(SORT(*)(.ctors))
KEEP(SORT(*)(.dtors))
/* From this point on, we don't bother about wether the insns are
below or above the 16 bits boundary. */
*(.init0) /* Start here after reset. */
KEEP (*(.init0))
*(.init1)
KEEP (*(.init1))
*(.init2) /* Clear __zero_reg__, set up stack pointer. */
KEEP (*(.init2))
*(.init3)
KEEP (*(.init3))
*(.init4) /* Initialize data and BSS. */
KEEP (*(.init4))
*(.init5)
KEEP (*(.init5))
*(.init6) /* C++ constructors. */
KEEP (*(.init6))
*(.init7)
KEEP (*(.init7))
*(.init8)
KEEP (*(.init8))
*(.init9) /* Call main(). */
KEEP (*(.init9))
*(.text)
. = ALIGN(2);
*(.text.*)
. = ALIGN(2);
*(.fini9) /* _exit() starts here. */
KEEP (*(.fini9))
*(.fini8)
KEEP (*(.fini8))
*(.fini7)
KEEP (*(.fini7))
*(.fini6) /* C++ destructors. */
KEEP (*(.fini6))
*(.fini5)
KEEP (*(.fini5))
*(.fini4)
KEEP (*(.fini4))
*(.fini3)
KEEP (*(.fini3))
*(.fini2)
KEEP (*(.fini2))
*(.fini1)
KEEP (*(.fini1))
*(.fini0) /* Infinite loop after program termination. */
KEEP (*(.fini0))
_etext = . ;
} > text
.data : AT (ADDR (.text) + SIZEOF (.text))
{
PROVIDE (__data_start = .) ;
*(.data)
*(.data*)
*(.rodata) /* We need to include .rodata here if gcc is used */
*(.rodata*) /* with -fdata-sections. */
*(.gnu.linkonce.d*)
. = ALIGN(2);
_edata = . ;
PROVIDE (__data_end = .) ;
} > data
.bss : AT (ADDR (.bss))
{
PROVIDE (__bss_start = .) ;
*(.bss)
*(.bss*)
*(COMMON)
PROVIDE (__bss_end = .) ;
} > data
__data_load_start = LOADADDR(.data);
__data_load_end = __data_load_start + SIZEOF(.data);
/* Global data not cleared after reset. */
.noinit :
{
PROVIDE (__noinit_start = .) ;
*(.noinit*)
PROVIDE (__noinit_end = .) ;
_end = . ;
PROVIDE (__heap_start = .) ;
} > data
.eeprom :
{
*(.eeprom*)
__eeprom_end = . ;
} > eeprom
.fuse :
{
KEEP(*(.fuse))
KEEP(*(.lfuse))
KEEP(*(.hfuse))
KEEP(*(.efuse))
} > fuse
.lock :
{
KEEP(*(.lock*))
} > lock
.signature :
{
KEEP(*(.signature*))
} > signature
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
}
==================================================
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/crtm328p.o succeeded
c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/crtm328p.o
attempt to open ./src/glowstick2.o succeeded
./src/glowstick2.o
attempt to open ./lib/CShiftPWM.o succeeded
./lib/CShiftPWM.o
attempt to open ./lib/MeetAndroid.o succeeded
./lib/MeetAndroid.o
attempt to open ./lib/hsv2rgb.o succeeded
./lib/hsv2rgb.o
attempt to open ./arduinolib/HardwareSerial.o succeeded
./arduinolib/HardwareSerial.o
attempt to open ./arduinolib/SPI.o succeeded
./arduinolib/SPI.o
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino/libArduinoCore.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\libArduinoCore.a failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src/libArduinoCore.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a succeeded
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)wiring.c.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)wiring_digital.c.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)main.cpp.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)new.cpp.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)Print.cpp.o
(C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libArduinoCore.a)WString.cpp.o
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino/libgcc.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\libgcc.a failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src/libgcc.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libgcc.a failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5/libgcc.so failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a succeeded
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_mulsi3.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_udivmodhi4.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_divmodhi4.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_udivmodsi4.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_exit.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_copy_data.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_clear_bss.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_ctors.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_dtors.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_fixunssfsi.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_addsub_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_mul_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_div_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_gt_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_ge_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_lt_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_si_to_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_sf_to_si.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_thenan_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_usi_to_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_prologue.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_epilogue.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_tablejump.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_clzsi2.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_pack_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_unpack_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_fpcmp_parts_sf.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a)_clz.o
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino/libc.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\libc.a failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src/libc.so failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libc.a failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5/libc.so failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libc.a failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/libc.so failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a succeeded
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)malloc.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)realloc.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)atof.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)atoi.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)atol.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)isspace.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)tolower.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)toupper.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)memcpy.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)memmove.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strchr.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strcmp.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strcpy.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strncmp.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strncpy.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strrchr.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strstr.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)itoa.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)ltoa.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)mulsi10.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)mul10.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)ultoa.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)utoa.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strtod.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)cty_isfalse.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strncasecmp_P.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)strrev.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)cmpsf2.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)fp_cmp.o
(c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a)errno.o
c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a(cmpsf2.o): In function `__lesf2':
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino/libgcc.so failed
(.text.fplib+0x0): multiple definition of `__ltsf2'
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\libgcc.a failed
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src/libgcc.so failed
c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a(_lt_sf.o):(.text+0x0): first defined here
attempt to open C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src\libgcc.a failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5/libgcc.so failed
attempt to open c:/users/justin/arduino/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr5\libgcc.a succeeded
make: *** [CustomLEDPoi.elf] Error 1
**** Build Finished ****
I realized that I did not add the libary m. So I appended -lm using the add libraries option.
The make file now has this command.
avr-g++ -o"CustomLEDPoi.elf" ./src/glowstick2.o ./lib/CShiftPWM.o ./lib/MeetAndroid.o ./lib/hsv2rgb.o ./arduinolib/HardwareSerial.o ./arduinolib/SPI.o -larduino_core -lm -Wl,-Map,CustomLEDPoi.map,--cref -Wl,--gc-sections -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino" -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src" -Xlinker -verbose -mmcu=atmega328p
This still gave me the same issue.
Looking at the guide at http://arduino.cc/playground/Code/Eclipse
It says,
If you're using C++ then the hex file can get really big. In the
linker menu, change the command to avr-gcc and the command line
pattern to the following: ${COMMAND} --cref -s -Os
${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} -lm ${FLAGS}
My make file now has this command.
avr-g++ --cref -s -Os -o"CustomLEDPoi.elf" ./src/glowstick2.o ./lib/CShiftPWM.o ./lib/MeetAndroid.o ./lib/hsv2rgb.o ./arduinolib/HardwareSerial.o ./arduinolib/SPI.o -larduino_core -lm -lm -Wl,-Map,CustomLEDPoi.map,--cref -Wl,--gc-sections -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino" -L"C:\Users\Justin\workspaceArduino\arduino_core\328P_16MHz Arduino\src" -Xlinker -verbose -mmcu=atmega328p
here is catastrohic error for ATmega32 (avr5) in GCC linker script:
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
the manual declares:
(0xC6) UDR0 USART I/O Data Register
the at address (0xC6) will be owerwritten by by user .data

How can I make an empty section with GNU ld?

I'm working on a cortex-m3 chip. The stack space was reserved in the source code with an uninitialized array on the bss section. The linker script I used is as follows:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256k
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64k
}
SECTIONS {
.text : {
KEEP(*(.isr_vector))
*(.text*)
*(.rodata*)
__text_end = .;
} >FLASH
.data : {
__data_start = .;
*(.data*)
__data_end = .;
} >SRAM AT>FLASH
.bss : {
__bss_start = .;
*(.bss*)
__bss_end = .;
} >SRAM
}
I'm trying to allocate a section for the stack in the beginning of the SRAM region so that i could detect stack overflow with usage fault.
I added a section named .stack:
SECTIONS {
.text : {
:
} >FLASH
.stack : {
__stack_size = 4k;
__stack_start = .;
. = . + __stack_size;
. = ALIGN(8); /* cortex-m3 uses full-descending stack aligned with 8 bytes */
__stack_end = .;
} >SRAM
.data : {
:
} >SRAM AT>FLASH
.bss : {
:
} >SRAM
}
Linking is done without any error or warning, but the problem is that __stack_end is not on the SRAM region but on the FLASH region.
I know I can use a separate section given with __attribute__((section("name"))) but I think it would be better if I can deal with it in the linker script.
How can I make an empty section on SRAM region?
Just split the RAM area in two:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256k
SRAM_STACK (rwx) : ORIGIN = 0x20000000, LENGTH = 4k
SRAM (rwx) : ORIGIN = 0x20001000, LENGTH = 60k
}
SECTIONS {
.text : {
KEEP(*(.isr_vector))
*(.text*)
*(.rodata*)
__text_end = .;
} >FLASH
.data : {
__data_start = .;
*(.data*)
__data_end = .;
} >SRAM AT>FLASH
.bss : {
__bss_start = .;
*(.bss*)
__bss_end = .;
} >SRAM
.stack : {
__stack_size = 4k;
__stack_start = .;
. = . + __stack_size;
. = ALIGN(8); /* cortex-m3 uses full-descending stack aligned with 8 bytes */
__stack_end = .;
} >SRAM_STACK
}