From 0628282072253bc1ec63d82dd1a89a0f2dbfe6e6 Mon Sep 17 00:00:00 2001 From: Luo Ji Date: Tue, 10 Apr 2018 12:55:09 +0800 Subject: [PATCH] MA-11705 [Android] Correct the parameters for 'sf' command Pass the parameters of 'sf' command in bytes instead of in block size. Change-Id: I7fa5bad97a0b61b35c7ba46770d3b56df3f6a41e Signed-off-by: Luo Ji --- drivers/usb/gadget/f_fastboot.c | 12 ++++++++---- include/configs/mx7ulp_evk_android.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index d126235d98..7a4b3d71a8 100755 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -570,15 +570,19 @@ static int saveenv_to_ptn(struct fastboot_ptentry *ptn, char *err_string) return ret; } +static int get_block_size(void); #ifdef CONFIG_FLASH_MCUFIRMWARE_SUPPORT static void process_flash_sf(const char *cmdbuf) { + int blksz = 0; + blksz = get_block_size(); + if (download_bytes) { struct fastboot_ptentry *ptn; ptn = fastboot_flash_find_ptn(cmdbuf); if (ptn == 0) { fastboot_fail("partition does not exist"); - } else if ((download_bytes > ptn->length)) { + } else if ((download_bytes > ptn->length * blksz)) { fastboot_fail("image too large for partition"); /* TODO : Improve check for yaffs write */ } else { @@ -593,8 +597,8 @@ static void process_flash_sf(const char *cmdbuf) return; } /* Erase */ - sprintf(sf_command, "sf erase 0x%x 0x%x",ptn->start, /*start*/ - ptn->length /*size*/); + sprintf(sf_command, "sf erase 0x%x 0x%x", ptn->start * blksz, /*start*/ + ptn->length * blksz /*size*/); ret = run_command(sf_command, 0); if (ret) { fastboot_fail("Erasing sf failed"); @@ -603,7 +607,7 @@ static void process_flash_sf(const char *cmdbuf) /* Write image */ sprintf(sf_command, "sf write 0x%x 0x%x 0x%x", (unsigned int)(ulong)interface.transfer_buffer, /* source */ - ptn->start, /* start */ + ptn->start * blksz, /* start */ download_bytes /*size*/); printf("sf write '%s'\n", ptn->name); ret = run_command(sf_command, 0); diff --git a/include/configs/mx7ulp_evk_android.h b/include/configs/mx7ulp_evk_android.h index 2e09547acb..3ce0ca9621 100644 --- a/include/configs/mx7ulp_evk_android.h +++ b/include/configs/mx7ulp_evk_android.h @@ -35,7 +35,7 @@ #ifdef CONFIG_FLASH_MCUFIRMWARE_SUPPORT #define ANDROID_MCU_FRIMWARE_DEV_TYPE DEV_SF #define ANDROID_MCU_FIRMWARE_START 0 -#define ANDROID_MCU_FIRMWARE_SIZE 0x4000000 +#define ANDROID_MCU_FIRMWARE_SIZE 0x20000 #endif #endif -- 2.17.1