Quick guide to install Samba/CIFS in Linux

You may want to install Samba/CIFS in a Linux host to share files with other Windows computer or to use as a media server with a networked media player. If samba is missing, install it in the host machine (foomachine):

Create a new smb user:

Start / check status / restart samba service:

To make samba service run automatically at startup:

Type \\foomachine\foouser  in Windows Explorer and type the username foouser and the password to access your Linux files. To add other directories to share with samba, edit /etc/samba/smb.conf Resource: http://www.cpqlinux.com/samba.html 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

Script to convert Twitter RSS feeds into text

[Update Nov 2012: URLs such as http://twitter.com/statuses/user_timeline/759251.rss do not work anymore, but you can get a Twitter timeline RSS feed by using http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=xxxxx, where xxxxx is the screen name such as cnxsoft] We needed to convert Twitter RSS feeds to UTF-16 text for displaying them into a digital signage (That did not support RSS feed directly).  This digital signage supports regular http download, .e.g every 5 minutes. Here’s the script (called with crontab) we used for CNN News Twitter RSS feed. #!/bin/sh # CNN Twitter wget http://twitter.com/statuses/user_timeline/759251.rss sleep 10 cat 759251.rss | grep title | sed s/\<title\>// | sed s/\<\\/title\>// > cnn.txt rm 759251.rss iconv -f utf-8 -t UCS-2LE cnn.txt > cnn-utf16.txt cp cnn-utf16.txt /var/www/html/livepics/cnn.txt The resulting text file looks like: Twitter / CNN CNN: BREAKING NEWS: Military: Last U.S. brigade combat team leaves Iraq; 56,000 troops remain. Fifty-thousand set to stay past August 31. CNN: NY Gov. David Paterson […]

Embedded Software Books

I’m often asked what useful books software engineers should read when they start to work on embedded systems. So here’s a list of books I would recommend as starters. First, nowadays many embedded systems are written in C (although lower end systems using 8-bit MCU are still likely to be written in Assembler), so software engineers had better make themselves very familiar with C/C++ and GNU tools (gcc, libtool. automake…) with a focus on embedded systems (e.g. interrupts handling, real-time capabilities, volatile variables, processes and threads’ stack handling, , cross compilers…).  Programming Embedded Systems: With C and GNU Development Tools, 2nd Edition is just the right book for that purpose. It deals with embedded Linux and eCos and provides useful examples. You may also read part of it online Once you start developing embedded systems you are likely to write device drivers at some points. Linux Device Drivers, 3rd Edition […]

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 do a framebuffer screenshot

I’ll explain how to do framebuffer screenshots on 16-bit and 32-bit framebuffer. For 16-bit this is fully based on http://docs.blackfin.uclinux.org/doku.php?id=framebuffer Capturing screenshots Whatever the bit-depth of your framebuffer, the first step is to capture the frambuffer raw data on the board:

Now the you need to take the raw image, and convert it to a standard image format. This step depends on what type of display is there Converting 16-bit Framebuffer screenshot (RGB565) into png To convert the raw rgb data extracted from /dev/fb0, use iraw2png perl script

To do the conversion, type the following command in the host:

where 640 and 480 are respectively the width and height of your framebuffer. This has been tried on a 16-bit framebuffer on EM8620 series. Converting 32-bit Framebuffer screenshot (ARGB, RGBA, BGRA…) into png The solution proposed here is not as neat as the blackfin’s solution for 16-bit framebuffer, […]

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 […]

Installing 2 Linux distributions in one PC

Here are the step I followed to install two distributions of Linux: Install the first distribution normally with GRUB in the MBR. While installing the second distribution make sure to set GRUB in its root partition. At this point the second distribution should not be available in GRUB Boot loader, login in the first distribution as root and edit /etc/grub.conf and add the following lines: Linux Distribution 2 root (hd0,2) chainloader +1 Save and restart your PC you should have 2 choices in GRUB, select “Linux Distribution 2”or whatever name you gave in grub.conf and this should start the second Linux distribution. 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

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