diff options
author | Marcin Juszkiewicz <hrw@openedhand.com> | 2007-10-29 11:00:19 +0000 |
---|---|---|
committer | Marcin Juszkiewicz <hrw@openedhand.com> | 2007-10-29 11:00:19 +0000 |
commit | 70abc059ebae6bd18399c0361d348f415a3f631a (patch) | |
tree | 86ae8bf44d64d40603b5bca6774eac7f1aaa3ce5 /meta/packages/uboot/u-boot-mkimage-openmoko-native/nand-createbbt.patch | |
parent | ce1e498f5d3a46642b6bb14c14ebae2a52f732a4 (diff) | |
download | poky-70abc059ebae6bd18399c0361d348f415a3f631a.tar.gz |
u-boot: import OpenMoko uboot from OE
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3014 311d38ba-8fff-0310-9ca6-ca027cbcb966
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, 126 insertions, 0 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 new file mode 100644 index 0000000000..74b79da0a9 --- /dev/null +++ b/meta/packages/uboot/u-boot-mkimage-openmoko-native/nand-createbbt.patch | |||
@@ -0,0 +1,126 @@ | |||
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; | ||