Browse Source

Dynamically partition ITCM & DTCM on IMXRT1062

teensy4-core
PaulStoffregen 5 years ago
parent
commit
24620b1a71
3 changed files with 23 additions and 12 deletions
  1. +4
    -0
      teensy4/bootdata.c
  2. +7
    -5
      teensy4/imxrt1062.ld
  3. +12
    -7
      teensy4/startup.c

+ 4
- 0
teensy4/bootdata.c View File



__attribute__ ((section(".vectors"), used)) __attribute__ ((section(".vectors"), used))
const uint32_t vector_table[2] = { const uint32_t vector_table[2] = {
#if defined(__IMXRT1052__)
(uint32_t)&_estack, (uint32_t)&_estack,
#elif defined(__IMXRT1062__)
0x20010000, // 64K DTCM for boot, ResetHandler configures stack after ITCM/DTCM setup
#endif
(uint32_t)&ResetHandler (uint32_t)&ResetHandler
}; };



+ 7
- 5
teensy4/imxrt1062.ld View File

MEMORY MEMORY
{ {
ITCM (rwx): ORIGIN = 0x00000000, LENGTH = 128K
DTCM (rwx): ORIGIN = 0x20000000, LENGTH = 128K
RAM (rwx): ORIGIN = 0x20200000, LENGTH = 256K
ITCM (rwx): ORIGIN = 0x00000000, LENGTH = 512K
DTCM (rwx): ORIGIN = 0x20000000, LENGTH = 512K
RAM (rwx): ORIGIN = 0x20200000, LENGTH = 512K
FLASH (rwx): ORIGIN = 0x60000000, LENGTH = 1536K FLASH (rwx): ORIGIN = 0x60000000, LENGTH = 1536K
} }


_edata = ADDR(.data) + SIZEOF(.data); _edata = ADDR(.data) + SIZEOF(.data);
_sdataload = LOADADDR(.data); _sdataload = LOADADDR(.data);


_estack = ORIGIN(DTCM) + LENGTH(DTCM);

_sbss = ADDR(.bss); _sbss = ADDR(.bss);
_ebss = ADDR(.bss) + SIZEOF(.bss); _ebss = ADDR(.bss) + SIZEOF(.bss);


_heap_start = ADDR(.bss.dma) + SIZEOF(.bss.dma); _heap_start = ADDR(.bss.dma) + SIZEOF(.bss.dma);
_heap_end = ORIGIN(RAM) + LENGTH(RAM); _heap_end = ORIGIN(RAM) + LENGTH(RAM);


_itcm_block_count = (SIZEOF(.text) + 0x7FFE) >> 15;
_flexram_bank_config = 0xAAAAAAAA | ((1 << (_itcm_block_count * 2)) - 1);
_estack = ORIGIN(DTCM) + ((16 - _itcm_block_count) << 15);

_flashimagelen = SIZEOF(.text.progmem) + SIZEOF(.text) + SIZEOF(.data); _flashimagelen = SIZEOF(.text.progmem) + SIZEOF(.text) + SIZEOF(.data);
_teensy_model_identifier = 0x24; _teensy_model_identifier = 0x24;



+ 12
- 7
teensy4/startup.c View File

extern unsigned long _edata; extern unsigned long _edata;
extern unsigned long _sbss; extern unsigned long _sbss;
extern unsigned long _ebss; extern unsigned long _ebss;

extern unsigned long _flexram_bank_config;
extern unsigned long _estack;


__attribute__ ((used, aligned(1024))) __attribute__ ((used, aligned(1024)))
void (* _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void); void (* _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void);
extern void __libc_init_array(void); // C++ standard library extern void __libc_init_array(void); // C++ standard library




__attribute__((section(".startup"), optimize("no-tree-loop-distribute-patterns")))
__attribute__((section(".startup"), optimize("no-tree-loop-distribute-patterns"), naked))
void ResetHandler(void) void ResetHandler(void)
{ {
unsigned int i; unsigned int i;


//force the stack to begin at some arbitrary location
//__asm__ volatile("mov sp, %0" : : "r" (0x20010000) : );

#if defined(__IMXRT1062__)
IOMUXC_GPR_GPR17 = (uint32_t)&_flexram_bank_config;
IOMUXC_GPR_GPR16 = 0x00000007;
IOMUXC_GPR_GPR14 = 0x00AA0000;
__asm__ volatile("mov sp, %0" : : "r" ((uint32_t)&_estack) : );
#endif
// pin 13 - if startup crashes, use this to turn on the LED early for troubleshooting // pin 13 - if startup crashes, use this to turn on the LED early for troubleshooting
//IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_03 = 5; //IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_03 = 5;
//IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_03 = IOMUXC_PAD_DSE(7); //IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_03 = IOMUXC_PAD_DSE(7);
//GPIO2_GDIR |= (1<<3);
//GPIO2_DR_SET = (1<<3); // digitalWrite(13, HIGH);
//IOMUXC_GPR_GPR27 = 0xFFFFFFFF;
//GPIO7_GDIR |= (1<<3);
//GPIO7_DR_SET = (1<<3); // digitalWrite(13, HIGH);


// Initialize memory // Initialize memory
memory_copy(&_stext, &_stextload, &_etext); memory_copy(&_stext, &_stextload, &_etext);

Loading…
Cancel
Save