From e26c93a666acceb0d73a80100a934b9875e6fa5b Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Wed, 19 Oct 2022 14:27:44 +0800 Subject: [PATCH] fix heap memory error : start from _bss_end and conflict with stack segment --- .../arch/arm/cortex-m4/hc32f4a0/boot.S | 22 +------------------ .../XiZi_IIoT/board/hc32f4a0/.defconfig | 4 ++-- Ubiquitous/XiZi_IIoT/board/hc32f4a0/board.h | 4 ++-- Ubiquitous/XiZi_IIoT/board/hc32f4a0/link.lds | 6 ++--- 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT/arch/arm/cortex-m4/hc32f4a0/boot.S b/Ubiquitous/XiZi_IIoT/arch/arm/cortex-m4/hc32f4a0/boot.S index c70e3a195..08860b4e2 100644 --- a/Ubiquitous/XiZi_IIoT/arch/arm/cortex-m4/hc32f4a0/boot.S +++ b/Ubiquitous/XiZi_IIoT/arch/arm/cortex-m4/hc32f4a0/boot.S @@ -48,7 +48,7 @@ Modification: ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ; */ - .equ Stack_Size, 0x00002000 + .equ Stack_Size, 0x00004000 .section .stack .align 3 @@ -60,26 +60,6 @@ __StackLimit: __StackTop: .size __StackTop, . - __StackTop - -/* -; Heap Configuration -; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> -; -*/ - .equ Heap_Size, 0x00002000 - - .if Heap_Size != 0 /* Heap is provided */ - .section .heap - .align 3 - .globl __HeapBase - .globl __HeapLimit -__HeapBase: - .space Heap_Size - .size __HeapBase, . - __HeapBase -__HeapLimit: - .size __HeapLimit, . - __HeapLimit - .endif - /* ; Reset handler start. */ diff --git a/Ubiquitous/XiZi_IIoT/board/hc32f4a0/.defconfig b/Ubiquitous/XiZi_IIoT/board/hc32f4a0/.defconfig index 90f2a047d..761c3df3d 100644 --- a/Ubiquitous/XiZi_IIoT/board/hc32f4a0/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/hc32f4a0/.defconfig @@ -75,7 +75,7 @@ CONFIG_KERNEL_SEMAPHORE=y CONFIG_KERNEL_MUTEX=y CONFIG_KERNEL_EVENT=y CONFIG_KERNEL_MESSAGEQUEUE=y -CONFIG_KERNEL_SOFTTIMER=n +CONFIG_KERNEL_SOFTTIMER=y CONFIG_SCHED_POLICY_RR_REMAINSLICE=y # CONFIG_SCHED_POLICY_RR is not set # CONFIG_SCHED_POLICY_FIFO is not set @@ -134,7 +134,7 @@ CONFIG_SHELL_HELP_LIST_VAR=y # Kernel data structure Manage # CONFIG_KERNEL_QUEUEMANAGE=y -CONFIG_KERNEL_WORKQUEUE=n +CONFIG_KERNEL_WORKQUEUE=y CONFIG_WORKQUEUE_KTASK_STACKSIZE=2048 CONFIG_WORKQUEUE_KTASK_PRIORITY=23 CONFIG_QUEUE_MAX=16 diff --git a/Ubiquitous/XiZi_IIoT/board/hc32f4a0/board.h b/Ubiquitous/XiZi_IIoT/board/hc32f4a0/board.h index 427f446d6..802b79aa0 100644 --- a/Ubiquitous/XiZi_IIoT/board/hc32f4a0/board.h +++ b/Ubiquitous/XiZi_IIoT/board/hc32f4a0/board.h @@ -35,11 +35,11 @@ Modification: #include -extern int __bss_end; +extern int __heap_start; extern unsigned int g_service_table_start; extern unsigned int g_service_table_end; -#define MEMORY_START_ADDRESS (&__bss_end) +#define MEMORY_START_ADDRESS (&__heap_start) #define HC32F4_SRAM_SIZE 512 #define MEMORY_END_ADDRESS (0x1FFE0000 + HC32F4_SRAM_SIZE * 1024) diff --git a/Ubiquitous/XiZi_IIoT/board/hc32f4a0/link.lds b/Ubiquitous/XiZi_IIoT/board/hc32f4a0/link.lds index 2960ba39f..fdf1b5e73 100644 --- a/Ubiquitous/XiZi_IIoT/board/hc32f4a0/link.lds +++ b/Ubiquitous/XiZi_IIoT/board/hc32f4a0/link.lds @@ -216,20 +216,18 @@ SECTIONS __end__ = .; PROVIDE(end = .); PROVIDE(_end = .); - *(.heap*) - . = ALIGN(8); - __HeapLimit = .; __StackLimit = .; *(.stack*) . = ALIGN(8); __StackTop = .; + + __heap_start = .; } >RAM .ARM.attributes 0 : { *(.ARM.attributes) } PROVIDE(_stack = __StackTop); - PROVIDE(_Min_Heap_Size = __HeapLimit - __HeapBase); PROVIDE(_Min_Stack_Size = __StackTop - __StackLimit); __RamEnd = ORIGIN(RAM) + LENGTH(RAM);