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

USE_RAM_DESCRIPTORS checks incorrectly calculate RAM usage #135

Open
hraftery opened this issue Dec 14, 2023 · 0 comments
Open

USE_RAM_DESCRIPTORS checks incorrectly calculate RAM usage #135

hraftery opened this issue Dec 14, 2023 · 0 comments

Comments

@hraftery
Copy link

In LUFAConfig.h, USE_RAM_DESCRIPTORS is set if (RAMEND - RAMSTART) >= 512. Assumedly this is to free up Flash by putting the USB Descriptor structs in RAM if the MCU has at least 512 bytes of SRAM.

But RAMEND is the last address of RAM, so RAMEND - RAMSTART returns one less than the RAM size. For example, for the atmega16u2, RAMEND is defined as (RAMSTART + RAMSIZE - 1) where RAMSIZE is 512.

The USB Descriptors seem to occupy 138 bytes, so assumedly would fit in the 16u2's 512 bytes of SRAM. Alas, there's a second issue - HoodLoader2 reserves the first 386 bytes for the rx/tx buffers! So the check fails anyway, because 386 + 138 > 512.

So I think the fix should be to compensate for RAM_OFFSET in the LUFAConfig check, and maybe for the size of the descriptors if we can get that accurate, but I'm not quite sure where responsibility lies...

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

1 participant