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.