开发者

Small libc for embedded systems [closed]

开发者 https://www.devze.com 2023-02-09 14:54 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 3 years ago.

Improve this question

I am looking for a small libc for embedded use开发者_StackOverflow with freertos on a ARM7 microcontroller. I have looked at newlib, but it is a bit too complex for my needs. Newlib calls malloc() in a number of functions (e.g. printf()), which is not good for small embedded realtime systems.

Does anyone know of a small, portable, open source libc implementation that will fit my application?


PDCLib might fit your needs. It's still incomplete [broken link], though, and probably in need of a lot more real-world testing. Its author goes by DevSolar here on SO.

update 2012-11-01: As of 2012-08-14, development has been taken over by Owen Shepherd, complete with a new homepage and bitbucket repository [broken link, use this one].

update 2015-10-31: The dedicated website seems to be dead, but the code can still be found on bitbucket. The last commit to that repository happened 2014-11-24.

update 2016-07-12: The website is back up, and DevSolar started committing again on 2016-03-01.


I use newlib on my Cortex_M3 with 32kB RAM, and to eliminate the malloc() you can use siprintf() or sniprintf().

Pro: No more calls to malloc().

Con: It does not suport formatting float and double, and is not really portable this way.


If you use newlib and do not implement the sbrk syscall, then any function you use that requires malloc will generate a linker error, which will prevent you from inadvertently using a call that requires dynamic memory . So I would suggest that you do that, and then simply avoid those functions that cause the linker error. You can modify or override any library functions you do not wish to use.


printf() is not good for small embedded realtime systems!

Actually it is worse than malloc in many ways. Variable argument lists, very complex formatting, float number support when you don't need it etc etc. printf() comes with an enormous overhead, and the compiler will not be able to reduce it, as every parameter passed to it is evaluated in runtime.

printf() is perhaps ok for hobbyists and beginners still learning C. But if you are a professional programmer, you really ought to write your own serial monitor / LCD routines. You will dramatically improve the program performance and flash consumption.


I had similar needs and found that klibc fit it quite well. The only downside (for commercial use) is that the distribution includes a few GPL-licensed files, even though most of it is BSD-licensed. I have hacked a minimal version of it here.

This is even more limited than PDCLib, and suitable if you just need a few basic functions such as printf and strtok. Compiles to just 4kB with all functions included.


You might want to look into the Embedded Artistry libc, which promises to be minimal and well-tested. It includes a malloc-free printf(). Disclaimer: I have not used it, but it appears well-structured and actively developed.


You can check out the LGPL µClibc, which is supposed to be close to glibc but much more suited to embedded systems.

It also has a page referencing other open source C libraries, including newlib and eCos, which may be more suited for non-Linux environments.


Look into uClibc and EGLIBC, perhaps.

0

精彩评论

暂无评论...
验证码 换一张
取 消