Friday, April 22, 2011

SBR600 Project - Release 0.3 :: How My Package Works

Hello,
I thought that it can be useful if I explain about my spec file and describe the major parts of this file for more clarification. It is simple. If the Arch is ARM, it follows the lines bellow. If the Arch is not ARM, it continues as a regular kernel package like before.
You can download my spec file from this link:  SPEC File
I am going to explain the major parts. I took the following lines from spec file (explanations are after commands which are started with #:

%prep
%setup -q
mkdir -p tmp
#Here, I made a temporary file for saving module files for later use. Modules files #are created by kernel and we will use that with dracut to make initramfs or #ramdisk.
%build
make ARCH=arm omap3_beagle_defconfig
#configuration of kernel source for a particular architecture, which is ARM in #this case, and select the config file. In this case, I selected #omap3_beagle_defconfig for my ARM board.
make clean
make uImage
#Compile the kernel. If you are testing on your own computer (different #architecture than ARM), you should use CROSS COMPILE
make modules
#Compile kernel modules
make modules_install INSTALL_MOD_PATH=tmp
#Install the modules into tmp directory that I mentioned above for later use.
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}/boot
#Prepare /boot directory for installing kernel and initramfs
cp arch/arm/boot/uImage %{buildroot}/boot/uImage-%{version}
#Copy the compiled kernel to the /boot directory with proper name.
ln -f %{buildroot}/boot/uImage-%{version} %{buildroot}/boot/uImage.bin
#Keep track of each installation of kernel by using ln command and make the last #one as a default for kernel
#mkdir -p %{buildroot}/%{_sysconfdir}
#cp -p %{SOURCE1} %{buildroot}/%{_sysconfdir}
#These two lines are not usable for release 0.3, but I mentioned here because I #used in previous versions. Because I wanted to make a small initramfs, I used a #small version of dracut.conf for using during the installation of package. So, I #imported dracut.conf by SOURCE1 and copied into the /etc directory.
mkdir -p %{buildroot}/lib/modules/%{version}
#Make a directory for copying the modules from tmp directory to proper #destinations.
cp -p -r tmp/lib/modules/%{version}/* %{buildroot}/lib/modules/%{version}
#Copy modules
%post
dracut -H -f /boot/initramfs-%{version}.img %{version}
#Making initramfs by dracut for last kernel
ln -f /boot/initramfs-%{version}.img /boot/initramfs.img
#keep track of each initramfs by using ln command and select the last one as a #default.

I hope you enjoyed from this article.
Best regards,
Khosro Taraghi

SBR600 Project Release 0.3


Hello Everybody,

Today, I released my SBR600 project version 0.3. I tested my last package several times and it worked successfully. It was actually an extension of my project version 0.2. Not only I changed version 0.2 to works with any kernel, including the new kernels, but also I merged my package with primary kernel package. So, when the Arch is ARM, it installs my package (RPM-based kernel for ARM) and when the Arch is something else, it works as a regular kernel installation. In other words, I could create a RPM-based kernel for ARM which was my project. I built my package on both ARM and Primary architecture to make sure that it works.
This is the output of "ll" command before installing of last version of kernel in my ARM board:

[root@fedora-arm khosro]# ll /boot/
total 7824
drwxr-xr-x 2 root root 4096 Apr 14 2011 grub
-rw-r--r-- 1 root root 2071652 Apr 14 2011 initramfs-2.6.32.img
-rw-r--r-- 1 root root 2071652 Apr 14 2011 initramfs.img
-rw-r--r-- 1 root root 1909048 Apr 14 2011 uImage-2.6.32
-rw-r--r-- 1 root root 1909048 Apr 14 2011 uImage.bin

And here is the output of "ll" command after installing my package which shows the new files: (pay attention to link files):

[root@fedora-arm ~]# ll /boot/
total 11900
drwxr-xr-x 2 root root 4096 Apr 14 2011 grub
-rw-r--r-- 1 root root 2071652 Apr 14 2011 initramfs-2.6.32.img
-rw-r--r-- 2 root root 2070985 Dec 31 1999 initramfs-2.6.35.img
-rw-r--r-- 2 root root 2070985 Dec 31 1999 initramfs.img
-rw-r--r-- 1 root root 1909048 Apr 14 2011 uImage-2.6.32
-rw-r--r-- 2 root root 2003236 Apr 21 2011 uImage-2.6.35
-rw-r--r-- 2 root root 2003236 Apr 21 2011 uImage.bin

The 2.6.35 is the last version of kernel up to this point that I wrote this blog.
Now, this is the output of booting my ARM board with new kernel (also, pay attention to “uname” command after logging to system):

## Booting kernel from Legacy Image at 80200000 ...
Image Name: Linux-2.6.35
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2003172 Bytes = 1.9 MB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 81600000 ...
Image Name: boot initramfs
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 2631748 Bytes = 2.5 MB 
Load Address: 81600000
Entry Point: 81600000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Data Size: Linux version 2.6.35 (mockbuild@koji3.laptop.org) (gcc version 4.4.5 20101112 (Red Hat 4.4.5-2) (GCC) ) #1 Thu Apr 21 14:40:04 EDT 2011
CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), cr=10c53c7f
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: OMAP3 Beagle Board
Memory policy: ECC disabled, Data cache writeback
OMAP3430/3530 ES3.1 (l2cache iva sgx neon isp )
SRAM: Mapped pa 0x40200000 to va 0xfe400000 size: 0x100000
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024
Kernel command line: console=ttyS2,115200n8 root=/dev/mmcblk0p2 rootfstype=ext2 eq rootdelay=1 nohz=off
PID hash table entries: 1024 (order: 0, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128MB 128MB = 256MB total
Memory: 253360k/253360k available, 8784k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xd0800000 - 0xf8000000 ( 632 MB)
lowmem : 0xc0000000 - 0xd0000000 ( 256 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc0027000 ( 124 kB)
.text : 0xc0027000 - 0xc037d000 (3416 kB)
.data : 0xc0394000 - 0xc03c58c0 ( 199 kB)
Hierarchical RCU implementation.
Verbose stalled-CPUs detection is disabled.
NR_IRQS:402
Clocking rate (Crystal/Core/MPU): 26.0/332/720 MHz
omap_hwmod: l3_hwmod: cannot be enabled (3)
omap_hwmod: l4_core_hwmod: cannot be enabled (3)
omap_hwmod: l4_per_hwmod: cannot be enabled (3)
omap_hwmod: l4_wkup_hwmod: cannot be enabled (3)
Reprogramming SDRC clock to 332000000 Hz
GPMC revision 5.0
IRQ: Found an INTC at 0xfa200000 (revision 4.0) with 96 interrupts
Total of 96 interrupts on 1 active controller
OMAP GPIO hardware version 2.5
OMAP clockevent source: GPTIMER12 at 32768 Hz
Console: colour dummy device 80x30
Calibrating delay loop... 742.58 BogoMIPS (lpj=2899968)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
regulator: core version 0.5
NET: Registered protocol family 16
Found NAND on CS0
Registering NAND on CS0
Unable Setting up Logical Volume Management: No volume groups found
[ OK ]
Checking filesystems
Checking all file systems.
[/sbin/fsck.ext2 (1) -- /] fsck.ext2 -a /dev/mmcblk0p2
/dev/mmcblk0p2: Superblock last mount time is in the future.
(by less than a day, probably due to the hardware clock being incorrectly set) FIXED.
/dev/mmcblk0p2: Superblock last write time is in the future.
(by less than a day, probably due to the hardware clock being incorrectly set). FIXED.
/dev/mmcblk0p2: clean, 46024/425152 files, 301506/1699840 blocks (check after next mount)
[ OK ]
Remounting root filesystem in read-write mode: [ OK ]
Mounting local filesystems: [ OK ]
Enabling /etc/fstab swaps: [ OK ]
Entering non-interactive startup
FATAL: Module ipv6 not found.
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
FATAL: Module ipv6 not found.
Mounting other filesystems: [ OK ]
Retrigger failed udev events[ OK ]
Starting sshd: [ OK ]

Fedora release 13 (Goddard)
Kernel 2.6.35 on an armv7l (console)
fedora-arm login: root
Password:
Last login: Fri Dec 31 19:01:49 on console
[root@fedora-arm ~]# uname -a
Linux fedora-arm 2.6.35 #1 Thu Apr 21 14:40:04 EDT 2011 armv7l armv7l armv7l GNU/Linux

These are the pictures form koji that shows my successful build:





These are the all links for downloading packages for release 0.3:
Thanks to everyone who helped me on this project, especially Chris Tyler.

Best Regards,
Khosro Taraghi
 



 


Monday, April 4, 2011

A Rough RPM-based Kernel for Fedora ARM - Release 0.2 SBR600 Project

Hello,
I already made a RPM package for kernel 2.6.32 which is installed in ARM architecture. This is a rough package which means I used some hardcode instead of macros since I was experimenting with this. However, it is very close to final package (I hope). I released this package for my SBR600 project as release 0.2. It installs kernel 2.6.32 and initramfs in your Beagle ARM board and changes your current kernel version to 2.6.32. It keeps the previous version too. Here is a brief explanation about my spec file that I hope it would be useful for you. Also, at the end, I added my spec and srpm files so that you can download them for further review.
I will focus on important parts of spec file:
  1. %prep:   Make a temporary directory for kernel modules so that they will use later for dracut
  2. %build:   Make config file for kernel, compile kernel, make modules, install modules for later use via dracut
  3. %install:  Preparing /boot directory and copying kernel, using "ln" command to keep track of installed kernels, preparing /etc directory for copying dracut.conf in this directory, and preparing installed modules with kernel for ARM which is used with dracut
  4. %post:   Install initramfs with dracut and use "ln" command to keep track of each installed initramfs
These are my spec, rpm, and srpm files: spec file, rpm file, and srpm file
This is a picture of koji that shows I made package successfully.

I will post more details very soon.

Best Regards,
Khosro Taraghi

Sunday, April 3, 2011

Fedora/ARM Cross Toolchain - Cross-compiling for ARM

Hello,
These are quick instructions to install Fedora/ARM cross toolchain in your computer if your computer has i386 or x86_64 architecture. So, after installation, you are able to cross compile your source code for ARM architeture in your i386 or x86_64 computer. These are the commands you should run:

# cd /etc/yum.repos.d/
# wget http://ftp.linux.org.uk/pub/linux/arm/fedora/cross/cross.repo
# yum install armv5tel-redhat-linux-gnueabi-gcc
This will install everything necessary to run the C compiler and  cross-build ARM libraries and binaries that are entirely binary  compatible with the native Fedora/ARM libraries and binaries.

Regards,
Khosro Taraghi