diff options
Diffstat (limited to 'meta/packages/uboot/u-boot-mkimage-openmoko-native/nand-createbbt.patch')
-rw-r--r-- | meta/packages/uboot/u-boot-mkimage-openmoko-native/nand-createbbt.patch | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/meta/packages/uboot/u-boot-mkimage-openmoko-native/nand-createbbt.patch b/meta/packages/uboot/u-boot-mkimage-openmoko-native/nand-createbbt.patch deleted file mode 100644 index 74b79da0a9..0000000000 --- a/meta/packages/uboot/u-boot-mkimage-openmoko-native/nand-createbbt.patch +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | This patch adds user-requested BBT creation. It includes the following changes: | ||
2 | |||
3 | - common/cmd_nand.c: move yes/no decision to separate function | ||
4 | - do_nand: ask for confirmation for "nand erase" | ||
5 | - do_nand: add command "nand createbbt" to erase NAND and create a new BBT | ||
6 | |||
7 | Experimental. | ||
8 | |||
9 | - Werner Almesberger <werner@openmoko.org> | ||
10 | |||
11 | |||
12 | Index: u-boot/common/cmd_nand.c | ||
13 | =================================================================== | ||
14 | --- u-boot.orig/common/cmd_nand.c 2007-02-16 23:53:28.000000000 +0100 | ||
15 | +++ u-boot/common/cmd_nand.c 2007-02-16 23:53:57.000000000 +0100 | ||
16 | @@ -163,6 +163,17 @@ | ||
17 | return 0; | ||
18 | } | ||
19 | |||
20 | +static int yes(void) | ||
21 | +{ | ||
22 | + char c; | ||
23 | + | ||
24 | + c = getc(); | ||
25 | + if (c != 'y' && c != 'Y') | ||
26 | + return 0; | ||
27 | + c = getc(); | ||
28 | + return c == '\r' || c == '\n'; | ||
29 | +} | ||
30 | + | ||
31 | int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) | ||
32 | { | ||
33 | int i, dev, ret; | ||
34 | @@ -228,7 +239,8 @@ | ||
35 | strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 && | ||
36 | strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 && | ||
37 | strcmp(cmd, "biterr") != 0 && | ||
38 | - strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 ) | ||
39 | + strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 && | ||
40 | + strcmp(cmd, "createbbt") != 0 ) | ||
41 | goto usage; | ||
42 | |||
43 | /* the following commands operate on the current device */ | ||
44 | @@ -283,13 +295,23 @@ | ||
45 | "are sure of what you are doing!\n" | ||
46 | "\nReally scrub this NAND flash? <y/N>\n"); | ||
47 | |||
48 | - if (getc() == 'y' && getc() == '\r') { | ||
49 | + if (yes()) { | ||
50 | opts.scrub = 1; | ||
51 | } else { | ||
52 | puts("scrub aborted\n"); | ||
53 | return -1; | ||
54 | } | ||
55 | } | ||
56 | + else { | ||
57 | + if (opts.length == nand->size) { | ||
58 | + puts("Really erase everything ? <y/N>\n"); | ||
59 | + if (!yes()) { | ||
60 | + puts("erase aborted\n"); | ||
61 | + return -1; | ||
62 | + } | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | ret = nand_erase_opts(nand, &opts); | ||
67 | printf("%s\n", ret ? "ERROR" : "OK"); | ||
68 | |||
69 | @@ -458,6 +480,33 @@ | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | + if (strcmp(cmd, "createbbt") == 0) { | ||
74 | + struct nand_chip *nand_chip = nand->priv; | ||
75 | + nand_erase_options_t opts; | ||
76 | + | ||
77 | + puts("Create BBT and erase everything ? <y/N>\n"); | ||
78 | + if (!yes()) { | ||
79 | + puts("createbbt aborted\n"); | ||
80 | + return -1; | ||
81 | + } | ||
82 | + memset(&opts, 0, sizeof(opts)); | ||
83 | + opts.length = nand->size; | ||
84 | + if (nand_erase_opts(nand, &opts)) { | ||
85 | + puts("Erase failed\n"); | ||
86 | + return 1; | ||
87 | + } | ||
88 | + nand_chip->options &= ~NAND_DONT_CREATE_BBT; | ||
89 | + puts("Creating BBT. Please wait ..."); | ||
90 | + if (nand_default_bbt(nand)) { | ||
91 | + puts("\nFailed\n"); | ||
92 | + return 1; | ||
93 | + } | ||
94 | + else { | ||
95 | + puts("\n"); | ||
96 | + return 0; | ||
97 | + } | ||
98 | + } | ||
99 | + | ||
100 | usage: | ||
101 | printf("Usage:\n%s\n", cmdtp->usage); | ||
102 | return 1; | ||
103 | @@ -478,7 +527,8 @@ | ||
104 | "nand markbad off - mark bad block at offset (UNSAFE)\n" | ||
105 | "nand biterr off - make a bit error at offset (UNSAFE)\n" | ||
106 | "nand lock [tight] [status] - bring nand to lock state or display locked pages\n" | ||
107 | - "nand unlock [offset] [size] - unlock section\n"); | ||
108 | + "nand unlock [offset] [size] - unlock section\n" | ||
109 | + "nand createbbt - create bad block table\n"); | ||
110 | |||
111 | static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, | ||
112 | ulong offset, ulong addr, char *cmd) | ||
113 | Index: u-boot/drivers/nand/nand_bbt.c | ||
114 | =================================================================== | ||
115 | --- u-boot.orig/drivers/nand/nand_bbt.c 2007-02-16 23:53:54.000000000 +0100 | ||
116 | +++ u-boot/drivers/nand/nand_bbt.c 2007-02-16 23:53:57.000000000 +0100 | ||
117 | @@ -795,7 +795,8 @@ | ||
118 | |||
119 | len = mtd->size >> (this->bbt_erase_shift + 2); | ||
120 | /* Allocate memory (2bit per block) */ | ||
121 | - this->bbt = kmalloc (len, GFP_KERNEL); | ||
122 | + if (!this->bbt) | ||
123 | + this->bbt = kmalloc (len, GFP_KERNEL); | ||
124 | if (!this->bbt) { | ||
125 | printk (KERN_ERR "nand_scan_bbt: Out of memory\n"); | ||
126 | return -ENOMEM; | ||