Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility when using large capacity disks (4T SSD) #12

Open
lisc5324 opened this issue Aug 27, 2022 · 1 comment
Open

Incompatibility when using large capacity disks (4T SSD) #12

lisc5324 opened this issue Aug 27, 2022 · 1 comment

Comments

@lisc5324
Copy link

lisc5324 commented Aug 27, 2022

I use the GPT partition tool to partition the disk and format the file system with exFAT. Use Filex (no system mode) on the zynq xc7z045(ARM Cortex-A9 32bit) development board. An error is always reported. Such as a function _fx_utility_logical_sector_read:

图片

Has anyone patched it.

@eclipsewebmaster eclipsewebmaster transferred this issue from another repository Jan 9, 2024
@nflandin
Copy link

nflandin commented Aug 30, 2024

This does appear to be a bug due to an overflow, as ULONG max is 4294967295, which would correspond to 21990023255040 bytes if there was a 512-byte sector size. I am not sure why fx_media_total_sectors (a ULONG64) is cast to ULONG, as there is no comment explaining it; perhaps this was done to speed up the comparison. I suspect this was a simple mistake, as fx_media_total_sectors is cast to ULONG64 in a number of other places, and is not cast at all when the exact same comparison is made in fx_utility_sector_write (lines 318 & 388).

The simplest solution (and the one I believe to be best) for this would be to simply eliminate the cast. Another solution (to allow for large drives without unnecessarily compromising performance for smaller media) would be to allow a ULONG64 comparison when exFAT is enabled:

`#ifdef FX_ENABLE_EXFAT

    if ((logical_sector + sectors - 1) > media_ptr -> fx_media_total_sectors)

#else

    if ((logical_sector + sectors - 1) > (ULONG)media_ptr -> fx_media_total_sectors)

#endif`

A workaround would be to increase sector size, and the exFAT max of 4096 bytes/sector would result in a 17592186040320 byte limit. The issue with this is that it limits you to what are basically FAT32 partitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants