Pārlūkot izejas kodu

Add extmem_smalloc_pool for PSRAM on Teensy 4.1

main
PaulStoffregen pirms 4 gadiem
vecāks
revīzija
e207bcff0a
2 mainītis faili ar 15 papildinājumiem un 1 dzēšanām
  1. +4
    -0
      teensy4/smalloc.h
  2. +11
    -1
      teensy4/startup.c

+ 4
- 0
teensy4/smalloc.h Parādīt failu

@@ -33,6 +33,10 @@ struct smalloc_pool {
/* a default one which is initialised with sm_set_default_pool. */
extern struct smalloc_pool smalloc_curr_pool;

#ifdef ARDUINO_TEENSY41
extern struct smalloc_pool extmem_smalloc_pool;
#endif

/* undefined behavior handler is called on typical malloc UB situations */
typedef void (*smalloc_ub_handler)(struct smalloc_pool *, const void *);


+ 11
- 1
teensy4/startup.c Parādīt failu

@@ -2,6 +2,7 @@
#include "wiring.h"
#include "usb_dev.h"
#include "avr/pgmspace.h"
#include "smalloc.h"

#include "debug/printf.h"

@@ -16,6 +17,8 @@ extern unsigned long _sbss;
extern unsigned long _ebss;
extern unsigned long _flexram_bank_config;
extern unsigned long _estack;
extern unsigned long _extram_start;
extern unsigned long _extram_end;

__attribute__ ((used, aligned(1024)))
void (* _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void);
@@ -37,6 +40,9 @@ uint32_t set_arm_clock(uint32_t frequency); // clockspeed.c
extern void __libc_init_array(void); // C++ standard library

uint8_t external_psram_size = 0;
#ifdef ARDUINO_TEENSY41
struct smalloc_pool extmem_smalloc_pool;
#endif

extern int main (void);
void startup_default_early_hook(void) {}
@@ -428,9 +434,13 @@ FLASHMEM void configure_external_ram()
}
// TODO: zero uninitialized EXTMEM variables
// TODO: copy from flash to initialize EXTMEM variables
// TODO: set up for malloc_extmem()
sm_set_pool(&extmem_smalloc_pool, &_extram_end,
external_psram_size * 0x100000 -
((uint32_t)&_extram_end - (uint32_t)&_extram_start),
1, NULL);
} else {
// No PSRAM
memset(&extmem_smalloc_pool, 0, sizeof(extmem_smalloc_pool));
}
}


Notiek ielāde…
Atcelt
Saglabāt