Skip to content
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

Try side-port of different linker and ram for PinecilV2 #1730

Merged
merged 1 commit into from
Jul 5, 2023
Merged
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
8 changes: 3 additions & 5 deletions source/Core/BSP/Pinecilv2/Setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ uint16_t ADCReadings[ADC_NORM_SAMPLES]; // room for 32 lots of the pair of readi

// Heap

extern uint8_t __HeapBase;
extern uint8_t __HeapLimit; // @suppress("Type cannot be resolved")
const uint32_t _heap_size = ((&__HeapLimit) - (&__HeapBase));
extern uint8_t _heap_start;
extern uint8_t _heap_size; // @suppress("Type cannot be resolved")
static HeapRegion_t xHeapRegions[] = {
{&__HeapBase, (unsigned int)_heap_size},
{&_heap_start, (unsigned int)&_heap_size},
{NULL, 0}, /* Terminates the array. */
{NULL, 0} /* Terminates the array. */
};

// Functions

void setup_timer_scheduler(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*
*/
#include "bflb_platform.h"
#include "drv_mmheap.h"
#include "hal_common.h"
#include "hal_flash.h"
#include "hal_mtimer.h"
Expand All @@ -32,8 +33,11 @@ extern uint32_t __HeapLimit;

static uint8_t uart_dbg_disable = 0;

// struct heap_info mmheap_root;
struct heap_info mmheap_root;

static struct heap_region system_mmheap[] = {
{NULL, 0}, {NULL, 0}, /* Terminates the array. */
};
__WEAK__ void board_init(void) {}

__WEAK__ enum uart_index_type board_get_debug_uart_index(void) { return 0; }
Expand Down Expand Up @@ -88,14 +92,14 @@ void bflb_platform_init(uint32_t baudrate) {
}
static bool initialized = false;
if (!initialized) {
// system_mmheap[0].addr = (uint8_t *)&__HeapBase;
// system_mmheap[0].mem_size = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
system_mmheap[0].addr = (uint8_t *)&__HeapBase;
system_mmheap[0].mem_size = ((size_t)&__HeapLimit - (size_t)&__HeapBase);

// if (system_mmheap[0].mem_size > 0) {
// mmheap_init(&mmheap_root, system_mmheap);
// }
if (system_mmheap[0].mem_size > 0) {
mmheap_init(&mmheap_root, system_mmheap);
}

// MSG("dynamic memory init success,heap size = %d Kbyte \r\n", system_mmheap[0].mem_size / 1024);
MSG("dynamic memory init success,heap size = %d Kbyte \r\n", system_mmheap[0].mem_size / 1024);
initialized = 1;
if (ret != SUCCESS) {
MSG("flash init fail!!!\r\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ OUTPUT_ARCH( "riscv" )
/* configure the entry point */
ENTRY(_enter)

StackSize = 0x800; /* 2KB */

__EM_SIZE = DEFINED(ble_controller_init) ? 8K : 0K;
StackSize = 0x1000; /* 4KB */
__EM_SIZE =8K;

MEMORY
{
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1022K
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 12K
dtcm_memory (rx) : ORIGIN = 0x42017000, LENGTH = 4K
ram_memory (!rx) : ORIGIN = 0x42018000, LENGTH = 96K
hbn_memory (rx) : ORIGIN = 0x40010000, LENGTH = 0xE00 /* hbn ram 4K used 3.5K*/
dtcm_memory (rx) : ORIGIN = 0x42014000, LENGTH = 8K
ram_memory (!rx) : ORIGIN = 0x42016000, LENGTH = 72K
rsvd_memory (!rx) : ORIGIN = 0x42028000, LENGTH = 1K
ram2_memory (!rx) : ORIGIN = 0x42028400, LENGTH = (31K - __EM_SIZE)
hbn_memory (rx) : ORIGIN = 0x40010000, LENGTH = 0xE00 /* hbn ram 4K used 3.5K*/
}

SECTIONS
Expand Down Expand Up @@ -91,29 +92,26 @@ SECTIONS
. = ALIGN(4);
__text_code_end__ = .;
} > xip_memory
.preinit_array :
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >xip_memory AT>xip_memory

.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
} >xip_memory AT>xip_memory

.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
} >xip_memory AT>xip_memory

.ctors :
{
/* gcc uses crtbegin.o to find the start of
Expand All @@ -137,7 +135,6 @@ SECTIONS
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} >xip_memory AT>xip_memory

.dtors :
{
KEEP (*crtbegin.o(.dtors))
Expand All @@ -146,13 +143,11 @@ SECTIONS
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} >xip_memory AT>xip_memory

.lalign :
{
. = ALIGN(4);
PROVIDE( _data_lma = . );
} >xip_memory AT>xip_memory

. = ALIGN(4);
__itcm_load_addr = .;

Expand Down Expand Up @@ -182,7 +177,7 @@ SECTIONS
__tcm_code_end__ = .;
} > itcm_memory

__hbn_load_addr = __itcm_load_addr + SIZEOF(.itcm_region);
__hbn_load_addr = __itcm_load_addr + SIZEOF(.itcm_region);

.hbn_ram_region : AT (__hbn_load_addr)
{
Expand All @@ -208,8 +203,6 @@ SECTIONS
. = ALIGN(4);
__tcm_data_end__ = .;
} > dtcm_memory


/*************************************************************************/
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
Expand All @@ -226,7 +219,6 @@ SECTIONS
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory);
PROVIDE( __freertos_irq_stack_top = __StackTop);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);

/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack")
/*************************************************************************/
Expand Down Expand Up @@ -326,5 +318,7 @@ SECTIONS

ASSERT((__HeapLimit - __HeapBase ) >= __heap_min_size, "heap size is too short.")

PROVIDE( _heap_start = ORIGIN(ram2_memory) );
PROVIDE( _heap_size = LENGTH(ram2_memory) );
}

Loading