void copy_code_to_dram(void) { //unsigned long ch; void (*user_bin)(void); //ch = *(volatile unsigned int *)(0xD0037488);//need modify // 函数指针 //copy_sd_mmc_to_mem copy_bl2 = (copy_sd_mmc_to_mem) (*(unsigned int *) (0xD0037F98)); //copy_bl2(0, 49, 32,(unsigned int *)0x23E00000, 0); // 49:源,代码位于扇区49,1 sector = 512 bytes // 32:长度,拷贝32 sector,即16K // 0x23E00000:目的,链接地址0x23E00000 volatile unsigned long count=0x100000; while(count>0){ count--;} uart_asm_putc('C'); uart_asm_putc('O'); uart_asm_putc('P'); uart_asm_putc('Y'); uart_asm_putc('\r'); uart_asm_putc('\n'); SDMMC_ReadBlocks(49,32,(unsigned int *)0x43e00000); //uart_asm_putx("now copy OVER!!!!/n"); uart_asm_putc('O'); uart_asm_putc('V'); uart_asm_putc('E'); uart_asm_putc('R'); uart_asm_putc('\r'); uart_asm_putc('\n'); unsigned int *p; int i; p = (unsigned int *) 0x43e00000; for (i = 0; i < 100; i++) { uart_asm_putx(*(p+i)); uart_asm_putc(' '); } // 跳转到DRAM user_bin = (void *)0x43e00000; (*user_bin)(); }
int main(void) { char rec; unsigned char value = 0; printf("\n\r\n\r"); iic_init(); printf("\n\r"); iic_master_write(0xa0, 0x3, 0x15); iic_master_read(0xa0, 0x3, &value); printf("addr 0x3 value is: "); uart_asm_putx(value); printf("\n\r"); iic_dest(); return 0; }
void uboot_mem_test(void) { unsigned int *p; int i; /* show dram config */ p = (unsigned int *) 0x10600000; for (i = 0; i < 0x100/4; i++, p++) { if (!(i & 0xf)) { uart_asm_putc('\r'); uart_asm_putc('\n'); } uart_asm_putx(*p); uart_asm_putc('.'); } p = (unsigned int *) 0x10610000; for (i = 0; i < 0x100/4; i++, p++) { if (!(i & 0xf)) { uart_asm_putc('\r'); uart_asm_putc('\n'); } uart_asm_putx(*p); uart_asm_putc('.'); } uart_asm_putc('\r'); uart_asm_putc('\n'); uart_asm_putc('L'); uart_asm_putc('e'); uart_asm_putc('n'); uart_asm_putc(':'); uart_asm_putc(' '); uart_asm_putx(MT_LEN); uart_asm_putc('\r'); uart_asm_putc('\n'); uart_asm_putc('W'); /* writing */ p = (unsigned int *) MT_START; for (i = 0; i < MT_LEN/4; i++, p++) { *p = i+0x5a000000; if (!(i & 0xfffff)) { uart_asm_putc('.'); } } uart_asm_putc('\r'); uart_asm_putc('\n'); uart_asm_putc('R'); /* read and verify */ p = (unsigned int *) MT_START; for (i = 0; i < MT_LEN/4; i++, p++) { if (*p != (i+0x5a000000)) { uart_asm_putc('X'); uart_asm_putx(i); uart_asm_putx(p); if (i > 4) { uart_asm_putx(*(p-4)); uart_asm_putx(*(p-3)); uart_asm_putx(*(p-2)); uart_asm_putx(*(p-1)); } uart_asm_putx(*p); uart_asm_putx(*(p+1)); uart_asm_putx(*(p+2)); uart_asm_putx(*(p+3)); uart_asm_putx(*(p+4)); break; } if (!(i & 0xfffff)) { uart_asm_putc('.'); } } uart_asm_putc('\r'); uart_asm_putc('\n'); uart_asm_putc('>'); #if 0 /* dump memory */ p = (unsigned int *) MT_START; for (i = 0; i < 0x200; i++, p++) { if (!(i & 0xf)) { uart_asm_putc('\r'); uart_asm_putc('\n'); } uart_asm_putx(*p); uart_asm_putc('.'); } uart_asm_putc('\r'); uart_asm_putc('\n'); #endif }