MA-11705 [Android] Correct the parameters for 'sf' command
authorLuo Ji <ji.luo@nxp.com>
Tue, 10 Apr 2018 04:55:09 +0000 (12:55 +0800)
committerLuo Ji <ji.luo@nxp.com>
Tue, 10 Apr 2018 05:30:15 +0000 (13:30 +0800)
Pass the parameters of 'sf' command in bytes instead of in
block size.

Change-Id: I7fa5bad97a0b61b35c7ba46770d3b56df3f6a41e
Signed-off-by: Luo Ji <ji.luo@nxp.com>
drivers/usb/gadget/f_fastboot.c
include/configs/mx7ulp_evk_android.h

index d126235..7a4b3d7 100755 (executable)
@@ -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);
index 2e09547..3ce0ca9 100644 (file)
@@ -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