Hi All,
On my project, I need to increase the amount of D-TCM from 64K to 128K. I have modified my linker script to do this (no problem), but now the device Hardfaults after reset. This is because the stack pointer is in the 'new' part of D-TCM which is not configured yet. I have configuration commands in my code (setting up GPR16 & GPR17), but it doesn't reach them because the crash is after the first PUSH instruction after Reset.
So, to fix it, I need to move my setting of GPR16 and GPR17 to before the first jump. To do this, I believe I need to change the DCD.
Currently the DCD is in evkmimxrt1020_sdram_ini_dcd.c, but it is in 'hex' form, so it is not clear what any of it does.
I could just experiment by adding commands to the end and see what happens, but it would be better if I could have a tool that creates this file from a template?, or the original source file with comments?, or something else?
How are we supposed to make our own DCD?
Thanks,
Chris.
Hello Chris,
you have to reconfigure the FlexRAM during the startup-code, the SystemInitHook Function would be a fine for that. For Detail how to configuration it, check the Application-Note AN12077
https://www.nxp.com/docs/en/application-note/AN12077.pdf
Best Regards
Hi Markus,
Thanks for your reply. That application note is useful - it confirmed a number of things for me.
There is another aspect which is not covered, and that is the debugger.
The problem is that the J-Link download from the IAR tools uses a small ELF file (C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\config\flashloader\NXP\FlashiMXRT1020_EVK_FlexSPI.out). This code assumes a certain configuration (the default) of FlexRAM. When the processor is reset via the debugger, it retains the FlexRAM configuration.
Therefore, if my code alters the FlexRAM configuration, the next time that I reset, the Debugger won't work. (It took me a while to figure this out!)
I believe the fix is to recompile the FlashIMXRT1050... project and use that, but I drew the line here at this point in time and decided to stick with the standard configuration.
This wasn't too hard because it turned out that the Linker configuration wasn't using the 128Kbyte of OCRAM. It set up 64K of D-TCM, and used that as the DATA segment. Nothing went into DATA2, so I just put some large buffers in there (e.g. Ethernet), which freed enough of the 64K to get me moving again.
Code:
SDK_ALIGN(uint8_t g_txDataBuff[ENET_TXBD_NUM][SDK_SIZEALIGN(ENET_TXBUFF_SIZE, APP_ENET_BUFF_ALIGNMENT)],
APP_ENET_BUFF_ALIGNMENT) @ "OCRAM";
Linker:
place in DATA2_region { section OCRAM };
(note I am using IAR tools)
Chris.
Hello Chris,
I don´t use IAR anymore (lucky me), but you can try to play with the reset options (reset with pin, etc).
In addition, IAR executes a macro after connect (*.mac files), you can alter this files to reconfigure the TCM-Configurations to the needs of the Flash-Loader.
Best regards
Markus
Good point Markus - thankyou. I had forgotten about the macro. That would be the more sensible way to 'fix' the limitations of the .out file.
Chris.