Summary
Tried to build and boot zImage on Embedded Linux S3C2440.
Install Buildroot
I tried to compile and install the latest Buildroot by downloading at https://buildroot.org/ , ‘buildroot-2018.02.9.tar.bz2’, the compiling and installation was successful, and change the /etc/profile to below,
PATH=$PATH:/home/iot/buildroot-2018.02.9/output/host/usr/bin
TARGET_DIR=/home/iot/buildroot-2018.02.9/output/target
Note: you cannot use root to compile Buildroot.
But the compiling for busybox and linux kernel by using the latest Buildroot was not successful, as I had a Buildroot 2013.02 ready to use, so I skip this step of installation of Buildroot, use the old Buildroot 2013.02, my Buildroot arm-linux-gcc version is as below,
[root@localhost Buildroot]# arm-linux-gcc -v
......
gcc version 4.7.2 (Buildroot 2013.02)
Compile and install Busybox
[root@localhost iot]#tar xjvf busybox-1.19.4.tar.bz2
[root@localhost busybox-1.19.4]# pwd
/home/iot/mini2440/busybox-1.19.4
[root@localhost busybox-1.19.4]# make menuconfig
Build BusyBox as a static binary and use arm-linux Cross Compiler.
Set the installation prefix to “./_install”
[root@localhost busybox-1.19.4]# make
[root@localhost busybox-1.19.4]# make install
Generating the Root Filesystem
#!/bin/sh
echo "------Create rootfs --------"
rm -fr rootfs
rm initramfs.cpio
mkdir rootfs
pushd rootfs
echo "--------Create root,dev....----------"
mkdir root dev etc boot tmp usr var sys proc lib mnt home
mkdir etc/init.d etc/rc.d etc/sysconfig lib/modules
mkdir usr/sbin usr/bin usr/lib usr/modules
echo "---------Copy from busybox, rootfs-base, libs -----------"
cp -aP /home/iot/mini2440/busybox-1.19.4/_install/* .
ln -s bin/busybox init
ln -s /proc/mounts etc/mtab
cp -arP ../rootfs-base/* /home/iot/mini2440/rootfilesystem/rootfs/
cp /home/iot/mini2440/linux-3.8.7/System.map boot/
#Copy applications
cp /home/iot/mini2440/myapp/greeting usr/bin
cp /home/iot/mini2440/myapp/thread_demo* usr/bin
cp $TARGET_DIR/usr/bin/gdbserver usr/bin
cp $TARGET_DIR/usr/bin/op* usr/bin
cp $TARGET_DIR/usr/bin/ldd usr/bin
cp $TARGET_DIR/usr/bin/objcopy usr/bin
cp $TARGET_DIR/usr/bin/objdump usr/bin
cp /home/iot/mini2440/buildroot-2013.02/output/target/usr/bin/gdbserver usr/bin
cp /home/iot/mini2440/buildroot-2013.02/output/target/usr/bin/ldd usr/bin
cp -P /home/iot/mini2440/buildroot-2013.02/output/target/lib/* lib/
cp -P $TARGET_DIR/lib/* lib/
cp -P $TARGET_DIR/usr/lib/libpopt* usr/lib
cp -P $TARGET_DIR/usr/lib/libbfd* usr/lib
cp -P $TARGET_DIR/usr/lib/libintl* usr/lib
cp -P $TARGET_DIR/usr/lib/libstdc++* usr/lib
cp -P $TARGET_DIR/usr/lib/libz* usr/lib
cp -P $TARGET_DIR/usr/lib/libopcodes* usr/lib
chown -R root.root ../rootfs
echo "---------make node dev/console dev/null-----------------"
mknod -m 600 dev/console c 5 1
mknod -m 600 dev/null c 1 3
chmod 666 dev/console
chmod 666 dev/null
mknod /dev/ptmx c 5 2
mkdir mnt/etc mnt/yaffs mnt/data mnt/temp
mkdir var/lib var/lock var/run var/tmp
chmod 1777 tmp
chmod 1777 var/tmp
# Create cpio image
find . | cpio -H newc -o > ../initramfs.cpio
# Move out of working directory
popd
Above $TARGET_DIR is the Buildroot folder, ‘/home/iot/buildroot-2013.02/output/target’. The script will create root file system, and create cpio image. The cpio image will be used in the Linux kernel compiling.
The rootfile system has a very important startup script,
[root@localhost rootfs-base]# pwd
/home/iot/mini2440/rootfilesystem/rootfs-base
[root@localhost rootfs-base]# vim ./etc/init.d/rcS
#!/bin/sh
echo "* Mounting /proc..."
mount -t proc /proc /proc
echo "* Mounting /dev..."
mount -t tmpfs mdev /dev
echo "* Mounting /sys..."
mount -t sysfs none /sys
echo "* Mounting /dev/pts..."
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo "* Mounting /dev/shm..."
mkdir /dev/shm
mount -t tmpfs none /dev/shm
echo "* Starting system loggers..."
syslogd -C
klogd
echo "* Creating devices..."
echo /sbin/mdev>/proc/sys/kernel/hotplug
/sbin/mdev -s
echo "* Configuring loopback interface..."
ifconfig lo 127.0.0.1
echo "* Setting hostname..."
hostname mini2440
echo "eth0 up"
ifconfig eth0 192.168.0.11 netmask 255.255.255.0 broadcast 192.168.0.255 up
#echo "* Running application start script..."
#/home/start.sh
Compiling the Linux kernel
[root@localhost iot]#tar xjvf linux-3.8.7.tar.bz2
[root@localhost linux-3.8.7]# pwd
/home/iot/mini2440/linux-3.8.7
[root@localhost linux-3.8.7]#
Apply patch, linux-3.8.7.patch.
[root@localhost linux-3.8.7]# patch -p1 <../config-files/linux-3.8.7.patch
Change Makefile to use arm-linux compiler,
[root@localhost linux-3.8.7]# vim Makefile
195 #ARCH ?= $(SUBARCH)
196 #CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
197
198 ARCH ?=arm
199 CROSS_COMPILE ?=arm-linux-
Configure Linux kernel compiling options,
[root@localhost linux-3.8.7]# make menuconfig
Configure ‘initramfs.cpio’.
Configure Samsung S3C24XX.
Compile,
[root@localhost linux-3.8.7]# make
It will return and error, as the compiling cannot locate the newly generated ‘initramfs.cpio’ file in previous step. Use below command,
[root@localhost linux-3.8.7]# ln -s ../rootfilesystem/initramfs.cpio
make again, it will take around 20 minutes to complete the compiling,
[root@localhost linux-3.8.7]# make
The new zImage will be in below folder,
[root@localhost linux-3.8.7]# ll ./arch/arm/boot/
total 15612
drwxrwxr-x. 2 root root 4096 Apr 13 2013 bootp
drwxrwxr-x. 2 root root 4096 Dec 28 15:48 compressed
drwxrwxr-x. 3 root root 12288 Apr 13 2013 dts
-rwxr-xr-x. 1 root root 10811784 Dec 28 15:48 Image
-rw-rw-r--. 1 root root 1274 Apr 13 2013 install.sh
-rw-rw-r--. 1 root root 3167 Apr 13 2013 Makefile
-rwxr-xr-x. 1 root root 5143240 Dec 28 15:48 zImage
[root@localhost linux-3.8.7]#
Download zImage
Startup S3C2440 and enter selection ‘k’,
##### FriendlyARM BIOS 2.0 for 2440 #####
[x] format NAND FLASH for Linux
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[a] Absolute User Application
[n] Download Nboot for WinCE
[l] Download WinCE boot-logo
[w] Download WinCE NK.bin
[d] Download & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the nand flash
[b] Boot the system
[s] Set the boot parameters
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
[i] Version: 1026-2K
Enter your selection: k
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:30000000h,TOTAL:5143250]
RECEIVED FILE SIZE: 5143250 (27KB/S, 180S)
Downloaded file at 0x30000000, size = 5143240 bytes
Found block size = 0x00500000
Erasing... ... done
Writing... ... done
Written 5143240 bytes
Use below command to download new zImage, the software is ‘s3c2410_boot_usb’.
1 #!/bin/sh
2 ./s3c2410_boot_usb linux-3.8.7/arch/arm/boot/zImage
Restart the S3C2440 board to start to use the new zImage.
Reference
Embedded Linux S3C2440 environment setup
Embedded Linux S3C2440 Environment Startup
https://buildroot.org/
tslib 1.18 Github
Is buildroot also working on Virtual machine
Yes, the test was done on Virtual Machine.