From 55bb484b22334678d76b8c1fec7b356685f8ceec Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Thu, 8 Nov 2012 11:37:29 -0500 Subject: [PATCH] [cpu arm_common] * added usb ram as heap3 * some feuerware merge adaptation [projects test_suite] * fixed some test scripts --- cpu/arm_common/hwtimer_cpu.c | 1 + cpu/arm_common/syscalls.c | 42 ++++++++++++------- cpu/lpc2387/linkerscript.x | 39 +++++++++++++++-- projects/test_suite/tests/01-basic | 7 +++- .../test_suite/tests/03-mutex_trylock_fail | 7 +++- projects/test_suite/tests/04-thread_sleep | 7 +++- 6 files changed, 77 insertions(+), 26 deletions(-) diff --git a/cpu/arm_common/hwtimer_cpu.c b/cpu/arm_common/hwtimer_cpu.c index 5fab317e4..a959429c8 100644 --- a/cpu/arm_common/hwtimer_cpu.c +++ b/cpu/arm_common/hwtimer_cpu.c @@ -14,6 +14,7 @@ #include "bitarithm.h" #include "hwtimer_cpu.h" #include "hwtimer_arch.h" +#include "irq.h" #define VULP(x) ((volatile unsigned long*) (x)) diff --git a/cpu/arm_common/syscalls.c b/cpu/arm_common/syscalls.c index 671a624e3..14dcda90a 100644 --- a/cpu/arm_common/syscalls.c +++ b/cpu/arm_common/syscalls.c @@ -31,9 +31,9 @@ and the mailinglist (subscription via web site) * * @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project * @author Michael Baar - * @version $Revision: 3914 $ + * @version $Revision$ * - * @note $Id: syscalls.c 3914 2012-02-14 09:31:06Z hwill $ + * @note $Id$ */ #include @@ -45,16 +45,15 @@ and the mailinglist (subscription via web site) #include // core #include "kernel.h" -// sys -#include "lpm.h" -#include "tracelog.h" -#include "hal-syscalls.h" +#include "irq.h" +#include "io.h" /* When using the HAL standard in and out are handled by HAL devices. */ #if FEUERWARE_CONF_ENABLE_HAL #include "hal.h" #include "interface-chardevice.h" +#include "hal-syscalls.h" #endif #define DEBUG_SYSCALLS 0 @@ -88,8 +87,7 @@ static caddr_t heap[NUM_HEAPS] = {(caddr_t)&__heap1_start,(caddr_t)&__heap3_star static const caddr_t heap_max[NUM_HEAPS] = {(caddr_t)&__heap1_max,(caddr_t)&__heap3_max,(caddr_t)&__heap2_max}; // start position in heap static const caddr_t heap_start[NUM_HEAPS] = {(caddr_t)&__heap1_start,(caddr_t)&__heap3_start,(caddr_t)&__heap2_start}; -// current heap in use -volatile static uint8_t iUsedHeap = 0; + /** @} */ @@ -127,7 +125,7 @@ caddr_t _sbrk_r(struct _reent *r, size_t incr) uint32_t cpsr = disableIRQ(); /* check all heaps for a chunk of the requested size */ - for( ; iUsedHeap < NUM_HEAPS; iUsedHeap++ ) { + for(volatile uint8_t iUsedHeap = 0; iUsedHeap < NUM_HEAPS; iUsedHeap++ ) { caddr_t new_heap = heap[iUsedHeap] + incr; #ifdef MODULE_TRACELOG @@ -151,7 +149,7 @@ caddr_t _sbrk_r(struct _reent *r, size_t incr) #endif r->_errno = ENOMEM; - return NULL; + return NULL; } /*---------------------------------------------------------------------------*/ int _isatty_r(struct _reent *r, int fd) @@ -249,6 +247,9 @@ int _write_r(struct _reent *r, int fd, const void *data, unsigned int count) #ifdef MODULE_FAT result = ff_write_r(r, fd, data, count); #endif + PRINTF("write [%i] data @%p count %i\n", fd, data, count); + + PRINTF("write [%i] returned %i errno %i\n", fd, result, r->_errno); break; } @@ -262,27 +263,36 @@ int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count) #ifdef MODULE_FAT result = ff_read_r(r, fd, buffer, count); #endif - return result; + PRINTF("read [%i] buffer @%p count %i\n", fd, buffer, count); + PRINTF("read [%i] returned %i\n", fd, result); + + return result; } /*---------------------------------------------------------------------------*/ int _close_r(struct _reent *r, int fd) { - int ret = -1; + int result = -1; r->_errno = EBADF; #ifdef MODULE_FAT ret = ff_close_r(r, fd); #endif - return ret; + PRINTF("close [%i]\n", fd); + PRINTF("close returned %i errno %i\n", result, errno); + + return result; } /*---------------------------------------------------------------------------*/ int _unlink_r(struct _reent *r, char* path) { - int ret = -1; + int result = -1; r->_errno = ENODEV; #ifdef MODULE_FAT - ret = ff_unlink_r(r, path); + result = ff_unlink_r(r, path); #endif - return ret; + PRINTF("unlink '%s'\n", path); + PRINTF("unlink returned %i errno %i\n", result, errno); + + return result; } /*---------------------------------------------------------------------------*/ void _exit(int n) diff --git a/cpu/lpc2387/linkerscript.x b/cpu/lpc2387/linkerscript.x index eaf2a69dc..efa60aaa2 100644 --- a/cpu/lpc2387/linkerscript.x +++ b/cpu/lpc2387/linkerscript.x @@ -27,11 +27,11 @@ and the mailinglist (subscription via web site) /* specify the LPC2387 memory areas (see LPC2387 datasheet page 15) */ MEMORY { - flash : ORIGIN = 0, LENGTH = 512K /* FLASH ROM */ + flash : ORIGIN = 0, LENGTH = 504K /* FLASH ROM 512kByte without ISP bootloader*/ infomem : ORIGIN = 0x0007D000, LENGTH = 4K /* Last sector in FLASH ROM for config data */ ram_battery : ORIGIN = 0xE0084000, LENGTH = 2K /* Battery RAM */ ram : ORIGIN = 0x40000000, LENGTH = 64K /* LOCAL ON-CHIP STATIC RAM */ - ram_usb : ORIGIN = 0x7FD00000, LENGTH = 16K /* USB RAM */ + ram_usb : ORIGIN = 0x7FD00000, LENGTH = 16K /* USB RAM !!! first 1024 bytes are occupied from GPDMA for MCI */ ram_ethernet : ORIGIN = 0x7FE00000, LENGTH = 16K /* ethernet RAM */ } @@ -177,7 +177,27 @@ SECTIONS *(.gnu.linkonce.d*) } >ram /* put all the above into RAM (but load the LMA copy into FLASH) */ . = ALIGN(4); /* ensure data is aligned so relocation can use 4-byte operations */ - _edata = .; /* define a global symbol marking the end of the .data section */ + _edata = .; /* define a global symbol marking the end of the .data section */ + + + /* + * Exception frames (newer linker versions generate these but they use of + * most of the RAM. + */ + /DISCARD/ : /* discard exception frames */ + { + *(.eh_*) + } + + /* to enable exception frames */ + /* + .eh_frame : + { + KEEP (*(.eh_frame)) + } > ram + . = ALIGN(4); + */ + _end = .; /* define a global symbol marking the end of application RAM */ __heap1_size = ORIGIN(ram) + LENGTH(ram) - . - __stack_size; @@ -219,12 +239,23 @@ SECTIONS PROVIDE(__heap2_max = .); /* _heap shall always be < _heap_max */ } > ram_ethernet + . = ORIGIN(ram_usb); .usbdata (NOLOAD) : /* USB RAM section, may be used otherwise if USB is disabled */ { *(.usbdata) } > ram_usb - .batteryram (NOLOAD) : /* battery ram stay on during powerdown but needs to be handled specially */ + .heap3 ALIGN(0x1000) (NOLOAD) : + { + __heap3_size = ORIGIN(ram_usb) + LENGTH(ram_usb) - ABSOLUTE(.); + PROVIDE(__heap3_start = . ); + . += __heap3_size; + PROVIDE(__heap3_max = .); + } > ram_usb + __heap_size = SIZEOF(.heap3); + + + .batteryram (NOLOAD) : /* battery ram stays on during powerdown but needs to be handled specially */ { *(.batteryram) } > ram_battery diff --git a/projects/test_suite/tests/01-basic b/projects/test_suite/tests/01-basic index bdeb11773..5f6068fc7 100755 --- a/projects/test_suite/tests/01-basic +++ b/projects/test_suite/tests/01-basic @@ -4,8 +4,11 @@ set timeout 5 spawn pseudoterm $env(PORT) +sleep 1 +send "\n" +send "\n" expect { - ">$" {} + ">" {} timeout { exit 1 } } @@ -16,7 +19,7 @@ expect { } expect { - ">$" {} + ">" {} timeout { exit 1 } } diff --git a/projects/test_suite/tests/03-mutex_trylock_fail b/projects/test_suite/tests/03-mutex_trylock_fail index e9fa06827..f04cb8b27 100755 --- a/projects/test_suite/tests/03-mutex_trylock_fail +++ b/projects/test_suite/tests/03-mutex_trylock_fail @@ -4,8 +4,11 @@ set timeout 5 spawn pseudoterm $env(PORT) +sleep 1 +send "\n" +send "\n" expect { - ">$" {} + ">" {} timeout { exit 1 } } @@ -16,7 +19,7 @@ expect { } expect { - ">$" {} + ">" {} timeout { exit 1 } } diff --git a/projects/test_suite/tests/04-thread_sleep b/projects/test_suite/tests/04-thread_sleep index 1734706b7..1c5544169 100755 --- a/projects/test_suite/tests/04-thread_sleep +++ b/projects/test_suite/tests/04-thread_sleep @@ -4,8 +4,11 @@ set timeout 5 spawn pseudoterm $env(PORT) +sleep 1 +send "\n" +send "\n" expect { - ">$" {} + ">" {} timeout { exit 1 } } @@ -16,7 +19,7 @@ expect { } expect { - ">$" {} + ">" {} timeout { exit 1 } }