Skip to content

Change the link script to optimum the RAM layout #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions cores/arduino/dccm/dccm_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions cores/arduino/dccm/dccm_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion system/libarc32_arduino101/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions system/libarc32_arduino101/bootcode/c_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
9 changes: 0 additions & 9 deletions system/libarc32_arduino101/framework/include/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
14 changes: 9 additions & 5 deletions system/libarc32_arduino101/framework/src/os/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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[] =
{
Expand Down Expand Up @@ -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 \
},
Expand Down Expand Up @@ -331,6 +333,7 @@ static void print_pool(int method, void *ctx)
*/
void os_abstraction_init_malloc(void)
{
/*
int indx;
uint32_t bufSize;

Expand All @@ -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;
}
*/
}

/**
Expand Down
Binary file modified variants/arduino_101/libarc32drv_arduino101.a
Binary file not shown.
12 changes: 10 additions & 2 deletions variants/arduino_101/linker_scripts/flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought "rwx" and "wx" were the same thing (i.e. "w" signifies both read and write). I'm not 100% sure though. Can somebody explain why this is needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping.... any answers to my question above?

DCCM (rw) : ORIGIN = 0x80000000, LENGTH = 8K
}

/* Define default stack size and FIRQ stack size.
Expand Down Expand Up @@ -181,6 +181,14 @@ SECTIONS

/* Data Closely Coupled Memory (DCCM) */
/* DCCM Start */
.kernelmempool (NOLOAD) :
{
. = ALIGN(4);
__dccm_start = .;
*(.kernelmempool)
*(".kernelmempool.*")
__dccm_end = ALIGN(4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this does not actually align the location counter-- it calculates the next aligned value based on the current location counter, although the counter itself remains unaligned. I think you should do something like this instead;

. = ALIGN(4);
__dccm_end = .;

} > DCCM
/* DCCM End */

}