`
haoningabc
  • 浏览: 1446855 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

用buildroot为jslinux建立最小rootfs

阅读更多
##############################################################################
制作镜像文件
buildroot-2016.08.1.tar.gz
make O=haoning menuconfig
 Target options  ---> 
	Target Architecture Variant (i686)  --->
因为我的当前系统uname是i686的,为了兼容指令集
Filesystem images  --->
	[*] ext2/3/4 root filesystem 
为了生成rootfs.ext2

Target packages  ---> 
	Development tools  --->  
		 [*] make    
生成命令行的make

make O=haoning -j16 

得到buildroot/haoning/images/rootfs.ext2
编译出来的最小大概2.1M

mount -o loop rootfs.ext2  root

mv root/sbin/init root/sbin/init

vim root/sbin/init
#!/bin/sh
echo "JSLinux started, initializing..."

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
export HOME=/root
export TERM=vt100
mount -n -t proc /proc /proc
mount -n -t sysfs /sys /sys
mount -n -t devpts devpts /dev/pts
mount -n -t tmpfs /tmp /tmp
mount -n -t tmpfs /var /var
ifconfig lo 127.0.0.1
#/sbin/mdev -s      
mkdir -p "/tmp/root"
                   
while /bin/true; do                                                     
    echo "haoning buildroot-2016.08.1 this is before sh ttyS0.........."
    setsid sh -c 'exec sh </dev/ttyS0 >/dev/ttyS0 2>&1 && echo "hahah"'
    echo "this is not over  ...."
done
~      

运行

qemu-system-i386 -kernel  /opt/jslinux/kernel/linux-2.6.20/arch/i386/boot/bzImage -drive file=rootfs.ext2.onlyext2,if=ide,cache=none -append "console=ttyS0 root=/dev/hda rw init=/sbin/init notsc=1"  -boot order=dc,menu=on -net nic,vlan=0,macaddr=52:54:00:12:34:22,model=e1000,addr=08 -net tap,ifname=tap1,script=./if-up,downscript=./if-down -nographic

启动之后
/sbin/mdev -s
会在/dev下建好设备
包括jsclipboard

sync,保存到磁盘,这些dev是jslinux启动的时候用的

ctl+a x 退出qemu
ctl+a c是切换到monitor

重新mount修改rootfs.ext2里面的 /sbin/init
注释
#/sbin/mdev -s

替换jslinux-network的硬盘
cp rootfs.ext2.onlyext2 /var/www/jslinux-network/root.bin



由于只有2M左右,所以修改jslinux.js

    /* Preload blocks so that the boot time does not depend on the
     * time to load the required disk data (optional) */
   // block_list = [ 0, 7, 3, 643, 720, 256, 336, 644, 781, 387, 464, 475, 131, 589, 468, 472, 474, 776, 777, 778, 779, 465, 466, 473, 467, 469, 470, 512, 59
2, 471, 691, 697, 708, 792, 775, 769 ];
    block_list = [ 0, 7, 3 ];



进入jslinux
ip link可用

如果嫌硬盘不够大,还想装点其他东西

cd /opt/jslinux/buildroot/buildroot-2016.08.1/haoning/images
qemu-img create -f raw image.raw 20M
mkfs.ext2  image.raw 
mkdir image
mount -o loop image.raw image
mount -o loop rootfs.ext2 root
cp -r root/* image/

把rootfs.ext2 里的文件cp到image.raw里面,jslinux和qemu可用

得到一个比较大有空间的image镜像image.raw给qemu用
如果使用gcc需要注意内核的版本
FATAL kernel too old
http://blog.csdn.net/yimiyangguang1314/article/details/6095740

★★★★★★★★★★★★★
交叉编译tcc
buildroot的i686-linux-gcc 在buildroot-2016.08.1/haoning/host
host目录下有完整的交叉编译用的gcc等,但是比较大,我们用tcc编译


export PATH=/opt/jslinux/buildroot/buildroot-2016.08.1/haoning/host/usr/bin
这下面有i686-linux-gcc
测试:
[root@centos32 tcc-0.9.25]# i686-linux-gcc --version
i686-linux-gcc.br_real (Buildroot 2016.08.1) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


export CC=i686-linux-gcc

cd tcc-0.9.25
注意这里CC要放在前面
CC=i686-linux-gcc ./configure --prefix=/opt/jslinux/buildroot/buildroot-2016.08.1/haoning/images/image/usr --cc=i686-linux-gcc


make
make install

image.raw 挂载在image下,把tcc写入了这个镜像
cp -r /opt/jslinux/buildroot/buildroot-2016.08.1/haoning/host/usr/i686-buildroot-linux-uclibc/sysroot/* /opt/jslinux/buildroot/buildroot-2016.08.1/haoning/images/image/


qemu执行

qemu-system-i386 -kernel  /opt/jslinux/kernel/linux-2.6.20/arch/i386/boot/bzImage -drive file=image.raw,if=ide,cache=none -append "console=ttyS0 root=/dev/hda rw init=/sbin/init notsc=1"  -boot order=dc,menu=on -net nic,vlan=0,macaddr=52:54:00:12:34:22,model=e1000,addr=08 -net tap,ifname=tap1,script=./if-up,downscript=./if-down -nographic



进入系统tcc

之后保存系统
sync
sync

vi /sbin/init
注释掉
#/sbin/mdev -s
替换/var/www/jslinux-network/root.bin
测试jslinux


最后报错:
/var # tcc sniffer.c -o sniffer                                                
In file included from sniffer.c:3:                                             
In file included from /usr/include/netinet/in.h:24:                            
In file included from /usr/include/sys/socket.h:27:                            
In file included from /usr/include/sys/uio.h:23:                               
/usr/include/sys/types.h:146: include file 'stddef.h' not found                


可能是没选c++
编译一次下周一再看

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics