-
Notifications
You must be signed in to change notification settings - Fork 95
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
Bunch of (I hope) improvements #53
Conversation
Hey Alexill. This looks really good. I have some suggestions before merging the PR.
|
I've gone ahead and implemented all three of these in commit You may now use You can override DATA and SIZE sections independently of one another with Thanks for the suggestions. I'm sorry I didn't use your PR directly. I think you'll find this is a lot cleaner and has a lot more options :) |
@graphitemaster I generally agree with what you've said, great work! A few comments, if I may On typing
Ah, you see, it's on "normal" architectures (with common address space) a string is expected to be In my lib I can just use On terminating nullIn my implementation the null byte wasn't included in the size count as to show character count like And a questionCould you please explain to me why appending the byte with the value of
I couldn't figure it out, and it just bus me at this point =) |
Also, I suggest adding |
|
To answer your question about that value. It's just a dummy value that needed to be something. There is an alignment of 1 for that end object after the data that is used to calculate the length, since putting an end variable after it may have padding bytes before it (would use same alignment set for the data), thus computing the wrong size. So an object is needed of some form. Originally the code just used a label but that broke when linked with LTO. The actual value of |
It's pretty late here. I'll look into making the |
Oh, Arduino is not particularly good at documenting it's inner workings. It's better to just see the source https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/WString.h
As you can see here, Then, most of the functions that work with string has two overloads, for example
These both will construct |
Thanks for the explanation. Of course my first thought was "why don't we just change 1 to 0 and have ourselves a null terminator".
Sorry, missed that |
It should also be noted that even if we changed that 1 to a 0, the size would be incorrect since it doesn't count it. |
@graphitemaster was that sufficient amount of info on |
@graphitemaster haven't heard from you for a while. There's still a problem #54 after the last update. Please take a look when you can. |
Hi!
I've made an Adurino library based on your project.
It required a few changes to be made to
incbin.h
which I think improve versatility and may be of use. All change are non-breaking and backward-compatible and I tried to follow the original code style closely.Explanation of every commit
bbc3000 - Add an option to specify different sections for data and its size
Arduino is based on AVR MCU, which has true harvard architecture. Its program memory cannot be directly read from the program, it requires special instructions. Due to this limitation it is very inconvenient to store the size of the included binary data in ROM. The size variable should be stored in RAM, hence it should be in different section.
The commit adds an option to specify section for data size variable by defining
INCBIN_SIZE_OUTPUT_SECTION
macro. If undefined, it defaults to the value ofINCBIN_OUTPUT_SECTION
.2e4c322 - Add terminating NULL at the end of the data (optionallny)
When including text files, it is convenient to treat them as a c-string. The problem is that c-string should be NULL-terminated. This commit adds an option to add NULL byte at the end of the included data by defining
INCBIN_APPEND_TERMINATING_NULL
. Disabled by default.Please check if I did ok there. I have a feeling this change may mess-up the alignment or something. I admit I don't fully understand the code here. For example, I don't understand why you append
.byte 1
at the end of the data.566be48 - Add an option to specify typename for data
Adds an option to specify the resulting pointer type of the included data.
Just a convenience feature that removes the need of the cast every time you use the included data.
Adds two new macros
INCBIN_PTR_TYPE(NAME, FILENAME, DATA_PTR_TYPE)
andINCBIN_EXTERN_PTR_TYPE(NAME, DATA_PTR_TYPE)
with one additional argument alongside the existing.