Пример #1
0
int main()
{	
	copy_vec();
	irq_init();
	button_init();
	uart0_init();
	timer_init();
//	timer4_init();

	lcd_init();
	lcd_clean(0xffff);
	adc_ts_init();
	ts_init();

//	tslib_calibrate();
//	lcd_clean(0xffff);

	nand_init();
#if 1	
	nand_read_id();
	
	while(1);
#endif

	printf("\r\n\n");
	printf("===============================================\r\n");
	printf("              NAND FLASH PROGRAMMING            \r\n");
	
	unsigned int size = 512 * 1024; // 512KB
	nand_read_id();

	printf("erase entire flash, waiting ... \r\n");

	int i;
	for(i = 0; i < 2048; i++)
		nand_erase_block(i);
	
	printf("start program ... \r\n");
	nand_write_bytes(0x0, (unsigned char *)0x31000000, size);
	printf("program end ... \r\n");
	printf("===============================================\r\n");
	while(1);
	
	return 0;
}
Пример #2
0
int mymain()
{
	unsigned char c = 68;
	//clock_init();
	uart_init();
	// 初始化nandflash
	nand_init();
	
	while (1)
	{
		printf("\r\n********Nandflash R/W Test*******\r\n");
		printf("[i] Read ID\r\n");
		printf("[e] Erase Nandflash\r\n");
		printf("[w] Write Nandflash\r\n");
		printf("[r] Read  Nandflash\r\n");
		printf("[n] read sdram to nand\r\n");
		printf("Enter your choice: ");
		c = getc();
		printf("%c\r\n",c);
		
		switch(c)
		{
		case 'i':
			nand_read_id();
			break;
		case 'e':
			erase_test();
			break;
		case 'w':
			write_test();
			break;
		case 'r':
			read_test();
			break;
		case 'n':
			sdram_to_nand_test();
			break;
		}
	}
	return 0;
}
Пример #3
0
void nand_mtd_init()
{

    /* initialize mutex */
	if (rt_mutex_init(&nand, "nand", RT_IPC_FLAG_FIFO) != RT_EOK)
	{
		rt_kprintf("init nand lock mutex failed\n");
	}


	nand_part[0].page_size = PAGE_DATA_SIZE;
	nand_part[0].pages_per_block = 32;//don't caculate oob size
	nand_part[0].block_start = 0;
	nand_part[0].block_end = 123;
	nand_part[0].oob_size = 16;
	nand_part[0].ops = &nand_mtd_ops;
	rt_mtd_nand_register_device("psram0", &nand_part[0]);

	nand_read_id(RT_NULL);

}
Пример #4
0
int mymain(void)
{
	int argc = 0;
	char * argv[10];
	int i = 0;

	led_init();
	uart_init();

	nand_init();
	nand_read_id(buf);
	putchar_hex(buf[0]);
	putchar_hex(buf[1]);
	putchar_hex(buf[2]);
	putchar_hex(buf[3]);
	putchar_hex(buf[4]);
	
	printf("\n\n" __DATE__ "  " __TIME__ "\n");
	printf("welcome to my boot v1.0 \n\n");
	
	//printf("test: %c,%s,%d,%x\n", 'A', "abcdef", 11, 0x23);

	while (1)
	{
		printf("LUMIT $ ");
		gets(buf);
		
		printf("your input: <%s>\n", buf);
			
		argc = shell_parse(buf, argv);
		
		for (i = 0; i < argc; i++)
			printf("%d: <%s>\n", i, argv[i]);	

		command_do(argc, argv);
	}
}
Пример #5
0
void nand_id(void)
{
	nand_read_id(NULL);
}
Пример #6
0
Файл: cmd.c Проект: huaweili/esd
void cmd_nid(void){
    nand_read_id();
}
Пример #7
0
static void nand_get_chip_info(void)
{
    unsigned char manuf_id;
    unsigned char id_buf[8];

    /* Read chip id from bank 0 */
    nand_read_id(0, id_buf);

    manuf_id = id_buf[0];

    /* Identify the chip geometry */
    nand_data = nand_identify(id_buf);

    if (nand_data == NULL)
    {
        panicf("Unknown NAND: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
                id_buf[0],id_buf[1],id_buf[2],id_buf[3],id_buf[4]);
    }

    pages_per_bank = nand_data->blocks_per_bank * nand_data->pages_per_block;

    segments_per_bank = nand_data->blocks_per_bank / nand_data->planes;

    bytes_per_segment = nand_data->page_size * nand_data->pages_per_block
        * nand_data->planes;

    sectors_per_page = nand_data->page_size / SECTOR_SIZE;

    sectors_per_segment = bytes_per_segment / SECTOR_SIZE;
    
    pages_per_segment = sectors_per_segment / sectors_per_page;

    /* Establish how many banks are present */
    nand_read_id(1, id_buf);

    if (id_buf[0] == manuf_id)
    {
        /* Bank 1 is populated, now check if banks 2/3 are valid */
        nand_read_id(2, id_buf);

        if (id_buf[0] == manuf_id)
        {
            /* Bank 2 returned matching id - check if 2/3 are shadowing 0/1 */
            unsigned int uid_buf0[8];
            unsigned int uid_buf2[8];

            nand_read_uid(0, uid_buf0);
            nand_read_uid(2, uid_buf2);

            if (memcmp(uid_buf0, uid_buf2, 32) == 0)
            {
                /* UIDs match, assume banks 2/3 are shadowing 0/1 */
                total_banks = 2;
            }
            else
            {
                /* UIDs differ, assume banks 2/3 are valid */
                total_banks = 4;
            }
        }
        else
        {
            /* Bank 2 returned differing id - assume 2/3 are junk */
            total_banks = 2;
        }
    }
    else
    {
        /* Bank 1 returned differing id - assume it is junk */
        total_banks = 1;
    }

    /*
       Sanity checks:
       1. "BMP" tag at block 0, page 0, offset <page_size> [always present]
       2. On most D2s, <page_size>+3 is 'M' and <page_size>+4 is no. of banks.
          This is not present on some older players (formatted with early FW?)
     */

    nand_read_raw(0, 0,                 /* bank, page */
                  nand_data->page_size, /* offset */
                  8, id_buf);           /* length, dest */

    if (strncmp(id_buf, "BMP", 3)) panicf("BMP tag not present");

    if (id_buf[3] == 'M')
    {
        if (id_buf[4] != total_banks) panicf("BMPM total_banks mismatch");
    }
}