kernel
busybox
をビルドしたらrootfs作成へ。
busyboxビルドしたときの_installフォルダに移動。
して下記項目をファイル化して実行する。
>スクリプト内で指定してあるディレクトリは任意の場所に書き換える必要がある。
ツールチェインで使ったライブラリ
・/opt/FriendlyARM/toolchain/4.4.3/arm-none-linux-gnueabi/sys-root/lib/
カーネルuImage
・~/kernel/mini2440
カーネルモジュール
・~/kernel/kernel-modules/
mkdir dev mkdir -p etc etc/init.d etc/network mkdir -p var var/run var/log mkdir -p usr/bin usr/sbin usr/lib usr/local/bin usr/local/sbin usr/local/lib ln -s usr/bin bin ln -s usr/sbin sbin ln -s usr/lib lib mkdir pt mnt proc sys mkdir -m 777 tmp mknod -m 622 dev/console c 5 1 mknod dev/ttySAC0 c 204 64 mknod dev/tty0 c 4 0 #touch linuxrc #chmod ug+x linuxrc #gcc 4.3.2 or 4.4.3 for frienldyARM toolchain #cp -Rp /opt/FriendlyARM/toolchain/4.4.3/arm-none-linux-gnueabi/sys-root/lib/* lib/ cp -Rp /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/* lib/ #kernel copy cp ~/kernel/mini2440/uImage boot/ cp -Rp ~/kernel/kernel-modules/lib/* lib/ # The operation of the init program is define in the inittab file, busybox init has the following default behaviour. printf "::sysinit:/etc/init.d/rcS\n" > ./etc/inittab printf "::askfirst:-/bin/sh\n" >> ./etc/inittab printf "::ctrlaltdel:/sbin/reboot\n" >> ./etc/inittab printf "::shutdown:/bin/umount -a \n" >> ./etc/inittab printf "::shutdown:/sbin/swapoff -a\n" >> ./etc/inittab printf "::restart:/sbin/init\n" >> ./etc/inittab printf "::respawn:/sbin/getty -L 115200 /dev/ttySAC0 vt100\n" >> ./etc/inittab # Create a rcS job file in the /rootfs/etc/init.d directory to initialize the target system. printf "#! /bin/sh\n" > ./etc/init.d/rcS printf "\n" >> ./etc/init.d/rcS printf "# Setup the bin file location and export to system PATH\n" >> ./etc/init.d/rcS printf "PATH=/sbin:/bin:/usr/sbin:/usr/bin\n" >> ./etc/init.d/rcS printf "umask 022\n" >> ./etc/init.d/rcS printf "export PATH\n" >> ./etc/init.d/rcS printf "\n" >> ./etc/init.d/rcS printf "# mount the filesystem directories\n" >> ./etc/init.d/rcS printf "mount -a\n" >> ./etc/init.d/rcS printf "mkdir /dev/pts\n" >> ./etc/init.d/rcS printf "mount -t devpts devpts /dev/pts -o mode=0622\n" >> ./etc/init.d/rcS printf "\n" >> ./etc/init.d/rcS printf "# create device nodes and directories\n" >> ./etc/init.d/rcS printf "echo /sbin/mdev>/proc/sys/kernel/hotplug\n" >> ./etc/init.d/rcS printf "mdev -s\n" >> ./etc/init.d/rcS printf "mkdir /var/lock\n" >> ./etc/init.d/rcS printf "\n" >> ./etc/init.d/rcS printf "# start logging utility services\n" >> ./etc/init.d/rcS printf "klogd\n" >> ./etc/init.d/rcS printf "syslogd\n" >> ./etc/init.d/rcS printf "\n" >> ./etc/init.d/rcS printf "# set system clock from RTC\n" >> ./etc/init.d/rcS printf "hwclock -s\n" >> ./etc/init.d/rcS printf "\n" >> ./etc/init.d/rcS printf "# set host and config loopback interface\n" >> ./etc/init.d/rcS printf "ifconfig lo 127.0.0.1\n" >> ./etc/init.d/rcS chmod +x ./etc/init.d/rcS #Create a mdev.conf file in the /rootfs/etc directory for the mdev process to do an initial update of the device files dynamically. printf "# system all-writable devices\n" > ./etc/mdev.conf printf "full 0:0 0666\n" >> ./etc/mdev.conf printf "null 0:0 0666\n" >> ./etc/mdev.conf printf "ptmx 0:0 0666\n" >> ./etc/mdev.conf printf "random 0:0 0666\n" >> ./etc/mdev.conf printf "tty 0:0 0666\n" >> ./etc/mdev.conf printf "zero 0:0 0666\n" >> ./etc/mdev.conf printf "\n" >> ./etc/mdev.conf printf "# console devices\n" >> ./etc/mdev.conf printf "tty[0-9]* 0:5 0660\n" >> ./etc/mdev.conf printf "vc/[0-9]* 0:5 0660\n" >> ./etc/mdev.conf printf "\n" >> ./etc/mdev.conf printf "# serial port devices\n" >> ./etc/mdev.conf printf "s3c2410_serial0 0:5 0666 =ttySAC0\n" >> ./etc/mdev.conf printf "s3c2410_serial1 0:5 0666 =ttySAC1\n" >> ./etc/mdev.conf printf "s3c2410_serial2 0:5 0666 =ttySAC2\n" >> ./etc/mdev.conf printf "s3c2410_serial3 0:5 0666 =ttySAC3\n" >> ./etc/mdev.conf printf "\n" >> ./etc/mdev.conf printf "# loop devices\n" >> ./etc/mdev.conf printf "loop[0-9]* 0:0 0660 =loop/\n" >> ./etc/mdev.conf printf "\n" >> ./etc/mdev.conf printf "# i2c devices\n" >> ./etc/mdev.conf printf "i2c-0 0:0 0666 =i2c/0\n" >> ./etc/mdev.conf printf "i2c-1 0:0 0666 =i2c/1\n" >> ./etc/mdev.conf printf "\n" >> ./etc/mdev.conf printf "# frame buffer devices\n" >> ./etc/mdev.conf printf "fb[0-9] 0:0 0666\n" >> ./etc/mdev.conf printf "\n" >> ./etc/mdev.conf printf "# input devices\n" >> ./etc/mdev.conf printf "mice 0:0 0660 =input/\n" >> ./etc/mdev.conf printf "mouse.* 0:0 0660 =input/\n" >> ./etc/mdev.conf printf "event.* 0:0 0660 =input/\n" >> ./etc/mdev.conf printf "ts.* 0:0 0660 =input/\n" >> ./etc/mdev.conf printf "\n" >> ./etc/mdev.conf printf "# rtc devices\n" >> ./etc/mdev.conf printf "rtc0 0:0 0644 >rtc\n" >> ./etc/mdev.conf printf "rtc[1-9] 0:0 0644\n" >> ./etc/mdev.conf printf "\n" >> ./etc/mdev.conf printf "# misc devices\n" >> ./etc/mdev.conf printf "mmcblk0p1 0:0 0600 =sdcard */bin/hotplug\n" >> ./etc/mdev.conf printf "sda1 0:0 0600 =udisk * /bin/hotplug\n" >> ./etc/mdev.conf #Create a fstab filesystem table in the /rootfs/etc directory to mount the system directories. printf "# device mount-point type options dump fsck order\n" > ./etc/fstab printf "proc /proc proc defaults 0 0\n" >> ./etc/fstab printf "sysfs /sys sysfs defaults 0 0\n" >> ./etc/fstab printf "tmpfs /dev tmpfs defaults 0 0\n" >> ./etc/fstab printf "tmpfs /tmp tmpfs defaults 0 0\n" >> ./etc/fstab printf "var /var tmpfs defaults 0 0\n" >> ./etc/fstab #Create a group file in /rootfs/etc directory. printf "grep root /etc/group>group\n" > ./etc/group #Create a password file in /rootfs/etc directory. printf "grep root /etc/passwd>passwd\n" > ./etc/password #Create a system wide 'profile' in /rootfs/etc directory. printf "USER=\"`id -un`\"\n" >> ./etc/profile printf "LOGNAME=$USER\n" >> ./etc/profile printf "PS1='[\\u@\\h \\W]\\# '\n" >> ./etc/profile printf "PATH=$PATH\n" >> ./etc/profile printf "HOSTNAME=`/bin/hostname`\n" >> ./etc/profile printf "export USER LOGNAME PS1 PATH HOSTNAME\n" >> ./etc/profile #Create a 'hostname' file in /rootfs/etc directory. printf "mini2440" > ./etc/hostname #Create a /rootfs/etc/issue to add a welcome prompt to the console login. printf "Welcome to Mini2440\n" >> ./etc/issue printf "Kernel \\r on an \\m \(\\l\)\n" >> ./etc/issue #Finally, create a resolv.conf file in /rootfs/etc directory to configure the #DNS address to access the internet with your service provider network domain #and ip address. printf "nameserver 192.168.1.1\n" > ./etc/resolv.conf printf "auto lo\niface lo inet loopback\n" > ./etc/network/interfaces printf "auto eth0\niface eth0 inet dhcp\n" >> ./etc/network/interfaces
参考サイト
http://cchia-cwp.blogspot.com/2010/03/build-root-file-system.html
http://for-invent.com/mini2440-linux-kernel-from-scratch-getting-started-with-linux-on-the-mini2440-part-1
0 件のコメント:
コメントを投稿