Skip to content

Commit

Permalink
[update] init psram before kmem_init
Browse files Browse the repository at this point in the history
  • Loading branch information
sakumisue committed Mar 6, 2023
1 parent 765a5d5 commit eb7afed
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 30 deletions.
13 changes: 13 additions & 0 deletions bsp/board/bl616dk/bl616_flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ENTRY(__start)

StackSize = 0x1000; /* 4KB */
HeapMinSize = 0x1000; /* 4KB */
psram_min_size = 0x1000;

__EM_SIZE = DEFINED(btble_controller_init) ? 32K : 0K;
__RFTLV_SIZE_OFFSET = 1K;
Expand Down Expand Up @@ -279,6 +280,18 @@ SECTIONS
__psram_data_end__ = .;
} > ram_code

.psram_heap (NOLOAD):
{
. = ALIGN(4);
__psram_heap_base = .;
KEEP(*(.psram_heap*))
. = ALIGN(4);
__psram_heap_end = .;
} > ram_code

__psram_limit = ORIGIN(ram_code) + LENGTH(ram_code);
ASSERT(__psram_limit - __psram_heap_base >= psram_min_size, "psram heap region overflow")

.wifibss (NOLOAD) :
{
PROVIDE( __wifi_bss_start = ADDR(.wifibss) );
Expand Down
24 changes: 13 additions & 11 deletions bsp/board/bl616dk/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,21 @@ void board_init(void)
bflb_irq_initialize();

console_init();

size_t heap_len = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
kmem_init((void *)&__HeapBase, heap_len);


bl_show_log();
if (ret != 0) {
printf("flash init fail!!!\r\n");
}
bl_show_flashinfo();

#ifdef CONFIG_PSRAM
board_psram_x8_init();
Tzc_Sec_PSRAMB_Access_Release();
#endif

size_t heap_len = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
kmem_init((void *)&__HeapBase, heap_len);

printf("dynamic memory init success,heap size = %d Kbyte \r\n", ((size_t)&__HeapLimit - (size_t)&__HeapBase) / 1024);

printf("sig1:%08x\r\n", BL_RD_REG(GLB_BASE, GLB_UART_CFG1));
Expand All @@ -237,11 +242,6 @@ void board_init(void)
rtc = bflb_device_get_by_name("rtc");
#endif

#ifdef CONFIG_PSRAM
board_psram_x8_init();
Tzc_Sec_PSRAMB_Access_Release();
#endif

bflb_irq_restore(flag);
}

Expand Down Expand Up @@ -463,9 +463,11 @@ void board_i2s_gpio_init()

void board_iso11898_gpio_init()
{
// struct bflb_device_s *gpio;
struct bflb_device_s *gpio;

// gpio = bflb_device_get_by_name("gpio");
gpio = bflb_device_get_by_name("gpio");
bflb_gpio_iso11898_init(gpio, GPIO_PIN_14, GPIO_ISO11898_FUNC_TX);
bflb_gpio_iso11898_init(gpio, GPIO_PIN_15, GPIO_ISO11898_FUNC_RX);
}

#ifdef CONFIG_BFLOG
Expand Down
13 changes: 7 additions & 6 deletions bsp/board/bl702dk/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,19 @@ void board_init(void)

console_init();

size_t heap_len = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
kmem_init((void *)&__HeapBase, heap_len);

bl_show_log();
if (ret != 0) {
printf("flash init fail!!!\r\n");
}
bl_show_flashinfo();

#ifdef CONFIG_PSRAM
board_psram_init();
#endif

size_t heap_len = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
kmem_init((void *)&__HeapBase, heap_len);

printf("dynamic memory init success,heap size = %d Kbyte \r\n", ((size_t)&__HeapLimit - (size_t)&__HeapBase) / 1024);

printf("cgen1:%08x\r\n", getreg32(BFLB_GLB_CGEN1_BASE));
Expand All @@ -253,9 +257,6 @@ void board_init(void)
#if defined(CONFIG_BFLOG)
rtc = bflb_device_get_by_name("rtc");
#endif
#ifdef CONFIG_PSRAM
board_psram_init();
#endif

bflb_irq_restore(flag);
}
Expand Down
4 changes: 2 additions & 2 deletions bsp/board/bl808dk/bl808_flash_lp.ld
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ HeapMinSize = 0x1000; /* 4KB */

MEMORY
{
fw_header_memory0 (rx) : ORIGIN = 0x58020000 - 0x1000, LENGTH = 4K
fw_header_memory (rx) : ORIGIN = 0x58020000 - 0x1000, LENGTH = 4K
xip_memory (rx) : ORIGIN = 0x58020000, LENGTH = 1M
itcm_memory (rx) : ORIGIN = 0x2202C000, LENGTH = 16K
dtcm_memory (rx) : ORIGIN = 0x22030000, LENGTH = 16K
Expand All @@ -36,7 +36,7 @@ SECTIONS
.fw_header :
{
KEEP(*(.fw_header))
} > fw_header_memory0
} > fw_header_memory

.text :
{
Expand Down
24 changes: 13 additions & 11 deletions bsp/board/bl808dk/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,21 @@ void board_init(void)

console_init();

size_t heap_len = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
kmem_init((void *)&__HeapBase, heap_len);

bl_show_log();
if (ret != 0) {
printf("flash init fail!!!\r\n");
}
bl_show_flashinfo();

#ifdef CONFIG_PSRAM
if (uhs_psram_init() < 0) {
while (1) {
}
}
#endif
size_t heap_len = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
kmem_init((void *)&__HeapBase, heap_len);

printf("dynamic memory init success,heap size = %d Kbyte \r\n", ((size_t)&__HeapLimit - (size_t)&__HeapBase) / 1024);

printf("sig1:%08x\r\n", BL_RD_REG(GLB_BASE, GLB_UART_CFG1));
Expand All @@ -265,12 +271,6 @@ void board_init(void)
rtc = bflb_device_get_by_name("rtc");
#endif

#ifdef CONFIG_PSRAM
if (uhs_psram_init() < 0) {
while (1) {
}
}
#endif
/* set CPU D0 boot XIP address and flash address */
Tzc_Sec_Set_CPU_Group(GLB_CORE_ID_D0, 1);
/* D0 boot from 0x58000000 */
Expand Down Expand Up @@ -554,9 +554,11 @@ void board_csi_gpio_init(void)

void board_iso11898_gpio_init()
{
// struct bflb_device_s *gpio;
struct bflb_device_s *gpio;

// gpio = bflb_device_get_by_name("gpio");
gpio = bflb_device_get_by_name("gpio");
bflb_gpio_iso11898_init(gpio, GPIO_PIN_14, GPIO_ISO11898_FUNC_TX);
bflb_gpio_iso11898_init(gpio, GPIO_PIN_15, GPIO_ISO11898_FUNC_RX);
}

#ifdef CONFIG_BFLOG
Expand Down

0 comments on commit eb7afed

Please sign in to comment.