Enabling swap in embedded systems

If your embedded system running Linux does not have enough memory, you can enable swap to get more memory. However if your platform does not have MMU (Memory Management Unit) as is the case for Sigma Designs EM8620 series, it won’t support swap, so forget it. If your platform does have MMU, as is the case for many newer platforms such as Sigma Designs SMP8630, SMP8640 and SMP8650 series, you can enable swap support. First you’ll have to make sure swap support is enabled in your kernel:

and swapon/swapoff is enabled in busybox. So for example if you have an IDE harddisk with the second partition configured as swap. (Use fdisk to create a partition and mkswap /dev/hda2 to initialize the partition), you can enable the swap as follows:

If you get out-of-memory killer kernel error, you can change the “swapiness” to avoid oom-killer to kick in.

[…]

How to Generate CVS Changelog Automatically

There is a perl script called cvs2cl.pl provided by Red-Bean You can get the latest version thru cvs: cvs -d :pserver:[email protected]:/usr/local/cvs co cvs2cl/cvs2cl.pl Copy the script in a directory that belong to the path e.g.: cp cvs2cl.pl /usr/local/bin Then just checkout your project and run cvs2cl.pl to generate a ChangeLog that will look like: 2010-01-18 developer1 * app/cnxapp/Makefile: Added support for SMP8652 target 2010-01-17 developer2 * app/cnxapp/cnx_download.c: Added HTTP resume support [Bug 1250]: Fixed potential buffer overflow … where developer1 and developer2 are the linux usernames of the developers, app/cnxapp/Makefile, app/cnxapp/cnx_download.c the files that have been modified, and the comments correspond to the messages input during cvs commit. cvs2cl.pl also have other options such as XML output, date selection etc… Just type cvs2cl.pl –help to get the full options. Jean-Luc Aufranc (CNXSoft)Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, […]

Block CVS Commits without message

If you are in my case, and you found it difficult to make some people in your team make proper comments/messages or any comments at all (cvs commit -m “Description of the changes”) while committing their changes to CVS, here’s what can be done to block commit without comments and with short comments. Checkout the CVSROOT directory cvs co CVSROOT Edit verifymsg in CVSROOT as follows #Set the verifymsg file to run a script DEFAULT /usr/local/bin/validate-cvs-log.sh Create /usr/local/bin/validate-cvs-log.sh script (make it executable for all cvs users): #!/bin/sh # # validate-cvs-log.sh logfile # test that log message has some characters in it if [ cat $1 | wc -c -lt 12 ] ; then echo “log message too short; please enter a description for the changes” exit 1 else exit 0 fi Commit verifymsg cvs commit -m “Added script to set minimum message size to 12 characters” verifymsg That’s it ! […]

uClinux kernel panic: Stack overflow

If you’re using ucLinux, you may get kernel panic errors coming out of nowhere. There may be several reasons (buffer overflow, out of memory..), but the most common is stack overflow for the process or one of the threads. To increase the stack size of a flat binary you’ll need to adjust the LDFLAGS as follows:

This will set the stack size to 64KB. To change the stack size of a thread (e.g. 32KB below), you’ll need to set the stack size attribute:

How to detect which thread suffers from stack overflow? First, you can check your code for recursive function calls and local variables (especially arrays) both of which will be added at runtime to the stack to estimate what should be the stack size. So if you have large arrays you may use a pointer + a call to malloc instead. If this can not fix […]

Finding large files in a Linux system

To list large files in a directory and subdirectories

This command looks for files larger than 10MB in /home/user directory and displays the result as follows: /home/user/largefile1.tar.bz2: 32M /home/user/bugzilla.sql: 21M Jean-Luc Aufranc (CNXSoft)Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011. www.cnx-software.com

sudo inside a cron job

If some reasons you need to use sudo in a cron job, for example if you use ltib (Linux Target Image Builder)  in a nightly build script, you may realize that it does not work by default and you may get the message: sudo: sorry, you must have a tty to run sudo In that case simply run visudo and comment out the line: #Default requiretty Jean-Luc Aufranc (CNXSoft)Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011. www.cnx-software.com

Replacing tabs by spaces in vi

In order to have code formatting consistency, we may choose to use only tabs or only spaces in the source code. We chose to only use spaces since that makes sure the code will be properly formatted in any text editor. In order to create 4 spaces while pressing tabs in vi, edit your vi settings: vi ~/.vimrc and add the 3 lines below to your config file set tabstop=4 set shiftwidth=4 set expandtab The next time you’ll use vi, pressing the tabulation key will create 4 spaces. However, in some cases, e.g. Makefile, you may still need to use real tabs. Just press Ctrl+V then tab to create a real tab. Jean-Luc Aufranc (CNXSoft)Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011. www.cnx-software.com

UP 7000 x86 SBC