Archive for the 'Embedded' Category

Benchmarking boot latency on x86

Gilad Ben-Yossef July 8th, 2008

One of the tasks embedded system developers face is managing boot latency, or the time it takes for a device to become functional after power up.

After all, a set top box that will take more then 60 seconds from the time the “On” button is pressed until the end customer can at least interact with the menus, for example, will most likely be returned to the store for a refund, no matter what feature set it has. When it come to our gadgets, we are all hungry for immediate satisfaction, it seems.

There are many tricks one can employ to to achieve boot time nirvana, but as Knuth taught us, premature optimization is the root of all evil. Therefore, before we turn our efforts to optimize boot latency, we should first try to measure what that boot latency really is and what part of the boot sequence contribute to it, lest we optimize the wrong thing.

Generally speaking, on a x86 (32bit or 64 bit), the boot process of a Linux system is comprised of the following phases and milestones:

  • The power up milestone: when the power is set to on
  • The BIOS phase: which includes the POST (or Power On Self Test), device initialization, running of option ROMs and loading the boot loader form the MBR (or Master Boot Record).
  • The boot loader phase: loading of an operating system kernel and ancillary data (such as Linux initrd or initramfs) into RAM.
  • Kernel initialization phase: initialization of CPU, peripherals and kernel data structures, including the bring up of the non boot cores in the case of a multi-core machine.
  • First user application first line of code milestone: the time when the first line of user application source code is executed.

Unfortunately, measuring the contribution of each of these phases to the overall boot latency is not an easy task to accomplish. At each of the phases different kind of code is executing on the machine: from the 16 bit BIOS code which is part of the machine firmware, via the 16 or 32 bit boot loader code, the 32 bit kernel code and the finally user applications - each of these is executing in a completely different software environment from the other and it is hard to find a common ground to compare the time each phase takes.

Luckily, the x86 architecture provides a useful tool: the TSC (or Time Stamp Clock) register. The TSC register was introduced in the original Intel Pentium CPU and counts the number of clock ticks from the last processor reset. Reading the current value of the TSC register is done using the RDTSC instruction.

Assuming no processor frequency changes (for example via SpeedStep technology) takes place and that we always sample the register of the same core in a multi core environment, both of which are easy to guarantee during the boot phase, the TSC register provides us with an accurate hi-res timer through which we can benchmarks the various phases in the boot process.

Continue Reading »

Penguin In a Box 2008

Limor Pipman June 5th, 2008

We are proud to announce that the third annual Penguin In A Box embedded Linux seminar organized by Codefidence ltd. in cooperation with Hi Tech College, will be held at the 03/07/2008 07/08/2008 in the Daniel hotel and convention center in Herzelia, Israel.

As the use of Linux in the embedded market is on the rise and it’s development continues at an extraordinary rate, the seminar will cover, as in previous years, a broad range of topics relevant to Linux based embedded system developers wishing to keep abreast of recent developments.

For further details, check out the seminar web page (in Hebrew).

Remote Debugging with Eclipse

Tuxology team June 5th, 2008

Eclipse is an open source development platform comprised of extensible frameworks, tools and run times for building, deploying and managing software across the life cycle.

CDT is the name of the C/C++ development plug-in. It includes a graphical GDB front end.

The following slides are a short visual “how to” demonstrating configuring and using CDT to debug a remote target with GDB.

Read this doc on Scribd: eclipse debug

Reducing the size of dynamic libraries

Gilad Ben-Yossef May 15th, 2008

Today we have a special reader request from an anonymous reader (slightly edited):


Hello,

Can you help me with some link issue which I face?

I need to compile tree of c-sources which produce .so files and exe
files. I want to decrease the sizes of .so by throwing away unused symbols.

I can compile my tree statically and used as compiler flags –static -ffunction-sections -fdata-sections and link with –gc-sections option and it reduces all the unneeded symbols but I want to achieve the same effect in dynamic linking.

Do you know some efficient way to do it?

Thanks,
Anonymous Reader

So the question is: how to make a minimal set of dynamic libraries for a known set of executables that only contain the code for those symbols which the executables actually use, thus saving expensive storage?

The quite simple answer is that there exists a Python utility that does exactly what you want called mklibs - It produces cut-down shared libraries that contain only the routines required by a particular set of executables.

On Debian just go “sudo apt-get install mklibs”, or you can get the source straight from the Buildroot source repository here.

If you don’t like Python (you really should!) you can try an older, shell script based variation on the same theme found here.

Note that you can pass the cross compiler prefix with the “–target” option, which is of course needed for supporting cross compilation.

Hope you found it useful and if you have more questions about Linux development you’d like answered, just let us know.

This post originally appeared in the Codefidence Technoblog