blob: 4858820a30ab3b0995d8b27e062cee0ba51b7b07 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <common.h>
2#include <command.h>
3#include <net.h>
4#include <jffs2/load_kernel.h>
5#include <common.h>
6#include <asm/arch/hardware.h>
7#include <asm/arch/uart.h>
8#include <asm/arch/cpu.h>
9#include <asm/arch/lsp_crpm.h>
10#include "errno.h"
11#include <drvs_gpio.h>
12
13
14#if CONFIG_HARDWARE_TEST
15
16/* ================================================================================
17 * do_test_nand :
18 * ³É¹¦: GPIO17 GPIO16 ¶¼ÁÁ
19 * ʧ°Ü: GPIO17 ÁÁ
20 */
21int do_test_nand(void)
22{
23 uint32_t is_ok = 0;
24 static uint32_t nand_led_state = 0;
25 static uint32_t test_cnt=0;
26
27 test_cnt++;
28
29 memcpy((uint8_t *)0x21000000, (uint8_t *)0x82000000, 0x4000); //SYS_IRAM2_BASE
30
31 run_command("nand erase 0x300000 0x20000", 0);
32 run_command("nand write 0x21000000 0x300000 0x4000", 0);
33 run_command("nand read 0x22000000 0x300000 0x4000", 0);
34 is_ok = memcmp((uint8_t *)0x21000000, (uint8_t *)0x22000000, 0x4000);
35 if( is_ok != 0 )
36 goto error;
37 printf("test round:%d\n",test_cnt);
38
39 run_command("nand erase 0x500000 0x20000", 0);
40 run_command("nand write 0x21000000 0x500000 0x4000", 0);
41 run_command("nand read 0x23000000 0x500000 0x4000", 0);
42 is_ok = memcmp((uint8_t *)0x21000000, (uint8_t *)0x23000000, 0x4000);
43 if( is_ok != 0 )
44 goto error;
45 printf("test round:%d\n",test_cnt);
46
47 run_command("nand erase 0x5000000 0x20000", 0);
48 run_command("nand write 0x21000000 0x5000000 0x4000", 0);
49 run_command("nand read 0x24000000 0x5000000 0x4000", 0);
50 is_ok = memcmp((uint8_t *)0x21000000, (uint8_t *)0x24000000, 0x4000);
51 if( is_ok != 0 )
52 goto error;
53 printf("test round:%d\n",test_cnt);
54
55 run_command("nand erase 0xf000000 0x20000", 0);
56 run_command("nand write 0x21000000 0xf000000 0x4000", 0);
57 run_command("nand read 0x25000000 0xf000000 0x4000", 0);
58 is_ok = memcmp((uint8_t *)0x21000000, (uint8_t *)0x25000000, 0x4000);
59 if( is_ok != 0 )
60 goto error;
61 printf("test round:%d\n",test_cnt);
62
63 if( nand_led_state ==0 )
64 {
65 zDrvGpio_SetOutputValue(GPIO33,GPIO_HIGH);
66 nand_led_state = 1;
67 }
68 else
69 {
70 zDrvGpio_SetOutputValue(GPIO33,GPIO_LOW);
71 nand_led_state = 0;
72 }
73
74 udelay(500000);
75
76 return 0;
77
78 error:
79 zDrvGpio_SetOutputValue(GPIO75,GPIO_HIGH);
80 while(1);
81 printf("nand test failed !");
82 run_command("nand erase 0x300000 0x20000", 0);
83 run_command("nand erase 0x500000 0x20000", 0);
84 run_command("nand erase 0x5000000 0x20000", 0);
85 run_command("nand erase 0xf000000 0x20000", 0);
86 return -1;
87
88}
89
90U_BOOT_CMD(
91 test_nand, CONFIG_SYS_MAXARGS, 0, do_test_nand,
92 "test_nand: test_nand ",
93 ""
94);
95
96#endif