Difference between revisions of "AXY:Linux MIB"

From SoftMC-Wiki
Jump to: navigation, search
(Created page with "[[Image:]][[Image:]][[Image:]][[Image:]][[Image:]][[Image:]][[Image:]][[Image:]][[Image:]] {| style="border-spacing:0;" | style="border:none;padding-top:0cm;padding-bottom:0cm...")
 
 
(59 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Image:]][[Image:]][[Image:]][[Image:]][[Image:]][[Image:]][[Image:]][[Image:]][[Image:]]
 
{| style="border-spacing:0;"
 
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"|
 
  
|}
+
== Introduction ==
  
{| style="border-spacing:0;"
+
This documentation explains most parts of the Linux MIB. It is intended for the following users:
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| '''LINUX on a MIB'''
 
  
|-
+
*softMC developers who are compiling and link C/C++ code
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| <div align="right">Moving to Linux</div>
+
*QA teams
 +
*Managers engaged in MIB development
  
|-
+
= MIB Software Components =
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"|
 
  
|-
+
The software on a common Linux MIB has two main types.
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| <div align="right">This paper details the way a developer should use a Linux Running MIB </div>
 
  
|-
+
The first type is software controlled by Servotronix, who builds and maintains the source code. The second type is software over which Servotronix has no control, such as third-party binaries.
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"|
 
  
|-
+
The first type includes:
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| <div align="right">'''Raz Ben Yehuda'''</div>
 
  
|-
+
*The Linux operating system. This includes all services and utilities along with their shared objects (aka dll) which take part of maintaining the operating system.
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"| <div align="right">'''18/01/2012'''</div>
+
*The Linux Kernel. The core of the operating system.  
  
|-
+
&nbsp;
| style="border:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.191cm;padding-right:0.191cm;"|
 
  
|}
+
*<font color="red">mc. Manz’s motion control and its bash scripts extensions.</font>
<div align="right">[#__RefHeading__2364_650756303 Paper Audience3]</div>
+
*<font color="red">/FFS0 with its mc basic programs.</font>
 +
*<font color="red">core dumper. Daemon used to redirect core files.</font>
 +
*<font color="red">pkgd. Package manager.</font>
 +
*<font color="red">Various in house drivers,such as , sercos 2, ethercat and so on.</font>
 +
*<font color="red">In the future, any third party software that is added, such as PNP plugins and 3s.</font>  
  
<div align="right">[#__RefHeading__2366_650756303 MIB software components3]</div>
+
<font color="red">All of the above software is built from source code. Servotronix does not ship any other component without its source code. Binaries passed to MIB through the aico are not considered part of Linux MIB system.</font>
  
<div align="right">[#__RefHeading__2368_650756303 Accessing the MIB4]</div>
+
= Accessing the MIB =
  
<div align="right">[#__RefHeading__2370_650756303 Access LinuxMIB through rs2324]</div>
+
The MIB is fully accessable from any machine. Accessing the LinuxMIB can be done in two ways – secure shell and RS232 connection.
  
<div align="right">[#__RefHeading__2372_650756303 Obtaining LinuxMIB IP5]</div>
+
== Access LinuxMIB through RS232 ==
  
<div align="right">[#__RefHeading__2374_650756303 Access LinuxMIB through secure shell6]</div>
+
It is assumed that you are familiar with RS232 connections.
  
<div align="right">[#__RefHeading__2376_650756303 Changing the password7]</div>
+
In Windows you can access the MIB through hyperterminal or putty.
  
<div align="right">[#__RefHeading__2378_650756303 Storage8]</div>
+
putty.exe can be downloaded from [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html].
 +
<pre>'''RS232 Configuration'''
 +
Speed 115200
 +
StopBits: 1
 +
Data: 8
 +
Parity:Odd ( N)
 +
</pre>
  
<div align="right">[#__RefHeading__2380_650756303 Block Devices8]</div>
+
<font color="red">Once connected a login session will appear:</font>
  
<div align="right">[#__RefHeading__2382_650756303 File systems9]</div>
+
<font color="red">''manz login:''</font>
  
<div align="right">[#__RefHeading__2384_650756303 Basic commands 10]</div>
+
<font color="red">enter '''mc'''</font>
  
<div align="right">[#__RefHeading__2386_650756303 File and file system10]</div>
+
<font color="red">and then:</font>
  
<div align="right">[#__RefHeading__2388_650756303 ls10]</div>
+
<font color="red">''Password:''</font>
  
<div align="right">[#__RefHeading__2390_650756303 cat11]</div>
+
<font color="red">Enter '''mc'''</font>
  
<div align="right">[#__RefHeading__2392_650756303 echo12]</div>
+
&nbsp;
  
<div align="right">[#__RefHeading__2394_650756303 less12]</div>
+
== Obtaining LinuxMIB IP ==
  
<div align="right">[#__RefHeading__2396_650756303 tail/head12]</div>
+
If you have aico, use “Select Device” and look for Linux. This should be some LinuxMIB IP.
  
<div align="right">[#__RefHeading__2398_650756303 fsck – check file system consistency13]</div>
+
Alternately, you can access through RS232:
 +
<pre>~ # '''''ifconfig'''''
 +
eth0 Link encap:Ethernet HWaddr 00:50:C2:5D:0F:5E
 +
inet addr:'''10.4.20.83''' Bcast:10.4.20.255 Mask:255.255.255.0
 +
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 +
RX packets:92287 errors:0 dropped:0 overruns:0 frame:0
 +
TX packets:4462 errors:0 dropped:0 overruns:0 carrier:0
 +
collisions:0 txqueuelen:1000
 +
RX bytes:13389368 (12.7 MiB) TX bytes:431984 (421.8 KiB)
 +
lo Link encap:Local Loopback
 +
inet addr:127.0.0.1 Mask:255.0.0.0
 +
UP LOOPBACK RUNNING MTU:16436 Metric:1
 +
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
 +
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
 +
collisions:0 txqueuelen:0
 +
RX bytes:612 (612.0 B) TX bytes:612 (612.0 B)
 +
</pre>
  
<div align="right">[#__RefHeading__2400_650756303 grep13]</div>
+
== Access LinuxMIB through Secure Shell ==
  
<div align="right">[#__RefHeading__2402_650756303 awk13]</div>
+
To access the MIB from windows without direct connection use secure shell, or in short “ssh”.
  
<div align="right">[#__RefHeading__2404_650756303 find 14]</div>
+
If you login through putty, run it. A screen will appear.
  
<div align="right">[#__RefHeading__2406_650756303 watch14]</div>
+
[[File:puttyconf.gif|putty]]
  
<div align="right">[#__RefHeading__2408_650756303 gzip/gunzip15]</div>
+
Perform the following steps:
 +
<div align="left">1. Choose ssh button</div> <div align="left">2. ssh port is 22 by default</div> <div align="left">3. Fill LinuxMIB ip in both feilds,ie host name and saved sessions.</div> <div align="left">4. save it</div> <div align="left">5. open it</div>  
 +
A login screen will appear.
  
<div align="right">[#__RefHeading__2410_650756303 zcat16]</div>
+
[[File:login.gif|putty]]
  
<div align="right">[#__RefHeading__2412_650756303 System 16]</div>
+
== Changing the password ==
  
<div align="right">[#__RefHeading__2414_650756303 free16]</div>
+
It is common to change the login password (for developers only):
  
<div align="right">[#__RefHeading__2416_650756303 lshw17]</div>
+
~ # '''''passwd'''''
  
<div align="right">[#__RefHeading__2418_650756303 udevadm19]</div>
+
Changing password for root
  
<div align="right">[#__RefHeading__2420_650756303 Reboot20]</div>
+
'''''New password:'''''
  
<div align="right">[#__RefHeading__2422_650756303 Poweroff21]</div>
+
Enter q
  
<div align="right">[#__RefHeading__2424_650756303 hwclock21]</div>
+
A prompt will appear:
  
<div align="right">[#__RefHeading__2426_650756303 Process 22]</div>
+
Bad password: too short.
  
<div align="right">[#__RefHeading__2428_650756303 Ps22]</div>
+
It is ok. “q” is bad password. but you’re likely to login so many times so you better of using this short password.
  
<div align="right">[#__RefHeading__2430_650756303 Kill28]</div>
+
Then it will ask you to retype the password,
  
<div align="right">[#__RefHeading__2432_650756303 Top28]</div>
+
'''''Retype password:'''''
  
<div align="right">[#__RefHeading__2434_650756303 htop30]</div>
+
Enter q again. You do not have to enter “q”, but you will learn that people access anyone’s MIB, so they will expect a short packet to be “q”.
  
<div align="right">[#__RefHeading__2436_650756303 Display process’s maps30]</div>
+
= Storage =
  
<div align="right">[#__RefHeading__2438_650756303 chrt35]</div>
+
This section details the storage of the LinuxMIB. Storage refers to the disks and file systems.
  
<div align="right">[#__RefHeading__2440_650756303 Network36]</div>
+
== Block Devices ==
  
<div align="right">[#__RefHeading__2442_650756303 ssh sshd and scp 36]</div>
+
A block device is a device that is accessed with blocks of data. This includes, hard drives, DVD devices, usb flash cards and so on. In the MIB case the block device that holds the file system is called /dev/sda or /dev/hda. It is referred to as /dev/root ( for reasons out this document scope I will not explain why ). Too examin the disk use the fdisk command&nbsp;:
  
<div align="right">[#__RefHeading__2444_650756303 Route38]</div>
+
&nbsp;
  
<div align="right">[#__RefHeading__2446_650756303 tcpdump38]</div>
+
fdisk -l
  
<div align="right">[#__RefHeading__2448_650756303 ethtool39]</div>
+
Disk /dev/sda: 1014 MB, 1014644736 bytes
 +
255 heads, 63 sectors/track, 123 cylinders
 +
Units = cylinders of 16065 * 512 = 8225280 bytes
 +
    Device Boot      Start        End      Blocks  Id System
 +
      /dev/sda1  *          1          57      449850+ 83 Linux
 +
    Partition 1 does not end on cylinder boundary
 +
      /dev/sda2              57        116      475000  83 Linux
 +
    Partition 2 does not end on cylinder boundary
  
<div align="right">[#__RefHeading__2450_650756303 Boot40]</div>
+
&nbsp;
  
<div align="right">[#__RefHeading__2452_650756303 BSP42]</div>
+
/dev/sda1 is / . /dev/sda2 is the backup partition. The backup partion is used /dev/sda1 is totally corrupted.
  
<div align="right">[#__RefHeading__2454_650756303 Virtual Build Machine42]</div>
+
== File systems ==
  
<div align="right">[#__RefHeading__2456_650756303 Building MC46]</div>
+
LinuxMIB is composed from several independent file systems. To examine the file systems please enter:
  
<div align="right">[#__RefHeading__2458_650756303 Toolchain48]</div>
+
~ # ''''df -h''''
  
<div align="right">[#__RefHeading__2460_650756303 The BSP49]</div>
+
                          Filesystem Size    Used    Available  Use%  Mounted on
 +
<div align="left">''1)''</div>  
 +
                        /dev/root  485.5M  83.8M    377.3M    18%  / 
  
<div align="right">[#__RefHeading__2462_650756303 Replicate an image50]</div>
+
&nbsp;
 +
<div align="left">''2)''</div>  
 +
                          none      246.9M  4.0K    246.9M    0% /tmp 
 +
<div align="left">''3)''</div>
 +
                            none      246.9M  24.0K  246.8M    0%  /RAM
 +
                            none      246.9M  44.0K  246.8M    0% /var/log
 +
                            none      246.9M  24.0K  246.8M    0% /var/run
 +
<div align="left">''4)''</div>
 +
                            none      246.9M    0      246.9M  0%  /var/lock
 +
                            none      246.9M    0      246.9M  0%  /var/tmp
 +
                            tmpfs      246.9M    4.0K  246.9M    0%  /dev
  
<div align="right">[#__RefHeading__2464_650756303 How to edit files in MIB51]</div>
+
&nbsp;
  
<div align="right">[#__RefHeading__2466_650756303 Upgrade Linux MIB51]</div>
+
#The main file system is called root file system. The root file system is said to be mounted on the mounting point “/”. Any other file system in Linux is mounted on top of the root file system at some directory. Here the root file system is of size of 485MB, and 83MB of it are used.
  
<div align="right">[#__RefHeading__2468_650756303 Control MC Start 51]</div>
+
#/tmp directory is mounted as tmpfs file system. This is a ram file system. It does not survive boots.
 +
#This is the RAM file system used by mc. It is also of type tmpfs.
 +
#/var/log , /var/run, /var/lock, and /var/tmp are tmps file system as well used by different services.
 +
#/dev/ is a file system that holds all device files. it is regenerated with each boot.
 +
#There is a nother file system called /dev/pts , it is visible through the mount command, it hold terminals information.
  
<div align="right">[#__RefHeading__2470_650756303 52]</div>
+
= Basic commands =
  
<div align="right">[#__RefHeading__2472_650756303 Debugging53]</div>
+
== File and file system ==
  
<div align="right">[#__RefHeading__2474_650756303 Logs53]</div>
+
=== ls ===
  
<div align="right">[#__RefHeading__2476_650756303 Core files53]</div>
+
To examine the content the of current directory use ls:
  
<div align="right">[#__RefHeading__2478_650756303 Memory Detector53]</div>
+
~ # ''ls''
  
<div align="right">[#__RefHeading__2480_650756303 MC cli54]</div>
+
&nbsp;
 +
<nowiki>To examine the content of another directory use ls <dir>. For example:</nowiki>
  
<div align="right">[#__RefHeading__2482_650756303 Profiling56]</div>
+
~ # ''ls /sbin/''
  
<div align="right">[#__RefHeading__2484_650756303 ftrace57]</div>= Paper Audience =
+
adjtimex halt init modprobe setconsole udevadm
# Manz developer that compiles and links c/c++ code .
 
# QA team.
 
# Managers which take part in MIB development.
 
  
= MIB software components =
+
blkid hdparm insmod poweroff sfdisk udevd
The software on a common Linux MIB is divided to two types.
 
  
The first type is software Manz controls, meaning, manz build it and holds its source code. The second type os software manz has no control , like third party binaries.
+
dhclient hwclock klogd reboot start-stop-daemon udhcpc
  
# Linux operating system. This includes all services and utilities along with their shared objects (aka dll) which take part of maintaining the operating system.
+
fdisk ifconfig loadkmap rmmod sulogin umount.devkit
# The Linux Kernel. The core of the operating system.
 
# mc. Manz’s mc binary and its bash scripts extensions.
 
# /FFS0 with its PRG programs.
 
# core dumper. Daemon used to redirect core files.
 
# pkgd. Package manager maintainer.
 
# sercos driver.
 
# In the future, any third party software that is added. Like pnp plugins.  
 
  
All of the above software is built from source code. We do not ship any component without its source code. Binaries are passed to MIB through the aico are considered part of Linux build system.
+
fsck ifdown lsmod route syslog-ng watchdog
  
Further information of each component is detailed in the rest of this paper.
+
getty ifup modinfo runlevel threads
  
= Accessing the MIB =
+
~ #
The MIB is fully access-able from any machine. Accessing the LinuxMIB can be done in two ways, secure shell and rs232 connection.
 
  
== Access LinuxMIB through rs232 ==
+
The “ls” commands have additional flags, such as&nbsp;: “ls –al” which provides more information about the files.
I assume the user is familiar with rs232 connection.  
 
  
In windows User can access the MIB through hyperterminal or putty. putty.exe can be downloaded from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
+
=== cat ===
  
Rs232 configuration:
+
To examine the content of a text file use the cat. For example:
  
Speed 115200
+
~ # ''cat /etc/busybox.conf''
  
StopBits: 1
+
you can also create new files with cat by redirecting cat’s output to a new file. For example:
  
Data: 8
+
~ # ''cat /etc/busybox.conf > /tmp/busybox.conf''
  
Parity:Odd ( N)
+
you can concatenate two files in to a single file by using the >> sign.
  
Once connected a login session would appear
+
For example the command
  
manz login:
+
~ # ''cat /etc/inet.conf >> /tmp/busybox.conf''
  
enter '''root'''
+
will concatenate to /tmp/busybox.conf the content of /etc/inet.conf.
  
and then:
+
=== echo ===
  
Password:
+
echo is a command that send a string to a file, where a file can be the terminal itself or simply a regular text file or any other file which receives data.
  
Enter '''1-login11'''.
+
~ # echo hello
  
 +
Hello
  
== Obtaining LinuxMIB IP ==
+
&nbsp;
If you have aico around, use “Select Device” and look for Linux. This should be some LinuxMIB ip. The other way is to access through rs<div align="right">IP here</div>232 as act as bellow:
 
  
~ # ifconfig
+
=== less ===
  
eth0 Link encap:Ethernet HWaddr 00:50:C2:5D:0F:5E
+
less is a textual viewer. It is used to examine text file content in read-only mode. Usage:
  
inet addr:10.4.20.83 Bcast:10.4.20.255 Mask:255.255.255.0
+
&nbsp;
 +
<nowiki>~# less <file name></nowiki>
  
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
+
=== tail/head ===
  
RX packets:92287 errors:0 dropped:0 overruns:0 frame:0
+
The tail comands prints last line of a file. The head command prints the first few lines of a file. tail is very useful a user wishes to examine how file is being updated , mostly logs.
  
TX packets:4462 errors:0 dropped:0 overruns:0 carrier:0
+
For example:
  
collisions:0 txqueuelen:1000
+
~ # tail –f /var/syslog
  
RX bytes:13389368 (12.7 MiB) TX bytes:431984 (421.8 KiB)
+
=== fsck – check file system consistency ===
  
 +
LinuxMIB uses ext3 as its file system, ext3 is a journaling file system which means file system corruption is much less to occur, there are still times where corruptions do happen ( not by abrupt power off but by exploding the file system or deliberately corrupting ).
  
lo Link encap:Local Loopback
+
LinuxMIB executes fsck.ext3 each time it is booted, if you wish to check file system integrity first create the device name:
  
inet addr:127.0.0.1 Mask:255.0.0.0
+
''mknod /dev/hda1 b 3 1''
  
UP LOOPBACK RUNNING MTU:16436 Metric:1
+
This is because /dev/hda1 does not exist on the MIB and neither /dev/root.
  
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
+
Now issue the fsck command as bellow. I use –n flag to do that in read only mode.
  
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
+
''fsck.ext3 –n /dev/hda1''
  
collisions:0 txqueuelen:0
+
=== grep ===
  
RX bytes:612 (612.0 B) TX bytes:612 (612.0 B)
+
grep prints lines matching a pattern. Example:
  
 +
/etc # ''grep mc /usr/bin/mc.sh''
  
~ #
+
/usr/bin/mc
  
== Access LinuxMIB through secure shell ==
+
The above command prints each line containing the word “mc”.
To access the MIB from windows without direct connection use secure shell, or in short “ssh”.  
 
  
If you login through putty please run it. You should see a window as bellow.
+
or check number of mc core files in the /cores/ directory.
  
 +
''nf=$(ls /cores/mc* | wc -l)''
  
[[Image:]]
+
''echo $nf''
  
Act according the steps above. Once you open ( yae..yae… I know you can double click instead of open) you get to a login screen:<div align="right">5. open it</div><div align="right">4. save it</div><div align="right">3. Fill LinuxMIB ip in both feilds</div># <div align="right">Choose ssh button</div>
+
4
  
<div align="right">2. ssh port is 22 by default</div>
+
=== awk ===
  
[[Image:]]
+
awk is a parsing language. The awk command scans an input file searching for some text pattern and when finding this pattern awk act according to the action specified.
  
== Changing the password ==
+
For example:
It is common to change the login password ( for developers only):
 
  
~ # passwd
+
~# awk '$2 == 0 { printf $1 " " $2 " " $3 "\n"}' /proc/interrupts
  
Changing password for root
+
NMI: 0 Non-maskable
  
New password:
+
LOC: 0 Local
  
Enter q
+
SPU: 0 Spurious
  
You will have a prompt saying
+
PMI: 0 Performance
  
Bad password: too short.
+
IWI: 0 IRQ
  
It is correct. “q” is bad password. but you’re likely to login so many times.
+
TRM: 0 Thermal
  
Then it will ask you ro retype the password,
+
THR: 0 Threshold
  
Retype password:
+
MCE: 0 Machine
  
Enter q again. You do not have to enter “q”, but you will learn that people access anyone’s MIB, so they will expect a short packet to be “q”.<sup><nowiki>[1]</nowiki></sup>
+
ERR: 0
  
 +
MIS: 0
  
1. ''One to keep in mind here. A LinuxMIB is a Linux. It means your IT department will suddenly have some new machines flying around asking for dhcp IP, performing ARP queries and so on. ''
+
This command prints columns 1, 2 and 3 in the /proc/interrupts if the second column equal 0.
  
= Storage =
+
=== find ===
This section details the storage of the LinuxMIB. In storage we mean, the disks and file systems.
 
  
== Block Devices ==
+
find searches for files in directory recursively. For example, if a user wants to find all files named mc in the LinuxMIB:
A block device is a device where access to this device is done with blocks. This includes, hard drives, DVD devices, usb flash cards and so on. In the MIB case the block device that holds the file system is called /dev/hda or hdb. It is referred to as /dev/root ( for reasons out this document scope I will not explain why ). To see that please :
 
  
~ # dmesg | grep hd
+
~ # find / -name mc
  
 +
/etc/init.d/mc
  
Output<sup><nowiki>[1]</nowiki></sup> should like the bellow:
+
/usr/bin/mc
  
<nowiki>[ </nowiki>0.000000] Kernel command line: root=/dev/hda1,/dev/hdc1 console=ttyS0,115200
+
&nbsp;
  
<nowiki>[ </nowiki>1.238729] hdc: TRANSCEND, CFA DISK drive
+
=== watch ===
  
<nowiki>[ </nowiki>1.850651] hdc: host max PIO4 wanted PIO255(auto-tune) selected PIO4
+
The watch command executes a command periodically. For example:
  
<nowiki>[ </nowiki>1.850666] hdc: UDMA/66 mode selected
+
watch –n1 ‘cat /proc/vmstat`
  
<nowiki>[ </nowiki>1.851138] hdc: max request size: 128KiB
+
print to screen the file /proc/vmstat .
  
<nowiki>[ </nowiki>1.851143] hdc: 1989792 sectors (1018 MB) w/1KiB Cache, CHS=1974/16/63
+
=== gzip/gunzip ===
  
<nowiki>[ </nowiki>1.856857] hdc: hdc1
+
The gzip command compresses a file. The gunzip command decompress a file.
  
<nowiki>[ </nowiki>2.134028] register_blkdev: cannot get major 3 for hd
+
Example:
  
<nowiki>[ </nowiki>2.847206] try device /dev/hda1 ROOT_DEV=0
+
gzip /etc/busybox.conf
  
<nowiki>[ </nowiki>2.847833] EXT3-fs (hdc1): recovery required on readonly filesystem
+
busybox.conf is compressed and renamed to busybox.conf.gz
  
<nowiki>[ </nowiki>2.847836] EXT3-fs (hdc1): write access will be enabled during recovery
+
to decompress&nbsp;:
  
<nowiki>[ </nowiki>4.836389] EXT3-fs (hdc1): recovery complete
+
gunzip /etc/busybox.cong.gz
  
<nowiki>[ </nowiki>4.838603] EXT3-fs (hdc1): mounted filesystem with ordered data mode
+
a new file /etc/busybox.conf is created.
  
 +
&nbsp;
  
So we have TRANSCEND Compact flash drive, size of 1018MB , its name is hdc and it has a single partition called /dev/hdc1.
+
=== zcat ===
  
 +
zcat is used to print a content of a compressed text file without decompressing it.
  
<nowiki>[1]</nowiki> ''There are many ways to examine storage devices. I will describe some on regular Linux machine. The LinuxMIB lack the tools for that.''
+
Example:
  
 +
zcat /etc/busybox.conf.gz
  
The device file /dev/root is considered the boot device because it keeps the first file system that is explored by the kernel when it performs a boot. Please note that it that /dev/root is not the entire disk but the partition holding file system.
+
This will dump to screen busybox.conf.a
  
== File systems ==
+
== System ==
LinuxMIB is composed from several independent file systems. To examine the file systems please enter:
 
  
~ # df -h
+
=== free ===
  
Like the in bellow example:
+
free returns the amount of RAM in the machine, the amount of used memory in the machine and the amount of used memory in the machine.
  
~ # df -h
+
~ # free
  
Filesystem Size Used Available Use% Mounted on<div align="right">1</div>
+
total used free shared buffers
  
/dev/root 485.5M 83.8M 377.3M 18% /<div align="right">2</div>
+
Mem: 505560 47912 457648 0 1356
  
none 246.9M 4.0K 246.9M 0% /tmp<div align="right">3</div>
+
Swap: 0 0 0
  
none 246.9M 24.0K 246.8M 0% /RAM
+
Total: 505560 47912 457648
  
none 246.9M 44.0K 246.8M 0% /var/log
+
=== lshw ===
  
none 246.9M 24.0K 246.8M 0% /var/run<div align="right">4</div>
+
Lists the hardware configuration of the machine.
  
none 246.9M 0 246.9M 0% /var/lock
+
~ # lshw
  
none 246.9M 0 246.9M 0% /var/tmp
+
manz
  
tmpfs 246.9M 4.0K 246.9M 0% /dev
+
description: Computer
  
~ #
+
product: N/A
  
 +
vendor: N/A
  
# The main file system is called root file system. The root file system is said to be mounted on the mounting point “/”. Any other file system in Linux is mounted on top of the root file system at some directory.
+
version: N/A
  
Here the root file system is of size of 485MB, and 83MB of it are used.
+
serial: N/A
  
# /tmp directory is mounted as tmpfs file system. This is a ram file system. It does not survive boots.
+
width: 32 bits
# This is the RAM file system used by mc. It is also of type tmpfs.
 
# /var/log , /var/run, /var/lock, and /var/tmp are tmps file system as well used by different services.
 
# /dev/ is a file system that holds all device files. it is regenerated with each boot.
 
# There is a nother file system called /dev/pts , it is visible through the mount command, it hold terminals information.
 
  
= Basic commands  =
+
capabilities: smbios-2.5 dmi-2.5
== File and file system ==
 
=== ls ===
 
To examine the content the of current directory use ls:
 
  
~ # ls
+
configuration: administrator_password=disabled boot=oem-specific frontpanel_
  
<nowiki>To examine the content of another directory use ls <dir>. For example:</nowiki>
+
password=unknown keyboard_password=unknown power-on_password=disabled
  
~ # ls /sbin/
+
&nbsp;
 +
<nowiki>*-core</nowiki>
  
adjtimex halt init modprobe setconsole udevadm
+
description: Motherboard
  
blkid hdparm insmod poweroff sfdisk udevd
+
product: MODB
  
dhclient hwclock klogd reboot start-stop-daemon udhcpc
+
vendor: Kontron Embedded Modules
  
fdisk ifconfig loadkmap rmmod sulogin umount.devkit
+
physical id: 0
  
fsck ifdown lsmod route syslog-ng watchdog
+
version: 05.00
  
getty ifup modinfo runlevel threads
+
serial: YXEBK0229
  
~ #
+
&nbsp;
 +
<nowiki>*-firmware</nowiki>
  
 +
description: BIOS
  
The “ls” commands have additional flags, such as : “ls –al” which provides more information about the files.
+
vendor: Phoenix Technologies LTD
  
=== cat ===
+
physical id: 0
To examine the content of a text file use the cat. For example:
 
  
~ # cat /etc/busybox.conf
+
version: MODBR131 (06/27/0808)
  
<nowiki>[SUID]</nowiki>
+
size: 104KiB
  
<nowiki>#lines starting with # are comments</nowiki>
+
capacity: 960KiB
  
<nowiki>#<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)</nowiki>
+
capabilities: isa pci pcmcia pnp apm upgrade shadowing escd cdboot acp
  
 +
i usb agp biosbootspecification
  
<nowiki>#reboot = ssx root.0 # applet reboot can be run by anyone and runs with euid=0/egid=0</nowiki>
+
&nbsp;
 +
<nowiki>*-cpu</nowiki>
  
 +
description: CPU
  
you can also create new files with cat by redirecting cat’s output to a new file. For example:
+
product: Intel(R) Celeron(R) M processor 1.50GHz
  
~ # cat /etc/busybox.conf > /tmp/busybox.conf
+
vendor: Intel Corp.
  
you can concatenate two files to single file by using the >> sign.
+
physical id: 4
  
For example the command
+
bus info: cpu@0
  
~ # cat /etc/inet.conf >> /tmp/busybox.conf
+
version: 6.13.8
  
will concatenate to /tmp/busybox.conf the content of /etc/inet.conf.
+
slot: U2E1
  
 +
size: 1500MHz
  
=== echo ===
+
capacity: 2048MHz
echo is a command that send a string to a file, where a file can be the terminal itself or simply a regular text file or any other file which receives data.
 
  
~ # echo hello
+
width: 32 bits
  
Hello
+
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 sep
  
 +
mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx bts
  
=== less ===
+
&nbsp;
less is a textual viewer. It is used to examine text file content in read-only mode. Usage:  
+
<nowiki>*-cache:0</nowiki>
  
<nowiki>~# less <file name></nowiki>
+
description: L1 cache
  
=== tail/head ===
+
physical id: 5
The tail comands prints last line of a file. The head command prints the first few lines of a file. tail is very useful a user wishes to examine how file is being updated , mostly logs.
 
  
For example:
+
slot: L1 Cache
  
~ # tail –f /var/syslog
+
size: 64KiB
  
=== fsck – check file system consistency ===
+
capacity: 64KiB
LinuxMIB uses ext3 as its file system, ext3 is a journaling file system which means file system corruption is much less to occur, there are still times where corruptions do happen ( not by abrupt power off but by exploding the file system or deliberately corrupting ).
 
  
LinuxMIB executes fsck.ext3 each time it is booted, if you wish to check file system integrity first create the device name:
+
&nbsp;
  
mknod /dev/hda1 b 3 1
+
=== udevadm ===
  
This is because /dev/hda1 does not exist on the MIB and neither /dev/root.  
+
udev is part of a linux device model. Udevadm is a tool used to query, monitor and control devices. For example, the hardisk “hda”,has a pci address, it belongs to the block device subsystem, and so on. To get this sort of information in one unified view, we do:
  
Now issue the fsck command as bellow. I use –n flag to do that in read only mode.
+
~ # udevadm info -a -p /sys/block/hda
  
fsck.ext3 –n /dev/hda1
+
Udevadm info starts with the device specified by the devpath and then
  
=== grep ===
+
walks up the chain of parent devices. It prints for every device
grep prints lines matching a pattern. Example:
 
  
/etc # grep mc /usr/bin/mc.sh
+
found, all possible attributes in the udev rules key format.
  
/usr/bin/mc
+
A rule to match, can be composed by the attributes of the device
  
<nowiki># check number of mc core files in /cores/ dir</nowiki>
+
and the attributes from one single parent device.
  
nf=$(ls -l mc_* | wc -l)
+
looking at device '/block/hda':
  
for i in `ls -t mc_*`; do
+
KERNEL=="hda"
  
The above command prints each line containing the word “mc”.
+
SUBSYSTEM=="block"
  
=== awk ===
+
DRIVER==""
awk is a parsing language. The awk command scans an input file searching for some text pattern and when finding this pattern awk act according to the action specified.
 
  
For example:
+
ATTR{range}=="64"
  
~# awk '$2 == 0 { printf $1 " " $2 " " $3 "\n"}' /proc/interrupts
+
ATTR{ext_range}=="256"
  
NMI: 0 Non-maskable
+
ATTR{removable}=="0"
  
LOC: 0 Local
+
ATTR{ro}=="0"
  
SPU: 0 Spurious
+
ATTR{size}=="1981728"
  
PMI: 0 Performance
+
ATTR{alignment_offset}=="0"
  
IWI: 0 IRQ
+
ATTR{discard_alignment}=="0"
  
TRM: 0 Thermal
+
ATTR{capability}=="50"
  
THR: 0 Threshold
+
ATTR{stat}==" 342 173 15716 1119 47 25 1
  
MCE: 0 Machine
+
1768 0 2179 2886"
  
ERR: 0
+
ATTR{inflight}==" 0 0"
  
MIS: 0
+
ATTR{events}==""
  
This command prints columns 1, 2 and 3 in the /proc/interrupts if the second column equal 0.
+
ATTR{events_async}==""
  
=== find  ===
+
ATTR{events_poll_msecs}=="-1"
find searches for files in directory recursively. For example, if a user wants to find all files named mc in the LinuxMIB:
 
  
~ # find / -name mc
+
As one can observe, a disk called had is part of the block subsystem, there is no driver for it as I did not compile external modules, additional information appears such as its size and some statistics.
  
/etc/init.d/mc
+
&nbsp;
  
/usr/bin/mc
+
=== Reboot ===
  
 +
To reboot the MIB use the “reboot” command.
  
=== watch ===
+
=== Poweroff ===
The watch command executes a command periodically. For example:
 
  
watch –n1 ‘cat /proc/vmstat`
+
To turn off the MIB, use the “poweroff” command.
  
print to screen the file /proc/vmstat .
+
=== hwclock ===
  
=== gzip/gunzip ===
+
To get or set the time to/from RTC hardware clock , use the “hwclock” command. In cases where RTC is broken, “hwlock” will hang or display bad time.
The gzip command compresses a file. The gunzip command decompress a file.
 
  
Example:
+
&nbsp;
  
gzip /etc/busybox.conf
+
== Process ==
  
busybox.conf is compressed and renamed to busybox.conf.gz
+
In this section I show some commands related to processes management.
  
to decompress :
+
=== Ps ===
  
gunzip /etc/busybox.cong.gz
+
Use the “ps” command to list system processes. For example, the “ps aux” outputs:
  
a new file /etc/busybox.conf is created.
+
~ # ps aux
  
 +
USER PID&nbsp;%CPU&nbsp;%MEM VSZ RSS TTY STAT START TIME COMMAND
  
=== zcat ===
+
root 1 0.0 0.1 2076 516&nbsp;? Ss 08:03 0:01 init
zcat is used to print a content of a compressed text file without decompressing it.
 
  
Example:
+
root 2 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kthreadd]</nowiki>
  
zcat /etc/busybox.conf.gz
+
root 3 0.1 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:02 [ksoftirqd/0]</nowiki>
  
This will dump to screen busybox.conf.a
+
root 5 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kworker/u:0]</nowiki>
  
== System  ==
+
root 6 0.0 0.0 0 0&nbsp;? S 08:03
=== free ===
+
<nowiki>0:00 [posixcputmr/0]</nowiki>
free returns the amount of RAM in the machine, the amount of used memory in the machine and the amount of used memory in the machine.
 
  
~ # free
+
root 7 0.0 0.0 0 0&nbsp;?
 +
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [khelper]</nowiki>
  
total used free shared buffers
+
root 8 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kworker/u:1]</nowiki>
  
Mem: 505560 47912 457648 0 1356
+
root 125 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [sync_supers]</nowiki>
  
Swap: 0 0 0
+
root 127 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [bdi-default]</nowiki>
  
Total: 505560 47912 457648
+
root 128 0.0 0.0 0 0&nbsp;?
 +
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [kblockd]</nowiki>
  
 +
root 135 0.0 0.0 0 0&nbsp;?
 +
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [ata_sff]</nowiki>
  
=== lshw ===
+
root 142 0.0 0.0 0 0&nbsp;? S 08:03
Lists the hardware configuration of the machine.
+
<nowiki>0:00 [khubd]</nowiki>
  
~ # lshw
+
root 248 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kworker/0:1]</nowiki>
  
manz
+
root 268 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kswapd0]</nowiki>
  
description: Computer
+
root 269 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [fsnotify_mark]</nowiki>
  
product: N/A
+
root 271 0.0 0.0 0 0&nbsp;?
 +
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [crypto]</nowiki>
  
vendor: N/A
+
root 869 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/15-ide0]</nowiki>
  
version: N/A
+
root 906 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/1-i8042]</nowiki>
  
serial: N/A
+
root 913 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/8-rtc0]</nowiki>
  
width: 32 bits
+
root 921 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [kworker/0:2]</nowiki>
  
capabilities: smbios-2.5 dmi-2.5
+
root 922 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/4-serial]</nowiki>
  
configuration: administrator_password=disabled boot=oem-specific frontpanel_
+
root 923 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [kjournald]</nowiki>
  
password=unknown keyboard_password=unknown power-on_password=disabled
+
root 945 0.0 0.1 1896 648&nbsp;?
 +
<nowiki>S<s </nowiki>
 +
08:04 0:00 /sbin/udevd --d root 999 0.0 0.1 1892 608&nbsp;? <nowiki>S< </nowiki>
 +
08:04 0:00 /sbin/udevd --d root 1002 0.0 0.1 1892 604&nbsp;? <nowiki>S< </nowiki>
 +
08:04 0:00 /sbin/udevd --d root 1017 0.0 0.1 2992 716&nbsp;? Ss 08:04 0:00 /sbin/syslog-ng
 +
root 1025 0.0 0.1 3932 996&nbsp;? Ss 08:04 0:00 /usr/sbin/sshd
  
<nowiki>*-core</nowiki>
+
root 1045 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/9-eth0]</nowiki>
  
description: Motherboard
+
root 1056 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/11-srcsII]</nowiki>
  
product: MODB
+
root 1075 99.7 0.0 1528 196&nbsp;? Rs 08:04 31:12 /usr/bin/pkgd /
  
vendor: Kontron Embedded Modules
+
root 1079 0.0 0.1 2080 544 ttyS0 Ss+ 08:04 0:00 /sbin/getty -L
  
physical id: 0
+
root 1093 0.0 0.3 6536 2004&nbsp;? Ss 08:04 0:00 sshd: root@pts/
  
version: 05.00
+
root 1097 0.0 0.1 2080 632 pts/0 Ss+ 08:04 0:00 -sh
  
serial: YXEBK0229
+
root 1107 0.0 0.3 6536 1988&nbsp;? Ss 08:05 0:00 sshd: root@pts/
  
<nowiki>*-firmware</nowiki>
+
root 1111 0.0 0.1 2080 664 pts/1 Ss 08:05 0:00 -sh
  
description: BIOS
+
root 1146 0.0 0.0 0 0&nbsp;? S 08:25
 +
<nowiki>0:00 [flush-3:0]</nowiki>
  
vendor: Phoenix Technologies LTD
+
root 1177 0.2 0.3 6536 1988&nbsp;? Ss 08:35 0:00 sshd: root@pts/
  
physical id: 0
+
root 1181 0.0 0.1 2080 608 pts/2 Ss 08:35 0:00 -sh
  
version: MODBR131 (06/27/0808)
+
root 1182 3.2 5.1 42140 26172 pts/2 Sl+ 08:35 0:00 mc
  
size: 104KiB
+
root 1209 0.0 0.1 2228 824 pts/1 R+ 08:35 0:00 ps aux
  
capacity: 960KiB
+
all processes in the entire operating system along with their memory consumption, state, pid, cpu usage and so on. As one can see the next to last process is mc itself, so where are his threads. For this I created an abbreviation called threads:
  
capabilities: isa pci pcmcia pnp apm upgrade shadowing escd cdboot acp
+
~ # threads
  
i usb agp biosbootspecification
+
Warning: bad ps syntax, perhaps a bogus '-'? See [http://procps.sf.net/faq.html http://procps.sf.net/faq.html]
  
<nowiki>*-cpu</nowiki>
+
PID TID CLS RTPRIO NI PRI PSR&nbsp;%CPU STAT WCHAN COMMAND
  
description: CPU
+
1 1 TS - 0 19 0 0.0 Ss wait init
  
product: Intel(R) Celeron(R) M processor 1.50GHz
+
2 2 TS - 0 19 0 0.0 S kthreadd kthreadd
  
vendor: Intel Corp.
+
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
  
physical id: 4
+
5 5 TS - 0 19 0 0.0 S worker_thread kworker/u:0
  
bus info: cpu@0
+
6 6 RR 16 - 56 0 0.0 S posix_cpu_time posixcputmr/0
  
version: 6.13.8
+
7 7 TS - -20 39 0
 +
<nowiki>0.0 S< </nowiki>
 +
rescuer_thread khelper 8 8 TS - 0 19 0 0.0 S worker_thread kworker/u:1
 +
125 125 TS - 0 19 0 0.0 S bdi_sync_super sync_supers
  
slot: U2E1
+
127 127 TS - 0 19 0 0.0 S bdi_forker_thr bdi-default
  
size: 1500MHz
+
128 128 TS - -20 39 0
 +
<nowiki>0.0 S< </nowiki>
 +
rescuer_thread kblockd 135 135 TS - -20 39 0 <nowiki>0.0 S< </nowiki>
 +
rescuer_thread ata_sff 142 142 TS - 0 19 0 0.0 S hub_thread khubd
 +
248 248 TS - 0 19 0 0.0 S worker_thread kworker/0:1
  
capacity: 2048MHz
+
268 268 TS - 0 19 0 0.0 S kswapd_try_to_ kswapd0
  
width: 32 bits
+
269 269 TS - 0 19 0 0.0 S fsnotify_mark_ fsnotify_mark
  
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 sep
+
271 271 TS - -20 39 0
 +
<nowiki>0.0 S< </nowiki>
 +
rescuer_thread crypto 869 869 FF 50 - 90 0 0.0 S irq_thread irq/15-ide0
 +
906 906 RR 16 - 56 0 0.0 S irq_thread irq/1-i8042
  
mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx bts
+
913 913 RR 16 - 56 0 0.0 S irq_thread irq/8-rtc0
  
<nowiki>*-cache:0</nowiki>
+
921 921 TS - 0 19 0 0.0 S worker_thread kworker/0:2
  
description: L1 cache
+
922 922 RR 16 - 56 0 0.0 S irq_thread irq/4-serial
  
physical id: 5
+
923 923 TS - 0 19 0 0.0 S kjournald kjournald
  
slot: L1 Cache
+
945 945 TS - -4 23 0
 +
<nowiki>0.0 S<s </nowiki>
 +
poll_schedule_ udevd 999 999 TS - -2 21 0 <nowiki>0.0 S< </nowiki>
 +
poll_schedule_ udevd 1002 1002 TS - -2 21 0 <nowiki>0.0 S< </nowiki>
 +
poll_schedule_ udevd 1017 1017 TS - 0 19 0 0.0 Ss poll_schedule_ syslog-ng
 +
1025 1025 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
  
size: 64KiB
+
1045 1045 RR 16 - 56 0 0.0 S irq_thread irq/9-eth0
  
capacity: 64KiB
+
1056 1056 RR 99 - 139 0 0.0 S irq_thread irq/11-srcsII
  
 +
1075 1075 TS - 0 19 0 99.5 Rs - pkgd
  
=== udevadm ===
+
1079 1079 TS - 0 19 0 0.0 Ss+ n_tty_read getty
udev is part of a linux device model. Udevadm is a tool used to query, monitor and control devices. For example, the hardisk “hda”,has a pci address, it belongs to the block device subsystem, and so on. To get this sort of information in one unified view, we do:
 
  
~ # udevadm info -a -p /sys/block/hda
+
1093 1093 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
  
 +
1097 1097 TS - 0 19 0 0.0 Ss+ poll_schedule_ sh
  
Udevadm info starts with the device specified by the devpath and then
+
1146 1146 TS - 0 19 0 0.0 S bdi_writeback_ flush-3:0
  
walks up the chain of parent devices. It prints for every device
+
1177 1177 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
  
found, all possible attributes in the udev rules key format.
+
1181 1181 TS - 0 19 0 0.0 Ss wait sh
  
A rule to match, can be composed by the attributes of the device
+
1182 1182 TS - 0 19 0 0.0 Sl+ futex_wait_que mc
  
and the attributes from one single parent device.
+
1182 1184 RR 1 - 41 0 0.0 Sl+ wq_sleep jexec
  
 +
1182 1186 RR 25 - 65 0 0.0 Sl+ semtimedop tErrHndl
  
looking at device '/block/hda':
+
1182 1187 RR 16 - 56 0 0.0 Sl+ semtimedop tLogger
  
KERNEL=="hda"
+
1182 1188 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ cli
  
SUBSYSTEM=="block"
+
1182 1189 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp
  
DRIVER==""
+
1182 1190 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut
  
ATTR{range}=="64"
+
1182 1191 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp2
  
ATTR{ext_range}=="256"
+
1182 1192 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut2
  
ATTR{removable}=="0"
+
1182 1193 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp0
  
ATTR{ro}=="0"
+
1182 1194 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut0
  
ATTR{size}=="1981728"
+
1182 1195 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp3
  
ATTR{alignment_offset}=="0"
+
1182 1196 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut3
  
ATTR{discard_alignment}=="0"
+
1182 1197 RR 16 - 56 0 0.0 Sl+ wait_for_packe RbootPd
  
ATTR{capability}=="50"
+
1182 1198 RR 16 - 56 0 0.0 Sl+ poll_schedule_ tVirtualInp
  
ATTR{stat}==" 342 173 15716 1119 47 25 1
+
1182 1199 RR 26 - 66 0 0.0 Sl+ hrtimer_nanosl tBit
  
1768 0 2179 2886"
+
1182 1200 RR 27 - 67 0 0.4 Sl+ semtimedop tSpy
  
ATTR{inflight}==" 0 0"
+
1182 1201 RR 21 - 61 0 0.1 Sl+ semtimedop tScHandler
  
ATTR{events}==""
+
1182 1202 RR 20 - 60 0 0.0 Sl+ semtimedop tScServer
  
ATTR{events_async}==""
+
1182 1203 RR 21 - 61 0 0.3 SNl+ sercosII_read sercosFun
  
ATTR{events_poll_msecs}=="-1"
+
1182 1204 RR 23 - 63 0 0.0 SNl+ semtimedop MotManager
  
 +
1182 1207 RR 28 - 68 0 0.1 SNl+ semtimedop tRecPeriodic
  
As one can observe, a disk called had is part of the block subsystem, there is no driver for it as I did not compile external modules, additional information appears such as its size and some statistics.
+
1182 1208 RR 29 - 69 0 0.0 SNl+ semtimedop tEvent
  
 +
1210 1210 TS - 0 19 0 0.6 Ss poll_schedule_ sshd
  
=== Reboot ===
+
1214 1214 TS - 0 19 0 0.0 Ss wait sh
To reboot the MIB use the “reboot” command.  
 
  
=== Poweroff ===
+
1215 1215 TS - 0 19 0 0.0 S+ wait sh
To turn off the MIB, use the “poweroff” command.
 
  
=== hwclock ===
+
1216 1216 TS - 0 19 0 0.0 R+ - ps
To get or set the time to/from RTC hardware clock , use the “hwclock” command. In cases where RTC is broken, “hwlock” will hang or display bad time.
 
  
 +
The "threads" is actually a shortcut for the following ps command:
  
== Process  ==
+
''ps -axH -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm''
In this section I show some commands related to processes management.
 
  
=== Ps ===
+
The above command presents the following information for each task in the operating system:
Use the “ps” command to list system processes. For example, the “ps aux” outputs:
 
  
~ # ps aux
+
'''pid''' = process id of the parent not-detached task
  
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
+
'''tid''' = process id of the task within parent task – what we refer as thread.
  
root 1 0.0 0.1 2076 516 ? Ss 08:03 0:01 init
+
'''class''' = scheduling class. TS = OTHER, RR = round robin, FF = fifo. - = not reported
  
root 2 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kthreadd]</nowiki>
+
'''rtprio''' = real time priority, ranging from 99 to 0. When 99 is strongest.
  
root 3 0.1 0.0 0 0 ? S 08:03 <nowiki>0:02 [ksoftirqd/0]</nowiki>
+
'''ni''' = niceness. Ranging from -19 to 20.
  
root 5 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/u:0]</nowiki>
+
'''pri''' = static priority.
  
root 6 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [posixcputmr/0]</nowiki>
+
'''psr''' = processor id.
  
root 7 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [khelper]</nowiki>
+
'''pcpu''' = overall cpu usage
  
root 8 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/u:1]</nowiki>
+
'''stat''' = process state. R for runnable or S for sleeping, Z for zombie.
  
root 125 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [sync_supers]</nowiki>
+
'''wchan''' = kernel function where process is waiting. If process is running a dash is displayed
  
root 127 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [bdi-default]</nowiki>
+
'''comm''' = name of process
  
root 128 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [kblockd]</nowiki>
+
If you wish to sort the list by the processes real time priority, use the following command:
  
root 135 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [ata_sff]</nowiki>
+
threads | sort –k4
  
root 142 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [khubd]</nowiki>
+
This command sorts the list according by the fourth column.
  
root 248 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/0:1]</nowiki>
+
=== Kill ===
  
root 268 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kswapd0]</nowiki>
+
To terminate a running process use the kill command. Kill needs the process id , so many times you can simply type:
  
root 269 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [fsnotify_mark]</nowiki>
+
kill -9 $(pidof mc)
  
root 271 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [crypto]</nowiki>
+
Which means, kill anyway, the mc by its process id.
  
root 869 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/15-ide0]</nowiki>
+
=== Top ===
  
root 906 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/1-i8042]</nowiki>
+
top is an interactive view of displaying system tasks. It refreshes the list every 1 or more second.
  
root 913 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/8-rtc0]</nowiki>
+
~ # top
  
root 921 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [kworker/0:2]</nowiki>
+
top - 09:21:51 up 1:17, 4 users, load average: 1.04, 1.03, 1.01
  
root 922 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/4-serial]</nowiki>
+
Tasks: 42 total, 2 running, 40 sleeping, 0 stopped, 0 zombie
  
root 923 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [kjournald]</nowiki>
+
Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
  
root 945 0.0 0.1 1896 648 ? <nowiki>S<s </nowiki>08:04 0:00 /sbin/udevd --d
+
Mem: 505536k total, 49120k used, 456416k free, 860k buffers
  
root 999 0.0 0.1 1892 608 ? <nowiki>S< </nowiki>08:04 0:00 /sbin/udevd --d
+
Swap: 0k total, 0k used, 0k free, 12288k cached
  
root 1002 0.0 0.1 1892 604 ? <nowiki>S< </nowiki>08:04 0:00 /sbin/udevd --d
+
PID USER PR NI VIRT RES SHR S&nbsp;%CPU&nbsp;%MEM TIME+ COMMAND
  
root 1017 0.0 0.1 2992 716 ? Ss 08:04 0:00 /sbin/syslog-ng
+
1075 root 20 0 1528 196 148 R 98.9 0.0 77:03.44 pkgd
  
root 1025 0.0 0.1 3932 996 ? Ss 08:04 0:00 /usr/sbin/sshd
+
1056 root RT 0 0 0 0 S 2.0 0.0 0:05.73 irq/11-srcsII
  
root 1045 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/9-eth0]</nowiki>
+
1 root 20 0 2076 520 460 S 0.0 0.1 0:01.17 init
  
root 1056 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/11-srcsII]</nowiki>
+
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
  
root 1075 99.7 0.0 1528 196 ? Rs 08:04 31:12 /usr/bin/pkgd /
+
3 root RT 0 0 0 0 S 0.0 0.0 0:07.44 ksoftirqd/0
  
root 1079 0.0 0.1 2080 544 ttyS0 Ss+ 08:04 0:00 /sbin/getty -L
+
5 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/u:0
  
root 1093 0.0 0.3 6536 2004 ? Ss 08:04 0:00 sshd: root@pts/
+
6 root -17 0 0 0 0 S 0.0 0.0 0:00.00 posixcputmr/0
  
root 1097 0.0 0.1 2080 632 pts/0 Ss+ 08:04 0:00 -sh
+
7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
  
root 1107 0.0 0.3 6536 1988 ? Ss 08:05 0:00 sshd: root@pts/
+
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:1
  
root 1111 0.0 0.1 2080 664 pts/1 Ss 08:05 0:00 -sh
+
125 root 20 0 0 0 0 S 0.0 0.0 0:00.00 sync_supers
  
root 1146 0.0 0.0 0 0 ? S 08:25 <nowiki>0:00 [flush-3:0]</nowiki>
+
127 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default
  
root 1177 0.2 0.3 6536 1988 ? Ss 08:35 0:00 sshd: root@pts/
+
128 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
  
root 1181 0.0 0.1 2080 608 pts/2 Ss 08:35 0:00 -sh
+
135 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff
  
root 1182 3.2 5.1 42140 26172 pts/2 Sl+ 08:35 0:00 mc
+
142 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd
  
root 1209 0.0 0.1 2228 824 pts/1 R+ 08:35 0:00 ps aux
+
248 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kworker/0:1
  
 +
268 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0
  
all processes in the entire operating system along with their memory consumption, state, pid, cpu usage and so on. As one can see the next to last process is mc itself, so where are his threads. For this I created an abbreviation called threads:  
+
269 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark
  
~ # threads
+
271 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
  
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
+
Top displays a nice summary before the list. Memory usage, cpu usage and so on. Important information is found in this line
  
PID TID CLS RTPRIO NI PRI PSR %CPU STAT WCHAN COMMAND
+
Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
  
1 1 TS - 0 19 0 0.0 Ss wait init
+
For example:
  
2 2 TS - 0 19 0 0.0 S kthreadd kthreadd
+
'''us''' is the Cpu usage in user space here is 29.6%
  
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
+
'''sy''' is the cpu usage in kernel space is 70%
  
5 5 TS - 0 19 0 0.0 S worker_thread kworker/u:0
+
'''ni''' is the niceness of last process
  
6 6 RR 16 - 56 0 0.0 S posix_cpu_time posixcputmr/0
+
'''wa''' is io wait which is the amount of time system is waiting for IO to complete.
  
7 7 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread khelper
+
'''hi''' is hardware interrupt usage
  
8 8 TS - 0 19 0 0.0 S worker_thread kworker/u:1
+
'''si''' is soft irqs usage
  
125 125 TS - 0 19 0 0.0 S bdi_sync_super sync_supers
+
'''st''' is virtualization usage ( always zero in mib)
  
127 127 TS - 0 19 0 0.0 S bdi_forker_thr bdi-default
+
=== htop ===
  
128 128 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread kblockd
+
htop is like top but more interactive. You can asks for different sorting keys, like sort by memory usage, sort by cpu usage and so on.
  
135 135 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread ata_sff
+
[[Image:]]
  
142 142 TS - 0 19 0 0.0 S hub_thread khubd
+
Type F6 and toy with it.
  
248 248 TS - 0 19 0 0.0 S worker_thread kworker/0:1
+
=== Display process’s maps ===
  
268 268 TS - 0 19 0 0.0 S kswapd_try_to_ kswapd0
+
To watch a process’ segmented allocation use the following commands:
  
269 269 TS - 0 19 0 0.0 S fsnotify_mark_ fsnotify_mark
+
~ # cat /proc/$(pidof mc)/maps
  
271 271 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread crypto
+
08048000-08429000 r-xp 00000000 03:01 13462 /usr/bin/mc
  
869 869 FF 50 - 90 0 0.0 S irq_thread irq/15-ide0
+
08429000-08558000 rwxp 003e1000 03:01 13462 /usr/bin/mc
  
906 906 RR 16 - 56 0 0.0 S irq_thread irq/1-i8042
+
08558000-085ed000 rwxp 00000000 00:00 0
  
913 913 RR 16 - 56 0 0.0 S irq_thread irq/8-rtc0
+
09afd000-0b060000 rwxp 00000000 00:00 0
 +
<nowiki>[heap]</nowiki>
  
921 921 TS - 0 19 0 0.0 S worker_thread kworker/0:2
+
b5a1c000-b5a1d000 ---p 00000000 00:00 0
  
922 922 RR 16 - 56 0 0.0 S irq_thread irq/4-serial
+
b5a1d000-b5a24000 rwxp 00000000 00:00 0
  
923 923 TS - 0 19 0 0.0 S kjournald kjournald
+
b5a24000-b5a25000 ---p 00000000 00:00 0
  
945 945 TS - -4 23 0 <nowiki>0.0 S<s </nowiki>poll_schedule_ udevd
+
b5a25000-b5a30000 rwxp 00000000 00:00 0
  
999 999 TS - -2 21 0 <nowiki>0.0 S< </nowiki>poll_schedule_ udevd
+
b5a30000-b5a31000 ---p 00000000 00:00 0
  
1002 1002 TS - -2 21 0 <nowiki>0.0 S< </nowiki>poll_schedule_ udevd
+
b5a31000-b5a3c000 rwxp 00000000 00:00 0
  
1017 1017 TS - 0 19 0 0.0 Ss poll_schedule_ syslog-ng
+
b5a3c000-b5a3d000 ---p 00000000 00:00 0
  
1025 1025 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
+
b5a3d000-b5a48000 rwxp 00000000 00:00 0
  
1045 1045 RR 16 - 56 0 0.0 S irq_thread irq/9-eth0
+
b5a48000-b5a49000 ---p 00000000 00:00 0
  
1056 1056 RR 99 - 139 0 0.0 S irq_thread irq/11-srcsII
+
b5a49000-b5a58000 rwxp 00000000 00:00 0
  
1075 1075 TS - 0 19 0 99.5 Rs - pkgd
+
b5a58000-b5a59000 ---p 00000000 00:00 0
  
1079 1079 TS - 0 19 0 0.0 Ss+ n_tty_read getty
+
b5a59000-b5a5c000 rwxp 00000000 00:00 0
  
1093 1093 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
+
b5a5c000-b5a5d000 ---p 00000000 00:00 0
  
1097 1097 TS - 0 19 0 0.0 Ss+ poll_schedule_ sh
+
b5a5d000-b5a64000 rwxp 00000000 00:00 0
  
1146 1146 TS - 0 19 0 0.0 S bdi_writeback_ flush-3:0
+
b5a64000-b5a65000 ---p 00000000 00:00 0
  
1177 1177 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
+
b5a65000-b5a6c000 rwxp 00000000 00:00 0
  
1181 1181 TS - 0 19 0 0.0 Ss wait sh
+
b5a6c000-b5a6d000 ---p 00000000 00:00 0
  
1182 1182 TS - 0 19 0 0.0 Sl+ futex_wait_que mc
+
b5a6d000-b5a74000 rwxp 00000000 00:00 0
  
1182 1184 RR 1 - 41 0 0.0 Sl+ wq_sleep jexec
+
b5a74000-b5a75000 ---p 00000000 00:00 0
  
1182 1186 RR 25 - 65 0 0.0 Sl+ semtimedop tErrHndl
+
b5a75000-b5a80000 rwxp 00000000 00:00 0
  
1182 1187 RR 16 - 56 0 0.0 Sl+ semtimedop tLogger
+
b5a81000-b5a82000 ---p 00000000 00:00 0
  
1182 1188 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ cli
+
b5a82000-b5aa5000 rwxp 00000000 00:00 0
  
1182 1189 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp
+
b5aa5000-b5aa6000 ---p 00000000 00:00 0
  
1182 1190 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut
+
b5aa6000-b5ac1000 rwxp 00000000 00:00 0
  
1182 1191 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp2
+
b5ac1000-b5ac2000 ---p 00000000 00:00 0
  
1182 1192 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut2
+
b5ac2000-b5ac9000 rwxp 00000000 00:00 0
  
1182 1193 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp0
+
b5ac9000-b5aca000 ---p 00000000 00:00 0
  
1182 1194 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut0
+
b5aca000-b5aed000 rwxp 00000000 00:00 0
  
1182 1195 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp3
+
b5aed000-b5aee000 ---p 00000000 00:00 0
  
1182 1196 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut3
+
b5aee000-b5af5000 rwxp 00000000 00:00 0
  
1182 1197 RR 16 - 56 0 0.0 Sl+ wait_for_packe RbootPd
+
b5af5000-b5af6000 ---p 00000000 00:00 0
  
1182 1198 RR 16 - 56 0 0.0 Sl+ poll_schedule_ tVirtualInp
+
b5af6000-b5b19000 rwxp 00000000 00:00 0
  
1182 1199 RR 26 - 66 0 0.0 Sl+ hrtimer_nanosl tBit
+
b5b19000-b5b1a000 ---p 00000000 00:00 0
  
1182 1200 RR 27 - 67 0 0.4 Sl+ semtimedop tSpy
+
b5b1a000-b5b21000 rwxp 00000000 00:00 0
  
1182 1201 RR 21 - 61 0 0.1 Sl+ semtimedop tScHandler
+
b5b21000-b5b22000 ---p 00000000 00:00 0
  
1182 1202 RR 20 - 60 0 0.0 Sl+ semtimedop tScServer
+
b5b22000-b5b45000 rwxp 00000000 00:00 0
  
1182 1203 RR 21 - 61 0 0.3 SNl+ sercosII_read sercosFun
+
b5b45000-b5b46000 ---p 00000000 00:00 0
  
1182 1204 RR 23 - 63 0 0.0 SNl+ semtimedop MotManager
+
b5b46000-b5b4d000 rwxp 00000000 00:00 0
  
1182 1207 RR 28 - 68 0 0.1 SNl+ semtimedop tRecPeriodic
+
b5b4d000-b5b4e000 ---p 00000000 00:00 0
  
1182 1208 RR 29 - 69 0 0.0 SNl+ semtimedop tEvent
+
b5b4e000-b5c18000 rwxp 00000000 00:00 0
  
1210 1210 TS - 0 19 0 0.6 Ss poll_schedule_ sshd
+
b5c18000-b5c19000 ---p 00000000 00:00 0
  
1214 1214 TS - 0 19 0 0.0 Ss wait sh
+
b5c19000-b6418000 rwxp 00000000 00:00 0
  
1215 1215 TS - 0 19 0 0.0 S+ wait sh
+
b6418000-b6419000 ---p 00000000 00:00 0
  
1216 1216 TS - 0 19 0 0.0 R+ - ps
+
b6419000-b6420000 rwxp 00000000 00:00 0
  
 +
b6420000-b6421000 ---p 00000000 00:00 0
  
Thread is a shortcut for the following ps command:
+
b6421000-b6429000 rwxp 00000000 00:00 0
  
ps -axH -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
+
b6429000-b642a000 ---p 00000000 00:00 0
  
 +
b642a000-b642d000 rwxp 00000000 00:00 0
  
The above command presents the following information for each task in the operating system:
+
b642d000-b742d000 rwxs fffe9000000 00:12 2311 /dev/sercosII
  
'''pid''' = process id of the parent not-detached task
+
b742d000-b742e000 ---p 00000000 00:00 0
  
'''tid''' = process id of the task within parent task – what we refer as thread.
+
b742e000-b7435000 rwxp 00000000 00:00 0
  
'''class''' = scheduling class. TS = OTHER, RR = round robin, FF = fifo. - = not reported
+
b7435000-b7436000 ---p 00000000 00:00 0
  
'''rtprio''' = real time priority, ranging from 99 to 0. When 99 is strongest.
+
b7436000-b7544000 rwxp 00000000 00:00 0
  
'''ni''' = niceness. Ranging from -19 to 20.  
+
b7544000-b7679000 r-xp 00000000 03:01 10172 /lib/libc-2.13.so
  
'''pri''' = static priority.  
+
b7679000-b767a000 ---p 00135000 03:01 10172 /lib/libc-2.13.so
  
'''psr''' = processor id.
+
b767a000-b767c000 r-xp 00135000 03:01 10172 /lib/libc-2.13.so
  
'''pcpu''' = overall cpu usage
+
b767c000-b767d000 rwxp 00137000 03:01 10172 /lib/libc-2.13.so
  
'''stat''' = process state. R for runnable or S for sleeping, Z for zombie.
+
b767d000-b7680000 rwxp 00000000 00:00 0
  
'''wchan''' = kernel function where process is waiting. If process is running a dash is displayed
+
b7680000-b769b000 r-xp 00000000 03:01 12467 /lib/libgcc_s.so.1
  
'''comm''' = name of process
+
b769b000-b769c000 rwxp 0001a000 03:01 12467 /lib/libgcc_s.so.1
  
 +
b769c000-b76c1000 r-xp 00000000 03:01 14763 /lib/libm-2.13.so
  
If you wish to sort the list by the processes real time priority, use the following command:
+
b76c1000-b76c2000 r-xp 00024000 03:01 14763 /lib/libm-2.13.so
  
threads | sort –k4
+
b76c2000-b76c3000 rwxp 00025000 03:01 14763 /lib/libm-2.13.so
  
 +
b76c3000-b779b000 r-xp 00000000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
  
This command sorts the list according by the fourth column.
+
b779b000-b779f000 r-xp 000d7000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
  
=== Kill ===
+
b779f000-b77a0000 rwxp 000db000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
To terminate a running process use the kill command. Kill needs the process id , so many times you can simply type:
 
  
kill -9 $(pidof mc)
+
b77a0000-b77a8000 rwxp 00000000 00:00 0
  
Which means, kill anyway, the mc by its process id.
+
b77a8000-b77b0000 r-xp 00000000 03:01 16731 /lib/libcrypt-2.13.so
  
=== Top ===
+
b77b0000-b77b1000 r-xp 00007000 03:01 16731 /lib/libcrypt-2.13.so
top is an interactive view of displaying system tasks. It refreshes the list every 1 or more second.  
 
  
~ # top
+
b77b1000-b77b2000 rwxp 00008000 03:01 16731 /lib/libcrypt-2.13.so
  
~ # top
+
b77b2000-b77d9000 rwxp 00000000 00:00 0
  
top - 09:21:51 up 1:17, 4 users, load average: 1.04, 1.03, 1.01
+
b77d9000-b77ed000 r-xp 00000000 03:01 17714 /lib/libpthread-2.13.so
  
Tasks: 42 total, 2 running, 40 sleeping, 0 stopped, 0 zombie
+
b77ed000-b77ee000 r-xp 00013000 03:01 17714 /lib/libpthread-2.13.so
  
Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
+
b77ee000-b77ef000 rwxp 00014000 03:01 17714 /lib/libpthread-2.13.so
  
Mem: 505536k total, 49120k used, 456416k free, 860k buffers
+
b77ef000-b77f1000 rwxp 00000000 00:00 0
  
Swap: 0k total, 0k used, 0k free, 12288k cached
+
b77f1000-b77f7000 r-xp 00000000 03:01 13450 /lib/librt-2.13.so
  
 +
b77f7000-b77f8000 r-xp 00005000 03:01 13450 /lib/librt-2.13.so
  
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
+
b77f8000-b77f9000 rwxp 00006000 03:01 13450 /lib/librt-2.13.so
  
1075 root 20 0 1528 196 148 R 98.9 0.0 77:03.44 pkgd
+
b77f9000-b77fb000 r-xp 00000000 03:01 17388 /lib/libdl-2.13.so
  
1056 root RT 0 0 0 0 S 2.0 0.0 0:05.73 irq/11-srcsII
+
b77fb000-b77fc000 r-xp 00001000 03:01 17388 /lib/libdl-2.13.so
  
1 root 20 0 2076 520 460 S 0.0 0.1 0:01.17 init
+
b77fc000-b77fd000 rwxp 00002000 03:01 17388 /lib/libdl-2.13.so
  
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
+
b77fd000-b7817000 r-xp 00000000 03:01 16404 /lib/ld-2.13.so
  
3 root RT 0 0 0 0 S 0.0 0.0 0:07.44 ksoftirqd/0
+
b7817000-b7818000 rwxp 00000000 00:00 0
  
5 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/u:0
+
b7818000-b7819000 r-xp 0001a000 03:01 16404 /lib/ld-2.13.so
  
6 root -17 0 0 0 0 S 0.0 0.0 0:00.00 posixcputmr/0
+
b7819000-b781a000 rwxp 0001b000 03:01 16404 /lib/ld-2.13.so
  
7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
+
bfd20000-bfd41000 rwxp 00000000 00:00 0
 +
<nowiki>[stack]</nowiki>
  
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:1
+
ffffe000-fffff000 r-xp 00000000 00:00 0
 +
<nowiki>[vdso]</nowiki>
  
125 root 20 0 0 0 0 S 0.0 0.0 0:00.00 sync_supers
+
From left to tight:
  
127 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default
+
#The segment ( also known as vma ) memory addresses
 +
#The segment permission
 +
#The segment offset into the file
 +
#The block device major/minor holding the file
 +
#The size of the segment
  
128 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
+
=== chrt ===
  
135 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff
+
change real time priority. You can control a processes scheduling class and priority level from the command line.
  
142 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd
+
For example:
  
248 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kworker/0:1
+
Ksoftirq is a kernel daemon that is widely used in the kernel.
  
268 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0
+
~ # threads |grep sof
  
269 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark
+
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
  
271 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
+
ksoftirq pid is 3. Its real time priority is 99. So , let say we wish to change its priority to 19.
  
Top displays a nice summary before the list. Memory usage, cpu usage and so on. Important information is found in this line
+
~ # chrt -r -p 19 3
  
 +
pid 3's current scheduling policy: SCHED_RR
  
Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
+
pid 3's current scheduling priority: 99
  
 +
pid 3's new scheduling policy: SCHED_RR
  
For example:
+
pid 3's new scheduling priority: 19
  
'''us''' is the Cpu usage in user space here is 29.6%
+
and indeed priority changed.
  
'''sy''' is the cpu usage in kernel space is 70%
+
~ # threads | grep sof
  
'''ni''' is the niceness of last process
+
3 3 RR 19 - 59 0 0.1 S run_ksoftirqd ksoftirqd/0
  
'''wa''' is io wait which is the amount of time system is waiting for IO to complete.
+
&nbsp;
  
'''hi''' is hardware interrupt usage
+
== Network ==
  
'''si''' is soft irqs usage
+
=== ssh sshd and scp ===
  
'''st''' is virtualization usage ( always zero in mib)
+
Secure shell is used to access remote machines. Sshd is service running in the target MIB and ssh is the client. You can login (perform ssh) to a MIB and login from a MIB to any other Linux machine. You can copy files with scp to and from Linux machines.
  
 +
To login to MIB ip 10.4.20.240 from any Linux machine enter:
  
=== htop ===
+
~ # ssh root@10.4.20.240
htop is like top but more interactive. You can asks for different sorting keys, like sort by memory usage, sort by cpu usage and so on.
 
  
[[Image:]]
+
The authenticity of host '10.4.20.240 (10.4.20.240)' can't be established.
  
Type F6 and toy with it.
+
RSA key fingerprint is ef:f6:72:7f:64:7a:21:d4:8b:c3:b2:db:cf:a0:0f:99.
  
=== Display process’s maps ===
+
Are you sure you want to continue connecting (yes/no)? yes
To watch a process’ segmented allocation use the following commands:
 
  
~ # cat /proc/$(pidof mc)/maps
+
Warning: Permanently added '10.4.20.240' (RSA) to the list of known hosts.
  
08048000-08429000 r-xp 00000000 03:01 13462 /usr/bin/mc
+
root@10.4.20.240's password:
  
08429000-08558000 rwxp 003e1000 03:01 13462 /usr/bin/mc
+
the first you will asked is enter yes/no. this happens only in the first time you access a remote machine. Enter “yes” and then you will be asked to enter a password, please do. Once entered, you will be in the MIB running in root privileges.
  
08558000-085ed000 rwxp 00000000 00:00 0
+
To copy files from Linux machine to another Linux machine in the command line we use scp command: for example, the command:
  
09afd000-0b060000 rwxp 00000000 00:00 0 <nowiki>[heap]</nowiki>
+
scp –r /tmp root@10.4.20.240:/root/
  
b5a1c000-b5a1d000 ---p 00000000 00:00 0
+
will copy tmp directory to to root directory in target machine. The “-r” means recursive copy, which is how we copy directories.
  
b5a1d000-b5a24000 rwxp 00000000 00:00 0
+
If you copy files from a windows machine to a linux machine you should use winscp.
  
b5a24000-b5a25000 ---p 00000000 00:00 0
+
[[File:winscp1.png|winscp]]
  
b5a25000-b5a30000 rwxp 00000000 00:00 0
+
The first window displays a list machines that were accessed previously. If this is the first time you use winscp this list is empty. To copy files to 10.4.20.240 please click on the New button.
  
b5a30000-b5a31000 ---p 00000000 00:00 0
+
[[File:winscp2.png|winscp]]
  
b5a31000-b5a3c000 rwxp 00000000 00:00 0
+
Fill the MIB’s ip. The user name “root”, the password, and change the protocol from sftp to scp. Click on “Save” to save the new machine in the list and then click on Login.
  
b5a3c000-b5a3d000 ---p 00000000 00:00 0
+
[[File:winscp3.png|winscp]]
  
b5a3d000-b5a48000 rwxp 00000000 00:00 0
+
You will windows saying that the command “group” returned error, disregard it, it is because MIB does not have group command, after that you will have the above screen. Now you can simply drag and drop files.
  
b5a48000-b5a49000 ---p 00000000 00:00 0
+
=== Route ===
  
b5a49000-b5a58000 rwxp 00000000 00:00 0
+
To watch the routing tables just type “route” or “netstat –r”. Here is route output in MIB
  
b5a58000-b5a59000 ---p 00000000 00:00 0
+
Ip 10.4.20.240.
  
b5a59000-b5a5c000 rwxp 00000000 00:00 0
+
Kernel IP routing table
  
b5a5c000-b5a5d000 ---p 00000000 00:00 0
+
Destination Gateway Genmask Flags Metric Ref Use Iface
  
b5a5d000-b5a64000 rwxp 00000000 00:00 0
+
10.0.0.0
 +
<nowiki>* </nowiki>
 +
255.0.0.0 U 0 0 0 eth0 As the reader can see, there is not default route, so if we try to access a different network segment will be getting “unreachable network” . We can only access network on the 10.x.x.x. because the netmask is 255.0.0.0.
 +
The only Ethernet interface a MIB has is eth0.
  
b5a64000-b5a65000 ---p 00000000 00:00 0
+
&nbsp;
  
b5a65000-b5a6c000 rwxp 00000000 00:00 0
+
=== tcpdump ===
  
b5a6c000-b5a6d000 ---p 00000000 00:00 0
+
tcpdump is a packet capture program. To capture packets simply type:
  
b5a6d000-b5a74000 rwxp 00000000 00:00 0
+
tcpdump
  
b5a74000-b5a75000 ---p 00000000 00:00 0
+
this will fill screen with traffic captures. If you use ssh to access the machine you will see ssh traffic as well. So you probably want to filter out this ssh traffic. To do that enter:
  
b5a75000-b5a80000 rwxp 00000000 00:00 0
+
tcpdump ip –i eth0 and not port 22
  
b5a81000-b5a82000 ---p 00000000 00:00 0
+
Which means, capture all traffic on interface eth0, but drop any traffic on directed to port 22.
  
b5a82000-b5aa5000 rwxp 00000000 00:00 0
+
There are many other ways to capture traffic. Sometimes you need to capture the traffic and want to analize it later with better tools, like wireshark. For this please enter:
  
b5aa5000-b5aa6000 ---p 00000000 00:00 0
+
tcpdump ip –i eth0 and not port 22 –w foo.cap
  
b5aa6000-b5ac1000 rwxp 00000000 00:00 0
+
This means that the captured data will be passed to a file called foo.cap.
  
b5ac1000-b5ac2000 ---p 00000000 00:00 0
+
&nbsp;
  
b5ac2000-b5ac9000 rwxp 00000000 00:00 0
+
=== ethtool ===
  
b5ac9000-b5aca000 ---p 00000000 00:00 0
+
ethtool is used to query and control network interfaces.
  
b5aca000-b5aed000 rwxp 00000000 00:00 0
+
~ # ethtool eth0
  
b5aed000-b5aee000 ---p 00000000 00:00 0
+
Settings for eth0:
  
b5aee000-b5af5000 rwxp 00000000 00:00 0
+
&nbsp;
 +
<nowiki>Supported ports: [ TP MII ]</nowiki>
  
b5af5000-b5af6000 ---p 00000000 00:00 0
+
Supported link modes: 10baseT/Half 10baseT/Full
  
b5af6000-b5b19000 rwxp 00000000 00:00 0
+
100baseT/Half 100baseT/Full
  
b5b19000-b5b1a000 ---p 00000000 00:00 0
+
Supports auto-negotiation: Yes
  
b5b1a000-b5b21000 rwxp 00000000 00:00 0
+
Advertised link modes: 10baseT/Half 10baseT/Full
  
b5b21000-b5b22000 ---p 00000000 00:00 0
+
100baseT/Half 100baseT/Full
  
b5b22000-b5b45000 rwxp 00000000 00:00 0
+
Advertised pause frame use: Symmetric
  
b5b45000-b5b46000 ---p 00000000 00:00 0
+
Advertised auto-negotiation: Yes
  
b5b46000-b5b4d000 rwxp 00000000 00:00 0
+
Link partner advertised link modes: 10baseT/Half 10baseT/Full
  
b5b4d000-b5b4e000 ---p 00000000 00:00 0
+
100baseT/Half 100baseT/Full
  
b5b4e000-b5c18000 rwxp 00000000 00:00 0
+
Link partner advertised pause frame use: Symmetric
  
b5c18000-b5c19000 ---p 00000000 00:00 0
+
Link partner advertised auto-negotiation: Yes
  
b5c19000-b6418000 rwxp 00000000 00:00 0
+
Speed: 100Mb/s
  
b6418000-b6419000 ---p 00000000 00:00 0
+
Duplex: Full
  
b6419000-b6420000 rwxp 00000000 00:00 0
+
Port: MII
  
b6420000-b6421000 ---p 00000000 00:00 0
+
PHYAD: 1
  
b6421000-b6429000 rwxp 00000000 00:00 0
+
Transceiver: internal
  
b6429000-b642a000 ---p 00000000 00:00 0
+
Auto-negotiation: on
  
b642a000-b642d000 rwxp 00000000 00:00 0
+
Supports Wake-on: g
  
b642d000-b742d000 rwxs fffe9000000 00:12 2311 /dev/sercosII
+
Wake-on: g
  
b742d000-b742e000 ---p 00000000 00:00 0
+
Current message level: 0x00000007 (7)
  
b742e000-b7435000 rwxp 00000000 00:00 0
+
Link detected: yes
  
b7435000-b7436000 ---p 00000000 00:00 0
+
Common use for it is checking the link type, 10/100/1000 Mbps and if the network is actually up (Last line: Link Detected).
  
b7436000-b7544000 rwxp 00000000 00:00 0
+
= Boot =
  
b7544000-b7679000 r-xp 00000000 03:01 10172 /lib/libc-2.13.so
+
Linux MIB boot is a two-phase boot. Once the computer passed the POST stage (Power On Self Test) it passes the control to the operating system. The first operating system is actually a boot loader. The boot loader is called grub – “grand unified boot loader”. Grub has one main purpose, to boot Linux. At the moment, the MIB hardware prevents us from seeing the grub loads. When grub loads it splashes a menu to screen (it is called splashing). This menu is kept in /boot/grub/menu.lst which is accessible through the LinuxMIB.
  
b7679000-b767a000 ---p 00135000 03:01 10172 /lib/libc-2.13.so
+
~ # cat /boot/grub/menu.lst
  
b767a000-b767c000 r-xp 00135000 03:01 10172 /lib/libc-2.13.so
+
serial --unit=0 --speed=115200
  
b767c000-b767d000 rwxp 00137000 03:01 10172 /lib/libc-2.13.so
+
terminal --timeout=0 serial console
  
b767d000-b7680000 rwxp 00000000 00:00 0
+
default 0
  
b7680000-b769b000 r-xp 00000000 03:01 12467 /lib/libgcc_s.so.1
+
timeout 0
  
b769b000-b769c000 rwxp 0001a000 03:01 12467 /lib/libgcc_s.so.1
+
color cyan/blue white/blue
  
b769c000-b76c1000 r-xp 00000000 03:01 14763 /lib/libm-2.13.so
+
title Standalone Boot
  
b76c1000-b76c2000 r-xp 00024000 03:01 14763 /lib/libm-2.13.so
+
root (hd0,0)
  
b76c2000-b76c3000 rwxp 00025000 03:01 14763 /lib/libm-2.13.so
+
kernel /boot/bzImage root=/dev/hda1,/dev/hdc1 console=ttyS0,115200
  
b76c3000-b779b000 r-xp 00000000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
+
title Network Boot
  
b779b000-b779f000 r-xp 000d7000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
+
ifconfig --server= --gateway= --mask= --address=
  
b779f000-b77a0000 rwxp 000db000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
+
root (nd)
  
b77a0000-b77a8000 rwxp 00000000 00:00 0
+
kernel (nd)/linux root=/dev/nfs console=ttyS0,115200 ip=:::::eth0: nfsroot=
  
b77a8000-b77b0000 r-xp 00000000 03:01 16731 /lib/libcrypt-2.13.so
+
~ #
  
b77b0000-b77b1000 r-xp 00007000 03:01 16731 /lib/libcrypt-2.13.so
+
The boot loader menu has two entries, the first entry boots Linux from the disk, and the second one boots Linux from the network. The first one is the default one.
  
b77b1000-b77b2000 rwxp 00008000 03:01 16731 /lib/libcrypt-2.13.so
+
Grub boots the kernel by loading the kernel file (bzImage) to the main memory and passing it some parameters. Current parameters are:
  
b77b2000-b77d9000 rwxp 00000000 00:00 0
+
root=/dev/hda1,/dev/hdc1 console=ttyS0, 115200
  
b77d9000-b77ed000 r-xp 00000000 03:01 17714 /lib/libpthread-2.13.so
+
This means that the kernel search for a root file system in a block device called /dev/hda1 and if it fails it tries /dev/hdc1. The “console=” means that the rs232 input and output redirected through a device file called /dev/ttyS0 in 115200 speed. These parameters are kernel parameters and do not relate to grub.
  
b77ed000-b77ee000 r-xp 00013000 03:01 17714 /lib/libpthread-2.13.so
+
&nbsp;
  
b77ee000-b77ef000 rwxp 00014000 03:01 17714 /lib/libpthread-2.13.so
+
= BSP =
  
b77ef000-b77f1000 rwxp 00000000 00:00 0
+
The board specific package I used to create the MIB is Pengutronix. Pengutronix is software builds an entire Linux distribution from scratch. Linux MIB software does not contain any binaries with the sources. So, in this section I will describe how to build the MIB bsp and MC in the virtual disk I supply for this.
  
b77f1000-b77f7000 r-xp 00000000 03:01 13450 /lib/librt-2.13.so
+
== Virtual Build Machine ==
  
b77f7000-b77f8000 r-xp 00005000 03:01 13450 /lib/librt-2.13.so
+
The virtual machine I use to virtual box. Please download and install it. The virtual machine is composed from two virtual disks, mib.vdi and buildDisk.vdi. The mib.vdi is 50MB disk, and buildDisk.vdi is 2 GB disk. This is because the build objects consume a lot of storage. Both disks can be found at //domainaxy/IL/MC/linux/buildmachine . Access to virtual machine is done through the terminal or through ssh with user root , no password required.
  
b77f8000-b77f9000 rwxp 00006000 03:01 13450 /lib/librt-2.13.so
+
'''Virtual Box Configuration'''
  
b77f9000-b77fb000 r-xp 00000000 03:01 17388 /lib/libdl-2.13.so
+
storage
  
b77fb000-b77fc000 r-xp 00001000 03:01 17388 /lib/libdl-2.13.so
+
[[File:vbox1.png|vbox]]
  
b77fc000-b77fd000 rwxp 00002000 03:01 17388 /lib/libdl-2.13.so
+
Network
  
b77fd000-b7817000 r-xp 00000000 03:01 16404 /lib/ld-2.13.so
+
[[File:vbox2.png|vbox]]
  
b7817000-b7818000 rwxp 00000000 00:00 0
+
share
  
b7818000-b7819000 r-xp 0001a000 03:01 16404 /lib/ld-2.13.so
+
[[File:vbox3.png|vbox]]
  
b7819000-b781a000 rwxp 0001b000 03:01 16404 /lib/ld-2.13.so
+
The guest gets static IP 192.168.56.101 . It is accessible only from the host. We decided to use this configuration as it simplifies things. If you wish to have the Linux connect to the network choose network card attached as bridge and choose intel PRO/1000 MT Desktop.
  
bfd20000-bfd41000 rwxp 00000000 00:00 0 <nowiki>[stack]</nowiki>
+
To have the virtual build machine access s shared folder in the host machine, please add a share name called amcs to whatever folder you wish.
  
ffffe000-fffff000 r-xp 00000000 00:00 0 <nowiki>[vdso]</nowiki>
+
The “amcs” share will mount automatically. Any other share has to be mounted manually in the guest:
  
 +
mount.vboxsf
 +
<nowiki><share name> </nowiki>
 +
<nowiki><mount point> </nowiki>
  
From left to tight:
+
'''Virtual Linux Configuration'''
  
# The segment ( also known as vma ) memory addresses
+
The virtual disk containing the toolchain is called toolchain.vdi. Once you boot the virtual build machine you need to make sure build disk is mounted. So check is /opt directory contains OSELAS toolchain. Also, please check the you have network access (with ifconfig) .If all well, please check if you can connect with ssh.
# The segment permission
 
# The segment offset into the file
 
# The block device major/minor holding the file
 
# The size of the segment
 
  
=== chrt ===
+
&nbsp;
change real time priority. You can control a processes scheduling class and priority level from the command line.
 
  
For example:
+
=== Building MC ===
  
Ksoftirq is a kernel daemon that is widely used in the kernel.  
+
#Make sure amcs share is mounted and contains all required sources. Make sure the toolchain is mounted on /opt.  
  
~ # threads |grep sof
+
~ # df
  
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
+
Filesystem 1K-blocks Used Available Use% Mounted on
  
 +
udev 191428 112 191316 0% /dev
  
ksoftirq pid is 3. Its real time priority is 99. So , let say we wish to change its priority to 19.
+
tmpfs 76572 144 76428 0% /run
  
~ # chrt -r -p 19 3
+
/dev/sda1 147415 85218 54697 61% /
  
pid 3's current scheduling policy: SCHED_RR
+
none 191428 0 191428 0% /tmp
  
pid 3's current scheduling priority: 99
+
none 191428 0 191428 0% /var/log
  
pid 3's new scheduling policy: SCHED_RR
+
none 191428 16 191412 0% /var/run
  
pid 3's new scheduling priority: 19
+
none 191428 0 191428 0% /var/lock
  
and indeed priority changed.
+
none 191428 0 191428 0% /var/tmp
  
~ # threads | grep sof
+
tmpfs 191428 112 191316 0% /dev
  
3 3 RR 19 - 59 0 0.1 S run_ksoftirqd ksoftirqd/0
+
''''/dev/sdb 8256952 1784056 6053468 23% /opt''''
  
 +
none 4217028 1366328 2850700 32% /media
  
== Network ==
+
Change directory to mc sources (inside the amcs share) or clone them from the linux. if this is the first time you build these sources please configure the build as follows:
=== ssh sshd and scp  ===
 
Secure shell is used to access remote machines. Sshd is service running in the target MIB and ssh is the client. You can login (perform ssh) to a MIB and login from a MIB to any other Linux machine. You can copy files with scp to and from Linux machines.
 
  
To login to MIB ip 10.4.20.240 from any Linux machine enter:
+
$ sh run_configure_all and now you can build these sources:
  
ssh [mailto:root@10.4.20.240 root@10.4.20.240]
+
$ make –j2
  
~ # ssh root@10.4.20.240
+
If you wish to configure eclipse ontop of the virtual box please refer to this document: [[Eclipse_Stand_Alone_Linux|Eclipse Stand Alone Linux]]
  
The authenticity of host '10.4.20.240 (10.4.20.240)' can't be established.
+
Once you’re done, you need to copy the binary to the target machine if you have external networking.
  
RSA key fingerprint is ef:f6:72:7f:64:7a:21:d4:8b:c3:b2:db:cf:a0:0f:99.
+
scp mc root@10.4.20.240:/usr/bin/mc
  
Are you sure you want to continue connecting (yes/no)? yes
+
else use eclipse terminal to copy.
  
Warning: Permanently added '10.4.20.240' (RSA) to the list of known hosts.
+
&nbsp;
  
root@10.4.20.240's password:
+
==== Troubleshoot ====
  
 +
'''run_configure_all'''
  
the first you will asked is enter yes/no. this happens only in the first time you access a remote machine. Enter “yes” and then you will be asked to enter a password, please do. Once entered, you will be in the MIB running in root privileges.  
+
If run_configure_all fails with numerous errors, edit in linux, and remove all ^M signs.
  
To copy files from Linux machine to another Linux machine in the command line we use scp command: for example, the command:
+
'''Out Of memory'''
  
scp –r /tmp root@10.4.20.240:/root/
+
Incase during the build you see a message “out of memory” please remove the –j from the make and remake or increase the virtual machine RAM.
  
will copy tmp directory to to root directory in target machine. The “-r” means recursive copy, which is how we copy directories.
+
'''Out of disk space'''
  
If you copy files from a windows machine to a linux machine you should use winscp.  
+
You are probably building on the virtual machine disk. Change to share directory.
  
 +
== Toolchain ==
  
[[Image:]]
+
The toochain is installed in the /opt/ directory. This requirement is strict and I do not support any other configuration. The toolchain we use is:
  
The first window displays a list machines that were accessed previously. If this is the first time you use winscp this list is empty. To copy files to 10.4.20.240 please click on the New button.
+
Gcc 4.52
  
[[Image:]]
+
Glibc 2.13
  
 +
Binutils 2.13
  
Fill the MIB’s ip. The user name “root”, the password, and change the protocol from sftp to scp. Click on “Save” to save the new machine in the list and then click on Login.
+
Sanitized kernel headers 2.6.36
  
[[Image:]]
+
Your /opt/ directory should contain a directory called:/opt/OSELAS.Toolchain-2011.03.1/.
  
You will windows saying that the command “group” returned error, disregard it, it is because MIB does not have group command, after that you will have the above screen. Now you can simply drag and drop files.
+
&nbsp;
  
=== Route ===
+
== The BSP ==
To watch the routing tables just type “route” or “netstat –r”. Here is route output in MIB
 
  
Ip 10.4.20.240.
+
To build the entire bsp you need a linux ubunto server. Building the bsp on a virtual box running ubunto is possible but will take a long time.
  
Kernel IP routing table
+
You can find the toolchain tar ball
  
Destination Gateway Genmask Flags Metric Ref Use Iface
+
//domainaxy/IL/MC/linux/buildmachine/OSELAS.Toolchain-2011.03.1.tar
  
10.0.0.0 <nowiki>* </nowiki>255.0.0.0 U 0 0 0 eth0
+
Copy it and extract it in the ubunto&nbsp;:
  
 +
$ sudo tar xvf OSELAS.Toolchain-2011.03.1.tar –C /opt/
  
As the reader can see, there is not default route, so if we try to access a different network segment will be getting “unreachable network” . We can only access network on the 10.x.x.x. because the netmask is 255.0.0.0.
+
Now, clone the bsp:
  
The only Ethernet interface a MIB has is eth0.
+
git clone [mailto:git@10.4.20.38:/home/git/bsp.git git@10.4.20.38:/home/git/bsp.git]
  
 +
to build the bsp master branch&nbsp;:
  
=== tcpdump ===
+
cd bsp/
tcpdump is a packet capture program. To capture packets simply type:
 
  
tcpdump
+
ptxdist go
  
this will fill screen with traffic captures. If you use ssh to access the machine you will see ssh traffic as well. So you probably want to filter out this ssh traffic. To do that enter:
+
at the end of the process you will have linuximage in platform-i586/images. This is not enough as you need to build to full image , for this run the bellow command:
  
tcpdump ip –i eth0 and not port 22
+
ptxdist images
  
Which means, capture all traffic on interface eth0, but drop any traffic on directed to port 22.
+
the image is hd.img. To burn it to the sdcard please:
  
There are many other ways to capture traffic. Sometimes you need to capture the traffic and want to analize it later with better tools, like wireshark. For this please enter:
+
sudo dd if=platform-i586/images/hd.img of=/dev/sdX
  
tcpdump ip –i eth0 and not port 22 –w foo.cap
+
when /dev/sdX is the sdcard device name. if you don’t the device name, do not bother dd’ing, you will probably destroy the build server.
  
This means that the captured data will be passed to a file called foo.cap.
+
Once you dd’ed, please sync and eject:
  
 +
sync
  
=== ethtool ===
+
eject /dev/sdX
ethtool is used to query and control network interfaces.
 
  
~ # ethtool eth0
+
=== Replicate an image ===
  
Settings for eth0:
+
There are times where one wishes to replicate an existing image. To do that he must copy the source image as file to some Linux machine using dd and then burn the source file image to new card. Here are the steps to do that:
  
<nowiki>Supported ports: [ TP MII ]</nowiki>
+
#Place in the card reader the source flash card. Linux will notice a new disk was pushed in.
 +
#dmesg and look for the new disk name, like /dev/sdd or/dev/sdb.
  
Supported link modes: 10baseT/Half 10baseT/Full
+
It will appear in the bottom of the dmesg log, for example:
  
100baseT/Half 100baseT/Full
+
&nbsp;
 +
<nowiki>[422238.883418] sd 9:0:0:0: [sdd] Assuming drive cache: write through</nowiki>
  
Supports auto-negotiation: Yes
+
&nbsp;
 +
<nowiki>[422238.883423] sd 9:0:0:0: [sdd] Attached SCSI removable disk</nowiki>
  
Advertised link modes: 10baseT/Half 10baseT/Full
+
&nbsp;
 +
<nowiki>[422470.346994] EXT3-fs: barriers not enabled</nowiki>
  
100baseT/Half 100baseT/Full
+
&nbsp;
 +
<nowiki>[422470.735075] kjournald starting. </nowiki>
 +
Commit interval 5 seconds &nbsp; <nowiki>[422470.735121] EXT3-fs (sdd1): warning: maximal mount count reached, running e2fsck is recommended</nowiki>
  
Advertised pause frame use: Symmetric
+
&nbsp;
 +
<nowiki>[422470.736077] EXT3-fs (sdd1): using internal journal</nowiki>
  
Advertised auto-negotiation: Yes
+
&nbsp;
 +
<nowiki>[422470.736083] EXT3-fs (sdd1): recovery complete</nowiki>
  
Link partner advertised link modes: 10baseT/Half 10baseT/Full
+
&nbsp;
 +
<nowiki>[422470.737199] EXT3-fs (sdd1): mounted filesystem with ordered data mode</nowiki>
  
100baseT/Half 100baseT/Full
+
The device ( disk ) in my machine is /dev/sdd. It has a single partition called /dev/sdd1.
  
Link partner advertised pause frame use: Symmetric
+
&nbsp;
  
Link partner advertised auto-negotiation: Yes
+
#Now copy the card to a file using dd: for example, if my disk name is /dev/sdb I enter:  
  
Speed: 100Mb/s
+
$ dd if=/dev/sdb bs=1M of=/tmp/hd.img
  
Duplex: Full
+
$ sync
  
Port: MII
+
#Now pull out the source sd card, and place the new card.
 +
#Push back the target flash card, and then:  
  
PHYAD: 1
+
$ dd if=/tmp/hd.img of=/dev/sdb
  
Transceiver: internal
+
$ sync
  
Auto-negotiation: on
+
&nbsp;
  
Supports Wake-on: g
+
= How to edit files in MIB =
  
Wake-on: g
+
There are cases where a user needs to edit a text file in the LinuxMIB. LinuxMIB has two editors, nano and vi.
  
Current message level: 0x00000007 (7)
+
vi is considered more powerfull than nano. Yet, I believe that the regular user should start with nano as it is more intuitive.
  
Link detected: yes
+
= Upgrade Linux MIB =
  
 +
Linux MIB is shipped with a debian based packaging system. This means that to any update is wrapped with ipkg. Once the package is ready, simply copy the package file to the target to the inbox directory.
  
Common use for it is checking the link type, 10/100/1000 Mbps and if the network is actually up (Last line: Link Detected).  
+
scp mc-4.9.0-linux.ipk 10.4.20.240:/inbox/ or by drag-and-drop through windows operating system with winscp.
  
 +
Packaging is triggered automatically. I wrote a package manager daemon that listens on /inbox directory and if a new file is put there it tries to install it.
  
= Boot =
+
You can list the packages with the following command:
Linux MIB boot is a two-phase boot. Once the computer passed the POST stage (Power On Self Test) it passes the control to the operating system. The first operating system is actually a boot loader. The boot loader is called grub – “grand unified boot loader”. Grub has one main purpose, to boot Linux. At the moment, the MIB hardware prevents us from seeing the grub loads. When grub loads it splashes a menu to screen (it is called splashing). This menu is kept in /boot/grub/menu.lst which is accessible through the LinuxMIB.
 
  
 +
dpkg -l
  
~ # cat /boot/grub/menu.lst
+
Currently you cannot uninstall a package, you have to remove the files manually.I believe it is a pengutronix bug.
  
serial --unit=0 --speed=115200
+
== Control MC Start ==
  
terminal --timeout=0 serial console
+
One of the first things a programmer does when developing is disabling the automatic start of the application he is debugging. In manz case it is mostly the mc.
  
 +
There are two ways to disable automatic starting:
  
default 0
+
&nbsp;
  
timeout 0
+
#Each time you boot.
  
color cyan/blue white/blue
+
&nbsp;
 +
<nowiki># ~ /etc/init.d/mc stop</nowiki>
  
 +
#Edit /etc/init.d/mc script and remark the mc launching as follows:
  
title Standalone Boot
+
  
root (hd0,0)
+
start)
  
kernel /boot/bzImage root=/dev/hda1,/dev/hdc1 console=ttyS0,115200
+
/etc/init.d/run_config
  
 +
&nbsp;
 +
<nowiki># nohup /bin/sh /usr/bin/mc.sh &</nowiki>
  
title Network Boot
+
Add # before the nohup as depicted in the line above.
  
ifconfig --server= --gateway= --mask= --address=
+
= Debugging =
  
root (nd)
+
Debugging mc can mostly with eclipse. Please refer to eclipse documentation to learn how to do that.
  
kernel (nd)/linux root=/dev/nfs console=ttyS0,115200 ip=:::::eth0: nfsroot=
+
== Logs ==
  
 +
In addition to the log files in /RAM file system. We added a linux-like logger which can be found at /var/syslog.
  
~ #
+
&nbsp;
  
 +
== Core files ==
  
The boot loader menu has two entries, the first entry boots Linux from the disk, and the second one boots Linux from the network. The first one is the default one.
+
A core file is a snapshot of the process memory when it crashed. It is a post mortem debugging method commonly used. All cores files are generated to /cores directory. There will no more than 5 cores. The 6-th core is written on the first core.
  
Grub boots the kernel by loading the kernel file (bzImage) to the main memory and passing it some parameters. Current parameters are:
+
To debug a core dump you must compile the same mc with debug info and copy the core file to the ubunto ( virtual build machine is not suitable for that ). Then type:
  
root=/dev/hda1,/dev/hdc1 console=ttyS0, 115200
+
gdb mc coredump
  
This means that the kernel search for a root file system in a block device called /dev/hda1 and if it fails it tries /dev/hdc1. The “console=” means that the rs232 input and output redirected through a device file called /dev/ttyS0 in 115200 speed. These parameters are kernel parameters and do not relate to grub.
+
&nbsp;
  
 +
== Memory Detector ==
  
= BSP =
+
To debug memory leaks you need valgrind. Valgrind is not installed as is in the bsp, simply take a package and put it in the target. If you do not know how to use valgrind I suggest you refer to valgrind web site. It is beyond the scope of this paper.
The board specific package I used to create the MIB is Pengutronix. Pengutronix is software builds an entire Linux distribution from scratch. Linux MIB software does not contain any binaries with the sources. So, in this section I will describe how to build the MIB bsp and MC in the virtual disk I supply for this.  
 
  
== Virtual Build Machine ==
+
&nbsp;
The virtual machine I use to virtual box. Please download and install it. The virtual machine is composed from two virtual disks, mib.vdi and buildDisk.vdi. The mib.vdi is 50MB disk, and buildDisk.vdi is 2 GB disk. This is because the build objects consume a lot of storage. Both disks can be found at //domainaxy/IL/MC/linux/buildmachine . Access to virtual machine is done through the terminal or through ssh with user root , no password required.
 
  
 +
== MC cli ==
  
'''Virtual Box Configuration'''
+
MC Linux is shipped with a telnet server. This telnet server resembles the vxworks terminal.
  
storage
+
To login please:
  
[[Image:]]
+
~ # telnet localhost:8000
  
Network
+
Entering character mode
  
[[Image:]]
+
Escape character is '^]'.
  
 +
AMCS shell
  
share
+
User name is root and password qwerty.
  
[[Image:]]
+
Username: root
  
 +
Password:
  
The guest gets static IP 192.168.56.101 . It is accessible only from the host. We decided to use configuration as it simplifies things. If you wish to have the Linux connect to the network choose network card attached as bridge and choose intel PRO/1000 MT Desktop.
+
The telnet is evolving and the command may differ from one version to another but to get help you can simply type help.
  
To have the virtual build machine access s shared folder in the host machine, please add a share name called amcs to whatever folder you wish.
+
> help
  
The “amcs” share will mount automatically. Any other share has to be mounted manually in the guest:
+
Commands available:
  
mount.vboxsf <nowiki><share name> </nowiki><nowiki><mount point> </nowiki>
+
help Show available commands
  
 +
logout Disconnect
  
'''Virtual Linux Configuration'''
+
history Show a list of previously run commands
  
The virtual disk containing the toolchain is called buildDisk.vdi. Once you boot the virtual build machine you need to make sure build disk is mounted. So check is /opt directory contains OSELAS toolchain. Also, please check the you have network access (with ifconfig) .If all well, please check if you can connect with ssh.
+
threads print all threads
  
 +
stack trace print the stack of a given thread
  
=== Building MC ===
+
p print a symbol
# Make sure amcs share is mounted and contains all required sources. Make sure the toolchain is mounted on /opt.
 
  
+
exit exit the process
  
 +
>
  
~ # df
+
&nbsp;
  
Filesystem 1K-blocks Used Available Use% Mounted on
+
== Profiling ==
  
udev 191428 112 191316 0% /dev
+
Profiling MC can be done with oprofile. To use oprofile you need to boot a kernel with oprofile support, and replace the drivers. For this you will have to install a package called kernel-oprofile.ipk and boot this kernel.
  
tmpfs 76572 144 76428 0% /run
+
To use oprofile please:
  
/dev/sda1 147415 85218 54697 61% /
+
$ opcontrol –reset
  
none 191428 0 191428 0% /tmp
+
$ opcontrol –deinit
  
none 191428 0 191428 0% /var/log
+
$ opcontrol –init
  
none 191428 16 191412 0% /var/run
+
Now to choose type of event you should make sure your processor support this type of event – if any.
  
none 191428 0 191428 0% /var/lock
+
$ opcontrol –list-events
  
none 191428 0 191428 0% /var/tmp
+
Let say you wish to check memory references.
  
tmpfs 191428 112 191316 0% /dev
+
$ opcontrol –event:DATA_MEM_REFS:30000
  
/dev/sdb 8256952 1784056 6053468 23% /opt
+
The above command sets the event memory references each time the a a hardware counter finish counting to 30000.
  
none 4217028 1366328 2850700 32% /media
+
$ opcontrol –session-dir=/home/myoprofile
  
 +
$ opcontrol –sparate=cpu
  
# Change directory to mc sources (inside the amcs share) or clone them from the linux.
+
$ opcontrol –callgraph=10
# If this is first time you build these sources please:
 
  
$ sh run_configure_all
+
$ opcontrol –novmlinux
  
# build
+
$ opcontrol –start
  
$ make –j2
+
./prog..
  
Or through the eclipse choose the virtual machine configuration and have eclipse build it for you.
+
$ opcontrol –stop
  
 +
Now copy the entire profiling results to your local machine home user.
  
Once you’re done, you need to copy the binary to the target machine if you have external networking.
+
$ opreport –session-dir=/home/raz/myprofile
  
scp mc root@10.4.20.240:/usr/bin/mc
+
CPU_CLK_UNHALT...|LLC_MISSES:466500|
  
else use eclipse terminal to copy.
+
samples|&nbsp;%| samples|&nbsp;%|
  
 +
&nbsp;
 +
<nowiki>------------------------------------</nowiki>
  
Troubleshoot
+
943 100.000 1 100.000 prog
  
'''run_configure_all '''
+
CPU_CLK_UNHALT...|LLC_MISSES:466500|
  
If run_configure_all fails with numerous errors, edit in linux, and remove all ^M signs.
+
samples|&nbsp;%| samples|&nbsp;%|
  
 +
&nbsp;
 +
<nowiki>------------------------------------</nowiki>
  
'''Machine Name'''
+
709 75.1856 1 100.000 prog
  
If you want to change the machine name, please:
+
234 24.8144 0 0 libc-2.11.1.so
  
'''Out Of memory'''
+
To get annotation per line use, run this from the mc directory. This way opannotate will find the source code.
  
Incase during the build you see a message “out of memory” please remove the –j from the make and remake or increase the virtual machine RAM.
+
$ opanotate –s session-dir=/home/raz/myprofile
  
 +
Please note if you intend to use oprofile please read the tutotial as it is beyond the spec of this paper.
  
'''Out of disk space'''
+
== ftrace ==
 
 
You are probably building on the virtual machine disk. Change to share directory.
 
 
 
  
== Toolchain ==
 
The toochain is installed in the /opt/ directory. This requirement is strict and I do not support any other configuration. The toolchain we use is:
 
 
Gcc 4.52
 
 
Glibc 2.13
 
 
Binutils 2.13
 
 
Sanitized kernel headers 2.6.36
 
 
Your /opt/ directory should contain a directory called:/opt/OSELAS.Toolchain-2011.03.1/.
 
 
 
== The BSP ==
 
To build the entire bsp you need a linux ubunto server. Building the bsp on a virtual box running ubunto is possible but will take a long time.
 
 
You can find the toolchain tar ball
 
 
//domainaxy/IL/MC/linux/buildmachine/OSELAS.Toolchain-2011.03.1.tar
 
 
Copy it and extract it in the ubunto :
 
 
$ sudo tar xvf OSELAS.Toolchain-2011.03.1.tar –C /opt/
 
 
 
Now, clone the bsp:
 
 
git clone [mailto:git@10.4.20.38:/home/git/bsp.git git@10.4.20.38:/home/git/bsp.git]
 
 
to build the bsp master branch :
 
 
cd bsp/
 
 
ptxdist go
 
 
at the end of the process you will have linuximage in platform-i586/images. This is not enough as you need to build to full image , for this run the bellow command:
 
 
ptxdist images
 
 
the image is hd.img. To burn it to the sdcard please:
 
 
sudo dd if=platform-i586/images/hd.img of=/dev/sdX
 
 
when /dev/sdX is the sdcard device name. if you don’t the device name, do not bother dd’ing, you will probably destroy the build server.
 
 
Once you dd’ed, please sync and eject:
 
 
sync
 
 
eject /dev/sdX
 
 
=== Replicate an image ===
 
There are times where one wishes to replicate an existing image. To do that he must copy the source image as file to some Linux machine using dd and then burn the source file image to new card. Here are the steps to do that:
 
 
# Place in the card reader the source flash card. Linux will notice a new disk was pushed in.
 
# dmesg and look for the new disk name, like /dev/sdd or/dev/sdb.
 
 
It will appear in the bottom of the dmesg log, for example:
 
 
<nowiki>[422238.883418] sd 9:0:0:0: [sdd] Assuming drive cache: write through</nowiki>
 
 
<nowiki>[422238.883423] sd 9:0:0:0: [sdd] Attached SCSI removable disk</nowiki>
 
 
<nowiki>[422470.346994] EXT3-fs: barriers not enabled</nowiki>
 
 
<nowiki>[422470.735075] kjournald starting. </nowiki>Commit interval 5 seconds
 
 
<nowiki>[422470.735121] EXT3-fs (sdd1): warning: maximal mount count reached, running e2fsck is recommended</nowiki>
 
 
<nowiki>[422470.736077] EXT3-fs (sdd1): using internal journal</nowiki>
 
 
<nowiki>[422470.736083] EXT3-fs (sdd1): recovery complete</nowiki>
 
 
<nowiki>[422470.737199] EXT3-fs (sdd1): mounted filesystem with ordered data mode</nowiki>
 
 
 
The device ( disk ) in my machine is /dev/sdd. It has a single partition called /dev/sdd1.
 
 
 
# Now copy the card to a file using dd: for example, if my disk name is /dev/sdb I enter:
 
 
$ dd if=/dev/sdb bs=1M of=/tmp/hd.img
 
 
$ sync
 
 
# Now pull out the source sd card, and place the new card.
 
# Push back the target flash card, and then:
 
 
$ dd if=/tmp/hd.img of=/dev/sdb
 
 
$ sync
 
 
 
= How to edit files in MIB =
 
There are cases where a user needs to edit a text file in the LinuxMIB. LinuxMIB has two editors, nano and vi.
 
 
vi is considered more powerfull than nano. Yet, I believe that the regular user should start with nano as it is more intuitive.
 
 
= Upgrade Linux MIB =
 
Linux MIB is shipped with a debian based packaging system. This means that to any update is wrapped with ipkg. Once the package is ready, simply copy the package file to the target to the inbox directory.
 
 
scp mc-4.9.0-linux.ipk 10.4.20.240:/inbox/ or by drag-and-drop through windows operating system with winscp.
 
 
Packaging is triggered automatically. I wrote a package manager daemon that listens on /inbox directory and if a new file is put there it tries to install it.
 
 
You can list the packages with the following command:
 
 
dpkg -l
 
 
Currently you cannot uninstall a package, you have to remove the files manually.I believe it is a pengutronix bug.
 
 
== Control MC Start  ==
 
One of the first things a programmer does when developing is disabling the automatic start of the application he is debugging. In manz case it is mostly the mc.
 
 
There are two ways to disable automatic starting:
 
 
 
# Each time you boot.
 
 
<nowiki># ~ /etc/init.d/mc stop</nowiki>
 
 
# Edit /etc/init.d/mc script and remark the mc launching as follows:
 
 
 
 
start)
 
 
/etc/init.d/run_config
 
 
<nowiki># nohup /bin/sh /usr/bin/mc.sh &</nowiki>
 
 
 
Add # before the nohup as depicted in the line above.
 
 
= Debugging =
 
Debugging mc can mostly with eclipse. Please refer to eclipse documentation to learn how to do that.
 
 
== Logs ==
 
In addition to the log files in /RAM file system. We added a linux-like logger which can be found at /var/syslog.
 
 
 
== Core files ==
 
A core file is a snapshot of the process memory when it crashed. It is a post mortem debugging method commonly used. All cores files are generated to /cores directory. There will no more than 5 cores. The 6-th core is written on the first core.
 
 
To debug a core dump you must compile the same mc with debug info and copy the core file to the ubunto ( virtual build machine is not suitable for that ). Then type:
 
 
gdb mc coredump
 
 
 
== Memory Detector ==
 
To debug memory leaks you need valgrind. Valgrind is not installed as is in the bsp, simply take a package and put it in the target. If you do not know how to use valgrind I suggest you refer to valgrind web site. It is beyond the scope of this paper.
 
 
 
== MC cli ==
 
MC Linux is shipped with a telnet server. This telnet server resembles the vxworks terminal.
 
 
To login please:
 
 
~ # telnet localhost:8000
 
 
 
Entering character mode
 
 
Escape character is '^]'.
 
 
 
AMCS shell
 
 
 
User name is root and password qwerty.
 
 
 
Username: root
 
 
Password:
 
 
 
The telnet is evolving and the command may differ from one version to another but to get help you can simply type help.
 
 
 
> help
 
 
 
Commands available:
 
 
help Show available commands
 
 
logout Disconnect
 
 
history Show a list of previously run commands
 
 
threads print all threads
 
 
stack trace print the stack of a given thread
 
 
p print a symbol
 
 
exit exit the process
 
 
 
>
 
 
 
== Profiling ==
 
Profiling MC can be done with oprofile. To use oprofile you need to boot a kernel with oprofile support, and replace the drivers. For this you will have to install a package called kernel-oprofile.ipk and boot this kernel.
 
 
To use oprofile please:
 
 
$ opcontrol –reset
 
 
$ opcontrol –deinit
 
 
$ opcontrol –init
 
 
Now to choose type of event you should make sure your processor support this type of event – if any.
 
 
$ opcontrol –list-events
 
 
Let say you wish to check memory references.
 
 
$ opcontrol –event:DATA_MEM_REFS:30000
 
 
The above command sets the event memory references each time the a a hardware counter finish counting to 30000.
 
 
$ opcontrol –session-dir=/home/myoprofile
 
 
$ opcontrol –sparate=cpu
 
 
$ opcontrol –callgraph=10
 
 
$ opcontrol –novmlinux
 
 
$ opcontrol –start
 
 
./prog..
 
 
$ opcontrol –stop
 
 
Now copy the entire profiling results to your local machine home user.
 
 
$ opreport –session-dir=/home/raz/myprofile
 
 
 
CPU_CLK_UNHALT...|LLC_MISSES:466500|
 
 
samples| %| samples| %|
 
 
<nowiki>------------------------------------</nowiki>
 
 
943 100.000 1 100.000 prog
 
 
CPU_CLK_UNHALT...|LLC_MISSES:466500|
 
 
samples| %| samples| %|
 
 
<nowiki>------------------------------------</nowiki>
 
 
709 75.1856 1 100.000 prog
 
 
234 24.8144 0 0 libc-2.11.1.so
 
 
 
To get annotation per line use, run this from the mc directory. This way opannotate will find the source code.
 
 
$ opanotate –s session-dir=/home/raz/myprofile
 
 
 
Please note if you intend to use oprofile please read the tutotial as it is beyond the spec of this paper.
 
 
== ftrace ==
 
 
I do not want to write what is ftrace in this book, please refer to the ftrace tutorials to do that:
 
I do not want to write what is ftrace in this book, please refer to the ftrace tutorials to do that:
  

Latest revision as of 08:56, 21 February 2022

Introduction

This documentation explains most parts of the Linux MIB. It is intended for the following users:

  • softMC developers who are compiling and link C/C++ code
  • QA teams
  • Managers engaged in MIB development

MIB Software Components

The software on a common Linux MIB has two main types.

The first type is software controlled by Servotronix, who builds and maintains the source code. The second type is software over which Servotronix has no control, such as third-party binaries.

The first type includes:

  • The Linux operating system. This includes all services and utilities along with their shared objects (aka dll) which take part of maintaining the operating system.
  • The Linux Kernel. The core of the operating system.

 

  • mc. Manz’s motion control and its bash scripts extensions.
  • /FFS0 with its mc basic programs.
  • core dumper. Daemon used to redirect core files.
  • pkgd. Package manager.
  • Various in house drivers,such as , sercos 2, ethercat and so on.
  • In the future, any third party software that is added, such as PNP plugins and 3s.

All of the above software is built from source code. Servotronix does not ship any other component without its source code. Binaries passed to MIB through the aico are not considered part of Linux MIB system.

Accessing the MIB

The MIB is fully accessable from any machine. Accessing the LinuxMIB can be done in two ways – secure shell and RS232 connection.

Access LinuxMIB through RS232

It is assumed that you are familiar with RS232 connections.

In Windows you can access the MIB through hyperterminal or putty.

putty.exe can be downloaded from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.

'''RS232 Configuration'''
Speed 115200
StopBits: 1
Data: 8
Parity:Odd ( N)

Once connected a login session will appear:

manz login:

enter mc

and then:

Password:

Enter mc

 

Obtaining LinuxMIB IP

If you have aico, use “Select Device” and look for Linux. This should be some LinuxMIB IP.

Alternately, you can access through RS232:

~ # '''''ifconfig'''''
eth0 Link encap:Ethernet HWaddr 00:50:C2:5D:0F:5E
inet addr:'''10.4.20.83''' Bcast:10.4.20.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:92287 errors:0 dropped:0 overruns:0 frame:0
TX packets:4462 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13389368 (12.7 MiB) TX bytes:431984 (421.8 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:612 (612.0 B) TX bytes:612 (612.0 B)

Access LinuxMIB through Secure Shell

To access the MIB from windows without direct connection use secure shell, or in short “ssh”.

If you login through putty, run it. A screen will appear.

putty

Perform the following steps:

1. Choose ssh button
2. ssh port is 22 by default
3. Fill LinuxMIB ip in both feilds,ie host name and saved sessions.
4. save it
5. open it

A login screen will appear.

putty

Changing the password

It is common to change the login password (for developers only):

~ # passwd

Changing password for root

New password:

Enter q

A prompt will appear:

Bad password: too short.

It is ok. “q” is bad password. but you’re likely to login so many times so you better of using this short password.

Then it will ask you to retype the password,

Retype password:

Enter q again. You do not have to enter “q”, but you will learn that people access anyone’s MIB, so they will expect a short packet to be “q”.

Storage

This section details the storage of the LinuxMIB. Storage refers to the disks and file systems.

Block Devices

A block device is a device that is accessed with blocks of data. This includes, hard drives, DVD devices, usb flash cards and so on. In the MIB case the block device that holds the file system is called /dev/sda or /dev/hda. It is referred to as /dev/root ( for reasons out this document scope I will not explain why ). Too examin the disk use the fdisk command :

 

fdisk -l

Disk /dev/sda: 1014 MB, 1014644736 bytes
255 heads, 63 sectors/track, 123 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks  Id System
     /dev/sda1   *           1          57      449850+ 83 Linux
   Partition 1 does not end on cylinder boundary
     /dev/sda2              57         116      475000  83 Linux
   Partition 2 does not end on cylinder boundary

 

/dev/sda1 is / . /dev/sda2 is the backup partition. The backup partion is used /dev/sda1 is totally corrupted.

File systems

LinuxMIB is composed from several independent file systems. To examine the file systems please enter:

~ # 'df -h'

                         Filesystem Size     Used    Available  Use%  Mounted on
1)
                        /dev/root   485.5M   83.8M    377.3M    18%   /  

 

2)
                          none       246.9M   4.0K    246.9M    0% /tmp  
3)
                           none       246.9M   24.0K   246.8M    0%  /RAM 
                           none       246.9M   44.0K   246.8M    0% /var/log
                           none       246.9M   24.0K   246.8M    0% /var/run
4)
                           none       246.9M     0      246.9M   0%   /var/lock
                           none       246.9M     0      246.9M   0%   /var/tmp
                           tmpfs      246.9M     4.0K   246.9M    0%  /dev

 

  1. The main file system is called root file system. The root file system is said to be mounted on the mounting point “/”. Any other file system in Linux is mounted on top of the root file system at some directory. Here the root file system is of size of 485MB, and 83MB of it are used.
  1. /tmp directory is mounted as tmpfs file system. This is a ram file system. It does not survive boots.
  2. This is the RAM file system used by mc. It is also of type tmpfs.
  3. /var/log , /var/run, /var/lock, and /var/tmp are tmps file system as well used by different services.
  4. /dev/ is a file system that holds all device files. it is regenerated with each boot.
  5. There is a nother file system called /dev/pts , it is visible through the mount command, it hold terminals information.

Basic commands

File and file system

ls

To examine the content the of current directory use ls:

~ # ls

  To examine the content of another directory use ls <dir>. For example:

~ # ls /sbin/

adjtimex halt init modprobe setconsole udevadm

blkid hdparm insmod poweroff sfdisk udevd

dhclient hwclock klogd reboot start-stop-daemon udhcpc

fdisk ifconfig loadkmap rmmod sulogin umount.devkit

fsck ifdown lsmod route syslog-ng watchdog

getty ifup modinfo runlevel threads

~ #

The “ls” commands have additional flags, such as : “ls –al” which provides more information about the files.

cat

To examine the content of a text file use the cat. For example:

~ # cat /etc/busybox.conf

you can also create new files with cat by redirecting cat’s output to a new file. For example:

~ # cat /etc/busybox.conf > /tmp/busybox.conf

you can concatenate two files in to a single file by using the >> sign.

For example the command

~ # cat /etc/inet.conf >> /tmp/busybox.conf

will concatenate to /tmp/busybox.conf the content of /etc/inet.conf.

echo

echo is a command that send a string to a file, where a file can be the terminal itself or simply a regular text file or any other file which receives data.

~ # echo hello

Hello

 

less

less is a textual viewer. It is used to examine text file content in read-only mode. Usage:

  ~# less <file name>

tail/head

The tail comands prints last line of a file. The head command prints the first few lines of a file. tail is very useful a user wishes to examine how file is being updated , mostly logs.

For example:

~ # tail –f /var/syslog

fsck – check file system consistency

LinuxMIB uses ext3 as its file system, ext3 is a journaling file system which means file system corruption is much less to occur, there are still times where corruptions do happen ( not by abrupt power off but by exploding the file system or deliberately corrupting ).

LinuxMIB executes fsck.ext3 each time it is booted, if you wish to check file system integrity first create the device name:

mknod /dev/hda1 b 3 1

This is because /dev/hda1 does not exist on the MIB and neither /dev/root.

Now issue the fsck command as bellow. I use –n flag to do that in read only mode.

fsck.ext3 –n /dev/hda1

grep

grep prints lines matching a pattern. Example:

/etc # grep mc /usr/bin/mc.sh

/usr/bin/mc

The above command prints each line containing the word “mc”.

or check number of mc core files in the /cores/ directory.

nf=$(ls /cores/mc* | wc -l)

echo $nf

4

awk

awk is a parsing language. The awk command scans an input file searching for some text pattern and when finding this pattern awk act according to the action specified.

For example:

~# awk '$2 == 0 { printf $1 " " $2 " " $3 "\n"}' /proc/interrupts

NMI: 0 Non-maskable

LOC: 0 Local

SPU: 0 Spurious

PMI: 0 Performance

IWI: 0 IRQ

TRM: 0 Thermal

THR: 0 Threshold

MCE: 0 Machine

ERR: 0

MIS: 0

This command prints columns 1, 2 and 3 in the /proc/interrupts if the second column equal 0.

find

find searches for files in directory recursively. For example, if a user wants to find all files named mc in the LinuxMIB:

~ # find / -name mc

/etc/init.d/mc

/usr/bin/mc

 

watch

The watch command executes a command periodically. For example:

watch –n1 ‘cat /proc/vmstat`

print to screen the file /proc/vmstat .

gzip/gunzip

The gzip command compresses a file. The gunzip command decompress a file.

Example:

gzip /etc/busybox.conf

busybox.conf is compressed and renamed to busybox.conf.gz

to decompress :

gunzip /etc/busybox.cong.gz

a new file /etc/busybox.conf is created.

 

zcat

zcat is used to print a content of a compressed text file without decompressing it.

Example:

zcat /etc/busybox.conf.gz

This will dump to screen busybox.conf.a

System

free

free returns the amount of RAM in the machine, the amount of used memory in the machine and the amount of used memory in the machine.

~ # free

total used free shared buffers

Mem: 505560 47912 457648 0 1356

Swap: 0 0 0

Total: 505560 47912 457648

lshw

Lists the hardware configuration of the machine.

~ # lshw

manz

description: Computer

product: N/A

vendor: N/A

version: N/A

serial: N/A

width: 32 bits

capabilities: smbios-2.5 dmi-2.5

configuration: administrator_password=disabled boot=oem-specific frontpanel_

password=unknown keyboard_password=unknown power-on_password=disabled

  *-core

description: Motherboard

product: MODB

vendor: Kontron Embedded Modules

physical id: 0

version: 05.00

serial: YXEBK0229

  *-firmware

description: BIOS

vendor: Phoenix Technologies LTD

physical id: 0

version: MODBR131 (06/27/0808)

size: 104KiB

capacity: 960KiB

capabilities: isa pci pcmcia pnp apm upgrade shadowing escd cdboot acp

i usb agp biosbootspecification

  *-cpu

description: CPU

product: Intel(R) Celeron(R) M processor 1.50GHz

vendor: Intel Corp.

physical id: 4

bus info: cpu@0

version: 6.13.8

slot: U2E1

size: 1500MHz

capacity: 2048MHz

width: 32 bits

capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 sep

mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx bts

  *-cache:0

description: L1 cache

physical id: 5

slot: L1 Cache

size: 64KiB

capacity: 64KiB

 

udevadm

udev is part of a linux device model. Udevadm is a tool used to query, monitor and control devices. For example, the hardisk “hda”,has a pci address, it belongs to the block device subsystem, and so on. To get this sort of information in one unified view, we do:

~ # udevadm info -a -p /sys/block/hda

Udevadm info starts with the device specified by the devpath and then

walks up the chain of parent devices. It prints for every device

found, all possible attributes in the udev rules key format.

A rule to match, can be composed by the attributes of the device

and the attributes from one single parent device.

looking at device '/block/hda':

KERNEL=="hda"

SUBSYSTEM=="block"

DRIVER==""

ATTR{range}=="64"

ATTR{ext_range}=="256"

ATTR{removable}=="0"

ATTR{ro}=="0"

ATTR{size}=="1981728"

ATTR{alignment_offset}=="0"

ATTR{discard_alignment}=="0"

ATTR{capability}=="50"

ATTR{stat}==" 342 173 15716 1119 47 25 1

1768 0 2179 2886"

ATTR{inflight}==" 0 0"

ATTR{events}==""

ATTR{events_async}==""

ATTR{events_poll_msecs}=="-1"

As one can observe, a disk called had is part of the block subsystem, there is no driver for it as I did not compile external modules, additional information appears such as its size and some statistics.

 

Reboot

To reboot the MIB use the “reboot” command.

Poweroff

To turn off the MIB, use the “poweroff” command.

hwclock

To get or set the time to/from RTC hardware clock , use the “hwclock” command. In cases where RTC is broken, “hwlock” will hang or display bad time.

 

Process

In this section I show some commands related to processes management.

Ps

Use the “ps” command to list system processes. For example, the “ps aux” outputs:

~ # ps aux

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 1 0.0 0.1 2076 516 ? Ss 08:03 0:01 init

root 2 0.0 0.0 0 0 ? S 08:03 0:00 [kthreadd]

root 3 0.1 0.0 0 0 ? S 08:03 0:02 [ksoftirqd/0]

root 5 0.0 0.0 0 0 ? S 08:03 0:00 [kworker/u:0]

root 6 0.0 0.0 0 0 ? S 08:03 0:00 [posixcputmr/0]

root 7 0.0 0.0 0 0 ? S< 08:03 0:00 [khelper]

root 8 0.0 0.0 0 0 ? S 08:03 0:00 [kworker/u:1]

root 125 0.0 0.0 0 0 ? S 08:03 0:00 [sync_supers]

root 127 0.0 0.0 0 0 ? S 08:03 0:00 [bdi-default]

root 128 0.0 0.0 0 0 ? S< 08:03 0:00 [kblockd]

root 135 0.0 0.0 0 0 ? S< 08:03 0:00 [ata_sff]

root 142 0.0 0.0 0 0 ? S 08:03 0:00 [khubd]

root 248 0.0 0.0 0 0 ? S 08:03 0:00 [kworker/0:1]

root 268 0.0 0.0 0 0 ? S 08:03 0:00 [kswapd0]

root 269 0.0 0.0 0 0 ? S 08:03 0:00 [fsnotify_mark]

root 271 0.0 0.0 0 0 ? S< 08:03 0:00 [crypto]

root 869 0.0 0.0 0 0 ? S 08:04 0:00 [irq/15-ide0]

root 906 0.0 0.0 0 0 ? S 08:04 0:00 [irq/1-i8042]

root 913 0.0 0.0 0 0 ? S 08:04 0:00 [irq/8-rtc0]

root 921 0.0 0.0 0 0 ? S 08:04 0:00 [kworker/0:2]

root 922 0.0 0.0 0 0 ? S 08:04 0:00 [irq/4-serial]

root 923 0.0 0.0 0 0 ? S 08:04 0:00 [kjournald]

root 945 0.0 0.1 1896 648 ? S<s 08:04 0:00 /sbin/udevd --d root 999 0.0 0.1 1892 608 ? S< 08:04 0:00 /sbin/udevd --d root 1002 0.0 0.1 1892 604 ? S< 08:04 0:00 /sbin/udevd --d root 1017 0.0 0.1 2992 716 ? Ss 08:04 0:00 /sbin/syslog-ng root 1025 0.0 0.1 3932 996 ? Ss 08:04 0:00 /usr/sbin/sshd

root 1045 0.0 0.0 0 0 ? S 08:04 0:00 [irq/9-eth0]

root 1056 0.0 0.0 0 0 ? S 08:04 0:00 [irq/11-srcsII]

root 1075 99.7 0.0 1528 196 ? Rs 08:04 31:12 /usr/bin/pkgd /

root 1079 0.0 0.1 2080 544 ttyS0 Ss+ 08:04 0:00 /sbin/getty -L

root 1093 0.0 0.3 6536 2004 ? Ss 08:04 0:00 sshd: root@pts/

root 1097 0.0 0.1 2080 632 pts/0 Ss+ 08:04 0:00 -sh

root 1107 0.0 0.3 6536 1988 ? Ss 08:05 0:00 sshd: root@pts/

root 1111 0.0 0.1 2080 664 pts/1 Ss 08:05 0:00 -sh

root 1146 0.0 0.0 0 0 ? S 08:25 0:00 [flush-3:0]

root 1177 0.2 0.3 6536 1988 ? Ss 08:35 0:00 sshd: root@pts/

root 1181 0.0 0.1 2080 608 pts/2 Ss 08:35 0:00 -sh

root 1182 3.2 5.1 42140 26172 pts/2 Sl+ 08:35 0:00 mc

root 1209 0.0 0.1 2228 824 pts/1 R+ 08:35 0:00 ps aux

all processes in the entire operating system along with their memory consumption, state, pid, cpu usage and so on. As one can see the next to last process is mc itself, so where are his threads. For this I created an abbreviation called threads:

~ # threads

Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html

PID TID CLS RTPRIO NI PRI PSR %CPU STAT WCHAN COMMAND

1 1 TS - 0 19 0 0.0 Ss wait init

2 2 TS - 0 19 0 0.0 S kthreadd kthreadd

3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0

5 5 TS - 0 19 0 0.0 S worker_thread kworker/u:0

6 6 RR 16 - 56 0 0.0 S posix_cpu_time posixcputmr/0

7 7 TS - -20 39 0 0.0 S< rescuer_thread khelper 8 8 TS - 0 19 0 0.0 S worker_thread kworker/u:1 125 125 TS - 0 19 0 0.0 S bdi_sync_super sync_supers

127 127 TS - 0 19 0 0.0 S bdi_forker_thr bdi-default

128 128 TS - -20 39 0 0.0 S< rescuer_thread kblockd 135 135 TS - -20 39 0 0.0 S< rescuer_thread ata_sff 142 142 TS - 0 19 0 0.0 S hub_thread khubd 248 248 TS - 0 19 0 0.0 S worker_thread kworker/0:1

268 268 TS - 0 19 0 0.0 S kswapd_try_to_ kswapd0

269 269 TS - 0 19 0 0.0 S fsnotify_mark_ fsnotify_mark

271 271 TS - -20 39 0 0.0 S< rescuer_thread crypto 869 869 FF 50 - 90 0 0.0 S irq_thread irq/15-ide0 906 906 RR 16 - 56 0 0.0 S irq_thread irq/1-i8042

913 913 RR 16 - 56 0 0.0 S irq_thread irq/8-rtc0

921 921 TS - 0 19 0 0.0 S worker_thread kworker/0:2

922 922 RR 16 - 56 0 0.0 S irq_thread irq/4-serial

923 923 TS - 0 19 0 0.0 S kjournald kjournald

945 945 TS - -4 23 0 0.0 S<s poll_schedule_ udevd 999 999 TS - -2 21 0 0.0 S< poll_schedule_ udevd 1002 1002 TS - -2 21 0 0.0 S< poll_schedule_ udevd 1017 1017 TS - 0 19 0 0.0 Ss poll_schedule_ syslog-ng 1025 1025 TS - 0 19 0 0.0 Ss poll_schedule_ sshd

1045 1045 RR 16 - 56 0 0.0 S irq_thread irq/9-eth0

1056 1056 RR 99 - 139 0 0.0 S irq_thread irq/11-srcsII

1075 1075 TS - 0 19 0 99.5 Rs - pkgd

1079 1079 TS - 0 19 0 0.0 Ss+ n_tty_read getty

1093 1093 TS - 0 19 0 0.0 Ss poll_schedule_ sshd

1097 1097 TS - 0 19 0 0.0 Ss+ poll_schedule_ sh

1146 1146 TS - 0 19 0 0.0 S bdi_writeback_ flush-3:0

1177 1177 TS - 0 19 0 0.0 Ss poll_schedule_ sshd

1181 1181 TS - 0 19 0 0.0 Ss wait sh

1182 1182 TS - 0 19 0 0.0 Sl+ futex_wait_que mc

1182 1184 RR 1 - 41 0 0.0 Sl+ wq_sleep jexec

1182 1186 RR 25 - 65 0 0.0 Sl+ semtimedop tErrHndl

1182 1187 RR 16 - 56 0 0.0 Sl+ semtimedop tLogger

1182 1188 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ cli

1182 1189 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp

1182 1190 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut

1182 1191 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp2

1182 1192 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut2

1182 1193 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp0

1182 1194 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut0

1182 1195 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp3

1182 1196 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut3

1182 1197 RR 16 - 56 0 0.0 Sl+ wait_for_packe RbootPd

1182 1198 RR 16 - 56 0 0.0 Sl+ poll_schedule_ tVirtualInp

1182 1199 RR 26 - 66 0 0.0 Sl+ hrtimer_nanosl tBit

1182 1200 RR 27 - 67 0 0.4 Sl+ semtimedop tSpy

1182 1201 RR 21 - 61 0 0.1 Sl+ semtimedop tScHandler

1182 1202 RR 20 - 60 0 0.0 Sl+ semtimedop tScServer

1182 1203 RR 21 - 61 0 0.3 SNl+ sercosII_read sercosFun

1182 1204 RR 23 - 63 0 0.0 SNl+ semtimedop MotManager

1182 1207 RR 28 - 68 0 0.1 SNl+ semtimedop tRecPeriodic

1182 1208 RR 29 - 69 0 0.0 SNl+ semtimedop tEvent

1210 1210 TS - 0 19 0 0.6 Ss poll_schedule_ sshd

1214 1214 TS - 0 19 0 0.0 Ss wait sh

1215 1215 TS - 0 19 0 0.0 S+ wait sh

1216 1216 TS - 0 19 0 0.0 R+ - ps

The "threads" is actually a shortcut for the following ps command:

ps -axH -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm

The above command presents the following information for each task in the operating system:

pid = process id of the parent not-detached task

tid = process id of the task within parent task – what we refer as thread.

class = scheduling class. TS = OTHER, RR = round robin, FF = fifo. - = not reported

rtprio = real time priority, ranging from 99 to 0. When 99 is strongest.

ni = niceness. Ranging from -19 to 20.

pri = static priority.

psr = processor id.

pcpu = overall cpu usage

stat = process state. R for runnable or S for sleeping, Z for zombie.

wchan = kernel function where process is waiting. If process is running a dash is displayed

comm = name of process

If you wish to sort the list by the processes real time priority, use the following command:

threads | sort –k4

This command sorts the list according by the fourth column.

Kill

To terminate a running process use the kill command. Kill needs the process id , so many times you can simply type:

kill -9 $(pidof mc)

Which means, kill anyway, the mc by its process id.

Top

top is an interactive view of displaying system tasks. It refreshes the list every 1 or more second.

~ # top

top - 09:21:51 up 1:17, 4 users, load average: 1.04, 1.03, 1.01

Tasks: 42 total, 2 running, 40 sleeping, 0 stopped, 0 zombie

Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

Mem: 505536k total, 49120k used, 456416k free, 860k buffers

Swap: 0k total, 0k used, 0k free, 12288k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

1075 root 20 0 1528 196 148 R 98.9 0.0 77:03.44 pkgd

1056 root RT 0 0 0 0 S 2.0 0.0 0:05.73 irq/11-srcsII

1 root 20 0 2076 520 460 S 0.0 0.1 0:01.17 init

2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd

3 root RT 0 0 0 0 S 0.0 0.0 0:07.44 ksoftirqd/0

5 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/u:0

6 root -17 0 0 0 0 S 0.0 0.0 0:00.00 posixcputmr/0

7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper

8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:1

125 root 20 0 0 0 0 S 0.0 0.0 0:00.00 sync_supers

127 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default

128 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd

135 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff

142 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd

248 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kworker/0:1

268 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0

269 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark

271 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto

Top displays a nice summary before the list. Memory usage, cpu usage and so on. Important information is found in this line

Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

For example:

us is the Cpu usage in user space here is 29.6%

sy is the cpu usage in kernel space is 70%

ni is the niceness of last process

wa is io wait which is the amount of time system is waiting for IO to complete.

hi is hardware interrupt usage

si is soft irqs usage

st is virtualization usage ( always zero in mib)

htop

htop is like top but more interactive. You can asks for different sorting keys, like sort by memory usage, sort by cpu usage and so on.

[[Image:]]

Type F6 and toy with it.

Display process’s maps

To watch a process’ segmented allocation use the following commands:

~ # cat /proc/$(pidof mc)/maps

08048000-08429000 r-xp 00000000 03:01 13462 /usr/bin/mc

08429000-08558000 rwxp 003e1000 03:01 13462 /usr/bin/mc

08558000-085ed000 rwxp 00000000 00:00 0

09afd000-0b060000 rwxp 00000000 00:00 0 [heap]

b5a1c000-b5a1d000 ---p 00000000 00:00 0

b5a1d000-b5a24000 rwxp 00000000 00:00 0

b5a24000-b5a25000 ---p 00000000 00:00 0

b5a25000-b5a30000 rwxp 00000000 00:00 0

b5a30000-b5a31000 ---p 00000000 00:00 0

b5a31000-b5a3c000 rwxp 00000000 00:00 0

b5a3c000-b5a3d000 ---p 00000000 00:00 0

b5a3d000-b5a48000 rwxp 00000000 00:00 0

b5a48000-b5a49000 ---p 00000000 00:00 0

b5a49000-b5a58000 rwxp 00000000 00:00 0

b5a58000-b5a59000 ---p 00000000 00:00 0

b5a59000-b5a5c000 rwxp 00000000 00:00 0

b5a5c000-b5a5d000 ---p 00000000 00:00 0

b5a5d000-b5a64000 rwxp 00000000 00:00 0

b5a64000-b5a65000 ---p 00000000 00:00 0

b5a65000-b5a6c000 rwxp 00000000 00:00 0

b5a6c000-b5a6d000 ---p 00000000 00:00 0

b5a6d000-b5a74000 rwxp 00000000 00:00 0

b5a74000-b5a75000 ---p 00000000 00:00 0

b5a75000-b5a80000 rwxp 00000000 00:00 0

b5a81000-b5a82000 ---p 00000000 00:00 0

b5a82000-b5aa5000 rwxp 00000000 00:00 0

b5aa5000-b5aa6000 ---p 00000000 00:00 0

b5aa6000-b5ac1000 rwxp 00000000 00:00 0

b5ac1000-b5ac2000 ---p 00000000 00:00 0

b5ac2000-b5ac9000 rwxp 00000000 00:00 0

b5ac9000-b5aca000 ---p 00000000 00:00 0

b5aca000-b5aed000 rwxp 00000000 00:00 0

b5aed000-b5aee000 ---p 00000000 00:00 0

b5aee000-b5af5000 rwxp 00000000 00:00 0

b5af5000-b5af6000 ---p 00000000 00:00 0

b5af6000-b5b19000 rwxp 00000000 00:00 0

b5b19000-b5b1a000 ---p 00000000 00:00 0

b5b1a000-b5b21000 rwxp 00000000 00:00 0

b5b21000-b5b22000 ---p 00000000 00:00 0

b5b22000-b5b45000 rwxp 00000000 00:00 0

b5b45000-b5b46000 ---p 00000000 00:00 0

b5b46000-b5b4d000 rwxp 00000000 00:00 0

b5b4d000-b5b4e000 ---p 00000000 00:00 0

b5b4e000-b5c18000 rwxp 00000000 00:00 0

b5c18000-b5c19000 ---p 00000000 00:00 0

b5c19000-b6418000 rwxp 00000000 00:00 0

b6418000-b6419000 ---p 00000000 00:00 0

b6419000-b6420000 rwxp 00000000 00:00 0

b6420000-b6421000 ---p 00000000 00:00 0

b6421000-b6429000 rwxp 00000000 00:00 0

b6429000-b642a000 ---p 00000000 00:00 0

b642a000-b642d000 rwxp 00000000 00:00 0

b642d000-b742d000 rwxs fffe9000000 00:12 2311 /dev/sercosII

b742d000-b742e000 ---p 00000000 00:00 0

b742e000-b7435000 rwxp 00000000 00:00 0

b7435000-b7436000 ---p 00000000 00:00 0

b7436000-b7544000 rwxp 00000000 00:00 0

b7544000-b7679000 r-xp 00000000 03:01 10172 /lib/libc-2.13.so

b7679000-b767a000 ---p 00135000 03:01 10172 /lib/libc-2.13.so

b767a000-b767c000 r-xp 00135000 03:01 10172 /lib/libc-2.13.so

b767c000-b767d000 rwxp 00137000 03:01 10172 /lib/libc-2.13.so

b767d000-b7680000 rwxp 00000000 00:00 0

b7680000-b769b000 r-xp 00000000 03:01 12467 /lib/libgcc_s.so.1

b769b000-b769c000 rwxp 0001a000 03:01 12467 /lib/libgcc_s.so.1

b769c000-b76c1000 r-xp 00000000 03:01 14763 /lib/libm-2.13.so

b76c1000-b76c2000 r-xp 00024000 03:01 14763 /lib/libm-2.13.so

b76c2000-b76c3000 rwxp 00025000 03:01 14763 /lib/libm-2.13.so

b76c3000-b779b000 r-xp 00000000 03:01 9190 /usr/lib/libstdc++.so.6.0.14

b779b000-b779f000 r-xp 000d7000 03:01 9190 /usr/lib/libstdc++.so.6.0.14

b779f000-b77a0000 rwxp 000db000 03:01 9190 /usr/lib/libstdc++.so.6.0.14

b77a0000-b77a8000 rwxp 00000000 00:00 0

b77a8000-b77b0000 r-xp 00000000 03:01 16731 /lib/libcrypt-2.13.so

b77b0000-b77b1000 r-xp 00007000 03:01 16731 /lib/libcrypt-2.13.so

b77b1000-b77b2000 rwxp 00008000 03:01 16731 /lib/libcrypt-2.13.so

b77b2000-b77d9000 rwxp 00000000 00:00 0

b77d9000-b77ed000 r-xp 00000000 03:01 17714 /lib/libpthread-2.13.so

b77ed000-b77ee000 r-xp 00013000 03:01 17714 /lib/libpthread-2.13.so

b77ee000-b77ef000 rwxp 00014000 03:01 17714 /lib/libpthread-2.13.so

b77ef000-b77f1000 rwxp 00000000 00:00 0

b77f1000-b77f7000 r-xp 00000000 03:01 13450 /lib/librt-2.13.so

b77f7000-b77f8000 r-xp 00005000 03:01 13450 /lib/librt-2.13.so

b77f8000-b77f9000 rwxp 00006000 03:01 13450 /lib/librt-2.13.so

b77f9000-b77fb000 r-xp 00000000 03:01 17388 /lib/libdl-2.13.so

b77fb000-b77fc000 r-xp 00001000 03:01 17388 /lib/libdl-2.13.so

b77fc000-b77fd000 rwxp 00002000 03:01 17388 /lib/libdl-2.13.so

b77fd000-b7817000 r-xp 00000000 03:01 16404 /lib/ld-2.13.so

b7817000-b7818000 rwxp 00000000 00:00 0

b7818000-b7819000 r-xp 0001a000 03:01 16404 /lib/ld-2.13.so

b7819000-b781a000 rwxp 0001b000 03:01 16404 /lib/ld-2.13.so

bfd20000-bfd41000 rwxp 00000000 00:00 0 [stack]

ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]

From left to tight:

  1. The segment ( also known as vma ) memory addresses
  2. The segment permission
  3. The segment offset into the file
  4. The block device major/minor holding the file
  5. The size of the segment

chrt

change real time priority. You can control a processes scheduling class and priority level from the command line.

For example:

Ksoftirq is a kernel daemon that is widely used in the kernel.

~ # threads |grep sof

3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0

ksoftirq pid is 3. Its real time priority is 99. So , let say we wish to change its priority to 19.

~ # chrt -r -p 19 3

pid 3's current scheduling policy: SCHED_RR

pid 3's current scheduling priority: 99

pid 3's new scheduling policy: SCHED_RR

pid 3's new scheduling priority: 19

and indeed priority changed.

~ # threads | grep sof

3 3 RR 19 - 59 0 0.1 S run_ksoftirqd ksoftirqd/0

 

Network

ssh sshd and scp

Secure shell is used to access remote machines. Sshd is service running in the target MIB and ssh is the client. You can login (perform ssh) to a MIB and login from a MIB to any other Linux machine. You can copy files with scp to and from Linux machines.

To login to MIB ip 10.4.20.240 from any Linux machine enter:

~ # ssh root@10.4.20.240

The authenticity of host '10.4.20.240 (10.4.20.240)' can't be established.

RSA key fingerprint is ef:f6:72:7f:64:7a:21:d4:8b:c3:b2:db:cf:a0:0f:99.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '10.4.20.240' (RSA) to the list of known hosts.

root@10.4.20.240's password:

the first you will asked is enter yes/no. this happens only in the first time you access a remote machine. Enter “yes” and then you will be asked to enter a password, please do. Once entered, you will be in the MIB running in root privileges.

To copy files from Linux machine to another Linux machine in the command line we use scp command: for example, the command:

scp –r /tmp root@10.4.20.240:/root/

will copy tmp directory to to root directory in target machine. The “-r” means recursive copy, which is how we copy directories.

If you copy files from a windows machine to a linux machine you should use winscp.

winscp

The first window displays a list machines that were accessed previously. If this is the first time you use winscp this list is empty. To copy files to 10.4.20.240 please click on the New button.

winscp

Fill the MIB’s ip. The user name “root”, the password, and change the protocol from sftp to scp. Click on “Save” to save the new machine in the list and then click on Login.

winscp

You will windows saying that the command “group” returned error, disregard it, it is because MIB does not have group command, after that you will have the above screen. Now you can simply drag and drop files.

Route

To watch the routing tables just type “route” or “netstat –r”. Here is route output in MIB

Ip 10.4.20.240.

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

10.0.0.0 * 255.0.0.0 U 0 0 0 eth0 As the reader can see, there is not default route, so if we try to access a different network segment will be getting “unreachable network” . We can only access network on the 10.x.x.x. because the netmask is 255.0.0.0. The only Ethernet interface a MIB has is eth0.

 

tcpdump

tcpdump is a packet capture program. To capture packets simply type:

tcpdump

this will fill screen with traffic captures. If you use ssh to access the machine you will see ssh traffic as well. So you probably want to filter out this ssh traffic. To do that enter:

tcpdump ip –i eth0 and not port 22

Which means, capture all traffic on interface eth0, but drop any traffic on directed to port 22.

There are many other ways to capture traffic. Sometimes you need to capture the traffic and want to analize it later with better tools, like wireshark. For this please enter:

tcpdump ip –i eth0 and not port 22 –w foo.cap

This means that the captured data will be passed to a file called foo.cap.

 

ethtool

ethtool is used to query and control network interfaces.

~ # ethtool eth0

Settings for eth0:

  Supported ports: [ TP MII ]

Supported link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Supports auto-negotiation: Yes

Advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Advertised pause frame use: Symmetric

Advertised auto-negotiation: Yes

Link partner advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Link partner advertised pause frame use: Symmetric

Link partner advertised auto-negotiation: Yes

Speed: 100Mb/s

Duplex: Full

Port: MII

PHYAD: 1

Transceiver: internal

Auto-negotiation: on

Supports Wake-on: g

Wake-on: g

Current message level: 0x00000007 (7)

Link detected: yes

Common use for it is checking the link type, 10/100/1000 Mbps and if the network is actually up (Last line: Link Detected).

Boot

Linux MIB boot is a two-phase boot. Once the computer passed the POST stage (Power On Self Test) it passes the control to the operating system. The first operating system is actually a boot loader. The boot loader is called grub – “grand unified boot loader”. Grub has one main purpose, to boot Linux. At the moment, the MIB hardware prevents us from seeing the grub loads. When grub loads it splashes a menu to screen (it is called splashing). This menu is kept in /boot/grub/menu.lst which is accessible through the LinuxMIB.

~ # cat /boot/grub/menu.lst

serial --unit=0 --speed=115200

terminal --timeout=0 serial console

default 0

timeout 0

color cyan/blue white/blue

title Standalone Boot

root (hd0,0)

kernel /boot/bzImage root=/dev/hda1,/dev/hdc1 console=ttyS0,115200

title Network Boot

ifconfig --server= --gateway= --mask= --address=

root (nd)

kernel (nd)/linux root=/dev/nfs console=ttyS0,115200 ip=:::::eth0: nfsroot=

~ #

The boot loader menu has two entries, the first entry boots Linux from the disk, and the second one boots Linux from the network. The first one is the default one.

Grub boots the kernel by loading the kernel file (bzImage) to the main memory and passing it some parameters. Current parameters are:

root=/dev/hda1,/dev/hdc1 console=ttyS0, 115200

This means that the kernel search for a root file system in a block device called /dev/hda1 and if it fails it tries /dev/hdc1. The “console=” means that the rs232 input and output redirected through a device file called /dev/ttyS0 in 115200 speed. These parameters are kernel parameters and do not relate to grub.

 

BSP

The board specific package I used to create the MIB is Pengutronix. Pengutronix is software builds an entire Linux distribution from scratch. Linux MIB software does not contain any binaries with the sources. So, in this section I will describe how to build the MIB bsp and MC in the virtual disk I supply for this.

Virtual Build Machine

The virtual machine I use to virtual box. Please download and install it. The virtual machine is composed from two virtual disks, mib.vdi and buildDisk.vdi. The mib.vdi is 50MB disk, and buildDisk.vdi is 2 GB disk. This is because the build objects consume a lot of storage. Both disks can be found at //domainaxy/IL/MC/linux/buildmachine . Access to virtual machine is done through the terminal or through ssh with user root , no password required.

Virtual Box Configuration

storage

vbox

Network

vbox

share

vbox

The guest gets static IP 192.168.56.101 . It is accessible only from the host. We decided to use this configuration as it simplifies things. If you wish to have the Linux connect to the network choose network card attached as bridge and choose intel PRO/1000 MT Desktop.

To have the virtual build machine access s shared folder in the host machine, please add a share name called amcs to whatever folder you wish.

The “amcs” share will mount automatically. Any other share has to be mounted manually in the guest:

mount.vboxsf <share name> <mount point>

Virtual Linux Configuration

The virtual disk containing the toolchain is called toolchain.vdi. Once you boot the virtual build machine you need to make sure build disk is mounted. So check is /opt directory contains OSELAS toolchain. Also, please check the you have network access (with ifconfig) .If all well, please check if you can connect with ssh.

 

Building MC

  1. Make sure amcs share is mounted and contains all required sources. Make sure the toolchain is mounted on /opt.

~ # df

Filesystem 1K-blocks Used Available Use% Mounted on

udev 191428 112 191316 0% /dev

tmpfs 76572 144 76428 0% /run

/dev/sda1 147415 85218 54697 61% /

none 191428 0 191428 0% /tmp

none 191428 0 191428 0% /var/log

none 191428 16 191412 0% /var/run

none 191428 0 191428 0% /var/lock

none 191428 0 191428 0% /var/tmp

tmpfs 191428 112 191316 0% /dev

'/dev/sdb 8256952 1784056 6053468 23% /opt'

none 4217028 1366328 2850700 32% /media

Change directory to mc sources (inside the amcs share) or clone them from the linux. if this is the first time you build these sources please configure the build as follows:

$ sh run_configure_all and now you can build these sources:

$ make –j2

If you wish to configure eclipse ontop of the virtual box please refer to this document: Eclipse Stand Alone Linux

Once you’re done, you need to copy the binary to the target machine if you have external networking.

scp mc root@10.4.20.240:/usr/bin/mc

else use eclipse terminal to copy.

 

Troubleshoot

run_configure_all

If run_configure_all fails with numerous errors, edit in linux, and remove all ^M signs.

Out Of memory

Incase during the build you see a message “out of memory” please remove the –j from the make and remake or increase the virtual machine RAM.

Out of disk space

You are probably building on the virtual machine disk. Change to share directory.

Toolchain

The toochain is installed in the /opt/ directory. This requirement is strict and I do not support any other configuration. The toolchain we use is:

Gcc 4.52

Glibc 2.13

Binutils 2.13

Sanitized kernel headers 2.6.36

Your /opt/ directory should contain a directory called:/opt/OSELAS.Toolchain-2011.03.1/.

 

The BSP

To build the entire bsp you need a linux ubunto server. Building the bsp on a virtual box running ubunto is possible but will take a long time.

You can find the toolchain tar ball

//domainaxy/IL/MC/linux/buildmachine/OSELAS.Toolchain-2011.03.1.tar

Copy it and extract it in the ubunto :

$ sudo tar xvf OSELAS.Toolchain-2011.03.1.tar –C /opt/

Now, clone the bsp:

git clone git@10.4.20.38:/home/git/bsp.git

to build the bsp master branch :

cd bsp/

ptxdist go

at the end of the process you will have linuximage in platform-i586/images. This is not enough as you need to build to full image , for this run the bellow command:

ptxdist images

the image is hd.img. To burn it to the sdcard please:

sudo dd if=platform-i586/images/hd.img of=/dev/sdX

when /dev/sdX is the sdcard device name. if you don’t the device name, do not bother dd’ing, you will probably destroy the build server.

Once you dd’ed, please sync and eject:

sync

eject /dev/sdX

Replicate an image

There are times where one wishes to replicate an existing image. To do that he must copy the source image as file to some Linux machine using dd and then burn the source file image to new card. Here are the steps to do that:

  1. Place in the card reader the source flash card. Linux will notice a new disk was pushed in.
  2. dmesg and look for the new disk name, like /dev/sdd or/dev/sdb.

It will appear in the bottom of the dmesg log, for example:

  [422238.883418] sd 9:0:0:0: [sdd] Assuming drive cache: write through

  [422238.883423] sd 9:0:0:0: [sdd] Attached SCSI removable disk

  [422470.346994] EXT3-fs: barriers not enabled

  [422470.735075] kjournald starting. Commit interval 5 seconds   [422470.735121] EXT3-fs (sdd1): warning: maximal mount count reached, running e2fsck is recommended

  [422470.736077] EXT3-fs (sdd1): using internal journal

  [422470.736083] EXT3-fs (sdd1): recovery complete

  [422470.737199] EXT3-fs (sdd1): mounted filesystem with ordered data mode

The device ( disk ) in my machine is /dev/sdd. It has a single partition called /dev/sdd1.

 

  1. Now copy the card to a file using dd: for example, if my disk name is /dev/sdb I enter:

$ dd if=/dev/sdb bs=1M of=/tmp/hd.img

$ sync

  1. Now pull out the source sd card, and place the new card.
  2. Push back the target flash card, and then:

$ dd if=/tmp/hd.img of=/dev/sdb

$ sync

 

How to edit files in MIB

There are cases where a user needs to edit a text file in the LinuxMIB. LinuxMIB has two editors, nano and vi.

vi is considered more powerfull than nano. Yet, I believe that the regular user should start with nano as it is more intuitive.

Upgrade Linux MIB

Linux MIB is shipped with a debian based packaging system. This means that to any update is wrapped with ipkg. Once the package is ready, simply copy the package file to the target to the inbox directory.

scp mc-4.9.0-linux.ipk 10.4.20.240:/inbox/ or by drag-and-drop through windows operating system with winscp.

Packaging is triggered automatically. I wrote a package manager daemon that listens on /inbox directory and if a new file is put there it tries to install it.

You can list the packages with the following command:

dpkg -l

Currently you cannot uninstall a package, you have to remove the files manually.I believe it is a pengutronix bug.

Control MC Start

One of the first things a programmer does when developing is disabling the automatic start of the application he is debugging. In manz case it is mostly the mc.

There are two ways to disable automatic starting:

 

  1. Each time you boot.

  # ~ /etc/init.d/mc stop

  1. Edit /etc/init.d/mc script and remark the mc launching as follows:

start)

/etc/init.d/run_config

  # nohup /bin/sh /usr/bin/mc.sh &

Add # before the nohup as depicted in the line above.

Debugging

Debugging mc can mostly with eclipse. Please refer to eclipse documentation to learn how to do that.

Logs

In addition to the log files in /RAM file system. We added a linux-like logger which can be found at /var/syslog.

 

Core files

A core file is a snapshot of the process memory when it crashed. It is a post mortem debugging method commonly used. All cores files are generated to /cores directory. There will no more than 5 cores. The 6-th core is written on the first core.

To debug a core dump you must compile the same mc with debug info and copy the core file to the ubunto ( virtual build machine is not suitable for that ). Then type:

gdb mc coredump

 

Memory Detector

To debug memory leaks you need valgrind. Valgrind is not installed as is in the bsp, simply take a package and put it in the target. If you do not know how to use valgrind I suggest you refer to valgrind web site. It is beyond the scope of this paper.

 

MC cli

MC Linux is shipped with a telnet server. This telnet server resembles the vxworks terminal.

To login please:

~ # telnet localhost:8000

Entering character mode

Escape character is '^]'.

AMCS shell

User name is root and password qwerty.

Username: root

Password:

The telnet is evolving and the command may differ from one version to another but to get help you can simply type help.

> help

Commands available:

help Show available commands

logout Disconnect

history Show a list of previously run commands

threads print all threads

stack trace print the stack of a given thread

p print a symbol

exit exit the process

>

 

Profiling

Profiling MC can be done with oprofile. To use oprofile you need to boot a kernel with oprofile support, and replace the drivers. For this you will have to install a package called kernel-oprofile.ipk and boot this kernel.

To use oprofile please:

$ opcontrol –reset

$ opcontrol –deinit

$ opcontrol –init

Now to choose type of event you should make sure your processor support this type of event – if any.

$ opcontrol –list-events

Let say you wish to check memory references.

$ opcontrol –event:DATA_MEM_REFS:30000

The above command sets the event memory references each time the a a hardware counter finish counting to 30000.

$ opcontrol –session-dir=/home/myoprofile

$ opcontrol –sparate=cpu

$ opcontrol –callgraph=10

$ opcontrol –novmlinux

$ opcontrol –start

./prog..

$ opcontrol –stop

Now copy the entire profiling results to your local machine home user.

$ opreport –session-dir=/home/raz/myprofile

CPU_CLK_UNHALT...|LLC_MISSES:466500|

samples| %| samples| %|

  ------------------------------------

943 100.000 1 100.000 prog

CPU_CLK_UNHALT...|LLC_MISSES:466500|

samples| %| samples| %|

  ------------------------------------

709 75.1856 1 100.000 prog
234 24.8144 0 0 libc-2.11.1.so

To get annotation per line use, run this from the mc directory. This way opannotate will find the source code.

$ opanotate –s session-dir=/home/raz/myprofile

Please note if you intend to use oprofile please read the tutotial as it is beyond the spec of this paper.

ftrace

I do not want to write what is ftrace in this book, please refer to the ftrace tutorials to do that:

Here are the steps to ftrace.

Boot the same kernel as the one for ftrace.

$ mount –t debugfs /sys/kernel/debug /debug

$ cd /debug/tracing/

$ echo 0 > tracing_on

$ echo function > current_tracer

$ echo 1 > tracing_on

….

$ echo 0 > tracing_on

File “trace” contains the tracing information. It a huge text file:

$ cat trace

A visual view for ftrace output is known as kernelshark.

To use it please issue the bellow command after you are done with the trace.

$ trace-cmd extract

A local file named trace.dat is created . copy it to your ubunto and launch kernelshard.

$ kernelshark trace.dat