SDRAM gets currupted

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SDRAM gets currupted

1,294 次查看
petrama
Contributor III

Initializing a struct in SDRAM and then reading the values when the application runs, does not return the same values as initially set.

The struct is defined as:

typedef struct _cf_full_t {
uint8_t cf_bnb[160+40+50];
uint16_t cf_word[10];
uint32_t cf_dword[10];
} cf_full_t;

The  global variable of this struct type is initialized as:

__DATA(RAM5) const cf_full_t cf_default =  // have tried with and w/o const
{
0, 1, 1, 0, 0, 0, 0, 0, 0, 0, // 0 - 9
1, 1, 1, 1, 1, 1, 1, 1, 0, 1, // 10 - 19
..
3, 0, 0, 0, 4, 0, 0, 0, 0, 0, // 190 - 199
3, 1, 25, 8, 40, 0, 65, 4, 65, 25, // 200 - 209
5, 5, 2, 1, 75, 1, 40, 20, 40, 50, // 210 - 219
..
2, 5, 50, 6, 4, 30, 30, 14, 30, 25, // 240 - 249
1571,2050,12200,0, 0,300, 10, 4, 40, 0, // 250 - 259
0, 0, 4, 140, 0, 0, 0, 0, 0, 0 // 260 - 269
};

 

Memory definition for i.MX RT1024

Skærmbillede 2025-03-12 160402.png

Does SDRAM need to specified in linker script as well? (tried it but it didn't help). SRAM blocks are additionally specified in ResetISR.

Skærmbillede 2025-03-12 160843.png

When reading the struct variable the first 200 bytes are rubbish, but from then on everything is correct.! (i.e. the last 50 bytes in cf_bnb as well as cf_word and cf_dword.

Any explanation or just a guide to using SDRAM will be highly appreciated. I have read the User Guide at found the __DATA, __BBS, __NOINIT keywords. Is that all there is to it?

标记 (2)
0 项奖励
回复
9 回复数

1,232 次查看
petrama
Contributor III

Hi Habib

No, the application does not run from SDRAM.

The SDRAM is Alliance AS4C4M16SAA-6TIN.

Are there any requirements to size and address of blocks inside the SDRAM?

0 项奖励
回复

1,210 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @petrama,

I highly recommend se the SDK (version 24.12) example called "semc" in order to see how configured the SDRAM inside the RT1024-EVK. 

Are there any requirements to size and address of blocks inside the SDRAM?

It depends on your SDRAM and the features of the SEMC, where you can find more information about this peripheral in the chapter 24.2 in the RM.

BR
Habib

0 项奖励
回复

1,186 次查看
petrama
Contributor III

Hi

I ran the semc demo as is and the output told me that 16 and 32 bit read/write-compare failed but 8 bit was OK.

I discovered the call to  BOARD_InitSEMC(void), which does a lot of configuration, that I previously didn't know was needed.

Do you happen to know, what I should change in order to properly use Alliance AS4C4M16SAA-6TIN?

rgds

0 项奖励
回复

1,166 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @petrama,

We do not provide instructions for configuring a different SDRAM, and the configuration depends on the features supported by your SDRAM.

However, you can refer to the connections in our RT1024-EVK and the example I provided.
On the other hand, if the SEMC_SDRAMReadWrite8Bit function is the only one that works correctly, the issue could be due to the SDRAM configuration, or the pins used in 16 and 32-bit writing/reading.

BR
Habib.

0 项奖励
回复

1,152 次查看
petrama
Contributor III

I am confused about the read/write function used in the semc-demo. They work with address and data size specification just as when accessing data on an EEPROM. But if I place a global variable in a SDRAM memory section with the __DATA(RAM5) directive, can't I access this variable as any other variable?

Do I need to setup anything regarding SDRAM in linker scripts?

I tried in my own application to execute the BOARD_InitSEMC copied from the demo. Now all bytes in the arrays are 0 (zero) when read.

The supplier of my custom board says, that the specifications of the Alliance AS4C4M16SAA-6TIN SDRAm are the same as those for the SDRAM on the EVK-Board.

rgds

 

0 项奖励
回复

1,138 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @petrama,
I am confused about the read/write function used in the semc-demo. They work with address and data size specification just as when accessing data on an EEPROM. But if I place a global variable in a SDRAM memory section with the __DATA(RAM5) directive, can't I access this variable as any other variable?

Yes, you can use __DATA(RAM5) directive to save variables in SDRAM, but please take in mind the SDRAM needs to be initialized. Or you can use the method of the example.

Do I need to setup anything regarding SDRAM in linker scripts?

Only add the SDRAM section in the memory map, as you made in the next image:

Habib_MS_0-1742594398888.png

 

I tried in my own application to execute the BOARD_InitSEMC copied from the demo. Now all bytes in the arrays are 0 (zero) when read.

Please make sure you have the pins configured correctly.

The supplier of my custom board says, that the specifications of the Alliance AS4C4M16SAA-6TIN SDRAm are the same as those for the SDRAM on the EVK-Board.

Although the AS4C4M16SAA-6TIN SDRAM has the same features of our SDRAM, the configuration flow depends on each SDRAM.

In the other hand, could you please try to save another array or variable in SDRAM and use this variable in your code, this with the propose to avoid compiler optimizations?

For example:
Declaration: 

__DATA(RAM2) char data_buffer3[1024];

Main:
data_buffer3[0]=12;

BR
Habib

 

0 项奖励
回复

1,041 次查看
petrama
Contributor III

Hi Habib

If I place the array in standard SRAM_DTC either automatically or via the __DATA(RAM) prefix, then everything works fine.

The supplier informs that the SDRAM needs to work with a 166Mhz or 143Mhz clock speed. How do I adjust the parameters in the demos BOARD_InitHardware function to commodate this?

 
void BOARD_InitHardware(void)
{
 BOARD_ConfigMPU();
 BOARD_InitBootPins();
 BOARD_InitBootClocks();

 CLOCK_InitSysPfd(kCLOCK_Pfd2, 24);
// Set semc clock to 132 MHz ( most be change to 166Mhz or 143 Mhz !)
 CLOCK_SetMux(kCLOCK_SemcMux, 1);
 CLOCK_SetDiv(kCLOCK_SemcDiv, 2);

 BOARD_InitDebugConsole();
}

 

rgds

0 项奖励
回复

1,032 次查看
Habib_MS
NXP Employee
NXP Employee

Hello again @petrama,

In order to change the semc clock source you can use config tools, where you can find the user's guide in this page.
Also, if you experience any issue, do not hesitate to let me know.
BR
Habib

0 项奖励
回复

1,262 次查看
Habib_MS
NXP Employee
NXP Employee

Hello @petrama,
In order to support you better, can you provide me the next information?

-Will you be running your application from SDRAM?
- Which SDRAM are you currently using?

In the other hand, I highly recommend check the "MCUXpresso Secure Provisioning Tool User Guide v.10", in order to obtain updated information. Inside you can find the chapter 6.2.1.3 called "Image running from external SDRAM", where shows the steps to getting a bootable image from SDRAM using MCUxpresso IDE.
BR
Habib

0 项奖励
回复