Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Compiling ARM7_LPC2368_ECLIPSE

Posted by Olivier GIBRALTA on April 28, 2008
Hello,

I want to compile ARM7_LPC2368_ECLIPSE project with eclipse v3.3.2 but i have this error :

**** Build of configuration Default for project RTOSDemo ****

make all
arm-elf-gcc -g -O1 -Tlpc2368.ld -I . -I ../../../Source/include -I ../../../Source/portable/GCC/ARM7_LPC23xx -I ../../Common/include -I ./webserver -I ../../Common/ethernet/uIP/uip-1.0/uip -D ROWLEY_LPC23xx -D THUMB_INTERWORK -mcpu=arm7tdmi -D PACK_STRUCT_END=__attribute\(\(packed\)\) -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) -fomit-frame-pointer -mthumb-interwork ../../../Source/portable/GCC/ARM7_LPC23xx/portISR.o ./webserver/EMAC_ISR.o main.o ./ParTest/ParTest.o ./LCD/portlcd.o ../../Common/Minimal/BlockQ.o ../../Common/Minimal/blocktim.o ../../Common/Minimal/flash.o ../../Common/Minimal/integer.o ../../Common/Minimal/GenQTest.o ../../Common/Minimal/QPeek.o ../../Common/Minimal/dynamic.o ./webserver/uIP_Task.o ./webserver/emac.o ./webserver/httpd.o ./webserver/httpd-cgi.o ./webserver/httpd-fs.o ./webserver/http-strings.o ../../Common/ethernet/uIP/uip-1.0/uip/uip_arp.o ../../Common/ethernet/uIP/uip-1.0/uip/psock.o ../../Common/ethernet/uIP/uip-1.0/uip/timer.o ../../Common/ethernet/uIP/uip-1.0/uip/uip.o ../../../Source/list.o ../../../Source/queue.o ../../../Source/tasks.o ../../../Source/portable/GCC/ARM7_LPC23xx/port.o ../../../Source/portable/MemMang/heap_2.o boot.s -mthumb -nostartfiles -Xlinker -oRTOSDemo.elf -Xlinker -M -Xlinker -Map=rtosdemo.map
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/interwork\libg.a(freer.o): In function `_malloc_trim_r':
mallocr.c:(.text+0x2c): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x3c): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x48): undefined reference to `_sbrk_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/interwork\libg.a(makebuf.o): In function `__smakebuf':
makebuf.c:(.text+0x1c): undefined reference to `_fstat_r'
makebuf.c:(.text+0xb2): undefined reference to `isatty'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/interwork\libg.a(mallocr.o): In function `_malloc_r':
mallocr.c:(.text+0x2e8): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x388): undefined reference to `_sbrk_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/interwork\libg.a(stdio.o): In function `__sclose':
stdio.c:(.text+0xc): undefined reference to `_close_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/interwork\libg.a(stdio.o): In function `__sseek':
stdio.c:(.text+0x2a): undefined reference to `_lseek_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/interwork\libg.a(stdio.o): In function `__swrite':
stdio.c:(.text+0x6e): undefined reference to `_lseek_r'
stdio.c:(.text+0x86): undefined reference to `_write_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/thumb/interwork\libg.a(stdio.o): In function `__sread':
stdio.c:(.text+0xaa): undefined reference to `_read_r'
collect2: ld returned 1 exit status
make: *** [RTOSDemo.elf] Error 1

Somebody can help me ?

Thanks

RE: Compiling ARM7_LPC2368_ECLIPSE

Posted by Çağlar Akyüz on April 28, 2008
Hi,

I think this demo is tested with toolchain GNUARM like other ARM7
GCC demos though I'm not 100% sure. To build it with winarm, you need to
include some extra code for system calls. I'm attaching inline my "syscalls.c"
file. I don't remember the exact web page which I found this code. You can use
it to get rid of link errors. Or you can use gnuarm. Here arethe necessary steps
in case you need them:

1) Save the attached file to somewhere in your project tree.
2) Edit your makefile to include this file in the build process.
For example you can add it under FREERTOS_THUMB_SRC.

I hope this helps.

Regards,
Caglar

===========================================================================

/***********************************************************************/
/* */
/* SYSCALLS.C: System Calls */
/* most of this is from newlib-lpc and a Keil-demo */
/* */
/* These are "reentrant functions" as needed by */
/* the WinARM-newlib-config, see newlib-manual. */
/* Collected and modified by Martin Thomas */
/* */
/***********************************************************************/


#include <stdlib.h>
#include <reent.h>
#include <sys/stat.h>

#include "Board.h"
#define __inline static inline
#include "lib_AT91SAM7X256.h"

static void my_putc(char c)
{
while (!AT91F_US_TxReady((AT91PS_USART)AT91C_BASE_DBGU));
AT91F_US_PutChar((AT91PS_USART)AT91C_BASE_DBGU, c);
}

static int my_kbhit( void )
{
if ((AT91F_US_RxReady((AT91PS_USART)AT91C_BASE_DBGU)) == 0) return 0;
else return 1;
}

static char my_getc( void )
{
return AT91F_US_GetChar((AT91PS_USART)AT91C_BASE_DBGU);
}

_ssize_t _read_r(
struct _reent *r,
int file,
void *ptr,
size_t len)
{
char c;
int i;
unsigned char *p;

p = (unsigned char*)ptr;

for (i = 0; i < len; i++) {
// c = uart0Getch();
// c = uart0GetchW();
while ( !my_kbhit() ) ;
c = (char) my_getc();
if (c == 0x0D) {
*p='\0';
break;
}
*p++ = c;
////// uart0_putc(c);
}
return len - i;
}


_ssize_t _write_r (
struct _reent *r,
int file,
const void *ptr,
size_t len)
{
int i;
const unsigned char *p;

p = (const unsigned char*) ptr;

for (i = 0; i < len; i++) {
if (*p == '\n' ) my_putc('\r');
my_putc(*p++);
}

return len;
}


int _close_r(
struct _reent *r,
int file)
{
return 0;
}


_off_t _lseek_r(
struct _reent *r,
int file,
_off_t ptr,
int dir)
{
return (_off_t)0;/* Always indicate we are at file beginning. */
}


int _fstat_r(
struct _reent *r,
int file,
struct stat *st)
{
/* Always set as character device.*/
st->st_mode = S_IFCHR;
/* assigned to strong type with implicit */
/* signed/unsigned conversion. Required by */
/* newlib.*/

return 0;
}


int isatty(int file); /* avoid warning */

int isatty(int file)
{
return 1;
}


#if 0
static void _exit (int n) {
label: goto label; /* endless loop */
}
#endif


/* "malloc clue function" from newlib-lpc/Keil-Demo/"generic" */

/**** Locally used variables. ****/
// mt: "cleaner": extern char* end;
extern char end[]; /* end is set in the linker command */
/* file and is the end of statically */
/* allocated data (thus start of heap).*/

static char *heap_ptr;/* Points to current end of the heap.*/

/************************** _sbrk_r *************************************
* Support function. Adjusts end of heap to provide more memory to
* memory allocator. Simple and dumb with no sanity checks.

* struct _reent *r -- re-entrancy structure, used by newlib to
* support multiple threads of operation.
* ptrdiff_t nbytes -- number of bytes to add.
* Returns pointer to start of new heap area.
*
* Note: This implementation is not thread safe (despite taking a
* _reent structure as a parameter).
* Since _s_r is not used in the current implementation,
* the following messages must be suppressed.
*/
void * _sbrk_r(
struct _reent *_s_r,
ptrdiff_t nbytes)
{
char *base;/* errno should be set to ENOMEM on error */

if (!heap_ptr) {/* Initialize if first time through. */
heap_ptr = end;
}
base = heap_ptr;/* Point to end of heap. */
heap_ptr += nbytes;/* Increase heap. */

return base;/* Return pointer to start of new heap area. */
}

RE: Compiling ARM7_LPC2368_ECLIPSE

Posted by Olivier GIBRALTA on April 28, 2008
How can I install GNUARM and remove WinARM from Eclipse ?

I have modify the path in Property -> C/C++ General -> Path and symbol -> Includes with the path of GNURAM, but I have the same error message.

Thanks

RE: Compiling ARM7_LPC2368_ECLIPSE

Posted by Richard on April 28, 2008
The LPC2368 docs actually recommend installing YAGARTO rather than GNUARM. This is just because this is what I tested it with. In anycase, the answer is the same.

If you are using the Eclipse projects from the FreeRTOS.org download then Eclipse knows nothing of your compiler or its install location, all it does is call the makefile. The compiler actually used will be the one that appears first in you PATH environment variable. If you open a command prompt and type "which arm-elf-gcc.exe" it will tell you which one its going to use (assuming you have which.exe installed). To use a different compiler just change the order in which they appear within your environment variable setup.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS