Skip to content

Commit 3f4c4f7

Browse files
committed
Change the link script to optimum the RAM layout
1. Revert the DCCM change 2. Update the link script
1 parent 752d872 commit 3f4c4f7

File tree

8 files changed

+21
-32
lines changed

8 files changed

+21
-32
lines changed

Diff for: cores/arduino/dccm/dccm_alloc.c

-9
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@ void* dccm_malloc(uint16_t size)
3737
return addr;
3838
}
3939

40-
void *dccm_memalign(uint16_t size)
41-
{
42-
if ((dccm_index +3) > DCCM_SIZE)
43-
return 0;
44-
45-
dccm_index = (dccm_index + 3) & ~((uint16_t)0x3); /* 4 byte addr alignment */
46-
return dccm_malloc(size);
47-
}
48-
4940
#ifdef __cplusplus
5041
}
5142
#endif

Diff for: cores/arduino/dccm/dccm_alloc.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3131

3232
void* dccm_malloc(uint16_t size);
3333

34-
void *dccm_memalign(uint16_t size);
35-
3634
#ifdef __cplusplus
3735
}
3836
#endif
3937

4038

41-
#endif
39+
#endif

Diff for: system/libarc32_arduino101/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ CFGFLAGS+=-DCONFIG_BLUETOOTH_MAX_CONN=2
4040
CFGFLAGS+=-DCONFIG_BT_GATT_BLE_MAX_SERVICES=10
4141
CFGFLAGS+=-DCONFIG_BLUETOOTH_GATT_CLIENT
4242
CFGFLAGS+=-DCONFIG_BLUETOOTH_CENTRAL -DCONFIG_BLUETOOTH_PERIPHERAL
43-
INCLUDES=-I. -Icommon -Idrivers -Ibootcode -Iframework/include -Iframework/include/services/ble -Iframework/src/services/ble_service -I../../cores/arduino/dccm
43+
INCLUDES=-I. -Icommon -Idrivers -Ibootcode -Iframework/include -Iframework/include/services/ble -Iframework/src/services/ble_service
4444
#-Iframework/src/services/ble -Iframework/include/services/ble
4545
INCLUDES+= -Idrivers/rpc -Iframework/src
4646
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 for: system/libarc32_arduino101/bootcode/c_init.c

-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121

2222
#include "interrupt.h"
2323
#include "arcv2_timer0.h"
24-
#include "os/os.h"
2524

2625
/* Application main() function prototype */
2726
extern int main (void);
@@ -61,8 +60,6 @@ static void _exec_ctors (void)
6160
interrupt_unit_device_init();
6261
/* Start the system's virtual 64-bit Real Time Counter */
6362
timer0_driver_init();
64-
/* Initialize the memory buffer for balloc() calls. */
65-
os_abstraction_init_malloc();
6663
/* Jump to application main() */
6764
main ();
6865
/* Never reached */

Diff for: system/libarc32_arduino101/framework/include/os/os.h

-9
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,6 @@ extern void queue_get_message (T_QUEUE queue, T_QUEUE_MESSAGE* message, int time
132132
*/
133133
extern void queue_send_message(T_QUEUE queue, T_QUEUE_MESSAGE message, OS_ERR_TYPE* err );
134134

135-
/**
136-
* \brief Initialize the resources used by the framework's memory allocation services
137-
*
138-
* IMPORTANT : This function must be called during the initialization
139-
* of the OS abstraction layer.
140-
* This function shall only be called once after reset.
141-
*/
142-
extern void os_abstraction_init_malloc(void);
143-
144135
/**
145136
* \brief Reserves a block of memory
146137
*

Diff for: system/libarc32_arduino101/framework/src/os/balloc.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "os/os.h"
1111
#include "infra/log.h"
12-
#include "dccm_alloc.h"
1312

1413
#ifdef CONFIG_MEMORY_POOLS_BALLOC_TRACK_OWNER
1514
#include "misc/printk.h"
@@ -48,18 +47,19 @@ typedef struct {
4847
/** Allocate the memory blocks and tracking variables for each pool */
4948
#ifdef CONFIG_MEMORY_POOLS_BALLOC_TRACK_OWNER
5049
#define DECLARE_MEMORY_POOL(index, size, count) \
51-
uint8_t mblock_ ## index[count][size] __aligned(4); \
50+
uint8_t mblock_ ## index[count][size] __aligned(4) __attribute__ ((section(".kernelmempool"))); \
5251
uint32_t mblock_alloc_track_ ## index[count / BITS_PER_U32 + 1] = { 0 }; \
5352
uint32_t *mblock_owners_ ## index[count] = { 0 };
5453
#else
5554
#define DECLARE_MEMORY_POOL(index, size, count) \
56-
uint8_t mblock_ ## index[count][size] __aligned(4); \
55+
uint8_t mblock_ ## index[count][size] __aligned(4) __attribute__ ((section(".kernelmempool"))); \
5756
uint32_t mblock_alloc_track_ ## index[count / BITS_PER_U32 + \
5857
1] = { 0 };
5958
#endif
6059

6160
#include "memory_pool_list.def"
6261

62+
6363
/** Pool descriptor definition */
6464
T_POOL_DESC mpool[] =
6565
{
@@ -100,19 +100,21 @@ T_POOL_DESC mpool[] =
100100

101101
/** Allocate the memory blocks and tracking variables for each pool */
102102
#define DECLARE_MEMORY_POOL(index, size, count) \
103+
uint8_t mblock_ ## index[count][size] __attribute__ ((section(".kernelmempool"))); \
103104
uint32_t mblock_alloc_track_ ## index[count / BITS_PER_U32 + 1] = { 0 };
104105

105106
#include "memory_pool_list.def"
106107

107108

109+
108110
/** Pool descriptor definition */
109111
T_POOL_DESC mpool [] =
110112
{
111113
#define DECLARE_MEMORY_POOL(index, size, count) \
112114
{ \
113115
/* T_POOL_DESC.track */ mblock_alloc_track_ ## index, \
114-
/* T_POOL_DESC.start */ 0, \
115-
/* T_POOL_DESC.end */ 0, \
116+
/* T_POOL_DESC.start */ (uint32_t)mblock_ ## index, \
117+
/* T_POOL_DESC.end */ (uint32_t)mblock_ ## index + count * size, \
116118
/* T_POOL_DESC.count */ count, \
117119
/* T_POOL_DESC.size */ size \
118120
},
@@ -331,6 +333,7 @@ static void print_pool(int method, void *ctx)
331333
*/
332334
void os_abstraction_init_malloc(void)
333335
{
336+
/*
334337
int indx;
335338
uint32_t bufSize;
336339
@@ -339,6 +342,7 @@ void os_abstraction_init_malloc(void)
339342
mpool[indx].start = (uint32_t)dccm_memalign((uint16_t)bufSize);
340343
mpool[indx].end = mpool[indx].start + bufSize;
341344
}
345+
*/
342346
}
343347

344348
/**

Diff for: variants/arduino_101/libarc32drv_arduino101.a

606 KB
Binary file not shown.

Diff for: variants/arduino_101/linker_scripts/flash.ld

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc", "elf32-littlearc")
4040
MEMORY
4141
{
4242
FLASH (rx) : ORIGIN = 0x40034000, LENGTH = 152K
43-
SRAM (wx) : ORIGIN = 0xa800e000, LENGTH = 24K
44-
DCCM (wx) : ORIGIN = 0x80000000, LENGTH = 8K
43+
SRAM (rwx) : ORIGIN = 0xa800e000, LENGTH = 24K
44+
DCCM (rw) : ORIGIN = 0x80000000, LENGTH = 8K
4545
}
4646

4747
/* Define default stack size and FIRQ stack size.
@@ -181,6 +181,14 @@ SECTIONS
181181

182182
/* Data Closely Coupled Memory (DCCM) */
183183
/* DCCM Start */
184+
.kernelmempool (NOLOAD) :
185+
{
186+
. = ALIGN(4);
187+
__dccm_start = .;
188+
*(.kernelmempool)
189+
*(".kernelmempool.*")
190+
__dccm_end = ALIGN(4);
191+
} > DCCM
184192
/* DCCM End */
185193

186194
}

0 commit comments

Comments
 (0)