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

afatfs.cache unaligned with latest GCC #6

Open
sean-lawless opened this issue Aug 28, 2024 · 4 comments
Open

afatfs.cache unaligned with latest GCC #6

sean-lawless opened this issue Aug 28, 2024 · 4 comments

Comments

@sean-lawless
Copy link
Contributor

sean-lawless commented Aug 28, 2024

I have added your fine library to my simple asynchronous OS (https://github.com/sean-lawless/computersystems/tree/master/Lab20%20Mass%20Storage/fat). All was working fine last time I tested. Recently I upgraded my PC and installed the latest versions of all my embedded development tools and now the sdcard integration was broken.

It turns out that with the latest GCC (arm-none-eabi-gcc.exe (GCC) 13.3.0) the afatfs.cache[] compiles to be unaligned (starts at 3 bytes from the structure start). This caused the lower-level code (USB SD card) to complain about an unaligned buffer (not 4 byte-aligned) when writing data to the afatfs.cache (reading from SD).

I fixed this locally by moving the cache and descriptors above the enumerated types, as below. If you like the change I can make a pull request.

typedef struct afatfs_t {
    uint8_t cache[AFATFS_SECTOR_SIZE * AFATFS_NUM_CACHE_SECTORS];
    afatfsCacheBlockDescriptor_t cacheDescriptor[AFATFS_NUM_CACHE_SECTORS];
    fatFilesystemType_e filesystemType;

    afatfsFilesystemState_e filesystemState;
    afatfsInitializationPhase_e initPhase;

Compile settings (see link):
arm-none-eabi-gcc -c -Wall -ggdb -O0 -ffreestanding

@thenickdude
Copy link
Owner

I think that comment must be a malware bot, definitely do not touch that. I've reported them to GitHub

@thenickdude
Copy link
Owner

The change looks great, thanks, please submit that PR!

@thenickdude
Copy link
Owner

Wow it's a different user posting the malware this time, I've reported them too. Hopefully GitHub gets on top of it.

Repository owner locked as spam and limited conversation to collaborators Aug 28, 2024
@thenickdude
Copy link
Owner

Locking this issue so that we don't get any more of them appearing.

Repository owner unlocked this conversation Aug 28, 2024
@thenickdude thenickdude reopened this Aug 28, 2024
Repository owner locked and limited conversation to collaborators Aug 28, 2024
@github-staff github-staff deleted a comment from sean-lawless Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@thenickdude @sean-lawless and others