External Memory Interface Handbook Volume 3: Reference Material

ID 683841
Date 7/24/2019
Public
Document Table of Contents

6.14.4. Writing a Predefined Data Pattern to SDRAM in the Preloader

You can include your own code to write a predefined data pattern to the SDRAM in the preloader for debugging purposes.
Include your code in the file: <project_folder>\software\spl_bsp\uboot-socfpga\arch\arm\cpu\armv7\socfpga\spl.c .
Adding the following code to the spl.c file causes the controller to write walking 1s and walking 0s, repeated five times, to the SDRAM.
/*added for demo, place after the last #define statement in spl.c */
#define ROTATE_RIGHT(X) ( (X>>1) | (X&1?0X80000000:0) )
/*added for demo, place after the calibration code */
 test_data_walk0((long *)0x100000,PHYS_SDRAM_1_SIZE);
int test_data_walk0(long *base, long maxsize)
{
	volatile long *addr;
	long           cnt;
	ulong	       data_temp[3];
        ulong	       expected_data[3];
	ulong	       read_data;   
        int            i = 0;  //counter to loop different data pattern
        int	       num_address;
       
       num_address=50;

       data_temp[0]=0XFFFFFFFE; //initial data for walking 0 pattern
       data_temp[1]=0X00000001; //initial data for walking 1 pattern
       data_temp[2]=0XAAAAAAAA; //initial data for A->5 switching

       expected_data[0]=0XFFFFFFFE; //initial data for walking 0 pattern
       expected_data[1]=0X00000001; //initial data for walking 1 pattern
       expected_data[2]=0XAAAAAAAA; //initial data for A->5 switching		
       
       for (i=0;i<3;i++) { 	
          
	printf("\nSTARTED %08X DATA PATTERN !!!!\n",data_temp[i]);
	/*write*/
	for (cnt = (0+i*num_address); cnt < ((i+1)*num_address) ;  cnt++ ) {
		addr = base + cnt;	/* pointer arith! */
		sync ();
	        *addr = data_temp[i];       
		data_temp[i]=ROTATE_RIGHT(data_temp[i]);

		}
 
	/*read*/
	for (cnt = (0+i*num_address); cnt < ((i+1)*num_address) ; cnt = cnt++ ) {
		addr = base + cnt;	/* pointer arith! */
		sync ();
		read_data=*addr;
      		printf("Address:%X  Expected: %08X    Read:%08X \n",addr, expected_data[i],read_data);
           	if (expected_data[i] !=read_data) {
                puts("!!!!!!FAILED!!!!!!\n\n");
		hang();
			}
                expected_data[i]=ROTATE_RIGHT(expected_data[i]); 
}
}
}
====//End Of Code//=====
Figure 155. Memory Contents After Executing Example Code


Did you find the information on this page useful?

Characters remaining:

Feedback Message