Wednesday, February 8, 2017

How to find the memory consumption of a particular process

How to measure actual memory usage of an application or process ?
How to find how much a specific process use ?
Just run pmem.sh script with a process name ! such as..

$ ./pmem.sh chrome
chrome's memory usage : 60.9 %

As you can see, you can find out what percentage does the process use of all memory.

$ cat pmem.sh
#!/bin/bash

if [ "$1" == "" ]; then
   echo "Please enter process name"
   exit 0
fi

p_count=`ps -eo comm | grep -wc "$1"`

if [ "$p_count" == "0" ]; then
   echo "Error: '$1' process don't exist"
   exit 0
fi


mem_usage=`ps -eo pmem,comm | grep -we "$1" | awk -F" " '{print  $1}' | paste -sd+ | bc`
echo "$1's memory usage : $mem_usage %"

exit 0

Wednesday, July 1, 2015

Virtual Box : SSH (How to login to a guest OS)

Virtual Box : SSH (How to login to a guest OS)

<1> Install SSH
Sure, you have to install a ‘ssh’ service on a guest OS

$ sudo apt-get install -y openssh-server

<2> Change VBox setting

# A guest OS name : my_ubuntu
# Host port       : 3022
# Guest port      : 22
#
# Sure, you can change port number as below
# $ emacs /etc/ssh/sshd_config
# $ service ssh restart

$ VBoxManage modifyvm my_ubuntu --natpf1 "ssh,tcp,,3022,,22"

# You can check VBox settings as below
$ VBoxManage showvminfo myserver | grep 'Rule'

<3> SSH into the guest OS on Virtual Box

# Even if network is unreachable, no problem
$ ssh -p 3022 user@127.0.0.1

* Referense page

solvedstack

Saturday, May 30, 2015

Cscope & Emacs ( simple integration)

Cscope & Emacs ( simple integration)

Installation cscope

# os           :  ubuntu 13.10
# emacs  :  24.3.1
# cscope :  15.8b

Dowload cscope

$ tar zxvf cscope-X.Y.tar.gz
$ cd cscope-X.Y
$ ./configure
$ sudo make install

Cscope & Emacs configuration

$ cd contrib/xcscope
$ sudo cp cscope-indexer /usr/local/bin
$ cp xcscope.el ~/.emacs.d/

# cscope configuration for emacs 
$ echo '(load-file "~/.emacs.d/xcscope.el")' >> ~/.emacs

Create index file and set initial dir

# get ready to browse your source code.
# if you installed cscope, run emacs and work some commands by following.
M-x cscope-index-file <RET>
# and then enter your workspace path 
# or in order to detailedly collect cscope information, separately create cscope.files and cscope.out as below  
$ rm -rf cscope.files cscope.out
$ find . \( -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.s' -o -name '*.S' \) -print > cscope.files
$ cscope -b -i cscope.files

M-x cscope-set-initial-directory <RET>
# or run this command to assign your workspace path to it
C-c s a 

Cscope commands on emacs

# most-used
C-c s d     Find global definition.
C-c s c     Find functions calling a function.
C-c s C     Find called functions (list functions called from a function).
C-c s s     Find symbol.
C-c s u     Return the point from where you jumped.

# other commands
C-c s g     Find global definition (alternate binding).
C-c s G     Find global definition without prompting.
C-c s t     Find text string.
C-c s e     Find egrep pattern.
C-c s f     Find a file.
C-c s i     Find files #including a file.
C-c s a     Set initial directory which has a index file (cscope.out).

Tuesday, February 10, 2015

Ubuntu Server 14.04 Network Bonding ( a simple expedient )

Ubuntu Server 14.04 Network Bonding ( a simple expedient )

Simple Ubuntu 14.04 Bonding

Just do it as below if you want to create or delete network bonding

<1> ifdown -a –exclude=lo
<2> edit network interfaces file (/etc/network/interfaces)
<3> service networking restart
<4> Done

< Using >
1. bond-mode ‘IEEE 802.3ad’
2. ifenslave (version 2.4ubnutu1)
3. service networking (13.10)

Create bonding

1) Install ifenslave

:> sudo apt-get install ifenslave

2) Restore 13.10 networking (instead of networking 14.04)

:> git clone https://github.com/metral/restore_networking.git
:> cd restore_networking/
:> ./restore_networking.sh

3) Bring network interfaces down

:> ifdown -a --exclude=lo

4) Edit /etc/network/interfaces file

:> emacs /etc/network/interfaces

auto lo eth0 eth1 eth2
iface lo inet loopback
iface eth0 inet manual
iface eth1 inet manual # bond-slave
        bond-master bond0
iface eth2 inet manual # bond-slave
        bond-master bond0

auto bond0
iface bond0 inet static
        address 192.168.1.105
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers  8.8.8.8
        bond-mode 802.3ad
        bond-slaves none # There is no need to declare bond-slaves
        bond-xmit_hash_policy layer3+4
        bond-miimon 100
        bond-updelay 200
        bond-downdelay 200
        bond-lacp-rate 1

5) Restart service networking

:> service networking restart 

Check bonding

:> cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer3+4 (1)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200

802.3ad info
LACP rate: fast
Min links: 0
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
    Aggregator ID: 1
    Number of ports: 1
    Actor Key: 17
    Partner Key: 1
    Partner Mac Address: 00:00:00:00:00:00

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 18:bx:cc:xx:xx:xx
Aggregator ID: 1
Slave queue ID: 0

Slave Interface: eth2 # isn't used and connected with LAN (even if it ware so, no matter)
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 18:bd:23:xx:xx:xx
Aggregator ID: 2
Slave queue ID: 0

Delete bonding

1) Remove bonding (module from kernel)

:> rmmod bonding

2) Bring network interfaces down

:> ifdown -a --exclude=lo

3) Edit /etc/network/interfaces file

:> emacs /etc/network/interfaces 

auto lo eth0 eth1 eth2
iface lo inet loopback
iface eth0 inet manual
iface eth1 inet static
        address 192.168.1.105
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers 8.8.8.8
iface eth2 inet manual

4) Restart service networking

:> service networking restart

Troubleshooting

After you set or unset ‘bonding’ , if ethernet not work.

  1. Check ‘/run/network/ifstate’ file
  2. Try to do “ifdown -a –exclude=lo && ifup -a –exclude=lo”
  3. Check LAN connector & port
  4. Check “route”

1) Check /run/network/ifstate

# ifup, ifdown commands work depending on /run/network/ifstate file
# and /etc/network/interfaces file.
# So if there are network interfaces which aren't written in /run/network/ifstate 
# file, the commands cannot perfectly work. 
# /run/network/ifstate file should have all network interfaces like this 

eth0=eth0
eth1=eth1
eth2=eth2
lo=lo

2) Try to bring down & up network interfaces

:> ifdown -a --exclude=lo && ifup -a --exclude=lo 

3) Check LAN connector & port

Check or change your LAN connector and port.
# There are sufficient cases of poor LAN connetor or port.

4) Check route

:> route

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 bond0
192.168.1.0     *               255.255.255.0   U     0      0        0 bond0

# As above this shuould be printed (if you only use bond interface)
# But output of command 'route' might not be like this.
#
# 1. Even a few minutes later, if it wasn't printed
#    check your hub or switch and try to replace port.
#
# 2. Even though bond0 has correct gateway like 192.168.1.1 
#    if your ethernet is unstable, 
#    check whether there's network interface which has IP address 
#    that use same extended network prefix.

Saturday, January 10, 2015

GIT Rebase in contributing opensource.

Simply introduce GIT Rebase command comparing GIT Merge

If you've been contributing linux-perf ..
1. origin = my remote repository
2. upstream = linux-perf remote repository
3. origin/master = to follow one branch of 'upstream'

If you’ve been working in ‘origin/master’ but ‘upstream’ is updated so you need to update your remote and local repository.
If you do..
After you make yours newest, you can do as below.
(ex> ‘git fetch upstream perf/core’ )

1) git rebase

$ git fetch upstream perf/core
$ git rebase upstream/perf/core (on 'master' branch)
# Contents of your commit is added on top of the newest commit history.

Saturday, October 4, 2014

In specific directory, how to copy-on-write like snapshot.

In the general , it is the method that make hard-link
and can do copy-on-write by two ways.

<1> Make hard-link

$ cp -al one_folder hard_linked_folder

<2> Simply, there are two ways to use copy-on-write.

<2-1> cowdancer

The way demonstrate copy-on-write in only a shell session.

$ sudo apt-get install cowdancer

Invoke cow-shell and it start a shell session that will protect the i-node below the current directory.

$ cd hard_linked_folder
$ cow-shell
 # Invoking /bin/bash (it is output)

And then, if you write any files in ‘hard_linked_folder’, copy-on-write coincide with it.
If you want to finish the situation, by ‘exit’ you can quit it.

$ exit

<2-2> fl-cow

This one can do copy-on-write when a specific program write some in the folder ‘hard_linked_folder’.

$ sudo apt-get install fl-cow

This one is more easy than cowdancer.
Just run a program you want to monitor with ‘cow‘.

$ cow program
$ cow utserver # it is a example.
               # utserver is utorrent server.
               # If utserver modify some in the folder,
               # fl-cow will protect the i-node
               # to preserve original files.

You can check whether the program is run with ‘fl-cow’ or not.

$ lsof | grep cow

If you can’t see anything, run the program with ‘cow’ again.

Tuesday, September 23, 2014

How to simply send patch to linux kernel

Title2

If you simply wanna send a patch linux kernel source tree, follow the process below.

<1> Find which source tree you want to contribute in the site https://git.kernel.org
(If you want to contribute to ‘tools/perf’, recommend the branch perf/core in ‘tip’ source tree below.. )

$ git clone -b perf/core git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core

(Even though you want to find other source tree, you can’t find it.
Find in ‘MAINTAINERS’ file or ask mailing list for the sub project you want “what is the source tree and branch in it ?”.)

<2> After you modify source code, check your commit.

$ git add -A && git commit -s && git show

<3> You can make a patch file.

$ git format-patch -1

<4> Check your patch.

$ scripts/checkpatch.pl 0001-modify-something.patch

<5> Get maintainer email address to which you send your patch.

$ scripts/get_maintainer.pl 0001-modify-something.patch

<6> If there isn’t the problems, send email to maintainer and kernel mailing list.

$ git send-email --to "email@address" --cc "some@address" //format
$ git send-email --to "Arnaldo Carvalho de Melo <acme@kernel.org>"\ 
> --cc "linux-kernel@vger.kernel.org" \
> --cc "linux-perf-users@vger.kernel.org"\
> 0001-modify-something.patch

Monday, August 18, 2014

How to show date next to time in the panel in Ubuntu Gnome

Title

How to show date next to time in the panel (Gnome)

If you might see calendar like as below.

but you can input as below in gnome shell terminal.

$ gsettings set org.gnome.desktop.interface clock-show-date true

and then, you can see like this.

Wednesday, August 13, 2014

Emacs print with color syntax highlighting

Welcome document

You can insert this line as below

(setq ps-paper-type 'letter
ps-font-size 8.0
ps-print-header nil
ps-landscape-mode t
ps-number-of-columns 2)

and than if you run ‘M-x ps-print-buffer-with-faces’, the buffer is printed.

Gnome ubuntu 13.10 한글 설정 (Korean language)

Welcome document

1) $ sudo apt-get install nabi language-selector-gnome
2) System Settings → Language support → Keyboard input method system : Ibus (select it)
3) install Language → korean
4) log out & log in
5) System Settings → Region & Language → Input Sources → add → Korean(Hangul)
6) press ’ Super + space ’ or your key to switch to next source (System Settings → Keyboard → Typing)

Tuesday, August 12, 2014

Simple setting for QT4 development environment

Welcome document

1) $ sudo apt-get install libqt4-core

2) $ sudo apt-get install libqt4-dev

3) $ dpkg -l | grep qt4 Check QT4 development environment

ii  libntrack-qt4-1                       016-1.1                                       amd64        Qt 4 API for ntrack
ii  libpoppler-qt4-4:amd64                0.24.3-0ubuntu1~saucy1                        amd64        PDF rendering library (Qt 4 based shared library)
ii  libqt4-core                           4:4.8.4+dfsg-0ubuntu18.1                      amd64        transitional package for Qt 4 core non-GUI runtime libraries
ii  libqt4-dbus:amd64                     4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 D-Bus module
ii  libqt4-declarative:amd64              4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 Declarative module
ii  libqt4-designer:amd64                 4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 designer module
ii  libqt4-dev                            4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 development files
ii  libqt4-dev-bin                        4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 development programs
ii  libqt4-help:amd64                     4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 help module
ii  libqt4-network:amd64                  4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 network module
ii  libqt4-opengl:amd64                   4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 OpenGL module
ii  libqt4-opengl-dev                     4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 OpenGL library development files
ii  libqt4-qt3support:amd64               4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 3 compatibility library for Qt 4
ii  libqt4-script:amd64                   4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 script module
ii  libqt4-scripttools:amd64              4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 script tools module
ii  libqt4-sql:amd64                      4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 SQL module
ii  libqt4-sql-mysql:amd64                4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 MySQL database driver
ii  libqt4-svg:amd64                      4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 SVG module
ii  libqt4-test:amd64                     4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 test module
ii  libqt4-xml:amd64                      4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 XML module
ii  libqt4-xmlpatterns:amd64              4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 XML patterns module
ii  qt4-linguist-tools                    4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 Linguist tools
ii  qt4-qmake                             4:4.8.4+dfsg-0ubuntu18.1                      amd64        Qt 4 qmake Makefile generator tool

If you can see it as above, it’s completed.

QT4 Development Simple Test

4-1) $ mkdir qt-test

4-2) $ cd qt-test

4-3) $ vi test.cpp

#include <QtCore/QCoreApplication>
 #include <QDebug>

 int main(int argc, char *argv[])
 {
              //QCoreApplication a(argc, argv);
              qDebug() << "hello world!" << endl;
                  //return a.exec();
  }

4-4) $ qmake-qt4 -project Create file ‘qt-test.pro’

4-5) $ qmake-qt4 Create file ‘Makefile’

4-6) $ make make and then you can see binary file ‘qt-test’

4-7) $ ./qt test just run it.

etc : problem & solution

  • a problem : after ‘make’ command
make: Warning: File `/usr/share/qt4/mkspecs/linux-g++/qmake.conf' has modification time 1.4e+09 s in the future
/usr/bin/qmake-qt4 -o Makefile qt.pro
make: Warning: File `/usr/share/qt4/mkspecs/linux-g++/qmake.conf' has modification time 1.4e+09 s in the future
/usr/bin/qmake-qt4 -o Makefile qt.pro
make: Warning: File `/usr/share/qt4/mkspecs/linux-g++/qmake.conf' has modification time 1.4e+09 s in the future
/usr/bin/qmake-qt4 -o Makefile qt.pro
make: Warning: File `/usr/share/qt4/mkspecs/linux-g++/qmake.conf' has modification time 1.4e+09 s in the future
/usr/bin/qmake-qt4 -o Makefile qt.pro
…
repeat output as above.
  • a solution : $ find {directory_name} -exec touch {} \;

I don’t know exactly the reason of this problem but it is about date of system? file?
$ touch /usr/share/qt4/mkspecs/linux-g++/qmake.conf wasn’t able to solve this problem.
So I solved it by the command line which can run ‘touch’ in all of subdirectories as above.

FEC ethernet driver on L4 Linux using Freescale imx6 Quad SABRE SD

Welcome document imx6q-fec.patch was made to load FEC ethernet driver on L4 Linux.
Author: Taeung Song <treeze.taeung@gmail.com>, Yeongchann Han <yeongchann@xsinc.co.kr>
Date:   Tue May 15 17:20:18 2014

This patch is 

to change UART2 to UART1 for imx6q sabresd (learned by Ahmed Ammar) and
to fix compile error(fiasco and l4linux),
to modify source related to FEC ethernet. 

diff -uNr a/src/kernel/fiasco/src/kern/arm/bsp/imx/mem_layout-arm-imx.cpp b/src/kernel/fiasco/src/kern/arm/bsp/imx/mem_layout-arm-imx.cpp
--- a/src/kernel/fiasco/src/kern/arm/bsp/imx/mem_layout-arm-imx.cpp 2014-03-01 02:17:42.000000000 +0900
+++ b/src/kernel/fiasco/src/kern/arm/bsp/imx/mem_layout-arm-imx.cpp 2014-05-15 21:12:50.814787510 +0900
@@ -80,6 +80,6 @@
     Gpt_phys_base        = 0x02098000,
     Src_phys_base        = 0x020d8000,
     Uart2_phys_base      = 0x021e8000, // uart2
-    Uart_phys_base       = Uart2_phys_base,
+    Uart_phys_base       = Uart1_phys_base, //imx6q use UART1
   };
 };
diff -uNr a/src/kernel/fiasco/src/kern/arm/bsp/imx/uart-imx.cpp b/src/kernel/fiasco/src/kern/arm/bsp/imx/uart-imx.cpp
--- a/src/kernel/fiasco/src/kern/arm/bsp/imx/uart-imx.cpp   2014-03-01 02:17:42.000000000 +0900
+++ b/src/kernel/fiasco/src/kern/arm/bsp/imx/uart-imx.cpp   2014-05-16 12:21:50.700017375 +0900
@@ -41,7 +41,8 @@

 #include "uart_imx.h"

-IMPLEMENT int Uart::irq() const { return 59; }
+//imx6q uses UART1 which uses (irq=58)
+IMPLEMENT int Uart::irq() const { return 58; }

 IMPLEMENT L4::Uart *Uart::uart()
 {
diff -uNr a/src/kernel/fiasco/src/kern/tb_entry_output.cc b/src/kernel/fiasco/src/kern/tb_entry_output.cc
--- a/src/kernel/fiasco/src/kern/tb_entry_output.cc 2014-03-01 02:17:42.000000000 +0900
+++ b/src/kernel/fiasco/src/kern/tb_entry_output.cc 2014-05-15 18:00:42.338421257 +0900
@@ -110,6 +110,7 @@
 class Tb_entry_ipc_fmt : public Tb_entry_formatter
 {
 public:
+  Tb_entry_ipc_fmt(){};
   void print(String_buffer *, Tb_entry const *) const {}
   Group_order has_partner(Tb_entry const *) const
   { return Tb_entry::Group_order::first(); }
@@ -126,6 +127,7 @@
 class Tb_entry_ipc_res_fmt : public Tb_entry_formatter
 {
 public:
+  Tb_entry_ipc_res_fmt(){};
   void print(String_buffer *, Tb_entry const *) const {}
   Group_order has_partner(Tb_entry const *) const
   { return Tb_entry::Group_order::last(); }
diff -uNr a/src/l4/conf/examples/imx6q.io b/src/l4/conf/examples/imx6q.io
--- a/src/l4/conf/examples/imx6q.io 1970-01-01 09:00:00.000000000 +0900
+++ b/src/l4/conf/examples/imx6q.io 2014-05-15 22:06:12.586889228 +0900
@@ -0,0 +1,22 @@
+hw-root
+{
+  NIC => new Device()
+  {
+    .hid = "imx6q-fec.0";
+    new-res Mmio(0x02188000 .. 0x0218BFFF);
+    new-res Irq(150);
+    new-res Irq(151);
+  }
+
+  DMAMEM => new Device()
+  {
+    .hid = "dmamem";
+    new-res Mmio_ram(0x80000, 0);
+  }
+}
+
+l4linux => new System_bus()
+{
+  "imx6q-fec.dev" => wrap(hw-root.NIC);
+  "dmamem" => wrap(hw-root.DMAMEM);
+} 
diff -uNr a/src/l4/conf/examples/l4lx-imx6q.cfg b/src/l4/conf/examples/l4lx-imx6q.cfg
--- a/src/l4/conf/examples/l4lx-imx6q.cfg   1970-01-01 09:00:00.000000000 +0900
+++ b/src/l4/conf/examples/l4lx-imx6q.cfg   2014-05-15 22:06:02.202888898 +0900
@@ -0,0 +1,30 @@
+-- vim:set ft=lua:
+
+loader = L4.default_loader;
+vbus_l4linux = loader:new_channel();
+
+local lxname = "vmlinuz";
+if L4.Info.arch() == "arm" then
+  lxname = "vmlinuz.arm";
+end
+
+loader:start(
+{
+   caps = {
+       sigma0  = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0);
+       icu     = L4.Env.icu;
+        l4linux = vbus_l4linux:svr();
+   },
+   log      = { "IO", "y" },
+   l4re_dbg = L4.Dbg.Warn,
+},"rom/io -vvv rom/imx6q.io");
+
+L4.default_loader:start(
+  { caps = {
+      vbus = vbus_l4linux; 
+      log = L4.Env.log:m("rws"),
+    },
+    l4re_dbg = L4.Dbg.Warn,
+    log = { "l4linux", "yellow" },
+  },
+  "rom/" .. lxname .. " mem=64M console=ttyLv0 l4x_rd=rom/ramdisk-" ..  L4.Info.arch() .. ".rd root=1:0 ramdisk_size=4000 ip=dhcp init=/bin/sh");
diff -uNr a/src/l4/conf/modules.list b/src/l4/conf/modules.list
--- a/src/l4/conf/modules.list  2014-03-01 02:17:42.000000000 +0900
+++ b/src/l4/conf/modules.list  2014-05-15 21:53:32.966865095 +0900
@@ -88,6 +88,16 @@
 module vmlinuz.arm
 module ramdisk-arm.rd

+entry L4Linux-imx6q
+roottask moe rom/l4lx-imx6q.cfg
+module l4re
+module ned
+module l4lx-imx6q.cfg
+module io
+module imx6q.io
+module vmlinuz.arm
+module ramdisk-arm.rd
+
 entry L4Linux-mag-x86
 roottask moe rom/l4lx-gfx.cfg
 module l4re
diff -uNr a/src/l4/pkg/bootstrap/server/src/platform/imx.cc b/src/l4/pkg/bootstrap/server/src/platform/imx.cc
--- a/src/l4/pkg/bootstrap/server/src/platform/imx.cc   2014-03-01 02:17:42.000000000 +0900
+++ b/src/l4/pkg/bootstrap/server/src/platform/imx.cc   2014-05-15 21:12:02.030785960 +0900
@@ -37,8 +37,9 @@
     static L4::Io_register_block_mmio r(0x73fbc000);
     static L4::Uart_imx51 _uart;
 #elif defined(PLATFORM_TYPE_imx6)
-    //static L4::Io_register_block_mmio r(0x02020000); // UART1
-    static L4::Io_register_block_mmio r(0x021e8000); // UART2
+    //imx6q use UART1
+    static L4::Io_register_block_mmio r(0x02020000); // UART1
+    //static L4::Io_register_block_mmio r(0x021e8000); // UART2
     static L4::Uart_imx6 _uart;
 #else
 #error Which platform type?
diff -uNr a/src/l4linux/arch/l4/Kconfig b/src/l4linux/arch/l4/Kconfig
--- a/src/l4linux/arch/l4/Kconfig   2014-03-01 02:17:42.000000000 +0900
+++ b/src/l4linux/arch/l4/Kconfig   2014-05-16 15:31:04.448378077 +0900
@@ -63,16 +63,20 @@
    config L4_PLATFORM_GENERIC
        bool "Generic"
        select CLKDEV_LOOKUP
-       select L4_CLK_NOOP
+       select HAVE_CLK_PREPARE
+       select HAVE_MACH_CLKDEV
+       select COMMON_CLK

    config L4_PLATFORM_REALVIEW
        bool "Realview"
        select CLKDEV_LOOKUP
        select OUTER_CACHE
-       select L4_CLK_NOOP

 endchoice

+config L4_CLK_NOOP
+   bool "L4 Clock Noop"
+   depends on (L4_PLATFORM_GENERIC || L4_PLATFORM_REALVIEW)

 menu "Features"

diff -uNr a/src/l4linux/arch/l4/kernel/arch-arm/mach_setup.c b/src/l4linux/arch/l4/kernel/arch-arm/mach_setup.c
--- a/src/l4linux/arch/l4/kernel/arch-arm/mach_setup.c  2014-03-01 02:17:42.000000000 +0900
+++ b/src/l4linux/arch/l4/kernel/arch-arm/mach_setup.c  2014-05-16 12:20:05.428014031 +0900
@@ -5,6 +5,7 @@
 #include <linux/platform_device.h>
 #include <linux/ata_platform.h>
 #include <linux/smsc911x.h>
+#include <linux/fec.h>
 #include <linux/slab.h>
 #include <linux/list.h>

@@ -228,6 +229,74 @@
 }
 #endif

+static struct resource imx6q_fec_resources[] = {
+   {
+       .start = 0x02188000,
+       .end = 0x0218BFFF,
+       .name = "imx6q-fec mem",
+       .flags = IORESOURCE_MEM
+   },
+   {
+       .start = 150,
+       .end = 151,
+       .name = "imx6q-fec irq",
+       .flags = IORESOURCE_IRQ
+   }
+};
+
+static struct fec_platform_data imx6q_fec_pd = {
+   .phy = PHY_INTERFACE_MODE_RGMII
+};
+
+static struct platform_device imx6q_fec_dev = {
+   .name = "imx6q-fec",
+   .id = 0,
+   .resource = imx6q_fec_resources,
+   .num_resources = ARRAY_SIZE(imx6q_fec_resources),
+   .dev = {
+       .platform_data = &imx6q_fec_pd,
+   },
+};
+
+static int ar8031_phy_fixup(struct phy_device *dev)
+{
+   u16 val;
+
+   /* To enable AR8031 output a 125MHz clk from CLK_25M */
+   phy_write(dev, 0xd, 0x7);
+   phy_write(dev, 0xe, 0x8016);
+   phy_write(dev, 0xd, 0x4007);
+
+   val = phy_read(dev, 0xe);
+   val &= 0xffe3;
+   val |= 0x18;
+   phy_write(dev, 0xe, val);
+
+   /* introduce tx clock delay */
+   phy_write(dev, 0x1d, 0x5);
+   val = phy_read(dev, 0x1e);
+   val |= 0x0100;
+   phy_write(dev, 0x1e, val);
+
+   return 0;
+}
+
+#define PHY_ID_AR8031  0x004dd074
+
+static void __init imx6q_enet_phy_init(void)
+{
+   if (IS_BUILTIN(CONFIG_PHYLIB)) {
+       phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
+               ar8031_phy_fixup);
+   }
+}
+
+static L4X_DEVICE_CB(imx6q_device_cb_fec)
+{
+   platform_device_register(&imx6q_fec_dev);
+   imx6q_enet_phy_init();
+}
+
 static void register_platform_callbacks(void)
 {
 #ifdef CONFIG_L4_DMAPOOL
@@ -239,6 +308,7 @@
    l4x_register_platform_device_callback("smsc911x",     realview_device_cb_smsc);
    l4x_register_platform_device_callback("aaci",         aaci_cb);
 #endif
+   l4x_register_platform_device_callback("imx6q-fec.dev",imx6q_device_cb_fec);
 }

 static void
diff -uNr a/src/l4linux/drivers/net/ethernet/freescale/fec.h b/src/l4linux/drivers/net/ethernet/freescale/fec.h
--- a/src/l4linux/drivers/net/ethernet/freescale/fec.h  2014-03-01 02:17:42.000000000 +0900
+++ b/src/l4linux/drivers/net/ethernet/freescale/fec.h  2014-05-15 18:31:45.018480434 +0900
@@ -19,7 +19,7 @@

 #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
     defined(CONFIG_M520x) || defined(CONFIG_M532x) || \
-    defined(CONFIG_ARCH_MXC) || defined(CONFIG_SOC_IMX28)
+    defined(CONFIG_ARCH_MXC) || defined(CONFIG_SOC_IMX28) || CONFIG_L4
 /*
  * Just figures, Motorola would have to change the offsets for
  * registers in the same peripheral device on different models
@@ -147,7 +147,7 @@
 /*
  * Define the buffer descriptor structure.
  */
-#if defined(CONFIG_ARCH_MXC) || defined(CONFIG_SOC_IMX28)
+#if defined(CONFIG_ARCH_MXC) || defined(CONFIG_SOC_IMX28) || defined(CONFIG_L4)
 struct bufdesc {
    unsigned short cbd_datlen;  /* Data length */
    unsigned short cbd_sc;  /* Control and status info */
diff -uNr a/src/l4linux/drivers/net/ethernet/freescale/fec_main.c b/src/l4linux/drivers/net/ethernet/freescale/fec_main.c
--- a/src/l4linux/drivers/net/ethernet/freescale/fec_main.c 2014-03-01 02:17:42.000000000 +0900
+++ b/src/l4linux/drivers/net/ethernet/freescale/fec_main.c 2014-05-15 18:31:07.446479240 +0900
@@ -60,6 +60,11 @@

 #include "fec.h"

+#ifdef CONFIG_L4
+//ahb clock
+#define clk_get_rate(x)                132000000
+#endif
+
 static void set_multicast_list(struct net_device *ndev);

 #if defined(CONFIG_ARM)
@@ -2138,6 +2143,15 @@
        fep->phy_interface = ret;
    }

+   #ifdef CONFIG_L4
+       //Do no setup Clocks or regulator
+       fep->clk_ahb = NULL;
+       fep->clk_ipg = NULL;
+       fep->clk_enet_out = NULL;
+       fep->clk_ptp = NULL;
+       fep->reg_phy = NULL;
+   #else
+
    fep->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
    if (IS_ERR(fep->clk_ipg)) {
        ret = PTR_ERR(fep->clk_ipg);
@@ -2195,6 +2209,8 @@
        fep->reg_phy = NULL;
    }

+   #endif
+
    fec_reset_phy(pdev);

    if (fep->bufdesc_ex)
diff -uNr a/src/l4linux/drivers/net/ethernet/freescale/fec_ptp.c b/src/l4linux/drivers/net/ethernet/freescale/fec_ptp.c
--- a/src/l4linux/drivers/net/ethernet/freescale/fec_ptp.c  2014-03-01 02:17:42.000000000 +0900
+++ b/src/l4linux/drivers/net/ethernet/freescale/fec_ptp.c  2014-05-15 18:30:38.826478331 +0900
@@ -49,6 +49,9 @@

 #include "fec.h"

+//ahb clock
+#define clk_get_rate(x)                132000000
+
 /* FEC 1588 register bits */
 #define FEC_T_CTRL_SLAVE                0x00002000
 #define FEC_T_CTRL_CAPTURE              0x00000800
diff -uNr a/src/l4linux/drivers/net/ethernet/freescale/Kconfig b/src/l4linux/drivers/net/ethernet/freescale/Kconfig
--- a/src/l4linux/drivers/net/ethernet/freescale/Kconfig    2014-03-01 02:17:42.000000000 +0900
+++ b/src/l4linux/drivers/net/ethernet/freescale/Kconfig    2014-05-15 18:33:37.014483992 +0900
@@ -7,7 +7,7 @@
    default y
    depends on FSL_SOC || QUICC_ENGINE || CPM1 || CPM2 || PPC_MPC512x || \
           M523x || M527x || M5272 || M528x || M520x || M532x || \
-          ARCH_MXC || ARCH_MXS || (PPC_MPC52xx && PPC_BESTCOMM)
+          ARCH_MXC || ARCH_MXS || (PPC_MPC52xx && PPC_BESTCOMM) || L4 
    ---help---
      If you have a network (Ethernet) card belonging to this class, say Y
      and read the Ethernet-HOWTO, available from
@@ -23,7 +23,7 @@
 config FEC
    tristate "FEC ethernet controller (of ColdFire and some i.MX CPUs)"
    depends on (M523x || M527x || M5272 || M528x || M520x || M532x || \
-          ARCH_MXC || SOC_IMX28)
+          ARCH_MXC || SOC_IMX28) || L4 
    default ARCH_MXC || SOC_IMX28 if ARM
    select PHYLIB
    select PTP_1588_CLOCK