imx rt 1024: dma for flexspi in nor_edma_transfer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx rt 1024: dma for flexspi in nor_edma_transfer

409 Views
bp1979
Senior Contributor I

After finally getting second flash working, I am trying to enable it through DMA buffers.

I can run the SDK example without problems. After integrating the changes into my own applications I get hardfaults when I program a page.

After many attempts to reproduce the issue in the SDK example, I finally succeeded. It has something to do with memory alignment, which is done in the SDK example by moving the vector table to SRAM, and align the ram vector table on 128.

When I change the ALIGN value from 128 to e.g. 124 in the linkscript "main_data_section.ldt", then the SDK example hard faults on exactly the same moment as my own application does.

I am trying really hard to understand what is going on here, but I need some guidance. Please look at this particular part in the linker script template:

    M_VECTOR_RAM_SIZE = 0x00000180;
    /* Main DATA section (SRAM) */
    .data : ALIGN(4)
    {
       FILL(0xff)
       _data = . ;
       *(vtable)
       *(.ramfunc*)
       KEEP(*(CodeQuickAccess))
       KEEP(*(DataQuickAccess))
       *flexspi_nor_flash_ops.o(.text .text* .rodata .rodata*)
       *fsl_flexspi.o(.text .text* .rodata .rodata*)
       *fsl_edma.o(.text .text* .rodata .rodata*)
       *fsl_flexspi_edma.o(.text .text* .rodata .rodata*)
       *(.data*)




/* ------------------------- IT STARTS HERE -------------------------*/
       . = ALIGN(128);
       __VECTOR_RAM = .;
       __interrupts_ram_start__ = .; /* Create a global symbol at data start */
       *(.m_interrupts_ram)     /* This is a user defined section */
/* ------------------------- IT ENDS HERE -------------------------*/




       . += M_VECTOR_RAM_SIZE;
       . = ALIGN(4) ;
       __interrupts_ram_end__ = .; /* Define a global symbol at data end */
       _edata = . ;
    } > SRAM_DTC AT>PROGRAM_FLASH
    __VECTOR_TABLE = __vectors_start__;
    __RAM_VECTOR_TABLE_SIZE_BYTES = (__interrupts_ram_end__ - __interrupts_ram_start__);

 

So, when I change the ALIGN(128) to ALIGN(124) and run the application, the application hard faults when it tries to program a page.

But what happens in the highlighted section above? Why is the ALIGN(128) important? And maybe even more important, the section doesn't seem to contain anything!

 

There is no function, or variable that has this attribute:

*(.m_interrupts_ram) /* This is a user defined section */ <<=== DOES NOT APPEAR ANYWHERE IN CODE?

 

My main question: is there a way to get this to work WITHOUT moving the vector table to SRAM? Can I align the two interrupt handlers for DMA (rx + tx) and link these two functions to SRAM to achieve the same? I already link these two interrupt handlers to SRAM, but that is not enough.

 

0 Kudos
3 Replies

371 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

 

Just to understand, when you change the ALIGN to 124 you are presenting problems on your code, but when it has the 128 value everything works fine?

This is because the functionality of ALIGN is to allow and specify the beginning offset of data or instruction. So reducing this value is probably affecting another section and it will require to re-adjust the affected areas.

0 Kudos

333 Views
bp1979
Senior Contributor I

Hi @nxf77486 

Hmm, so maybe I am not reproducing the problem exactly then. I am just injecting a different problem which has a very similar outcome.

 

What I also don't fully understand is why I would the SDK example links the entire vector table to SRAM? I understand that every line of code that executes while interacting with flash, must run in SRAM. Or at least, while interacting with flash, no instruction can be fetched from flash. I get that much. But why do we need to move the entire vector table to SRAM?

I would expect that I only need to link the interrupt handlers for the DMA buffers used by flexspi should be linked to SRAM. But when I do that, the application hard faults too. So clearly I am wrong.

Can you explain why? The vector table is just an array of function pointers, right? These function pointers as assigned to SCB->VTOR. When an exception occurs (interrupt) the CPU would call the corresponding function. As long as I am taking care that the function itself is linked to SRAM, I thought it should work.

Is there more to it? Am I missing something?

0 Kudos

323 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

I understand your question, I think most of your concerns can be answered on the MCUXpresso User Guide, on the chapter 20 Memory configuration and liker scripts. This chapter also explain ow to perform changes.

0 Kudos