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

make debug.c components optional to save code size #17

Open
nerdralph opened this issue Jun 29, 2020 · 4 comments
Open

make debug.c components optional to save code size #17

nerdralph opened this issue Jun 29, 2020 · 4 comments

Comments

@nerdralph
Copy link
Contributor

I was able to reduce the compiled size of the blink example from 700B to 232B by conditionally excluding the UART functions. Another 36B can be saved by excluding the WDT functions. Instead of adding #ifdef BUILD_UART around the code, another option would be to break up debug.c into separate files and build it as a library. Then the linker will only pull in .rel files that are actually used.

@cibomahto
Copy link
Member

Both of those sound useful. One of the original design goals (that it looks like I didn't actually write down), was to avoid modifying the WCH code structure too much, so that it would be easier to pull in updates from WCH. From that angle, I would prefer #ifdefs. Separating them into individual library files does seem to be inline with how SDCC works, though.

@nerdralph
Copy link
Contributor Author

I think you could probably do a lot better job if you had written it from scratch. The UART code isn't the only thing that needs work; mDelayuS could use a rewrite too. I also would've named it util.c instead of debug, since it's not specific to debugging.

@cibomahto
Copy link
Member

Yeah, I agree- This was more of a strategy for keeping the scope of the project small enough so that I could get something working. As long as the example files are modified to work with the changes, it seems reasonable to rename and/or split the files up. We should probably put a short note at the top of the new files to say where they came from originally, for the probably few people who are trying to follow a Keil example.

@nerdralph
Copy link
Contributor Author

Another idea is to make most of the functions inline.

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