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

Size bloat when LED_DDR != USBDDR #251

Open
duckythescientist opened this issue Nov 10, 2021 · 1 comment
Open

Size bloat when LED_DDR != USBDDR #251

duckythescientist opened this issue Nov 10, 2021 · 1 comment
Labels

Comments

@duckythescientist
Copy link

duckythescientist commented Nov 10, 2021

Changing the LED_DDR to be a different register than the USB DDR bloats the code size (even if the LED isn't used).

I'm testing with t167_default on master. Building as-is: 1340 bytes. If in bootloaderconfig.h I change #define LED_DDR DDRB to #define LED_DDR DDRA, the code now builds with size 1454 bytes.

I haven't gone too far down the rabbit hole, but I'm thinking that https://github.com/micronucleus/micronucleus/blob/master/firmware/main.c#L600 isn't actually getting optimized like the comment indicates. If I comment out the if/else section and hardcode it to always use usbDeviceConnect();, then the code stays at 1340 bytes independent of which DDR the LED uses.

@ArminJo
Copy link
Contributor

ArminJo commented Nov 10, 2021

You are right the compiler in this case refuses to optimize the constant expression. what a pity.
But the code looks like requiring to be tested better, since for USB_CFG_PULLUP_IOPORTNAME the device is still disconnected.

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

No branches or pull requests

2 participants