From b28f754f789dd0142da3193d38ac924509b3bddc Mon Sep 17 00:00:00 2001 From: Gurjant Kalsi Date: Wed, 9 Mar 2016 16:08:27 -0800 Subject: [PATCH] [dartuino][bootloader] Add some more tracing to fsboot, look for proper system image name. --- app/moot/fsboot.c | 24 +++++++++++++++++++++++- app/moot/moot.c | 3 +++ app/moot/usbboot.c | 1 - 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/moot/fsboot.c b/app/moot/fsboot.c index da1faca1..f95f0a0e 100644 --- a/app/moot/fsboot.c +++ b/app/moot/fsboot.c @@ -29,9 +29,12 @@ #include #include #include +#include #define MAX_FPATH_LEN 64 +#define LOCAL_TRACE 1 + // Attempt to boot from the filesystem. void attempt_fs_boot(void) { @@ -40,15 +43,18 @@ void attempt_fs_boot(void) status_t retcode = moot_mount_default_fs(&mount_path, &device_name); if (retcode != NO_ERROR) { + LTRACEF("Failed: Unable to mount default fs. retcode = %d\n", retcode); return; } char fpath[MAX_FPATH_LEN]; - + snprintf(fpath, MAX_FPATH_LEN, "%s/system.img", mount_path); filehandle *handle; retcode = fs_open_file(fpath, &handle); if (retcode != NO_ERROR) { + LTRACEF("Failed: to open recovery file: '%s'. retcode = %d\n", + fpath ,retcode); goto finish; } @@ -56,6 +62,8 @@ void attempt_fs_boot(void) struct file_stat stat; retcode = fs_stat_file(handle, &stat); if (retcode != NO_ERROR) { + LTRACEF("Failed: to stat recovery file: '%s'. retcode = %d\n", + fpath ,retcode); goto finish; } @@ -68,11 +76,15 @@ void attempt_fs_boot(void) fs_close_file(handle); if (retcode != NO_ERROR) { + LTRACEF("Failed: to get file memmap for '%s'. retcode = %d\n", + fpath ,retcode); goto finish; } bdev_t *secondary_flash = bio_open(device_name); if (!secondary_flash) { + LTRACEF("Failed: Unable to open secondary flash at '%s'. " + "retcode = %d\n", device_name ,retcode); goto finish; } @@ -81,11 +93,14 @@ void attempt_fs_boot(void) bio_close(secondary_flash); if (retcode != NO_ERROR) { + LTRACEF("Failed: to get file memmap for '%s'. " + "retcode = %d\n", device_name ,retcode); goto finish; } retcode = bootimage_open(address, stat.size, &bi); if (retcode != NO_ERROR) { + LTRACEF("Failed: Unable to open bootimage. retcode = %d\n" ,retcode); goto finish; } @@ -93,18 +108,23 @@ void attempt_fs_boot(void) const void *imgptr; retcode = bootimage_get_file_section(bi, TYPE_LK, &imgptr, &imglen); if (retcode != NO_ERROR) { + LTRACEF("Failed: Unable to find lk section. retcode = %d\n" ,retcode); goto finish; } // Flash the new image. bdev_t *system_flash = bio_open(moot_system_info.system_flash_name); if (!system_flash) { + LTRACEF("Failed: Unable to open system flash at '%s'.\n", + moot_system_info.system_flash_name); goto finish; } ssize_t n_bytes_erased = bio_erase(system_flash, moot_system_info.system_offset, imglen); if (n_bytes_erased < (ssize_t)imglen) { + LTRACEF("Failed: Unable to erase system flash at '%s'. retcode = %ld\n", + moot_system_info.system_flash_name, n_bytes_erased); bio_close(system_flash); goto finish; } @@ -114,6 +134,8 @@ void attempt_fs_boot(void) bio_close(system_flash); if (written < (ssize_t)imglen) { + LTRACEF("Failed: Unable to write system flash at '%s'. retcode = %ld\n", + moot_system_info.system_flash_name, written); goto finish; } diff --git a/app/moot/moot.c b/app/moot/moot.c index 258fd34a..d62f4bf4 100644 --- a/app/moot/moot.c +++ b/app/moot/moot.c @@ -53,12 +53,15 @@ static void moot_init(const struct app_descriptor *app) static void moot_entry(const struct app_descriptor *app, void *args) { // Wait a few seconds for the host to try to talk to us over USB. + printf("attempting usb boot...\n"); attempt_usb_boot(); // Check the SPIFlash for an upgrade image. + printf("attempting fs boot...\n"); attempt_fs_boot(); // Boot the main system image. + printf("proceeding to boot...\n"); do_boot(); } diff --git a/app/moot/usbboot.c b/app/moot/usbboot.c index 91c80428..250bd883 100644 --- a/app/moot/usbboot.c +++ b/app/moot/usbboot.c @@ -246,7 +246,6 @@ void init_usb_boot(void) void attempt_usb_boot(void) { - printf("attempting usb boot\n"); uint8_t *buf = malloc(USB_XFER_SIZE); lk_time_t start = current_time();