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

Change all types to use stdint types #13

Open
andrewparlane opened this issue Jun 22, 2017 · 7 comments
Open

Change all types to use stdint types #13

andrewparlane opened this issue Jun 22, 2017 · 7 comments

Comments

@andrewparlane
Copy link
Contributor

There's a lot of use of int's in this lib, in some case they should be unsigned, in others we only need 8 bits etc.... Additionally since sizeof(int) is defined per compiler, it's recommended to use the more explicit stdint.h types.

This would be a lot of work, but I think it would help code readability.

@cederom
Copy link
Owner

cederom commented Jun 23, 2017

Yup, the assumpion here we have at least 32-bit int, oherwise char is used for 8-bits. I was considering once to use 8-bits only but that seems lots of additional work... on the other hand could allow working on cheap 8-bit MCUs..

@andrewparlane
Copy link
Contributor Author

andrewparlane commented Jun 23, 2017 via email

@cederom
Copy link
Owner

cederom commented Jun 23, 2017

Would that imply any portability/platform/compiler issues/restrictions/obligations? I considered int to be most generic..

Not really a priority right now, but of you have time and energy to work on that feel free Andy :-)

@andrewparlane
Copy link
Contributor Author

andrewparlane commented Jun 23, 2017 via email

@cederom
Copy link
Owner

cederom commented Jun 24, 2017

Andy, thanks for reference :-) Why efficiency could be impacted? What about the memory footprint?

We have Thomas from Czech that already ported LibSWD to a microcontroller (32bit ARM) and has noted problems with memory management.. maybe he could also compare the possible efficiency changes..

@ViaExplore
Copy link

Hello Andy, Cederom,
Let me say few words about using stdint.h. In embedded system this is must have and it is also absolute base stone requirements. As they discussed in stackoverflow, it is much easier and safer to port such code which uses stdint.h. If such compiler, which do not support stdint.h exist, than it is very easy for developer to create his own definitions. I am using the library on STM32F205 CPU, and it is running well, but integration and calling functions has lot of redefinitions like int to u32, char to u8 and so on.
In conlusion I would say that I recommend to use stdint.h absolutely everywhere, where it is possible. Using pure int just in case, where you wanna grow with CPU bus width in future usage.

I have found some issues with libswd_error which is holding his history in error cmdq pointer, which is absolutely not handled and not freed anywhere. This can cause runtime memory depletion. Also this error part does not count whit my memory limitation implement. Need to work out a clean solution.

At this time I have tested flash readout from STM32F030 and STM32F207 with success. On my todo list is an automatic CPU recognition and then try flash a new FW into target.

@andrewparlane
Copy link
Contributor Author

andrewparlane commented Jun 24, 2017 via email

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

3 participants