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

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++;
}
}

Related

How to add recipe in yocto to build curl example?

I can build the test.c without using yocto in my terminal easily. So this means
there is no problem with the test.c or the libcurl in my host machine.
However, when I build using yocto it complains that it cannot find curl/curl.h.
DEBUG: Executing shell function do_compile
| test.c:5:10: fatal error: curl/curl.h: No such file or directory
| #include <curl/curl.h>
| ^~~~~~~~~~~~~
| compilation terminated.
| WARNING: exit code 1 from a shell command.
Here is my directory structure which contains my example based out of libcurl.
├── curlTest
│   ├── curlTest
│   │   ├── README.txt
│   │   └── test.c
│   └── curlTest.bb
Here is my curlTest.bb
curlTest.bb
SUMMARY = "Simple Hello World Application"
DESCRIPTION = "A test application to demonstrate how to create a recipe \
by directly compiling C files with BitBake."
SECTION = "examples"
PRIORITY = "optional"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "\
file://README.txt;md5=321180101a13e8916e6753497a4f9c82"
SRC_URI = "file://test.c \
file://README.txt"
S = "${WORKDIR}"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} -o testCurl test.c -lcurl
}
do_install() {
install -d ${D}${bindir}
install -m 0755 hello ${D}${bindir}
}
Here is the example of libcurl based out of the libcurl website.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
struct MemoryStruct {
char *memory;
size_t size;
};
static size_t
WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)userp;
char *ptr = realloc(mem->memory, mem->size + realsize + 1);
if(ptr == NULL) {
/* out of memory! */
printf("not enough memory (realloc returned NULL)\n");
return 0;
}
mem->memory = ptr;
memcpy(&(mem->memory[mem->size]), contents, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
return realsize;
}
int main(void)
{
CURL *curl_handle;
CURLcode res;
struct MemoryStruct chunk;
chunk.memory = malloc(1); /* will be grown as needed by the realloc above */
chunk.size = 0; /* no data at this point */
curl_global_init(CURL_GLOBAL_ALL);
/* init the curl session */
curl_handle = curl_easy_init();
/* specify URL to get */
curl_easy_setopt(curl_handle, CURLOPT_URL, "https://www.example.com/");
/* send all data to this function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
/* we pass our 'chunk' struct to the callback function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
/* some servers don't like requests that are made without a user-agent
field, so we provide one */
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
/* get it! */
res = curl_easy_perform(curl_handle);
/* check for errors */
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
}
else {
/*
* Now, our chunk.memory points to a memory block that is chunk.size
* bytes big and contains the remote file.
*
* Do something nice with it!
*/
printf("%lu bytes retrieved\n", (unsigned long)chunk.size);
}
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
free(chunk.memory);
/* we're done with libcurl, so clean it up */
curl_global_cleanup();
return 0;
}

Eclipse and Codesourcery for ARM generate very large binary

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.

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
}

How to run a .patch file with several diffs inside

I have never used a .patch file but I need to run SEGGER's FreeRTOSV10_Core.patch file.
The shown file can be found in the SystemView Zip Archive.
diff -rupN org/Source/include/FreeRTOS.h new/Source/include/FreeRTOS.h
--- org/Source/include/FreeRTOS.h 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/include/FreeRTOS.h 2017-12-11 00:54:49.522222000 -0800
## -157,6 +157,10 ## extern "C" {
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#endif
+#ifndef INCLUDE_pxTaskGetStackStart
+ #define INCLUDE_pxTaskGetStackStart 0
+#endif
+
#ifndef INCLUDE_eTaskGetState
#define INCLUDE_eTaskGetState 0
#endif
## -393,6 +397,23 ## extern "C" {
#define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
#endif
+#ifndef traceREADDED_TASK_TO_READY_STATE
+ #define traceREADDED_TASK_TO_READY_STATE( pxTCB ) traceMOVED_TASK_TO_READY_STATE( pxTCB )
+#endif
+
+#ifndef traceMOVED_TASK_TO_DELAYED_LIST
+ #define traceMOVED_TASK_TO_DELAYED_LIST()
+#endif
+
+#ifndef traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST
+ #define traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST()
+#endif
+
+#ifndef traceMOVED_TASK_TO_SUSPENDED_LIST
+ #define traceMOVED_TASK_TO_SUSPENDED_LIST( pxTCB )
+#endif
+
+
#ifndef traceQUEUE_CREATE
#define traceQUEUE_CREATE( pxNewQueue )
#endif
## -637,6 +658,18 ## extern "C" {
#define traceTASK_NOTIFY_GIVE_FROM_ISR()
#endif
+#ifndef traceISR_EXIT_TO_SCHEDULER
+ #define traceISR_EXIT_TO_SCHEDULER()
+#endif
+
+#ifndef traceISR_EXIT
+ #define traceISR_EXIT()
+#endif
+
+#ifndef traceISR_ENTER
+ #define traceISR_ENTER()
+#endif
+
#ifndef traceSTREAM_BUFFER_CREATE_FAILED
#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
#endif
diff -rupN org/Source/include/task.h new/Source/include/task.h
--- org/Source/include/task.h 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/include/task.h 2017-12-11 00:56:29.783423000 -0800
## -1422,6 +1422,25 ## TaskHandle_t xTaskGetHandle( const char
*/
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
+/**
+ * task.h
+ * <PRE>uint8_t* pxTaskGetStackStart( TaskHandle_t xTask);</PRE>
+ *
+ * INCLUDE_pxTaskGetStackStart must be set to 1 in FreeRTOSConfig.h for
+ * this function to be available.
+ *
+ * Returns the start of the stack associated with xTask. That is,
+ * the highest stack memory address on architectures where the stack grows down
+ * from high memory, and the lowest memory address on architectures where the
+ * stack grows up from low memory.
+ *
+ * #param xTask Handle of the task associated with the stack returned.
+ * Set xTask to NULL to return the stack of the calling task.
+ *
+ * #return A pointer to the start of the stack.
+ */
+uint8_t* pxTaskGetStackStart( TaskHandle_t xTask) PRIVILEGED_FUNCTION;
+
/* When using trace macros it is sometimes necessary to include task.h before
FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
so the following two prototypes will cause a compilation error. This can be
diff -rupN org/Source/portable/GCC/ARM_CM0/port.c new/Source/portable/GCC/ARM_CM0/port.c
--- org/Source/portable/GCC/ARM_CM0/port.c 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/portable/GCC/ARM_CM0/port.c 2017-12-11 01:11:45.061429000 -0800
## -333,13 +333,19 ## void xPortSysTickHandler( void )
uint32_t ulPreviousMask;
ulPreviousMask = portSET_INTERRUPT_MASK_FROM_ISR();
+ traceISR_ENTER();
{
/* Increment the RTOS tick. */
if( xTaskIncrementTick() != pdFALSE )
{
+ traceISR_EXIT_TO_SCHEDULER();
/* Pend a context switch. */
*(portNVIC_INT_CTRL) = portNVIC_PENDSVSET;
}
+ else
+ {
+ traceISR_EXIT();
+ }
}
portCLEAR_INTERRUPT_MASK_FROM_ISR( ulPreviousMask );
}
diff -rupN org/Source/portable/GCC/ARM_CM0/portmacro.h new/Source/portable/GCC/ARM_CM0/portmacro.h
--- org/Source/portable/GCC/ARM_CM0/portmacro.h 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/portable/GCC/ARM_CM0/portmacro.h 2017-12-11 01:10:27.732228000 -0800
## -82,7 +82,7 ## extern void vPortYield( void );
#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portYIELD() vPortYield()
-#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
+#define portEND_SWITCHING_ISR( xSwitchRequired ) { if( xSwitchRequired ) { traceISR_EXIT_TO_SCHEDULER(); portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } else { traceISR_EXIT(); } }
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
/*-----------------------------------------------------------*/
diff -rupN org/Source/portable/GCC/ARM_CM3/port.c new/Source/portable/GCC/ARM_CM3/port.c
--- org/Source/portable/GCC/ARM_CM3/port.c 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/portable/GCC/ARM_CM3/port.c 2017-12-11 01:14:50.515630000 -0800
## -431,14 +431,20 ## void xPortSysTickHandler( void )
save and then restore the interrupt mask value as its value is already
known. */
portDISABLE_INTERRUPTS();
+ traceISR_ENTER();
{
/* Increment the RTOS tick. */
if( xTaskIncrementTick() != pdFALSE )
{
+ traceISR_EXIT_TO_SCHEDULER();
/* A context switch is required. Context switching is performed in
the PendSV interrupt. Pend the PendSV interrupt. */
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
}
+ else
+ {
+ traceISR_EXIT();
+ }
}
portENABLE_INTERRUPTS();
}
diff -rupN org/Source/portable/GCC/ARM_CM3/portmacro.h new/Source/portable/GCC/ARM_CM3/portmacro.h
--- org/Source/portable/GCC/ARM_CM3/portmacro.h 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/portable/GCC/ARM_CM3/portmacro.h 2017-12-11 01:13:36.868029000 -0800
## -90,7 +90,7 ## typedef unsigned long UBaseType_t;
#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
-#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) portYIELD()
+#define portEND_SWITCHING_ISR( xSwitchRequired ) {} if( xSwitchRequired != pdFALSE ) { traceISR_EXIT_TO_SCHEDULER(); portYIELD() } else { traceISR_EXIT(); } }
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
/*-----------------------------------------------------------*/
diff -rupN org/Source/portable/GCC/ARM_CM4F/port.c new/Source/portable/GCC/ARM_CM4F/port.c
--- org/Source/portable/GCC/ARM_CM4F/port.c 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/portable/GCC/ARM_CM4F/port.c 2017-12-11 01:16:01.771230000 -0800
## -493,14 +493,20 ## void xPortSysTickHandler( void )
save and then restore the interrupt mask value as its value is already
known. */
portDISABLE_INTERRUPTS();
+ traceISR_ENTER();
{
/* Increment the RTOS tick. */
if( xTaskIncrementTick() != pdFALSE )
{
+ traceISR_EXIT_TO_SCHEDULER();
/* A context switch is required. Context switching is performed in
the PendSV interrupt. Pend the PendSV interrupt. */
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
}
+ else
+ {
+ traceISR_EXIT();
+ }
}
portENABLE_INTERRUPTS();
}
diff -rupN org/Source/portable/GCC/ARM_CM4F/portmacro.h new/Source/portable/GCC/ARM_CM4F/portmacro.h
--- org/Source/portable/GCC/ARM_CM4F/portmacro.h 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/portable/GCC/ARM_CM4F/portmacro.h 2017-12-11 01:15:16.546830000 -0800
## -90,7 +90,7 ## typedef unsigned long UBaseType_t;
#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
-#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) portYIELD()
+#define portEND_SWITCHING_ISR( xSwitchRequired ) { if( xSwitchRequired != pdFALSE ) { traceISR_EXIT_TO_SCHEDULER(); portYIELD(); } else { traceISR_EXIT(); } }
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
/*-----------------------------------------------------------*/
diff -rupN org/Source/tasks.c new/Source/tasks.c
--- org/Source/tasks.c 2017-11-28 13:48:34.000000000 -0800
+++ new/Source/tasks.c 2017-12-11 01:08:48.591428000 -0800
## -237,6 +237,17 ## count overflows. */
taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \
vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \
tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
+
+/*
+ * Place the task represented by pxTCB which has been in a ready list before
+ * into the appropriate ready list for the task.
+ * It is inserted at the end of the list.
+ */
+#define prvReaddTaskToReadyList( pxTCB ) \
+ traceREADDED_TASK_TO_READY_STATE( pxTCB ); \
+ taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \
+ vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \
+ tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
/*-----------------------------------------------------------*/
/*
## -1598,7 +1609,7 ## static void prvAddNewTaskToReadyList( TC
{
mtCOVERAGE_TEST_MARKER();
}
- prvAddTaskToReadyList( pxTCB );
+ prvReaddTaskToReadyList( pxTCB );
}
else
{
## -1659,7 +1670,7 ## static void prvAddNewTaskToReadyList( TC
{
mtCOVERAGE_TEST_MARKER();
}
-
+ traceMOVED_TASK_TO_SUSPENDED_LIST(pxTCB);
vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xStateListItem ) );
#if( configUSE_TASK_NOTIFICATIONS == 1 )
## -3671,6 +3682,20 ## static void prvCheckTasksWaitingTerminat
#endif /* INCLUDE_uxTaskGetStackHighWaterMark */
/*-----------------------------------------------------------*/
+#if (INCLUDE_pxTaskGetStackStart == 1)
+ uint8_t* pxTaskGetStackStart( TaskHandle_t xTask)
+ {
+ TCB_t *pxTCB;
+ UBaseType_t uxReturn;
+ (void)uxReturn;
+
+ pxTCB = prvGetTCBFromHandle( xTask );
+ return ( uint8_t * ) pxTCB->pxStack;
+ }
+
+#endif /* INCLUDE_pxTaskGetStackStart */
+/*-----------------------------------------------------------*/
+
#if ( INCLUDE_vTaskDelete == 1 )
static void prvDeleteTCB( TCB_t *pxTCB )
## -3840,7 +3865,7 ## TCB_t *pxTCB;
/* Inherit the priority before being moved into the new list. */
pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority;
- prvAddTaskToReadyList( pxMutexHolderTCB );
+ prvReaddTaskToReadyList( pxMutexHolderTCB );
}
else
{
## -3930,7 +3955,7 ## TCB_t *pxTCB;
any other purpose if this task is running, and it must be
running to give back the mutex. */
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
- prvAddTaskToReadyList( pxTCB );
+ prvReaddTaskToReadyList( pxTCB );
/* Return true to indicate that a context switch is required.
This is only actually required in the corner case whereby
## -4940,6 +4965,7 ## const TickType_t xConstTickCount = xTick
/* Add the task to the suspended task list instead of a delayed task
list to ensure it is not woken by a timing event. It will block
indefinitely. */
+ traceMOVED_TASK_TO_SUSPENDED_LIST(pxCurrentTCB);
vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) );
}
else
## -4956,12 +4982,14 ## const TickType_t xConstTickCount = xTick
{
/* Wake time has overflowed. Place this item in the overflow
list. */
+ traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST();
vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
}
else
{
/* The wake time has not overflowed, so the current block list
is used. */
+ traceMOVED_TASK_TO_DELAYED_LIST();
vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
/* If the task entering the blocked state was placed at the
## -4991,11 +5019,13 ## const TickType_t xConstTickCount = xTick
if( xTimeToWake < xConstTickCount )
{
/* Wake time has overflowed. Place this item in the overflow list. */
+ traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST();
vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
}
else
{
/* The wake time has not overflowed, so the current block list is used. */
+ traceMOVED_TASK_TO_DELAYED_LIST();
vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
/* If the task entering the blocked state was placed at the head of the
I tried to run this .patch file in my windows bash like this
$ patch /c/Users/ps/Documents/Git/STM32L432/Middlewares/Third_Party/FreeRTOS /c/Users/ps/Documents/Git/STM32L432/SEGGER/FreeRTOSV10/Patch/FreeRTOSV10_Core.patch
But I get the following error message
File /c/Users/ps/Documents/Git/STM32L432/Middlewares/Third_Party/FreeRTOS is not a regular file -- refusing to patch
Of course, the path /c/Users/ps/Documents/Git/STM32L432/Middlewares/Third_Party/FreeRTOS isn't a path to a file but it should be the root path for all diff cmd's. So how to determine a root path or concatenate more that one path to use a .patch file with several diffs inside?
BTW:
$ patch --help
Usage: patch [OPTION]... [ORIGFILE [PATCHFILE]]
Doesn't help me...
EDIT 1
Now I tried to run my bash from the Source directory and try the patch call like this
PS#PCENTW-PS MINGW64 ~/Documents/Git/STM32L432/Middlewares/Third_Party/FreeRTOS/Source (UseSystemView)
$ patch < /c/Users/ps/Documents/Git/STM32L432/SEGGER/FreeRTOSV10/Patch/FreeRTOSV10_Core.patch
can't find file to patch at input line 4
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff -rupN org/Source/include/FreeRTOS.h new/Source/include/FreeRTOS.h
|--- org/Source/include/FreeRTOS.h 2017-11-28 13:48:34.000000000 -0800
|+++ new/Source/include/FreeRTOS.h 2017-12-11 00:54:49.522222000 -0800
--------------------------
File to patch:
This seems to be much better than my previous call. But regardless I get the error can't find file to patch at input line 4
Open cmd.exe
Switch to the Source directory where all files are located
$ cd .../Source
Run patch.exe
$ patch < .../FreeRTOSV10_Core.patch
Determine the specific files to patch
File to patch: .../FreeRTOS.h
FINISH