diff --git a/cores/arduino/dccm/dccm_alloc.c b/cores/arduino/dccm/dccm_alloc.c index b34dd020..d679c8b3 100644 --- a/cores/arduino/dccm/dccm_alloc.c +++ b/cores/arduino/dccm/dccm_alloc.c @@ -37,15 +37,6 @@ void* dccm_malloc(uint16_t size) return addr; } -void *dccm_memalign(uint16_t size) -{ - if ((dccm_index +3) > DCCM_SIZE) - return 0; - - dccm_index = (dccm_index + 3) & ~((uint16_t)0x3); /* 4 byte addr alignment */ - return dccm_malloc(size); -} - #ifdef __cplusplus } #endif diff --git a/cores/arduino/dccm/dccm_alloc.h b/cores/arduino/dccm/dccm_alloc.h index a25ca9c7..bddc21d3 100644 --- a/cores/arduino/dccm/dccm_alloc.h +++ b/cores/arduino/dccm/dccm_alloc.h @@ -31,11 +31,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA void* dccm_malloc(uint16_t size); -void *dccm_memalign(uint16_t size); - #ifdef __cplusplus } #endif -#endif +#endif \ No newline at end of file diff --git a/system/libarc32_arduino101/Makefile b/system/libarc32_arduino101/Makefile index bccd2ab3..8b81ad32 100644 --- a/system/libarc32_arduino101/Makefile +++ b/system/libarc32_arduino101/Makefile @@ -40,7 +40,7 @@ CFGFLAGS+=-DCONFIG_BLUETOOTH_MAX_CONN=2 CFGFLAGS+=-DCONFIG_BT_GATT_BLE_MAX_SERVICES=10 CFGFLAGS+=-DCONFIG_BLUETOOTH_GATT_CLIENT CFGFLAGS+=-DCONFIG_BLUETOOTH_CENTRAL -DCONFIG_BLUETOOTH_PERIPHERAL -INCLUDES=-I. -Icommon -Idrivers -Ibootcode -Iframework/include -Iframework/include/services/ble -Iframework/src/services/ble_service -I../../cores/arduino/dccm +INCLUDES=-I. -Icommon -Idrivers -Ibootcode -Iframework/include -Iframework/include/services/ble -Iframework/src/services/ble_service #-Iframework/src/services/ble -Iframework/include/services/ble INCLUDES+= -Idrivers/rpc -Iframework/src EXTRA_CFLAGS=-D__CPU_ARC__ -DCLOCK_SPEED=32 -std=c99 -fno-reorder-functions -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -fno-defer-pop -Wno-unused-but-set-variable -Wno-main -ffreestanding -fno-stack-protector -mno-sdata -ffunction-sections -fdata-sections diff --git a/system/libarc32_arduino101/bootcode/c_init.c b/system/libarc32_arduino101/bootcode/c_init.c index a6256c45..243622d6 100644 --- a/system/libarc32_arduino101/bootcode/c_init.c +++ b/system/libarc32_arduino101/bootcode/c_init.c @@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "interrupt.h" #include "arcv2_timer0.h" -#include "os/os.h" /* Application main() function prototype */ extern int main (void); @@ -61,8 +60,6 @@ static void _exec_ctors (void) interrupt_unit_device_init(); /* Start the system's virtual 64-bit Real Time Counter */ timer0_driver_init(); - /* Initialize the memory buffer for balloc() calls. */ - os_abstraction_init_malloc(); /* Jump to application main() */ main (); /* Never reached */ diff --git a/system/libarc32_arduino101/framework/include/os/os.h b/system/libarc32_arduino101/framework/include/os/os.h index 7f5103d9..12b9a11a 100644 --- a/system/libarc32_arduino101/framework/include/os/os.h +++ b/system/libarc32_arduino101/framework/include/os/os.h @@ -132,15 +132,6 @@ extern void queue_get_message (T_QUEUE queue, T_QUEUE_MESSAGE* message, int time */ extern void queue_send_message(T_QUEUE queue, T_QUEUE_MESSAGE message, OS_ERR_TYPE* err ); -/** - * \brief Initialize the resources used by the framework's memory allocation services - * - * IMPORTANT : This function must be called during the initialization - * of the OS abstraction layer. - * This function shall only be called once after reset. - */ -extern void os_abstraction_init_malloc(void); - /** * \brief Reserves a block of memory * diff --git a/system/libarc32_arduino101/framework/src/os/balloc.c b/system/libarc32_arduino101/framework/src/os/balloc.c index aa2906b3..f1691472 100644 --- a/system/libarc32_arduino101/framework/src/os/balloc.c +++ b/system/libarc32_arduino101/framework/src/os/balloc.c @@ -9,7 +9,6 @@ #include "os/os.h" #include "infra/log.h" -#include "dccm_alloc.h" #ifdef CONFIG_MEMORY_POOLS_BALLOC_TRACK_OWNER #include "misc/printk.h" @@ -48,18 +47,19 @@ typedef struct { /** Allocate the memory blocks and tracking variables for each pool */ #ifdef CONFIG_MEMORY_POOLS_BALLOC_TRACK_OWNER #define DECLARE_MEMORY_POOL(index, size, count) \ - uint8_t mblock_ ## index[count][size] __aligned(4); \ + uint8_t mblock_ ## index[count][size] __aligned(4) __attribute__ ((section(".kernelmempool"))); \ uint32_t mblock_alloc_track_ ## index[count / BITS_PER_U32 + 1] = { 0 }; \ uint32_t *mblock_owners_ ## index[count] = { 0 }; #else #define DECLARE_MEMORY_POOL(index, size, count) \ - uint8_t mblock_ ## index[count][size] __aligned(4); \ + uint8_t mblock_ ## index[count][size] __aligned(4) __attribute__ ((section(".kernelmempool"))); \ uint32_t mblock_alloc_track_ ## index[count / BITS_PER_U32 + \ 1] = { 0 }; #endif #include "memory_pool_list.def" + /** Pool descriptor definition */ T_POOL_DESC mpool[] = { @@ -100,19 +100,21 @@ T_POOL_DESC mpool[] = /** Allocate the memory blocks and tracking variables for each pool */ #define DECLARE_MEMORY_POOL(index, size, count) \ + uint8_t mblock_ ## index[count][size] __attribute__ ((section(".kernelmempool"))); \ uint32_t mblock_alloc_track_ ## index[count / BITS_PER_U32 + 1] = { 0 }; #include "memory_pool_list.def" + /** Pool descriptor definition */ T_POOL_DESC mpool [] = { #define DECLARE_MEMORY_POOL(index, size, count) \ { \ /* T_POOL_DESC.track */ mblock_alloc_track_ ## index, \ -/* T_POOL_DESC.start */ 0, \ -/* T_POOL_DESC.end */ 0, \ +/* T_POOL_DESC.start */ (uint32_t)mblock_ ## index, \ +/* T_POOL_DESC.end */ (uint32_t)mblock_ ## index + count * size, \ /* T_POOL_DESC.count */ count, \ /* T_POOL_DESC.size */ size \ }, @@ -331,6 +333,7 @@ static void print_pool(int method, void *ctx) */ void os_abstraction_init_malloc(void) { +/* int indx; uint32_t bufSize; @@ -339,6 +342,7 @@ void os_abstraction_init_malloc(void) mpool[indx].start = (uint32_t)dccm_memalign((uint16_t)bufSize); mpool[indx].end = mpool[indx].start + bufSize; } +*/ } /** diff --git a/variants/arduino_101/libarc32drv_arduino101.a b/variants/arduino_101/libarc32drv_arduino101.a index db6e5b45..f839afbc 100644 Binary files a/variants/arduino_101/libarc32drv_arduino101.a and b/variants/arduino_101/libarc32drv_arduino101.a differ diff --git a/variants/arduino_101/linker_scripts/flash.ld b/variants/arduino_101/linker_scripts/flash.ld index 335f7ef6..53eaddf4 100644 --- a/variants/arduino_101/linker_scripts/flash.ld +++ b/variants/arduino_101/linker_scripts/flash.ld @@ -40,8 +40,8 @@ OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc", "elf32-littlearc") MEMORY { FLASH (rx) : ORIGIN = 0x40034000, LENGTH = 152K - SRAM (wx) : ORIGIN = 0xa800e000, LENGTH = 24K - DCCM (wx) : ORIGIN = 0x80000000, LENGTH = 8K + SRAM (rwx) : ORIGIN = 0xa800e000, LENGTH = 24K + DCCM (rw) : ORIGIN = 0x80000000, LENGTH = 8K } /* Define default stack size and FIRQ stack size. @@ -181,6 +181,14 @@ SECTIONS /* Data Closely Coupled Memory (DCCM) */ /* DCCM Start */ + .kernelmempool (NOLOAD) : + { + . = ALIGN(4); + __dccm_start = .; + *(.kernelmempool) + *(".kernelmempool.*") + __dccm_end = ALIGN(4); + } > DCCM /* DCCM End */ }