Hi,
i don't have much experience to software embedded. I work with am335x pocessor in Linux ubuntu. My board have a 256 MiB RAM. I use the file source code u-boot-2011.09. I have to realize the function that read automatically the size of DDR3 RAM.
In file board.c i have add this row code:
static int display_dram_config(void)
{
int i;
unsigned long *p_write_ram = NULL;
#ifndef DEBUG
puts("RAM Configuration:\n");
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
{
printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
print_size(gd->bd->bi_dram[i].size, "\n");
}
#else
ulong size = 0;
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
{
size += gd->bd->bi_dram[i].size;
}
puts("DRAM: ");
/*TODO: row add to original code*/
p_write_ram = 0x80000000; // first address ddr RAM 256MiB
*p_write_ram = 0xABCDEF00;
printf("%x %x \n", p_write_ram, *p_write_ram);
p_write_ram = 0x90000000;
printf("%x %x \n", p_write_ram, *p_write_ram);
#endif
return (0);
}
0x80000000 is the first address to write in RAM block 0
0x90000000 is the second address to write in RAM block 1
Either the size block is 256MiB.
In the file am335_evm.h i modify the following #define
#define CONFIG_NR_DRAM_BANKS 2 /* 2 bank of DRAM */
#define PHYS_DRAM_1 0x80000000 /* DRAM Bank #1 */
#define PHYS_DRAM_2 0x90000000 /* DRAM Bank #2 */
#define PHYS_DRAM_1_SIZE 0x10000000 /* 256 MiB */
#define CONFIG_SYS_SDRAM_BASE PHYS_DRAM_1
#define CONFIG_SYS_SDRAM_BASE_2 PHYS_DRAM_2
In the code i write to address 0x80000000 the value 0xABCDEF00. After i read the value from address 0x90000000 and i read the same value of the address 0x80000000. Why the two address have the same value?
How can i realize the function that automatically read the size of RAM of my board? For example if my board mount RAM 512, the function return me 512.
Thanks