Commit 1cb075c6c6ce1a46c3423e63013686e74457275c
Committed by
Heiko Schocher
1 parent
c1f51e0f3e
Exists in
v2017.01-smarct4x
and in
25 other branches
splash_source: add support for ubifs formatted nand
Add support for loading splash image from NAND Flash formatted with a (UBI) filesystem. Signed-off-by: Eran Matityahu <eran.m@variscite.com> Cc: Heiko Schocher <hs@denx.de> Cc: Igor Grinberg <grinberg@compulab.co.il> Cc: Tom Rini <trini@konsulko.com> Cc: Nikita Kiryanov <nikita@compulab.co.il> Cc: Stefano Babic <sbabic@denx.de> Acked-by: Nikita Kiryanov <nikita@compulab.co.il>
Showing 2 changed files with 57 additions and 4 deletions Side-by-side Diff
common/splash_source.c
... | ... | @@ -120,6 +120,12 @@ |
120 | 120 | case SPLASH_STORAGE_SATA: |
121 | 121 | res = fs_set_blk_dev("sata", location->devpart, FS_TYPE_ANY); |
122 | 122 | break; |
123 | + case SPLASH_STORAGE_NAND: | |
124 | + if (location->ubivol != NULL) | |
125 | + res = fs_set_blk_dev("ubi", NULL, FS_TYPE_UBIFS); | |
126 | + else | |
127 | + res = -ENODEV; | |
128 | + break; | |
123 | 129 | default: |
124 | 130 | printf("Error: unsupported location storage.\n"); |
125 | 131 | return -ENODEV; |
... | ... | @@ -163,6 +169,41 @@ |
163 | 169 | } |
164 | 170 | #endif |
165 | 171 | |
172 | +#ifdef CONFIG_CMD_UBIFS | |
173 | +static int splash_mount_ubifs(struct splash_location *location) | |
174 | +{ | |
175 | + int res; | |
176 | + char cmd[32]; | |
177 | + | |
178 | + sprintf(cmd, "ubi part %s", location->mtdpart); | |
179 | + res = run_command(cmd, 0); | |
180 | + if (res) | |
181 | + return res; | |
182 | + | |
183 | + sprintf(cmd, "ubifsmount %s", location->ubivol); | |
184 | + res = run_command(cmd, 0); | |
185 | + | |
186 | + return res; | |
187 | +} | |
188 | + | |
189 | +static inline int splash_umount_ubifs(void) | |
190 | +{ | |
191 | + return run_command("ubifsumount", 0); | |
192 | +} | |
193 | +#else | |
194 | +static inline int splash_mount_ubifs(struct splash_location *location) | |
195 | +{ | |
196 | + printf("Cannot load splash image: no UBIFS support\n"); | |
197 | + return -ENOSYS; | |
198 | +} | |
199 | + | |
200 | +static inline int splash_umount_ubifs(void) | |
201 | +{ | |
202 | + printf("Cannot unmount UBIFS: no UBIFS support\n"); | |
203 | + return -ENOSYS; | |
204 | +} | |
205 | +#endif | |
206 | + | |
166 | 207 | #define SPLASH_SOURCE_DEFAULT_FILE_NAME "splash.bmp" |
167 | 208 | |
168 | 209 | static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr) |
169 | 210 | |
170 | 211 | |
171 | 212 | |
172 | 213 | |
... | ... | @@ -181,26 +222,36 @@ |
181 | 222 | if (location->storage == SPLASH_STORAGE_SATA) |
182 | 223 | res = splash_init_sata(); |
183 | 224 | |
225 | + if (location->ubivol != NULL) | |
226 | + res = splash_mount_ubifs(location); | |
227 | + | |
184 | 228 | if (res) |
185 | 229 | return res; |
186 | 230 | |
187 | 231 | res = splash_select_fs_dev(location); |
188 | 232 | if (res) |
189 | - return res; | |
233 | + goto out; | |
190 | 234 | |
191 | 235 | res = fs_size(splash_file, &bmp_size); |
192 | 236 | if (res) { |
193 | 237 | printf("Error (%d): cannot determine file size\n", res); |
194 | - return res; | |
238 | + goto out; | |
195 | 239 | } |
196 | 240 | |
197 | 241 | if (bmp_load_addr + bmp_size >= gd->start_addr_sp) { |
198 | 242 | printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n"); |
199 | - return -EFAULT; | |
243 | + res = -EFAULT; | |
244 | + goto out; | |
200 | 245 | } |
201 | 246 | |
202 | 247 | splash_select_fs_dev(location); |
203 | - return fs_read(splash_file, bmp_load_addr, 0, 0, NULL); | |
248 | + res = fs_read(splash_file, bmp_load_addr, 0, 0, NULL); | |
249 | + | |
250 | +out: | |
251 | + if (location->ubivol != NULL) | |
252 | + splash_umount_ubifs(); | |
253 | + | |
254 | + return res; | |
204 | 255 | } |
205 | 256 | |
206 | 257 | /** |
include/splash.h
... | ... | @@ -43,6 +43,8 @@ |
43 | 43 | enum splash_flags flags; |
44 | 44 | u32 offset; /* offset from start of storage */ |
45 | 45 | char *devpart; /* Use the load command dev:part conventions */ |
46 | + char *mtdpart; /* MTD partition for ubi part */ | |
47 | + char *ubivol; /* UBI volume-name for ubifsmount */ | |
46 | 48 | }; |
47 | 49 | |
48 | 50 | int splash_source_load(struct splash_location *locations, uint size); |