From 8f6ae7c398168e2923ba9135556b61a207c5553f Mon Sep 17 00:00:00 2001 From: Sam Grove Date: Sat, 11 Jun 2016 07:00:23 -0700 Subject: [PATCH 1/5] add IAR placement for LPC1768 and lwip buffers --- net/LWIPInterface/lwip/core/mem.c | 15 ++++++-- net/LWIPInterface/lwip/core/memp.c | 61 +++++++++++++++++------------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/net/LWIPInterface/lwip/core/mem.c b/net/LWIPInterface/lwip/core/mem.c index 7ebe304138..e00eadf0e1 100644 --- a/net/LWIPInterface/lwip/core/mem.c +++ b/net/LWIPInterface/lwip/core/mem.c @@ -187,12 +187,19 @@ struct mem { # define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned)) # endif #elif defined(TARGET_LPC1768) -# define ETHMEM_SECTION __attribute((section("AHBSRAM0"))) -#else -# define ETHMEM_SECTION +# if defined (__ICCARM__) +# define ETHMEM_SECTION +# elif defined(TOOLCHAIN_GCC_CR) +# define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32"))) +# else +# define ETHMEM_SECTION __attribute__((section("AHBSRAM0"),aligned)) +# endif #endif /** the heap. we need one struct mem at the end and some room for alignment */ +#if defined (__ICCARM__) +#pragma location = ".ethusbram" +#endif u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT] ETHMEM_SECTION; #define LWIP_RAM_HEAP_POINTER ram_heap #endif /* LWIP_RAM_HEAP_POINTER */ @@ -483,7 +490,7 @@ mem_trim(void *rmem, mem_size_t newsize) /* else { next struct mem is used but size between mem and mem2 is not big enough to create another struct mem - -> don't do anyhting. + -> don't do anyhting. -> the remaining space stays unused since it is too small } */ #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT diff --git a/net/LWIPInterface/lwip/core/memp.c b/net/LWIPInterface/lwip/core/memp.c index 19bc5579db..fca1a25ca5 100644 --- a/net/LWIPInterface/lwip/core/memp.c +++ b/net/LWIPInterface/lwip/core/memp.c @@ -8,9 +8,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, @@ -19,21 +19,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -155,25 +155,32 @@ static const char *memp_desc[MEMP_MAX] = { * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[]; */ #define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \ - [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; + [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; #include "lwip/memp_std.h" /** This array holds the base of each memory pool. */ -static u8_t *const memp_bases[] = { -#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base, +static u8_t *const memp_bases[] = { +#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base, #include "lwip/memp_std.h" }; #else /* MEMP_SEPARATE_POOLS */ #if defined(TARGET_LPC1768) -# define ETHMEM_SECTION __attribute((section("AHBSRAM1"))) -#else -# define ETHMEM_SECTION +# if defined (__ICCARM__) +# define ETHMEM_SECTION +# elif defined(TOOLCHAIN_GCC_CR) +# define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32"))) +# else +# define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned)) +# endif #endif /** This is the actual memory used by the pools (all pools in one big block). */ -static u8_t memp_memory[MEM_ALIGNMENT - 1 +#if defined (__ICCARM__) +#pragma location = ".ethusbram" +#endif +static u8_t memp_memory[MEM_ALIGNMENT - 1 #define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) #include "lwip/memp_std.h" ] ETHMEM_SECTION; @@ -336,7 +343,7 @@ memp_overflow_init(void) /** * Initialize this module. - * + * * Carves out memp_memory into linked lists for each pool-type. */ void @@ -399,7 +406,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line) { struct memp *memp; SYS_ARCH_DECL_PROTECT(old_level); - + LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;); SYS_ARCH_PROTECT(old_level); @@ -408,7 +415,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line) #endif /* MEMP_OVERFLOW_CHECK >= 2 */ memp = memp_tab[type]; - + if (memp != NULL) { memp_tab[type] = memp->next; #if MEMP_OVERFLOW_CHECK @@ -460,9 +467,9 @@ memp_free(memp_t type, void *mem) #endif /* MEMP_OVERFLOW_CHECK >= 2 */ #endif /* MEMP_OVERFLOW_CHECK */ - MEMP_STATS_DEC(used, type); - - memp->next = memp_tab[type]; + MEMP_STATS_DEC(used, type); + + memp->next = memp_tab[type]; memp_tab[type] = memp; #if MEMP_SANITY_CHECK From 9d8f33be641977d6393d67929a4f10e5ddcb94bf Mon Sep 17 00:00:00 2001 From: Sam Grove Date: Sat, 11 Jun 2016 07:02:34 -0700 Subject: [PATCH 2/5] ignore generated test_spec.json --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6a4824e402..cf5211ed99 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ MANIFEST # Private settings private_settings.py +test_spec.json # Default Build Directory build/ @@ -74,4 +75,3 @@ cscope.* # vim swap files *.swp *~ - From 167fe6333676688ddf4da6312bbdc782d0a87447 Mon Sep 17 00:00:00 2001 From: Sam Grove Date: Sat, 11 Jun 2016 10:01:37 -0700 Subject: [PATCH 3/5] added default placement macro for all boards and toolchains --- net/LWIPInterface/lwip/core/mem.c | 4 +++- net/LWIPInterface/lwip/core/memp.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/net/LWIPInterface/lwip/core/mem.c b/net/LWIPInterface/lwip/core/mem.c index e00eadf0e1..84aa8bb0cf 100644 --- a/net/LWIPInterface/lwip/core/mem.c +++ b/net/LWIPInterface/lwip/core/mem.c @@ -189,11 +189,13 @@ struct mem { #elif defined(TARGET_LPC1768) # if defined (__ICCARM__) # define ETHMEM_SECTION -# elif defined(TOOLCHAIN_GCC_CR) +# elif defined(TOOLCHAIN_GCC_CR) || defined(TOOLCHAIN_GCC_ARM) # define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32"))) # else # define ETHMEM_SECTION __attribute__((section("AHBSRAM0"),aligned)) # endif +#else +#define ETHMEM_SECTION #endif /** the heap. we need one struct mem at the end and some room for alignment */ diff --git a/net/LWIPInterface/lwip/core/memp.c b/net/LWIPInterface/lwip/core/memp.c index fca1a25ca5..688c210dd6 100644 --- a/net/LWIPInterface/lwip/core/memp.c +++ b/net/LWIPInterface/lwip/core/memp.c @@ -174,6 +174,8 @@ static u8_t *const memp_bases[] = { # else # define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned)) # endif +#else +#define ETHMEM_SECTION #endif /** This is the actual memory used by the pools (all pools in one big block). */ From c9705ab43c89afc11312cdfce55a1b5f6c4a5ef0 Mon Sep 17 00:00:00 2001 From: Sam Grove Date: Sat, 11 Jun 2016 16:24:25 -0700 Subject: [PATCH 4/5] Update mbed.lib https://github.com/mbedmicro/mbed/compare/52e93aebd083b679a8fe7b0e47039f138fa8c224...df0c855df97688074545693f66bcca5cf9f42111 --- mbed.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbed.lib b/mbed.lib index 086dc81bfe..5d4b3928f6 100644 --- a/mbed.lib +++ b/mbed.lib @@ -1 +1 @@ -https://github.com/mbedmicro/mbed/#52e93aebd083b679a8fe7b0e47039f138fa8c224 +https://github.com/mbedmicro/mbed/#df0c855df97688074545693f66bcca5cf9f42111 From d9ead4dbc6a718b8aad0287f19fe3e7ad4d2ab57 Mon Sep 17 00:00:00 2001 From: Sam Grove Date: Sun, 12 Jun 2016 04:27:16 -0700 Subject: [PATCH 5/5] ignore generated project files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cf5211ed99..9317ab0d46 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ MANIFEST # Private settings private_settings.py test_spec.json +projectfiles/ # Default Build Directory build/