Skip to content

Commit

Permalink
Upgrade the Zynq driver to recognise and use drives larger than 64GB (#3
Browse files Browse the repository at this point in the history
)

Authored-by: Hein Tibosch
  • Loading branch information
htibosch committed Oct 31, 2020
1 parent 49b4719 commit 680393f
Show file tree
Hide file tree
Showing 13 changed files with 6,859 additions and 4 deletions.
9 changes: 7 additions & 2 deletions ff_format.c
Expand Up @@ -115,6 +115,9 @@

#define RESV_COUNT 32

#define MX_LBA_TO_MOVE_FAT 8192uL
#define SIZE_512_MB 0x100000uL

#ifdef ffconfigMIN_CLUSTERS_FAT32
#define MIN_CLUSTER_COUNT_FAT32 ffconfigMIN_CLUSTERS_FAT32
#else
Expand Down Expand Up @@ -289,7 +292,9 @@ FF_IOManager_t *pxIOManager = pxDisk->pxIOManager;
}
}

if( ( ucFATType == FF_T_FAT32 ) && ( ulSectorCount >= 0x100000UL ) ) /* Larger than 0.5 GB */
if( ( ucFATType == FF_T_FAT32 ) &&
( ulSectorCount >= SIZE_512_MB ) &&
( pxMyPartition->ulStartLBA < MX_LBA_TO_MOVE_FAT ) )
{
uint32_t ulRemaining;
/*
Expand All @@ -298,7 +303,7 @@ FF_IOManager_t *pxIOManager = pxDisk->pxIOManager;
* See e.g. here:
* http://3gfp.com/wp/2014/07/formatting-sd-cards-for-speed-and-lifetime/
*/
ulFATReservedSectors = 8192 - ulHiddenSectors;
ulFATReservedSectors = MX_LBA_TO_MOVE_FAT - ulHiddenSectors;
ulNonDataSectors = ulFATReservedSectors + iFAT16RootSectors;

ulRemaining = (ulNonDataSectors + 2 * ulSectorsPerFAT) % 128;
Expand Down
4 changes: 3 additions & 1 deletion ff_ioman.c
Expand Up @@ -401,6 +401,7 @@ const FF_Buffer_t *pxLastBuffer = &( pxIOManager->pxBuffers[ pxIOManager->usCach

if( pxMatchingBuffer->usNumHandles == 0 )
{
/* Copy the read & write flags. */
pxMatchingBuffer->ucMode = ( ucMode & FF_MODE_RD_WR );
if( ( ucMode & FF_MODE_WRITE ) != 0 )
{
Expand All @@ -413,7 +414,8 @@ const FF_Buffer_t *pxLastBuffer = &( pxIOManager->pxBuffers[ pxIOManager->usCach
break;
}

pxMatchingBuffer = NULL; /* Sector is already in use, keep yielding until its available! */
/* Sector is already in use in a different mode, keep yielding until its available! */
pxMatchingBuffer = NULL;
}
else
{
Expand Down

0 comments on commit 680393f

Please sign in to comment.