Hi Yuri,
I tried your standalone LED program to test the board is working or not using internal SRAM. When using the sb_loader to send the test.sb file to board there is error during download but in board, i can see the blinking of LED and print message in Hyperterminal. The log information for your reference.
D:\sharelinux\LED>sb_loader.exe -f test.sb
Downloading test.sb to device.
.. CStHidDevice::Download() Error(258) during read.
Quitting.
Error(258) during download.
Quitting.
Can you give me an idea to test the SDRAM. I modified your code and cross compiled to test the SDRAM but it ends with error as follows
pause
DDR2 Test Starting
Writing
Bank Selection done
Writing 0
0x8020a014
Test program to test DDR
!
#include "stdio.h"
#include "hardware.h" /* note, this is where the SoC specific header file is included */
#define TXFE 0x0080
#define R32 volatile unsigned long *
#define R16 volatile unsigned short *
#define R8 volatile unsigned char *
#define PARAM_DDR_TEST_DENSITY (128 * 1024 * 1024)
#define PARAM_DDR_TEST_CS_NR 1
#define HW_UARTDBG_FR (*(R32)(0x80074018)) // UART Flag Register
#define HW_UARTDBG_DR (*(R32)(0x80074000)) // UART Data Register
#define HW_PWM_CTRL (*(R32)(0x80064000))
#define HW_PWM_ACTIVE0 (*(R32)(HW_PWM_CTRL + 0x10))
#define HW_PWM_PERIOD0 (*(R32)(HW_PWM_CTRL + 0x20))
#define HW_PWM_ACTIVE1 (*(R32)(HW_PWM_CTRL + 0x30))
#define HW_PWM_PERIOD1 (*(R32)(HW_PWM_CTRL + 0x40))
#define PINCTRL_MUXSEL6 (*(R32)(0x80018160))
#define PINCTRL_MUXSEL7 (*(R32)(0x80018170))
#define PINCTRL_MUXSEL7_SET (*(R32)(0x80018174))
#define PINCTRL_DOE3 (*(R32)(0x80018B30))
#define PINCTRL_DOUT3 (*(R32)(0x80018730))
void pwm1_init(U32 bright)
{
HW_PWM_CTRL = 0 ; //disable pwm 1
HW_PWM_ACTIVE1 = (bright<<16) & 0x01FF0000 ; // set pwm 1 0<bright<0x200
HW_PWM_PERIOD1 = 0x5B0200; // set pwm 1
HW_PWM_CTRL = 0x2 ; //enable pwm 1
}
void pause(int time)
{
volatile int i ;
while (time--) i = time ;
}
void outbyte(int c)
{
while( !(HW_UARTDBG_FR & TXFE) );
HW_UARTDBG_DR = c ;
}
int ddr_test(u32 density, u32 number_of_cs)
{
unsigned int failCount = 0;
unsigned int i;
unsigned int mem_src;
unsigned int *ps;
int bank_size = density / 8;
/* Data bus, walking ones test */
/* Looking for shorts on the board, so no need to test both chip selects */
printf("\n\rWriting \n\r");
/* First, write walking ones to DDR memory */
ps = (unsigned int *)(CSD0_BASE_ADDR + bank_size * 4);
printf("\n\r Bank Selection done \n\r");
for (i = 0; i <= 31; i++) {
printf("\n\r Writing %d \n\r",i);
*ps = 0x1 << i;
ps++;
}
printf("\n\r Reading \n\r");
/* Now, read-verify the memory */
ps = (unsigned int *)(CSD0_BASE_ADDR + bank_size * 4);
for (i = 0; i <= 31; i++) {
if (*ps != (0x1 << i)) {
failCount++;
}
ps++;
}
/* BANK ADDRESS test */
/* CS0 bank address test - note since code is stored in first part of DDR in CSD0
do not write data to the first bank to avoid overwriting code.
Hence variable "i" starts at 1 not 0 */
/* First, write data to each bank */
for (i = 1; i <= 7; i++) {
ps = (unsigned int *)(CSD0_BASE_ADDR + bank_size * i);
*ps = 0x11111111 * i;
}
/* Second, read back data from each bank to verify */
for (i = 1; i <= 7; i++) {
ps = (unsigned int *)(CSD0_BASE_ADDR + bank_size * i);
if (*ps != 0x11111111 * i) {
failCount++;
}
}
if (number_of_cs == 2) {
/* CS1 bank address test */
/* First, write data to each bank */
for (i = 0; i <= 7; i++) {
ps = (unsigned int *)(CSD1_BASE_ADDR + bank_size * i);
*ps = 0x88888888 + 0x11111111 * i;
}
/* Second, read back data from each bank to verify */
for (i = 0; i <= 7; i++) {
ps = (unsigned int *)(CSD1_BASE_ADDR + bank_size * i);
if (*ps != (0x88888888 + 0x11111111 * i)) {
failCount++;
}
}
}
/* DDR ADDRESS test, test the last two banks for each chip select */
/* CS0 */
/* First, write data to each row */
mem_src = CSD0_BASE_ADDR + bank_size * 6;
for (i = 0; i < bank_size * 2; i = i + 512) {
ps = (unsigned int *)(mem_src + i);
*ps = 0x12345678 + 0x11111111 * i;
}
/* Second, read back data from each row to verify */
mem_src = CSD0_BASE_ADDR + bank_size * 6;
for (i = 0; i < bank_size * 2; i = i + 512) {
ps = (unsigned int *)(mem_src + i);
if (*ps != (0x12345678 + 0x11111111 * i)) {
failCount++;
}
}
if (number_of_cs == 2) {
/* CS1 */
/* First, write data to each row */
mem_src = CSD1_BASE_ADDR + bank_size * 6;
for (i = 0; i < bank_size * 2; i = i + 512) {
ps = (unsigned int *)(mem_src + i);
*ps = 0x87654321 + 0x11111111 * i;
}
/* Second, read back data from each row to verify */
mem_src = CSD1_BASE_ADDR + bank_size * 6;
for (i = 0; i < bank_size * 2; i = i + 512) {
ps = (unsigned int *)(mem_src + i);
if (*ps != (0x87654321 + 0x11111111 * i)) {
failCount++;
}
}
}
if (failCount == 0) {
printf(" DDR test passed \n");
return 1;
} else {
printf(" DDR test failed \n");
return 0;
}
}
int main ()
{
printf("pause \n\r");
pause (100);
printf("DDR2 Test Starting\n\r");
pause (100);
ddr_test(PARAM_DDR_TEST_DENSITY, PARAM_DDR_TEST_CS_NR);
printf("DDR Test Finished\n\r");
PINCTRL_DOE3 = 0x30 ;
while (1)
{
pause(2000000);
PINCTRL_DOUT3 = 0x10 ;
printf("RAM 1\n\r");
pause(2000000);
PINCTRL_DOUT3 = 0 ;
printf("test 0\n\r");
PINCTRL_DOUT3 = 0x20 ;
printf("test 1\n\r");
pause(2000000);
PINCTRL_DOUT3 = 0 ;
printf("test 0\n\r");
}
}
!
Thanks,
RAM