[U-Boot] fatwrite problem

Mats Kärrman Mats.Karrman at tritech.se
Fri Apr 12 16:11:06 CEST 2013


Hi Ruud,

Ruud Commandeur wrote:
> Once the size of the set_cluster call equals 0, the mmc command is
> incomplete and times out. In the earlier reported problem, a patch is
> mentioned, but not available for dowload here. Also in the latest
> versions of the git repository I could not find a patch for this
> problem. Can anyone tell me if there is a fix for this problem?

I asked Damien Huang (back then) and got the following reply (I think there was
some character encoding problem so his mail never was accepted by the list).
I have not further analyzed the contents, anyway it wasn't the solution to my problem.
BR // Mats

Damien Huang wrote:
As requested from Mats, I am resending this email. The patch is given below:

diff -cr ./u-boot-original/u-boot/fs/fat/fat_write.c ./u-boot-test/u-boot/fs/fat/fat_write.c
*** ./u-boot-original/u-boot/fs/fat/fat_write.c    2013-02-07 14:47:33.314732999 +1100
--- ./u-boot-test/u-boot/fs/fat/fat_write.c    2013-02-28 15:36:24.551861920 +1100
***************
*** 562,596 ****
  {
      int idx = 0;
      __u32 startsect;
!
!     if (clustnum > 0)
!         startsect = mydata->data_begin +
!                 clustnum * mydata->clust_size;
!     else
!         startsect = mydata->rootdir_sect;
!
!     debug("clustnum: %d, startsect: %d\n", clustnum, startsect);
!
!     if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
!         debug("Error writing data\n");
!         return -1;
!     }
!
!     if (size % mydata->sect_size) {
!         __u8 tmpbuf[mydata->sect_size];
!
!         idx = size / mydata->sect_size;
!         buffer += idx * mydata->sect_size;
!         memcpy(tmpbuf, buffer, size % mydata->sect_size);
!
!         if (disk_write(startsect + idx, 1, tmpbuf) < 0) {
!             debug("Error writing data\n");
!             return -1;
!         }
!
!         return 0;
!     }
!
      return 0;
  }
 
--- 562,595 ----
  {
      int idx = 0;
      __u32 startsect;
!     if(size) //if there are data to be set
!     {
!         if (clustnum > 0)
!             startsect = mydata->data_begin +
!                     clustnum * mydata->clust_size;
!         else
!             startsect = mydata->rootdir_sect;
!
!         debug("clustnum: %d, startsect: %d\n", clustnum, startsect);
!
!         if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
!             debug("Error writing data\n");
!             return -1;
!         }
!
!         if (size % mydata->sect_size) {
!             __u8 tmpbuf[mydata->sect_size];
!
!             idx = size / mydata->sect_size;
!             buffer += idx * mydata->sect_size;
!             memcpy(tmpbuf, buffer, size % mydata->sect_size);
!
!             if (disk_write(startsect + idx, 1, tmpbuf) < 0) {
!                 debug("Error writing data\n");
!                 return -1;
!             }
!         }
!     }//end if data to be set
      return 0;
  }
 
diff -cr ./u-boot-original/u-boot/include/configs/am335x_evm.h ./u-boot-test/u-boot/include/configs/am335x_evm.h
*** ./u-boot-original/u-boot/include/configs/am335x_evm.h    2013-02-07 14:47:35.754702325 +1100
--- ./u-boot-test/u-boot/include/configs/am335x_evm.h    2013-03-01 12:25:23.942104474 +1100
***************
*** 143,148 ****
--- 143,149 ----
  #define CONFIG_CMD_MMC
  #define CONFIG_DOS_PARTITION
  #define CONFIG_FS_FAT
+ #define CONFIG_FAT_WRITE
  #define CONFIG_FS_EXT4
  #define CONFIG_CMD_FAT
  #define CONFIG_CMD_EXT2


More information about the U-Boot mailing list