blob: b6c60f28289268d2c5d1b18b58f2ae821841f3b9 [file] [log] [blame]
Brian Swetland9c4c0752009-01-25 16:23:50 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
4 *
Ajay Dudanid04110c2011-01-17 23:55:07 -08005 * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
Brian Swetland9c4c0752009-01-25 16:23:50 -08006 *
Chandan Uddaraju5fa471a2009-12-02 17:31:34 -08007 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of Code Aurora nor
15 * the names of its contributors may be used to endorse or promote
16 * products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
Brian Swetland9c4c0752009-01-25 16:23:50 -080031 */
32
33#include <app.h>
34#include <debug.h>
35#include <arch/arm.h>
36#include <dev/udc.h>
37#include <string.h>
38#include <kernel/thread.h>
39#include <arch/ops.h>
40
Dima Zavin214cc642009-01-26 11:16:21 -080041#include <dev/flash.h>
42#include <lib/ptable.h>
Dima Zavinb4283602009-01-26 16:36:57 -080043#include <dev/keys.h>
Shashank Mittal4f99a882010-02-01 13:58:50 -080044#include <dev/fbcon.h>
Ajay Dudanid04110c2011-01-17 23:55:07 -080045#include <baseband.h>
Greg Griscod6250552011-06-29 14:40:23 -070046#include <target.h>
47#include <mmc.h>
Kinson Chikf1a43512011-07-14 11:28:39 -070048#include <partition_parser.h>
Greg Griscod6250552011-06-29 14:40:23 -070049#include <platform.h>
Dima Zavin214cc642009-01-26 11:16:21 -080050
Shashank Mittal024c0332010-02-03 11:44:00 -080051#include "recovery.h"
Brian Swetland9c4c0752009-01-25 16:23:50 -080052#include "bootimg.h"
53#include "fastboot.h"
Ajay Dudani5c761132011-04-07 20:19:04 -070054#include "sparse_format.h"
Greg Grisco6e754772011-06-23 12:19:39 -070055#include "mmc.h"
Brian Swetland9c4c0752009-01-25 16:23:50 -080056
kchik@codeaurora.orgbce18ea2011-04-18 20:22:28 -070057#include "scm_decrypt.h"
58
Subbaraman Narayanamurthyeb92bcc2010-07-20 14:32:46 -070059#define EXPAND(NAME) #NAME
60#define TARGET(NAME) EXPAND(NAME)
Chandan Uddarajuda919832009-11-17 01:06:11 -080061#define DEFAULT_CMDLINE "mem=100M console=null";
Brian Swetland2defe162009-08-18 14:35:59 -070062
Ajay Dudanicd01f9b2010-02-23 21:13:04 -080063#ifdef MEMBASE
64#define EMMC_BOOT_IMG_HEADER_ADDR (0xFF000+(MEMBASE))
65#else
David Ng183a7422009-12-07 14:55:21 -080066#define EMMC_BOOT_IMG_HEADER_ADDR 0xFF000
Ajay Dudanicd01f9b2010-02-23 21:13:04 -080067#endif
68
Chandan Uddarajude85d3f2010-01-05 16:32:33 -080069#define RECOVERY_MODE 0x77665502
70#define FASTBOOT_MODE 0x77665500
71
David Ng183a7422009-12-07 14:55:21 -080072static const char *emmc_cmdline = " androidboot.emmc=true";
Subbaraman Narayanamurthyf17b4ae2011-02-16 20:19:56 -080073static const char *usb_sn_cmdline = " androidboot.serialno=";
David Ngf773dde2010-07-26 19:55:08 -070074static const char *battchg_pause = " androidboot.battchg_pause=true";
David Ng183a7422009-12-07 14:55:21 -080075
Ajay Dudani6cff85e2011-02-04 16:02:16 -080076static const char *baseband_apq = " androidboot.baseband=apq";
77static const char *baseband_msm = " androidboot.baseband=msm";
78static const char *baseband_csfb = " androidboot.baseband=csfb";
79static const char *baseband_svlte2a = " androidboot.baseband=svlte2a";
Ajay Dudanid04110c2011-01-17 23:55:07 -080080
Brian Swetland9c4c0752009-01-25 16:23:50 -080081static struct udc_device surf_udc_device = {
82 .vendor_id = 0x18d1,
Chandan Uddarajuc53a1a12009-11-18 14:53:40 -080083 .product_id = 0xD00D,
Brian Swetland9c4c0752009-01-25 16:23:50 -080084 .version_id = 0x0100,
85 .manufacturer = "Google",
86 .product = "Android",
87};
88
Dima Zavin42168f22009-01-30 11:52:22 -080089struct atag_ptbl_entry
90{
91 char name[16];
92 unsigned offset;
93 unsigned size;
94 unsigned flags;
95};
96
Subbaraman Narayanamurthyf17b4ae2011-02-16 20:19:56 -080097char sn_buf[13];
Greg Griscod6250552011-06-29 14:40:23 -070098
Greg Griscod2471ef2011-07-14 13:00:42 -070099extern int emmc_recovery_init(void);
100
101
102
Dima Zavin42168f22009-01-30 11:52:22 -0800103static void ptentry_to_tag(unsigned **ptr, struct ptentry *ptn)
104{
105 struct atag_ptbl_entry atag_ptn;
106
Greg Griscod6250552011-06-29 14:40:23 -0700107 if (ptn->type == TYPE_MODEM_PARTITION) {
Shashank Mittal8e49dec2010-03-01 15:19:04 -0800108 return;
Greg Griscod6250552011-06-29 14:40:23 -0700109 }
Dima Zavin42168f22009-01-30 11:52:22 -0800110 memcpy(atag_ptn.name, ptn->name, 16);
111 atag_ptn.name[15] = '\0';
112 atag_ptn.offset = ptn->start;
113 atag_ptn.size = ptn->length;
114 atag_ptn.flags = ptn->flags;
115 memcpy(*ptr, &atag_ptn, sizeof(struct atag_ptbl_entry));
116 *ptr += sizeof(struct atag_ptbl_entry) / sizeof(unsigned);
117}
Brian Swetland9c4c0752009-01-25 16:23:50 -0800118
kchik@codeaurora.orgbce18ea2011-04-18 20:22:28 -0700119void boot_linux(void *kernel, unsigned *tags,
Brian Swetland9c4c0752009-01-25 16:23:50 -0800120 const char *cmdline, unsigned machtype,
121 void *ramdisk, unsigned ramdisk_size)
122{
123 unsigned *ptr = tags;
Shashank Mittal8e49dec2010-03-01 15:19:04 -0800124 unsigned pcount = 0;
Brian Swetland9c4c0752009-01-25 16:23:50 -0800125 void (*entry)(unsigned,unsigned,unsigned*) = kernel;
Dima Zavin42168f22009-01-30 11:52:22 -0800126 struct ptable *ptable;
David Ng183a7422009-12-07 14:55:21 -0800127 int cmdline_len = 0;
128 int have_cmdline = 0;
David Ngf773dde2010-07-26 19:55:08 -0700129 int pause_at_bootup = 0;
Brian Swetland9c4c0752009-01-25 16:23:50 -0800130
131 /* CORE */
132 *ptr++ = 2;
133 *ptr++ = 0x54410001;
134
135 if (ramdisk_size) {
136 *ptr++ = 4;
137 *ptr++ = 0x54420005;
Dima Zavin214cc642009-01-26 11:16:21 -0800138 *ptr++ = (unsigned)ramdisk;
Brian Swetland9c4c0752009-01-25 16:23:50 -0800139 *ptr++ = ramdisk_size;
140 }
141
Chandan Uddarajuc6860e12009-11-19 11:22:15 -0800142 ptr = target_atag_mem(ptr);
143
David Ng183a7422009-12-07 14:55:21 -0800144 if (!target_is_emmc_boot()) {
145 /* Skip NAND partition ATAGS for eMMC boot */
146 if ((ptable = flash_get_ptable()) && (ptable->count != 0)) {
147 int i;
Shashank Mittal8e49dec2010-03-01 15:19:04 -0800148 for(i=0; i < ptable->count; i++) {
149 struct ptentry *ptn;
150 ptn = ptable_get(ptable, i);
151 if (ptn->type == TYPE_APPS_PARTITION)
152 pcount++;
153 }
154 *ptr++ = 2 + (pcount * (sizeof(struct atag_ptbl_entry) /
David Ng183a7422009-12-07 14:55:21 -0800155 sizeof(unsigned)));
156 *ptr++ = 0x4d534d70;
157 for (i = 0; i < ptable->count; ++i)
158 ptentry_to_tag(&ptr, ptable_get(ptable, i));
159 }
Dima Zavin42168f22009-01-30 11:52:22 -0800160 }
161
Brian Swetland9c4c0752009-01-25 16:23:50 -0800162 if (cmdline && cmdline[0]) {
David Ng183a7422009-12-07 14:55:21 -0800163 cmdline_len = strlen(cmdline);
164 have_cmdline = 1;
165 }
166 if (target_is_emmc_boot()) {
167 cmdline_len += strlen(emmc_cmdline);
168 }
Subbaraman Narayanamurthyf17b4ae2011-02-16 20:19:56 -0800169
170 cmdline_len += strlen(usb_sn_cmdline);
171 cmdline_len += strlen(sn_buf);
172
David Ngf773dde2010-07-26 19:55:08 -0700173 if (target_pause_for_battery_charge()) {
174 pause_at_bootup = 1;
175 cmdline_len += strlen(battchg_pause);
176 }
Ajay Dudanid04110c2011-01-17 23:55:07 -0800177
178 /* Determine correct androidboot.baseband to use */
179 switch(target_baseband())
180 {
181 case BASEBAND_APQ:
182 cmdline_len += strlen(baseband_apq);
183 break;
184
185 case BASEBAND_MSM:
186 cmdline_len += strlen(baseband_msm);
187 break;
188
189 case BASEBAND_CSFB:
190 cmdline_len += strlen(baseband_csfb);
191 break;
192
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800193 case BASEBAND_SVLTE2A:
194 cmdline_len += strlen(baseband_svlte2a);
Ajay Dudanid04110c2011-01-17 23:55:07 -0800195 break;
196 }
197
David Ng183a7422009-12-07 14:55:21 -0800198 if (cmdline_len > 0) {
199 const char *src;
200 char *dst;
Brian Swetland9c4c0752009-01-25 16:23:50 -0800201 unsigned n;
202 /* include terminating 0 and round up to a word multiple */
David Ng183a7422009-12-07 14:55:21 -0800203 n = (cmdline_len + 4) & (~3);
Brian Swetland9c4c0752009-01-25 16:23:50 -0800204 *ptr++ = (n / 4) + 2;
205 *ptr++ = 0x54410009;
David Ng183a7422009-12-07 14:55:21 -0800206 dst = (char *)ptr;
207 if (have_cmdline) {
208 src = cmdline;
209 while ((*dst++ = *src++));
210 }
211 if (target_is_emmc_boot()) {
212 src = emmc_cmdline;
213 if (have_cmdline) --dst;
David Ngf773dde2010-07-26 19:55:08 -0700214 have_cmdline = 1;
215 while ((*dst++ = *src++));
216 }
Subbaraman Narayanamurthyf17b4ae2011-02-16 20:19:56 -0800217
218 src = usb_sn_cmdline;
219 if (have_cmdline) --dst;
220 have_cmdline = 1;
221 while ((*dst++ = *src++));
222 src = sn_buf;
223 if (have_cmdline) --dst;
224 have_cmdline = 1;
225 while ((*dst++ = *src++));
226
David Ngf773dde2010-07-26 19:55:08 -0700227 if (pause_at_bootup) {
228 src = battchg_pause;
229 if (have_cmdline) --dst;
David Ng183a7422009-12-07 14:55:21 -0800230 while ((*dst++ = *src++));
231 }
Ajay Dudanid04110c2011-01-17 23:55:07 -0800232
233 switch(target_baseband())
234 {
235 case BASEBAND_APQ:
236 src = baseband_apq;
237 if (have_cmdline) --dst;
238 while ((*dst++ = *src++));
239 break;
240
241 case BASEBAND_MSM:
242 src = baseband_msm;
243 if (have_cmdline) --dst;
244 while ((*dst++ = *src++));
245 break;
246
247 case BASEBAND_CSFB:
248 src = baseband_csfb;
249 if (have_cmdline) --dst;
250 while ((*dst++ = *src++));
251 break;
252
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800253 case BASEBAND_SVLTE2A:
254 src = baseband_svlte2a;
Ajay Dudanid04110c2011-01-17 23:55:07 -0800255 if (have_cmdline) --dst;
256 while ((*dst++ = *src++));
257 break;
258 }
Brian Swetland9c4c0752009-01-25 16:23:50 -0800259 ptr += (n / 4);
260 }
261
262 /* END */
263 *ptr++ = 0;
264 *ptr++ = 0;
265
266 dprintf(INFO, "booting linux @ %p, ramdisk @ %p (%d)\n",
267 kernel, ramdisk, ramdisk_size);
268 if (cmdline)
269 dprintf(INFO, "cmdline: %s\n", cmdline);
270
271 enter_critical_section();
Amol Jadi4421e652011-06-16 15:00:48 -0700272 /* do any platform specific cleanup before kernel entry */
273 platform_uninit();
Brian Swetland9c4c0752009-01-25 16:23:50 -0800274 arch_disable_cache(UCACHE);
Brian Swetland9c4c0752009-01-25 16:23:50 -0800275 arch_disable_mmu();
Brian Swetland9c4c0752009-01-25 16:23:50 -0800276 entry(0, machtype, tags);
Brian Swetland9c4c0752009-01-25 16:23:50 -0800277}
278
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800279unsigned page_size = 0;
280unsigned page_mask = 0;
Brian Swetland9c4c0752009-01-25 16:23:50 -0800281
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800282#define ROUND_TO_PAGE(x,y) (((x) + (y)) & (~(y)))
Brian Swetland9c4c0752009-01-25 16:23:50 -0800283
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800284static unsigned char buf[4096]; //Equal to max-supported pagesize
Dima Zavin214cc642009-01-26 11:16:21 -0800285
Shashank Mittal23b8f422010-04-16 19:27:21 -0700286int boot_linux_from_mmc(void)
287{
288 struct boot_img_hdr *hdr = (void*) buf;
289 struct boot_img_hdr *uhdr;
290 unsigned offset = 0;
291 unsigned long long ptn = 0;
292 unsigned n = 0;
293 const char *cmdline;
Kinson Chikf1a43512011-07-14 11:28:39 -0700294 int index = INVALID_PTN;
Shashank Mittal23b8f422010-04-16 19:27:21 -0700295
296 uhdr = (struct boot_img_hdr *)EMMC_BOOT_IMG_HEADER_ADDR;
297 if (!memcmp(uhdr->magic, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
298 dprintf(INFO, "Unified boot method!\n");
299 hdr = uhdr;
300 goto unified_boot;
301 }
Greg Griscod6250552011-06-29 14:40:23 -0700302 if (!boot_into_recovery) {
Kinson Chikf1a43512011-07-14 11:28:39 -0700303 index = partition_get_index("boot");
304 ptn = partition_get_offset(index);
305 if(ptn == 0) {
Shashank Mittal85b91f62010-10-30 10:12:38 -0700306 dprintf(CRITICAL, "ERROR: No boot partition found\n");
307 return -1;
308 }
Kinson Chikf1a43512011-07-14 11:28:39 -0700309 }
310 else {
311 index = partition_get_index("recovery");
312 ptn = partition_get_offset(index);
313 if(ptn == 0) {
Shashank Mittal85b91f62010-10-30 10:12:38 -0700314 dprintf(CRITICAL, "ERROR: No recovery partition found\n");
315 return -1;
316 }
Shashank Mittal23b8f422010-04-16 19:27:21 -0700317 }
318
Greg Griscod6250552011-06-29 14:40:23 -0700319 if (mmc_read(ptn + offset, (unsigned int *) buf, page_size)) {
Shashank Mittal23b8f422010-04-16 19:27:21 -0700320 dprintf(CRITICAL, "ERROR: Cannot read boot image header\n");
321 return -1;
322 }
Shashank Mittal23b8f422010-04-16 19:27:21 -0700323
324 if (memcmp(hdr->magic, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
Kinson Chik kchik@codeaurora.org82e4ae62011-04-12 17:42:07 -0700325 dprintf(CRITICAL, "ERROR: Invalid boot image header\n");
Shashank Mittal23b8f422010-04-16 19:27:21 -0700326 return -1;
327 }
328
Subbaraman Narayanamurthyfbe13a02010-09-10 11:51:12 -0700329 if (hdr->page_size && (hdr->page_size != page_size)) {
330 page_size = hdr->page_size;
331 page_mask = page_size - 1;
Shashank Mittal23b8f422010-04-16 19:27:21 -0700332 }
Subbaraman Narayanamurthyfbe13a02010-09-10 11:51:12 -0700333 offset += page_size;
Shashank Mittal23b8f422010-04-16 19:27:21 -0700334
335 n = ROUND_TO_PAGE(hdr->kernel_size, page_mask);
336 if (mmc_read(ptn + offset, (void *)hdr->kernel_addr, n)) {
337 dprintf(CRITICAL, "ERROR: Cannot read kernel image\n");
338 return -1;
339 }
340 offset += n;
341
342 n = ROUND_TO_PAGE(hdr->ramdisk_size, page_mask);
Subbaraman Narayanamurthy958fa242011-01-27 17:42:38 -0800343 if(n != 0)
344 {
345 if (mmc_read(ptn + offset, (void *)hdr->ramdisk_addr, n)) {
346 dprintf(CRITICAL, "ERROR: Cannot read ramdisk image\n");
347 return -1;
348 }
Shashank Mittal23b8f422010-04-16 19:27:21 -0700349 }
350 offset += n;
351
352unified_boot:
353 dprintf(INFO, "\nkernel @ %x (%d bytes)\n", hdr->kernel_addr,
354 hdr->kernel_size);
355 dprintf(INFO, "ramdisk @ %x (%d bytes)\n", hdr->ramdisk_addr,
356 hdr->ramdisk_size);
357
358 if(hdr->cmdline[0]) {
359 cmdline = (char*) hdr->cmdline;
360 } else {
361 cmdline = DEFAULT_CMDLINE;
362 }
363 dprintf(INFO, "cmdline = '%s'\n", cmdline);
364
365 dprintf(INFO, "\nBooting Linux\n");
Greg Griscod2471ef2011-07-14 13:00:42 -0700366 boot_linux((void *)hdr->kernel_addr, (unsigned *) hdr->tags_addr,
Shashank Mittal23b8f422010-04-16 19:27:21 -0700367 (const char *)cmdline, board_machtype(),
368 (void *)hdr->ramdisk_addr, hdr->ramdisk_size);
369
370 return 0;
371}
372
Dima Zavin214cc642009-01-26 11:16:21 -0800373int boot_linux_from_flash(void)
374{
375 struct boot_img_hdr *hdr = (void*) buf;
376 unsigned n;
377 struct ptentry *ptn;
378 struct ptable *ptable;
379 unsigned offset = 0;
380 const char *cmdline;
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800381
David Ng183a7422009-12-07 14:55:21 -0800382 if (target_is_emmc_boot()) {
383 hdr = (struct boot_img_hdr *)EMMC_BOOT_IMG_HEADER_ADDR;
384 if (memcmp(hdr->magic, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
385 dprintf(CRITICAL, "ERROR: Invalid boot image header\n");
386 return -1;
387 }
388 goto continue_boot;
389 }
390
Dima Zavin214cc642009-01-26 11:16:21 -0800391 ptable = flash_get_ptable();
392 if (ptable == NULL) {
393 dprintf(CRITICAL, "ERROR: Partition table not found\n");
394 return -1;
395 }
396
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800397 if(!boot_into_recovery)
398 {
399 ptn = ptable_find(ptable, "boot");
400 if (ptn == NULL) {
401 dprintf(CRITICAL, "ERROR: No boot partition found\n");
402 return -1;
403 }
404 }
405 else
406 {
407 ptn = ptable_find(ptable, "recovery");
408 if (ptn == NULL) {
409 dprintf(CRITICAL, "ERROR: No recovery partition found\n");
410 return -1;
411 }
Dima Zavin214cc642009-01-26 11:16:21 -0800412 }
413
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800414 if (flash_read(ptn, offset, buf, page_size)) {
Dima Zavin214cc642009-01-26 11:16:21 -0800415 dprintf(CRITICAL, "ERROR: Cannot read boot image header\n");
416 return -1;
417 }
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800418 offset += page_size;
Dima Zavin214cc642009-01-26 11:16:21 -0800419
420 if (memcmp(hdr->magic, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
Kinson Chik kchik@codeaurora.org82e4ae62011-04-12 17:42:07 -0700421 dprintf(CRITICAL, "ERROR: Invalid boot image header\n");
Dima Zavin214cc642009-01-26 11:16:21 -0800422 return -1;
423 }
424
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800425 if (hdr->page_size != page_size) {
Kinson Chik kchik@codeaurora.org82e4ae62011-04-12 17:42:07 -0700426 dprintf(CRITICAL, "ERROR: Invalid boot image pagesize. Device pagesize: %d, Image pagesize: %d\n",page_size,hdr->page_size);
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800427 return -1;
428 }
429
430 n = ROUND_TO_PAGE(hdr->kernel_size, page_mask);
Dima Zavin214cc642009-01-26 11:16:21 -0800431 if (flash_read(ptn, offset, (void *)hdr->kernel_addr, n)) {
432 dprintf(CRITICAL, "ERROR: Cannot read kernel image\n");
433 return -1;
434 }
435 offset += n;
436
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800437 n = ROUND_TO_PAGE(hdr->ramdisk_size, page_mask);
Dima Zavin214cc642009-01-26 11:16:21 -0800438 if (flash_read(ptn, offset, (void *)hdr->ramdisk_addr, n)) {
439 dprintf(CRITICAL, "ERROR: Cannot read ramdisk image\n");
440 return -1;
441 }
442 offset += n;
443
David Ng183a7422009-12-07 14:55:21 -0800444continue_boot:
Dima Zavin214cc642009-01-26 11:16:21 -0800445 dprintf(INFO, "\nkernel @ %x (%d bytes)\n", hdr->kernel_addr,
446 hdr->kernel_size);
447 dprintf(INFO, "ramdisk @ %x (%d bytes)\n", hdr->ramdisk_addr,
448 hdr->ramdisk_size);
449
450 if(hdr->cmdline[0]) {
451 cmdline = (char*) hdr->cmdline;
452 } else {
453 cmdline = DEFAULT_CMDLINE;
454 }
455 dprintf(INFO, "cmdline = '%s'\n", cmdline);
456
457 /* TODO: create/pass atags to kernel */
458
459 dprintf(INFO, "\nBooting Linux\n");
Ajay Dudanie28a6072011-07-01 13:59:46 -0700460 boot_linux((void *)hdr->kernel_addr, (void *)hdr->tags_addr,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800461 (const char *)cmdline, board_machtype(),
Dima Zavin214cc642009-01-26 11:16:21 -0800462 (void *)hdr->ramdisk_addr, hdr->ramdisk_size);
463
464 return 0;
465}
Brian Swetland9c4c0752009-01-25 16:23:50 -0800466
467void cmd_boot(const char *arg, void *data, unsigned sz)
468{
469 unsigned kernel_actual;
470 unsigned ramdisk_actual;
471 static struct boot_img_hdr hdr;
472 char *ptr = ((char*) data);
473
474 if (sz < sizeof(hdr)) {
475 fastboot_fail("invalid bootimage header");
476 return;
477 }
478
479 memcpy(&hdr, data, sizeof(hdr));
480
481 /* ensure commandline is terminated */
482 hdr.cmdline[BOOT_ARGS_SIZE-1] = 0;
483
Subbaraman Narayanamurthyfbe13a02010-09-10 11:51:12 -0700484 if(target_is_emmc_boot() && hdr.page_size) {
485 page_size = hdr.page_size;
486 page_mask = page_size - 1;
487 }
488
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800489 kernel_actual = ROUND_TO_PAGE(hdr.kernel_size, page_mask);
490 ramdisk_actual = ROUND_TO_PAGE(hdr.ramdisk_size, page_mask);
Brian Swetland9c4c0752009-01-25 16:23:50 -0800491
Chandan Uddaraju1f6030f2010-03-19 13:26:38 -0700492 if (page_size + kernel_actual + ramdisk_actual < sz) {
Brian Swetland9c4c0752009-01-25 16:23:50 -0800493 fastboot_fail("incomplete bootimage");
494 return;
495 }
496
Ajay Dudanie28a6072011-07-01 13:59:46 -0700497 memmove((void*) hdr.kernel_addr, ptr + page_size, hdr.kernel_size);
498 memmove((void*) hdr.ramdisk_addr, ptr + page_size + kernel_actual, hdr.ramdisk_size);
Brian Swetland9c4c0752009-01-25 16:23:50 -0800499
500 fastboot_okay("");
501 udc_stop();
502
Amol Jadie67872e2011-06-27 14:14:11 -0700503 boot_linux((void*) hdr.kernel_addr, (void*) hdr.tags_addr,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800504 (const char*) hdr.cmdline, board_machtype(),
Ajay Dudanie28a6072011-07-01 13:59:46 -0700505 (void*) hdr.ramdisk_addr, hdr.ramdisk_size);
Brian Swetland9c4c0752009-01-25 16:23:50 -0800506}
507
Dima Zavin214cc642009-01-26 11:16:21 -0800508void cmd_erase(const char *arg, void *data, unsigned sz)
509{
510 struct ptentry *ptn;
511 struct ptable *ptable;
512
513 ptable = flash_get_ptable();
514 if (ptable == NULL) {
515 fastboot_fail("partition table doesn't exist");
516 return;
517 }
518
519 ptn = ptable_find(ptable, arg);
520 if (ptn == NULL) {
521 fastboot_fail("unknown partition name");
522 return;
523 }
524
525 if (flash_erase(ptn)) {
526 fastboot_fail("failed to erase partition");
527 return;
528 }
529 fastboot_okay("");
530}
531
Bikas Gurungd48bd242010-09-04 19:54:32 -0700532
533void cmd_erase_mmc(const char *arg, void *data, unsigned sz)
534{
535 unsigned long long ptn = 0;
536 unsigned int out[512] = {0};
Kinson Chikf1a43512011-07-14 11:28:39 -0700537 int index = INVALID_PTN;
Bikas Gurungd48bd242010-09-04 19:54:32 -0700538
Kinson Chikf1a43512011-07-14 11:28:39 -0700539 index = partition_get_index(arg);
540 ptn = partition_get_offset(index);
541 if(ptn == 0) {
Bikas Gurungd48bd242010-09-04 19:54:32 -0700542 fastboot_fail("partition table doesn't exist");
543 return;
544 }
545
Bikas Gurungd48bd242010-09-04 19:54:32 -0700546 /* Simple inefficient version of erase. Just writing
547 0 in first block */
548 if (mmc_write(ptn , 512, (unsigned int *)out)) {
549 fastboot_fail("failed to erase partition");
550 return;
551 }
552 fastboot_okay("");
553}
554
555
Ajay Dudani5c761132011-04-07 20:19:04 -0700556void cmd_flash_mmc_img(const char *arg, void *data, unsigned sz)
Shashank Mittal23b8f422010-04-16 19:27:21 -0700557{
558 unsigned long long ptn = 0;
Subbaraman Narayanamurthyc95b5b12010-08-31 13:19:48 -0700559 unsigned long long size = 0;
Kinson Chikf1a43512011-07-14 11:28:39 -0700560 int index = INVALID_PTN;
Subbaraman Narayanamurthyc95b5b12010-08-31 13:19:48 -0700561
Greg Grisco6e754772011-06-23 12:19:39 -0700562 if (!strcmp(arg, "partition"))
563 {
564 dprintf(INFO, "Attempt to write partition image.\n");
565 if (mmc_write_partition(sz, (unsigned char *) data)) {
566 fastboot_fail("failed to write partition");
Shashank Mittal23b8f422010-04-16 19:27:21 -0700567 return;
568 }
569 }
Greg Grisco6e754772011-06-23 12:19:39 -0700570 else
571 {
Kinson Chikf1a43512011-07-14 11:28:39 -0700572 index = partition_get_index(arg);
573 ptn = partition_get_offset(index);
Greg Grisco6e754772011-06-23 12:19:39 -0700574 if(ptn == 0) {
575 fastboot_fail("partition table doesn't exist");
576 return;
577 }
Shashank Mittal23b8f422010-04-16 19:27:21 -0700578
Greg Grisco6e754772011-06-23 12:19:39 -0700579 if (!strcmp(arg, "boot") || !strcmp(arg, "recovery")) {
580 if (memcmp((void *)data, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
581 fastboot_fail("image is not a boot image");
582 return;
583 }
584 }
Subbaraman Narayanamurthyc95b5b12010-08-31 13:19:48 -0700585
Kinson Chikf1a43512011-07-14 11:28:39 -0700586 size = partition_get_size(index);
Greg Grisco6e754772011-06-23 12:19:39 -0700587 if (ROUND_TO_PAGE(sz,511) > size) {
588 fastboot_fail("size too large");
589 return;
590 }
591 else if (mmc_write(ptn , sz, (unsigned int *)data)) {
592 fastboot_fail("flash write failure");
593 return;
594 }
Shashank Mittal23b8f422010-04-16 19:27:21 -0700595 }
596 fastboot_okay("");
597 return;
598}
599
Greg Griscod6250552011-06-29 14:40:23 -0700600
601
Ajay Dudani5c761132011-04-07 20:19:04 -0700602void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz)
603{
604 unsigned int chunk;
605 unsigned int chunk_data_sz;
606 sparse_header_t *sparse_header;
607 chunk_header_t *chunk_header;
Ajay Dudaniab18f022011-05-12 14:39:22 -0700608 uint32_t total_blocks = 0;
Ajay Dudani5c761132011-04-07 20:19:04 -0700609 unsigned long long ptn = 0;
Kinson Chikf1a43512011-07-14 11:28:39 -0700610 int index = INVALID_PTN;
Ajay Dudani5c761132011-04-07 20:19:04 -0700611
Kinson Chikf1a43512011-07-14 11:28:39 -0700612 index = partition_get_index(arg);
613 ptn = partition_get_offset(index);
614 if(ptn == 0) {
Ajay Dudani5c761132011-04-07 20:19:04 -0700615 fastboot_fail("partition table doesn't exist");
616 return;
617 }
618
619 /* Read and skip over sparse image header */
620 sparse_header = (sparse_header_t *) data;
621 data += sparse_header->file_hdr_sz;
622 if(sparse_header->file_hdr_sz > sizeof(sparse_header_t))
623 {
624 /* Skip the remaining bytes in a header that is longer than
625 * we expected.
626 */
627 data += (sparse_header->file_hdr_sz - sizeof(sparse_header_t));
628 }
629
Ajay Dudanib06c05f2011-05-12 14:46:10 -0700630 dprintf (SPEW, "=== Sparse Image Header ===\n");
631 dprintf (SPEW, "magic: 0x%x\n", sparse_header->magic);
632 dprintf (SPEW, "major_version: 0x%x\n", sparse_header->major_version);
633 dprintf (SPEW, "minor_version: 0x%x\n", sparse_header->minor_version);
634 dprintf (SPEW, "file_hdr_sz: %d\n", sparse_header->file_hdr_sz);
635 dprintf (SPEW, "chunk_hdr_sz: %d\n", sparse_header->chunk_hdr_sz);
636 dprintf (SPEW, "blk_sz: %d\n", sparse_header->blk_sz);
637 dprintf (SPEW, "total_blks: %d\n", sparse_header->total_blks);
638 dprintf (SPEW, "total_chunks: %d\n", sparse_header->total_chunks);
Ajay Dudani5c761132011-04-07 20:19:04 -0700639
640 /* Start processing chunks */
641 for (chunk=0; chunk<sparse_header->total_chunks; chunk++)
642 {
643 /* Read and skip over chunk header */
644 chunk_header = (chunk_header_t *) data;
645 data += sizeof(chunk_header_t);
646
647 dprintf (SPEW, "=== Chunk Header ===\n");
648 dprintf (SPEW, "chunk_type: 0x%x\n", chunk_header->chunk_type);
649 dprintf (SPEW, "chunk_data_sz: 0x%x\n", chunk_header->chunk_sz);
650 dprintf (SPEW, "total_size: 0x%x\n", chunk_header->total_sz);
651
652 if(sparse_header->chunk_hdr_sz > sizeof(chunk_header_t))
653 {
654 /* Skip the remaining bytes in a header that is longer than
655 * we expected.
656 */
657 data += (sparse_header->chunk_hdr_sz - sizeof(chunk_header_t));
658 }
659
660 chunk_data_sz = sparse_header->blk_sz * chunk_header->chunk_sz;
661 switch (chunk_header->chunk_type)
662 {
663 case CHUNK_TYPE_RAW:
664 if(chunk_header->total_sz != (sparse_header->chunk_hdr_sz +
665 chunk_data_sz))
666 {
667 fastboot_fail("Bogus chunk size for chunk type Raw");
668 return;
669 }
670
Ajay Dudaniab18f022011-05-12 14:39:22 -0700671 if(mmc_write(ptn + ((uint64_t)total_blocks*sparse_header->blk_sz),
672 chunk_data_sz,
673 (unsigned int*)data))
Ajay Dudani5c761132011-04-07 20:19:04 -0700674 {
675 fastboot_fail("flash write failure");
676 return;
677 }
678 total_blocks += chunk_header->chunk_sz;
679 data += chunk_data_sz;
680 break;
681
682 case CHUNK_TYPE_DONT_CARE:
Kinson Chik kchik@codeaurora.orgda29b1e2011-05-06 17:36:39 -0700683 total_blocks += chunk_header->chunk_sz;
684 break;
685
Ajay Dudani5c761132011-04-07 20:19:04 -0700686 case CHUNK_TYPE_CRC:
687 if(chunk_header->total_sz != sparse_header->chunk_hdr_sz)
688 {
689 fastboot_fail("Bogus chunk size for chunk type Dont Care");
690 return;
691 }
692 total_blocks += chunk_header->chunk_sz;
693 data += chunk_data_sz;
694 break;
695
Kinson Chik kchik@codeaurora.orgda29b1e2011-05-06 17:36:39 -0700696 default:
Ajay Dudani5c761132011-04-07 20:19:04 -0700697 fastboot_fail("Unknown chunk type");
698 return;
699 }
700 }
701
Ajay Dudani0c6927b2011-05-18 11:12:16 -0700702 dprintf(INFO, "Wrote %d blocks, expected to write %d blocks\n",
703 total_blocks, sparse_header->total_blks);
704
705 if(total_blocks != sparse_header->total_blks)
706 {
707 fastboot_fail("sparse image write failure");
708 }
Ajay Dudani5c761132011-04-07 20:19:04 -0700709
710 fastboot_okay("");
711 return;
712}
713
714void cmd_flash_mmc(const char *arg, void *data, unsigned sz)
715{
716 sparse_header_t *sparse_header;
kchik@codeaurora.orgbce18ea2011-04-18 20:22:28 -0700717 /* 8 Byte Magic + 2048 Byte xml + Encrypted Data */
718 unsigned int *magic_number = (unsigned int *) data;
719 int ret=0;
Ajay Dudani5c761132011-04-07 20:19:04 -0700720
kchik@codeaurora.orgbce18ea2011-04-18 20:22:28 -0700721 if (magic_number[0] == SSD_HEADER_MAGIC_0 &&
722 magic_number[1] == SSD_HEADER_MAGIC_1)
723 {
724#ifdef SSD_ENABLE
Greg Griscod6250552011-06-29 14:40:23 -0700725 ret = decrypt_img_scm((uint32 **) &data, &sz);
kchik@codeaurora.orgbce18ea2011-04-18 20:22:28 -0700726#endif
Greg Griscod6250552011-06-29 14:40:23 -0700727 if (ret != 0) {
kchik@codeaurora.orgbce18ea2011-04-18 20:22:28 -0700728 dprintf(CRITICAL, "ERROR: Invalid secure image\n");
729 return;
730 }
731 }
732 sparse_header = (sparse_header_t *) data;
Ajay Dudani5c761132011-04-07 20:19:04 -0700733 if (sparse_header->magic != SPARSE_HEADER_MAGIC)
734 cmd_flash_mmc_img(arg, data, sz);
735 else
736 cmd_flash_mmc_sparse_img(arg, data, sz);
Ajay Dudani5c761132011-04-07 20:19:04 -0700737 return;
738}
739
Dima Zavin214cc642009-01-26 11:16:21 -0800740void cmd_flash(const char *arg, void *data, unsigned sz)
741{
742 struct ptentry *ptn;
743 struct ptable *ptable;
744 unsigned extra = 0;
745
746 ptable = flash_get_ptable();
747 if (ptable == NULL) {
748 fastboot_fail("partition table doesn't exist");
749 return;
750 }
751
752 ptn = ptable_find(ptable, arg);
753 if (ptn == NULL) {
754 fastboot_fail("unknown partition name");
755 return;
756 }
757
758 if (!strcmp(ptn->name, "boot") || !strcmp(ptn->name, "recovery")) {
759 if (memcmp((void *)data, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
760 fastboot_fail("image is not a boot image");
761 return;
762 }
763 }
764
Chandan Uddarajud6d45042010-02-24 21:12:45 -0800765 if (!strcmp(ptn->name, "system") || !strcmp(ptn->name, "userdata")
Channagoud Kadabi404a7062011-03-21 19:27:50 +0530766 || !strcmp(ptn->name, "persist")) {
767 if (flash_ecc_bch_enabled())
768 /* Spare data bytes for 8 bit ECC increased by 4 */
769 extra = ((page_size >> 9) * 20);
770 else
771 extra = ((page_size >> 9) * 16);
772 } else
Shashank Mittaldcc2e352009-11-19 19:11:16 -0800773 sz = ROUND_TO_PAGE(sz, page_mask);
Dima Zavin214cc642009-01-26 11:16:21 -0800774
775 dprintf(INFO, "writing %d bytes to '%s'\n", sz, ptn->name);
776 if (flash_write(ptn, extra, data, sz)) {
777 fastboot_fail("flash write failure");
778 return;
779 }
780 dprintf(INFO, "partition '%s' updated\n", ptn->name);
781 fastboot_okay("");
782}
783
784void cmd_continue(const char *arg, void *data, unsigned sz)
785{
786 fastboot_okay("");
787 udc_stop();
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700788 if (target_is_emmc_boot())
789 {
790 boot_linux_from_mmc();
791 }
792 else
793 {
794 boot_linux_from_flash();
795 }
Dima Zavin214cc642009-01-26 11:16:21 -0800796}
797
Chandan Uddaraju94183c02010-01-15 15:13:59 -0800798void cmd_reboot(const char *arg, void *data, unsigned sz)
799{
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700800 dprintf(INFO, "rebooting the device\n");
Chandan Uddaraju94183c02010-01-15 15:13:59 -0800801 fastboot_okay("");
802 reboot_device(0);
803}
804
805void cmd_reboot_bootloader(const char *arg, void *data, unsigned sz)
806{
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700807 dprintf(INFO, "rebooting the device\n");
Chandan Uddaraju94183c02010-01-15 15:13:59 -0800808 fastboot_okay("");
809 reboot_device(FASTBOOT_MODE);
810}
811
Chandan Uddaraju2943fd62010-06-21 10:56:39 -0700812void splash_screen ()
813{
814 struct ptentry *ptn;
815 struct ptable *ptable;
816 struct fbcon_config *fb_display = NULL;
817
818 if (!target_is_emmc_boot())
819 {
820 ptable = flash_get_ptable();
821 if (ptable == NULL) {
822 dprintf(CRITICAL, "ERROR: Partition table not found\n");
Greg Griscod6250552011-06-29 14:40:23 -0700823 return;
Chandan Uddaraju2943fd62010-06-21 10:56:39 -0700824 }
825
826 ptn = ptable_find(ptable, "splash");
827 if (ptn == NULL) {
828 dprintf(CRITICAL, "ERROR: No splash partition found\n");
829 } else {
830 fb_display = fbcon_display();
831 if (fb_display) {
832 if (flash_read(ptn, 0, fb_display->base,
833 (fb_display->width * fb_display->height * fb_display->bpp/8))) {
834 fbcon_clear();
835 dprintf(CRITICAL, "ERROR: Cannot read splash image\n");
836 }
837 }
838 }
839 }
840}
841
Brian Swetland9c4c0752009-01-25 16:23:50 -0800842void aboot_init(const struct app_descriptor *app)
843{
Shashank Mittal4f99a882010-02-01 13:58:50 -0800844 unsigned reboot_mode = 0;
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700845 unsigned usb_init = 0;
Vivek Mehta5f1c9d42011-04-01 20:11:59 -0700846 unsigned sz = 0;
Chandan Uddarajubedca152010-06-02 23:05:15 -0700847
Chandan Uddaraju2943fd62010-06-21 10:56:39 -0700848 /* Setup page size information for nand/emmc reads */
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700849 if (target_is_emmc_boot())
850 {
851 page_size = 2048;
852 page_mask = page_size - 1;
853 }
854 else
855 {
856 page_size = flash_page_size();
857 page_mask = page_size - 1;
858 }
859
Greg Griscod6250552011-06-29 14:40:23 -0700860 target_serialno((unsigned char *) sn_buf);
Ajay Dudanib06c05f2011-05-12 14:46:10 -0700861 dprintf(SPEW,"serial number: %s\n",sn_buf);
Subbaraman Narayanamurthyf17b4ae2011-02-16 20:19:56 -0800862 surf_udc_device.serialno = sn_buf;
863
Chandan Uddaraju2943fd62010-06-21 10:56:39 -0700864 /* Check if we should do something other than booting up */
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700865 if (keys_get_state(KEY_HOME) != 0)
866 boot_into_recovery = 1;
Wentao Xu153902c2010-12-20 16:20:52 -0500867 if (keys_get_state(KEY_VOLUMEUP) != 0)
868 boot_into_recovery = 1;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700869 if(!boot_into_recovery)
870 {
871 if (keys_get_state(KEY_BACK) != 0)
872 goto fastboot;
873 if (keys_get_state(KEY_VOLUMEDOWN) != 0)
874 goto fastboot;
875 }
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700876
877 #if NO_KEYPAD_DRIVER
878 /* With no keypad implementation, check the status of USB connection. */
879 /* If USB is connected then go into fastboot mode. */
880 usb_init = 1;
881 udc_init(&surf_udc_device);
882 if (usb_cable_status())
883 goto fastboot;
884 #endif
Chandan Uddarajubedca152010-06-02 23:05:15 -0700885
Ajay Dudani77421292010-10-27 19:34:06 -0700886 reboot_mode = check_reboot_mode();
887 if (reboot_mode == RECOVERY_MODE) {
888 boot_into_recovery = 1;
889 } else if(reboot_mode == FASTBOOT_MODE) {
890 goto fastboot;
891 }
892
Shashank Mittal23b8f422010-04-16 19:27:21 -0700893 if (target_is_emmc_boot())
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700894 {
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700895 if(emmc_recovery_init())
896 dprintf(ALWAYS,"error in emmc_recovery_init\n");
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700897 boot_linux_from_mmc();
898 }
899 else
900 {
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700901 recovery_init();
902 boot_linux_from_flash();
903 }
Dima Zavinb4283602009-01-26 16:36:57 -0800904 dprintf(CRITICAL, "ERROR: Could not do normal boot. Reverting "
905 "to fastboot mode.\n");
906
907fastboot:
Chandan Uddaraju2943fd62010-06-21 10:56:39 -0700908
Amol Jadi57abe4c2011-05-24 15:47:27 -0700909 target_fastboot_init();
910
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700911 if(!usb_init)
912 udc_init(&surf_udc_device);
Brian Swetland9c4c0752009-01-25 16:23:50 -0800913
914 fastboot_register("boot", cmd_boot);
Bikas Gurungd48bd242010-09-04 19:54:32 -0700915
Shashank Mittal23b8f422010-04-16 19:27:21 -0700916 if (target_is_emmc_boot())
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700917 {
918 fastboot_register("flash:", cmd_flash_mmc);
Bikas Gurungd48bd242010-09-04 19:54:32 -0700919 fastboot_register("erase:", cmd_erase_mmc);
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700920 }
921 else
922 {
923 fastboot_register("flash:", cmd_flash);
Bikas Gurungd48bd242010-09-04 19:54:32 -0700924 fastboot_register("erase:", cmd_erase);
Shashank Mittald8c42bf2010-06-09 15:44:28 -0700925 }
926
927 fastboot_register("continue", cmd_continue);
Chandan Uddaraju94183c02010-01-15 15:13:59 -0800928 fastboot_register("reboot", cmd_reboot);
929 fastboot_register("reboot-bootloader", cmd_reboot_bootloader);
Subbaraman Narayanamurthyeb92bcc2010-07-20 14:32:46 -0700930 fastboot_publish("product", TARGET(BOARD));
Brian Swetland9c4c0752009-01-25 16:23:50 -0800931 fastboot_publish("kernel", "lk");
Kinson Chikf1a43512011-07-14 11:28:39 -0700932 partition_dump();
Vivek Mehta5f1c9d42011-04-01 20:11:59 -0700933 sz = target_get_max_flash_size();
934 fastboot_init(target_get_scratch_address(), sz);
Brian Swetland9c4c0752009-01-25 16:23:50 -0800935 udc_start();
Brian Swetland9c4c0752009-01-25 16:23:50 -0800936}
937
938APP_START(aboot)
939 .init = aboot_init,
940APP_END
941