summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorguozhanxin <[email protected]>2021-03-24 18:37:28 +0800
committerguozhanxin <[email protected]>2021-03-24 18:57:23 +0800
commitbaaf81872def107b71ef27a8c168e6c64b83cfb6 (patch)
tree970a1e7066d95107e6134a924bc52b52214ac993 /bsp
parenteee1453c808074bb18c072032ee7e3feddd1679a (diff)
[bsp][raspberry-pico]All memory is used for heap.
Diffstat (limited to 'bsp')
-rw-r--r--bsp/raspberry-pico/drivers/board.c4
-rw-r--r--bsp/raspberry-pico/drivers/board.h6
-rw-r--r--bsp/raspberry-pico/libraries/pico-sdk/src/rp2_common/pico_runtime/runtime.c38
-rw-r--r--bsp/raspberry-pico/link.ld9
4 files changed, 6 insertions, 51 deletions
diff --git a/bsp/raspberry-pico/drivers/board.c b/bsp/raspberry-pico/drivers/board.c
index 1a4639095e..ff99bbfe86 100644
--- a/bsp/raspberry-pico/drivers/board.c
+++ b/bsp/raspberry-pico/drivers/board.c
@@ -16,8 +16,6 @@
#include "board.h"
#include "hardware/structs/systick.h"
-uint8_t heap[1024 * 80];
-
void isr_systick(void)
{
/* enter interrupt */
@@ -45,7 +43,7 @@ uint32_t systick_config(uint32_t ticks)
void rt_hw_board_init()
{
- rt_system_heap_init(heap, (uint8_t *)heap + sizeof(heap));
+ rt_system_heap_init(HEAP_BEGIN, HEAP_END);
alarm_pool_init_default();
diff --git a/bsp/raspberry-pico/drivers/board.h b/bsp/raspberry-pico/drivers/board.h
index e762b479f8..0c418d5c4e 100644
--- a/bsp/raspberry-pico/drivers/board.h
+++ b/bsp/raspberry-pico/drivers/board.h
@@ -20,9 +20,9 @@
#define PICO_SRAM_SIZE 256
#define PICO_SRAM_END (0x20000000 + PICO_SRAM_SIZE * 1024)
-extern int __bss_end;
-#define HEAP_BEGIN (&__bss_end)
-#define HEAP_END PICO_SRAM_END
+extern int __bss_end__;
+#define HEAP_BEGIN (&__bss_end__)
+#define HEAP_END ((void *)PICO_SRAM_END)
int rt_hw_uart_init(void);
diff --git a/bsp/raspberry-pico/libraries/pico-sdk/src/rp2_common/pico_runtime/runtime.c b/bsp/raspberry-pico/libraries/pico-sdk/src/rp2_common/pico_runtime/runtime.c
index af1bdd2b3a..98f124f0a3 100644
--- a/bsp/raspberry-pico/libraries/pico-sdk/src/rp2_common/pico_runtime/runtime.c
+++ b/bsp/raspberry-pico/libraries/pico-sdk/src/rp2_common/pico_runtime/runtime.c
@@ -27,6 +27,7 @@
#endif
extern char __StackLimit; /* Set by linker. */
+extern void _exit(int status);
uint32_t __attribute__((section(".ram_vector_table"))) ram_vector_table[48];
@@ -138,43 +139,6 @@ void runtime_init(void) {
irq_init_priorities();
}
-void _exit(int status) {
-#if PICO_ENTER_USB_BOOT_ON_EXIT
- reset_usb_boot(0,0);
-#else
- while (1) {
- __breakpoint();
- }
-#endif
-}
-
-void *_sbrk(int incr) {
- extern char end; /* Set by linker. */
- static char *heap_end;
- char *prev_heap_end;
-
- if (heap_end == 0)
- heap_end = &end;
-
- prev_heap_end = heap_end;
- char *next_heap_end = heap_end + incr;
-
- if (__builtin_expect(next_heap_end >= (&__StackLimit), false)) {
-#if PICO_USE_OPTIMISTIC_SBRK
- if (next_heap_end == &__StackLimit) {
-// errno = ENOMEM;
- return (char *) -1;
- }
- next_heap_end = &__StackLimit;
-#else
- return (char *) -1;
-#endif
- }
-
- heap_end = next_heap_end;
- return (void *) prev_heap_end;
-}
-
// exit is not useful... no desire to pull in __call_exitprocs
// void exit(int status) {
// _exit(status);
diff --git a/bsp/raspberry-pico/link.ld b/bsp/raspberry-pico/link.ld
index 898139432f..ae2889b0fd 100644
--- a/bsp/raspberry-pico/link.ld
+++ b/bsp/raspberry-pico/link.ld
@@ -224,13 +224,6 @@ SECTIONS
__bss_end__ = .;
} > RAM
- .heap (COPY):
- {
- __end__ = .;
- end = __end__;
- *(.heap*)
- __HeapLimit = .;
- } > RAM
/* .stack*_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
@@ -263,7 +256,7 @@ SECTIONS
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
- ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
+ ASSERT(__StackLimit >= __bss_end__, "region RAM overflowed")
/* todo assert on extra code */
}