External Memory Chip Select

toyosm

Well-known member
I've done a custom board with an external memory but mistakenly I connected the chip select pin to the F1 pin of the iMXRT instead of the D3 (that's the chip select for the second flash/psram chip). There's any change I can do on the software to solve this, because I know is possible to connect an external memory with that chip select but on the PSRAM page on the site says that if you're using one solder it to the small pads (corresponding to the chip select on D3). I don't want to throw away all the boards of this run.
 
For a first attempt, maybe try editing the startup code where it checks for the first and second chip. If you just hard-code it to pass the check as if the first chip was found, then it should find the second chip. Then try editing the PSRAM memory test to check 8MB at 0x78000000. Proper memory test is essential because the 32K cache can make bad memory appear to be good if you test only a small amount.

Once you get memory working at 0x78000000, then try 1 of 2 possible paths. Edit the linker script to just use the memory at that location, or go back to the startup code and try editing the FlexSPI config so the 2nd chip appears at 0x70000000.

This isn't a normally supported thing, so this general guide is the most I can do. I know you probably want more specific code and example, but you're going to have to experiment a bit and fill in the details. If you do get it working, maybe post known-working code so anyone else who later has this problem (sometimes people solder the chip to the wrong place and ask a similar question) can find the solution more easily.
 
I made it work!. Changed the startup.c to pass the check of the first chip and go directly to the second one and adjusting the memory size to 8 all the time. Then on the Linker script changed the memory origin to 0x70800000 (not 0x78000000, didn't work like that, re checked with the memory_end on the psram_test).

Here are the changes, starts on line 482 of the startup.c


C++:
// look for the first PSRAM chip
    flexspi2_command(0, 0); // exit quad mode
    flexspi2_command(1, 0); // reset enable
    flexspi2_command(2, 0); // reset (is this really necessary?)
    if (!(flexspi2_psram_id(0) == 0x5D0D)) // * Force to enter the if without first chip
    {
        // first PSRAM chip is present, look for a second PSRAM chip
        flexspi2_command(4, 0);
        flexspi2_command(0, 0x800000); // exit quad mode
        flexspi2_command(1, 0x800000); // reset enable
        flexspi2_command(2, 0x800000); // reset (is this really necessary?)
        if (flexspi2_psram_id(0x800000) == 0x5D0D)
        {
            flexspi2_command(4, 0x800000);
            // Two PSRAM chips are present, 16 MByte
            //external_psram_size = 16;   // There's only one chip, so can't be 16
        //}
        //else
        //{
            // One PSRAM chip is present, 8 MByte
            external_psram_size = 8;
        }
        // TODO: zero uninitialized EXTMEM variables
        // TODO: copy from flash to initialize EXTMEM variables
        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));
    }

Then on the psram test I changed the memory_begin and memory_end variables to start on 0x70800000:

C++:
memory_begin = (uint32_t *)(0x70800000);                    // Memory on slot 2 start address
memory_end = (uint32_t *)(0x70800000 + size * 1048576);        // Memory on slot 2 end address

Finally, on the likner script imxrt1062_t41.id changed the memory origin address and the length (since we're only going to get 8M)


Code:
MEMORY
{
    ITCM (rwx):  ORIGIN = 0x00000000, LENGTH = 512K
    DTCM (rwx):  ORIGIN = 0x20000000, LENGTH = 512K
    RAM (rwx):   ORIGIN = 0x20200000, LENGTH = 512K
    FLASH (rwx): ORIGIN = 0x60000000, LENGTH = 7936K
    ERAM (rwx):  ORIGIN = 0x70800000, LENGTH = 8192K
}

Also, since my custom board is based on the Micro Mod, changed the imxrt1062_mm.id linker script to add the ERAM memory area, just adding the last line (ERAM (rxw)...) to the end. If you have a MicroMod or a custom board based on that don't copy/paste all the structure from the T4.1 because the Flash on the MM is bigger

Tested all this on a 4.1 teensy with the memory soldered to the second slot
 
Out of curiosity, with a custom board, why did you choose PSRAM over faster SDRAM?
 
Out of curiosity, with a custom board, why did you choose PSRAM over faster SDRAM?
Just for development speed. I used PSRAM before and had more information about it. So just to get this working asap (product release is behind schedule) I chose the PSRAM.

As soon as the production is set I'll surely start the road to the SDRAM
 
Back
Top