Category Archives: Uncategorized

Building a Root File System


This page provides instructions on how to build a basic root file-system for application development.

Pre-built ramdisk images are available in each release package and recommended for getting started with application development before attempting to built a custom root filesystem as directed by this page.


This process requires a Linux development machine with root access along with the following tools:


The directions on this page assume:

  • The directory used for the root filesystem is “/home/devel/_rootfs”.
  • The Xilinx ARM toolchain {this is the toolchain what we are using currently , as we use a zedboard for our developments } is located in “/opt/14.2/ISE_DS/EDK/gnu/arm/lin64/”.
  • CROSS_COMPILE environment variable is set to arm-xilinx-linux-gnueabi-

Any references to these directories should be modified for specific design needs.

Build process

These instructions use BusyBox for common Unix tools, Dropbear to provide an SSH client/server, and the Xilinx Toolchain for the standard C library and helper applications such as gdb-server.

The root filesystem will be built in the following order:

  1. Building BusyBox
  2. Building Dropbear
  3. Toolchain Library and Application Setup
  4. Directory Creation and Configuration

Building BusyBox

Get a copy of BusyBox from and enter the new directory:

bash> git clone git://
bash> cd busybox

Setup the initial default configuration for BusyBox:

bash> make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- defconfig

The build can be customized from the supplied defaults by running “make menuconfig”.

In the menu options set the install location to “/home/devel/_rootfs” (BusyBox Settings->Installation Options->BusyBox installation prefix):

bash> make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- menuconfig

To setup the initial root filesystem directory for BusyBox run “make install”:

bash> make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- install

Building Dropbear

This build uses Dropbear v0.53.1.

Get a copy from the Dropbear website, extract the tarball and enter the directory:

bash> wget
bash> tar xfvz dropbear-0.53.1.tar.gz
bash> cd dropbear-0.53.1

Configure the build as follows:

bash> ./configure --prefix=/home/devel/_rootfs --host=arm-xilinx-linux-gnueabi --disable-zlib CC=arm-xilinx-linux-gnueabi-gcc LDFLAGS="-Wl,--gc-sections" CFLAGS="-ffunction-sections -fdata-sections -Os"

Build Dropbear with the following command:

bash> make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 strip

Finalize the Dropbear installation by running “make install” and create a symbolic link for scp in the root filesystem:

bash> sudo make install
bash> ln -s ../../sbin/dropbear /home/devel/_rootfs/usr/bin/scp

Toolchain Library and Application Setup

The Xilinx ARM tool-chain includes a pre-built standard C library along with some helper applications like gdb-server.

Enter the “_rootfs” directory and create a “lib” directory:

bash> cd /home/devel/_rootfs
bash> mkdir lib

Copy in the supplied libraries:

bash> cp /opt/14.2/ISE_DS/EDK/gnu/arm/lin64/arm-xilinx-linux-gnueabi/libc/lib/* lib -r

Strip the libraries of debug symbols:

bash> arm-xilinx-linux-gnueabi-strip lib/*

Copy in the supplied tools in libc/sbin and libc/usr/bin

bash> cp /opt/14.2/ISE_DS/EDK/gnu/arm/lin64/arm-xilinx-linux-gnueabi/libc/sbin/* sbin/ -r
bash> cp /opt/14.2/ISE_DS/EDK/gnu/arm/lin64/arm-xilinx-linux-gnueabi/libc/usr/bin/* usr/bin/ -r

Directory Creation and Configuration

This last portion of the root filesystem creation will setup the needed directory structure along with the miscellaneous configuration files needed to start the system up appropriately.

This step will be performed within the “_rootfs” directory.

Create the needed directory structure:

bash> mkdir dev etc etc/dropbear etc/init.d mnt opt proc root sys tmp var var/log var/www

Now that the directories are present etc needs to be populated.

Create “etc/fstab” containing the following:

LABEL=/     /           tmpfs   defaults        0 0
none        /dev/pts    devpts  gid=5,mode=620  0 0
none        /proc       proc    defaults        0 0
none        /sys        sysfs   defaults        0 0
none        /tmp        tmpfs   defaults        0 0

Create “etc/inittab”


# /bin/ash
# Start an askfirst shell on the serial ports


# What to do when restarting the init process


# What to do before rebooting

::shutdown:/bin/umount -a -r

“etc/passwd” should contain:


“etc/init.d/rcS” needs the following:


echo "Starting rcS..."

echo "++ Mounting filesystem"
mount -t proc none /proc
mount -t sysfs none /sys
mount -t tmpfs none /tmp

echo "++ Setting up mdev"

echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

mkdir -p /dev/pts
mkdir -p /dev/i2c
mount -t devpts devpts /dev/pts

echo "++ Starting telnet daemon"
telnetd -l /bin/sh

echo "++ Starting http daemon"
httpd -h /var/www

echo "++ Starting ftp daemon"
tcpsvd 0:21 ftpd ftpd -w /&

echo "++ Starting dropbear (ssh) daemon"

echo "rcS Complete"

Set the appropriate permissions on “etc/init.d/rcS”:

bash> chmod 755 etc/init.d/rcS
bash> sudo chown root:root etc/init.d/rcS

Building the Ramdisk

Now that the root filesystem has been built the last step will create the final ramdisk image that can be used with QEMU or on the board.

Start by creating the file that will contain the final image and format it’s contents with the desired filesystem.

bash> cd ~
bash> dd if=/dev/zero of=ramdisk.img bs=1024 count=8192
bash> mke2fs -F ramdisk.img -L "ramdisk" -b 1024 -m 0
bash> tune2fs ramdisk.img -i 0
bash> chmod 777 ramdisk.img

Mount the image to a folder and copy the “_rootfs” contents to the mounted image:

bash> mkdir ramdisk
bash> sudo mount -o loop ramdisk.img ramdisk/
bash> sudo cp -R _rootfs/* ramdisk
bash> sudo umount ramdisk/

Compress the image:

bash> gzip -9 ramdisk.img

Test the image

This step assumes that QEMU has already been installed and the Linux kernel has been built. To test the image run the following command:

bash> qemu-system-arm -M xilinx-zynq-a9 -m 1024 -kernel zImage -initrd ramdisk.img.gz -nographic -net nic,model=cadence_gem -net user

How to Compile and build U-Boot

Compiling U-Boot

To configure and build U-Boot for a target board “cd” to, or copy the source tree to somewhere local and then type:

host% make distclean
host% make <config>
host% make

Where <config> is one of the configuration names given. ( check include/configs )

Note: If building for a 32-bit environment (SE=1) then the config will have a “se” suffix after the board name, otherwise, for 29-bit mode (SE=0) it will not.

This will create the following set of files:

  • u-boot – Elf executable file (for download with GDB)
  • u-boot.bin – binary file (for burning into Flash)
  • – Linker memory map file

For example, to build a 29-bit U-Boot for a STx7111 on a MB618 board, then run the following commands:

host% make distclean
host% make mb618_config
host% make

To build a 32-bit U-Boot for a STx7105 on a MB680 board, then run the following commands:

host% make distclean
host% make mb680se_config
host% make

U-Boot commands
The list of U-boot commands can be accessed while in the U-Boot prompt.
Type "help" or "?" for a complete listing of available commands.
Documentation on U-Boot may be found at .

Running Linux using U-Boot
Preparing the Linux images for U-Boot

Specific details on building the kernel for MicroBlaze are contained in 
the Build Kernel page.Instructions to obtain a root filesystem can be found
at the Build and Modify a Root File System page.
The kernel and the root filesystem must be wrapped with a U-Boot header 
in order for U-Boot to accept these files. The mkimage utility is used 
for this purpose, however, it is not part of the MicroBlaze GNU tools.
It is part of U-Boot itself and if U-Boot has been compiled as specified on
 this page, it will be found under <u-boot-src>/build/tools/ .
When building linux.bin, as explained in the Build Kernel page, the kernel
 build process automatically creates an additional image, with the ".ub" 
suffix. linux.bin.ub is the Linux binary image wrapped with a U-Boot header.
The Linux compilation process will automatically invoke mkimage, therefore,
it is important to include the path to the U-Boot tools in the PATH environment 
The root filesystem also needs to be wrapped with a U-Boot header as follows:
mkimage -A microblaze -O linux -T ramdisk -C gzip -d ramdisk.image.gz uramdisk.image.gz
Booting Linux
Once the kernel, root filesystem, and device tree images are present in memory,
the command to boot Linux is:
U-Boot> bootm <addr of kernel> <addr of rootfs> <addr of device tree blob (dtb)>
Note: Make sure the kernel and root filesystem images are wrapped by with the U-Boot 
header. The device tree blob does not need to be wrapped with the U-Boot header.

Vim Editor | Why do I need it ?

Vim is the editor of choice for many developers and power users. It’s a “modal” text editor based on the vi editor written by Bill Joy in the 1970s for a version of UNIX. It inherits the key bindings of vi, but also adds a great deal of functionality and extensibility that are missing from the original vi.

Interactive tutorial @


:e filename Open filename for edition
:w Save file
:q Exit Vim
:q! Quit without saving
: x Write file (if changes has been made) and exit
:sav filename Saves file as filename
. Repeats the last change made in normal mode
5. Repeats 5 times the last change made in normal mode

Moving in the file

k or Up Arrow move the cursor up one line
j or Down Arrow move the cursor down one line
e move the cursor to the end of the word
b move the cursor to the begining of the word
0 move the cursor to the begining of the line
G move the cursor to the end of the file
gg move the cursor to the begining of the file
L move the cursor to the bottom of the screen
:59 move cursor to line 59. Replace 59 by the desired line number.
20| move cursor to column 20.
% Move cursor to matching parenthesis
[[ Jump to function start
[{ Jump to block start

Cut, copy & paste

y Copy the selected text to clipboard
p Paste clipboard contents
dd Cut current line
yy Copy current line
y$ Copy to end of line
D Cut to end of line


/word Search word from top to bottom
?word Search word from bottom to top
* Search the word under cursor
/\cstring Search STRING or string, case insensitive
/jo[ha]n Search john or joan
/\< the Search the, theatre or then
/the\> Search the or breathe
/\< the\> Search the
/\< ¦.\> Search all words of 4 letters
/\/ Search fred but not alfred or frederick
/fred\|joe Search fred or joe
/\<\d\d\d\d\> Search exactly 4 digits
/^\n\{3} Find 3 empty lines
:bufdo /searchstr/ Search in all open files
bufdo %s/something/somethingelse/g Search something in all the open buffers and replace it with somethingelse


:%s/old/new/g Replace all occurences of old by new in file
:%s/onward/forward/gi Replace onward by forward, case unsensitive
:%s/old/new/gc Replace all occurences with confirmation
:2,35s/old/new/g Replace all occurences between lines 2 and 35
:5,$s/old/new/g Replace all occurences from line 5 to EOF
:%s/^/hello/g Replace the begining of each line by hello
:%s/$/Harry/g Replace the end of each line by Harry
:%s/onward/forward/gi Replace onward by forward, case unsensitive
:%s/ *$//g Delete all white spaces
:g/string/d Delete all lines containing string
:v/string/d Delete all lines containing which didn’t contain string
:s/Bill/Steve/ Replace the first occurence of Bill by Steve in current line
:s/Bill/Steve/g Replace Bill by Steve in current line
:%s/Bill/Steve/g Replace Bill by Steve in all the file
:%s/^M//g Delete DOS carriage returns (^M)
:%s/\r/\r/g Transform DOS carriage returns in returns
:%s#<[^>]\+>##g Delete HTML tags but keeps text
:%s/^\(.*\)\n\1$/\1/ Delete lines which appears twice
Ctrl+a Increment number under the cursor
Ctrl+x Decrement number under cursor
ggVGg? Change text to Rot13


Vu Lowercase line
VU Uppercase line
g~~ Invert case
vEU Switch word to uppercase
vE~ Modify word case
ggguG Set all text to lowercase
gggUG Set all text to uppercase
:set ignorecase Ignore case in searches
:set smartcase Ignore case in searches excepted if an uppercase letter is used
:%s/\<./\u&/g Sets first letter of each word to uppercase
:%s/\<./\l&/g Sets first letter of each word to lowercase
:%s/.*/\u& Sets first letter of each line to uppercase
:%s/.*/\l& Sets first letter of each line to lowercase

Read/Write files

:1,10 w outfile Saves lines 1 to 10 in outfile
:1,10 w >> outfile Appends lines 1 to 10 to outfile
:r infile Insert the content of infile
:23r infile Insert the content of infile under line 23

File explorer

:e . Open integrated file explorer
:Sex Split window and open integrated file explorer
:Sex! Same as :Sex but split window vertically
:browse e Graphical file explorer
:ls List buffers
:cd .. Move to parent directory
:args List files
:args *.php Open file list
:grep expression *.php Returns a list of .php files contening expression
gf Open file name under cursor

Interact with Unix

:!pwd Execute the pwd unix command, then returns to Vi
!!pwd Execute the pwd unix command and insert output in file
:sh Temporary returns to Unix
$exit Retourns to Vi


:%!fmt Align all lines
!}fmt Align all lines at the current position
5!!fmt Align the next 5 lines


:tabnew Creates a new tab
gt Show next tab
:tabfirst Show first tab
:tablast Show last tab
:tabm n(position) Rearrange tabs
:tabdo %s/foo/bar/g Execute a command in all tabs
:tab ball Puts all open files in tabs
:new abc.txt Edit abc.txt in new window

Window spliting

:e filename Edit filename in current window
:split filename Split the window and open filename
ctrl-w up arrow Puts cursor in top window
ctrl-w ctrl-w Puts cursor in next window
ctrl-w_ Maximize current window vertically
ctrl-w| Maximize current window horizontally
ctrl-w= Gives the same size to all windows
10 ctrl-w+ Add 10 lines to current window
:vsplit file Split window vertically
:sview file Same as :split in readonly mode
:hide Close current window
:­nly Close all windows, excepted current
:b 2 Open #2 in this window


Ctrl+n Ctrl+p (in insert mode) Complete word
Ctrl+x Ctrl+l Complete line
:set dictionary=dict Define dict as a dictionnary
Ctrl+x Ctrl+k Complete with dictionnary


m {a-z} Marks current position as {a-z}
‘ {a-z} Move to position {a-z}
Move to previous position


:ab mail Define mail as abbreviation of

Text indent

:set autoindent Turn on auto-indent
:set smartindent Turn on intelligent auto-indent
:set shiftwidth=4 Defines 4 spaces as indent size
ctrl-t, ctrl-d Indent/un-indent in insert mode
>> Indent
<< Un-indent
=% Indent the code between parenthesis
1GVG= Indent the whole file

Syntax highlighting

:syntax on Turn on syntax highlighting
:syntax off Turn off syntax highlighting
:set syntax=perl Force syntax highlighting


How to create patch file using patch and diff

Hi folks , Before doing this, please backup your source code, patch wrongly will screwup your source code.


First, how to create patch file?
Patch file is a readable file that created by diff with -c (context output format). It doesn’t matter and if you wanna know more, man diff. To patch the entire folder of source codes(as usually people do)I do as bellow:

Assume Original source code at folder Tb01, and latest source code at folder Tb02. And there have multiple sub directories at Tb01 and Tb02 too.

diff -crB Tb01 Tb02 > Tb02.patch

-c context, -r recursive (multiple levels dir), -B is to ignore Blank Lines.
I put -B because blank lines is really useless for patching, sometimes I need to manually read the patch file to track the changes, without -B is really headache.

How to patch?
First of all, please do a dry-run before really patch it. Bare in mind, patch will be working very specifically. Let say the version 3 Tb03.patch is use to patch from Tb02, if you apply patch on Tb01, sometimes it will corrupt your source code. So, to make sure it works, do a dry run. Dry-run means a fake-test, do it at the directory of the source code targeted to patch.

Doing dry-run like this:

patch --dry-run -p1 -i Tb02.patch

The success output looks like this:

patching file TbApi.cpp
patching file TbApi.h
patching file TbCard.cpp

The failure ouptut looks like this:

patching file TbCard.cpp
Hunk #2 FAILED at 585.
1 out of 2 hunks FAILED -- saving rejects to file TbCard.cpp.rej
patching file TbCard.h
Hunk #1 FAILED at 57.
Hunk #2 FAILED at 77.
Hunk #3 succeeded at 83 with fuzz 1 (offset -21 lines).

At last, if the dry-run is giving good result, do this and enjoy the compilation.

patch -p1 -i Tb02.patch

This woman and her machine learning tech could make Box a whole lot smarter

One more indian talent


When cloud collaboration goldenboy Box acquired a stealth content-discovery startup called dLoop last month, the deal was about a lot more than helping Box become this generation’s version of Autonomy. Box sees a lot of potential in dLoop’s machine learning technology to help the company evolve into a platform for developers and maybe even a pioneer in mobile content-management. Divya Jain, dLoop’s co-founder and now a software engineer at Box, will help lead that charge.

The dLoop technology uses machine learning algorithms and graph analysis to detect the similarities among documents and organize them into clusters that are searchable not just by keyword, but by relevance. The immediate benefits are obvious — Box users will be able to search for documents more confidently, knowing they’ll see everything they might need even if it doesn’t feature or even include a particular term. It’s helpful for security, too, Jain explained in recent…

View original post 726 more words

Nanotech – Future Applications of Graphene: Video

Great Things from Small Things .. Nanotechnology Innovation

4 DisruptiveSamsung Advanced Institute of Technology, the core R&D incubator for Samsung Electronics, has developed a new transistor structure utilizing graphene, touted as the “miracle material.”

As published online in the journal Science on Thursday, 17th May, this research is regarded to have brought us one step closer to the development of transistors that can overcome the limits of conventional silicon.

Currently, semiconductor devices consist of billions of silicon transistors. To increase the performance of semiconductors (the speed of devices), the options have to been to either reduce the size of individual transistors to shorten the traveling distance of electrons, or to use a material with higher electron mobility which allows for faster electron velocity. For the past 40 years, the industry has been increasing performance by reducing size. However, experts believe we are now nearing the potential limits of scaling down.

Since graphene possesses electron mobility about 200 times greater…

View original post 346 more words