码迷,mamicode.com
首页 > 系统相关 > 详细

[原创]基于Zynq Linux环境搭建(四)

时间:2018-01-03 11:41:09      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:lag   cli   mode   src   before   tfs   sysinit   dem   PFS   

此篇编译跟我姐系统

下载busybox和dropbear,

 

[#73#13:04:52 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS]$wget --no-check-certificate https://git.busybox.net/busybox/snapshot/busybox-1_23_1.tar.gz 
--2017-08-14 13:04:56--  https://git.busybox.net/busybox/snapshot/busybox-1_23_1.tar.gz
Resolving git.busybox.net (git.busybox.net)... 140.211.167.122
Connecting to git.busybox.net (git.busybox.net)|140.211.167.122|:443... connected.
WARNING: no certificate subject alternative name matches
        requested host name `git.busybox.net‘.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: `busybox-1_23_1.tar.gz‘

    [                                                 <=>                ] 2,800,283    230K/s   in 13s     

2017-08-14 13:05:14 (211 KB/s) - `busybox-1_23_1.tar.gz‘ saved [2800283]

  

[#74#13:05:14 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS]$wget http://matt.ucc.asn.au/dropbear/releases/dropbear-0.53.1.tar.gz
--2017-08-14 13:06:25--  http://matt.ucc.asn.au/dropbear/releases/dropbear-0.53.1.tar.gz
Resolving matt.ucc.asn.au (matt.ucc.asn.au)... 130.95.13.18, 2405:3c00:5200:100::18
Connecting to matt.ucc.asn.au (matt.ucc.asn.au)|130.95.13.18|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1772583 (1.7M) [application/x-gzip]
Saving to: `dropbear-0.53.1.tar.gz‘

100%[===================================================================>] 1,772,583    156K/s   in 12s     

2017-08-14 13:06:39 (143 KB/s) - `dropbear-0.53.1.tar.gz‘ saved [1772583/1772583]

  

 

在busybox目录下,默认配置并初始化

make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- defconfig

可视化配置

make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- menuconfig

 

 技术分享图片

 技术分享图片

安装根文件系统到指定目录

make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- install

 

 技术分享图片

 

在dropbear目录下配置dropbear

/home/fpgadeveloper/Zybo_Demo/XilinxFS/dropbear-0.53.1

 

./configure --prefix=/home/fpgadeveloper/Zybo_Demo/XilinxFS/RootFS --host=arm-xilinx-linux-gnueabi --disable-zlib CC=arm-xilinx-linux-gnueabi-gcc LDFLAGS="-Wl,--gc-sections" CFLAGS="-ffunction-sections -fdata-sections -Os" 

  

编译dropbear

make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 strip

安装dropbear并创建符号链接

sudo make install

 

 技术分享图片

建立软连接,进入/home/fpgadeveloper/Zybo_Demo/XilinxFS/RootFS/usr/bin

 

[#23#23:28:47 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr/bin]$ln -s ../../sbin/dropbear ./scp

  

将交叉编译库拷贝到下述目录

sudo cp ~/SDK2015/lin/arm-xilinx-linux-gnueabi/libc/lib/* lib -r

sudo cp ~/SDK2015/lin/arm-xilinx-linux-gnueabi/libc/sbin/* sbin -r

sudo cp ~/SDK2015/lin/arm-xilinx-linux-gnueabi/libc/usr/bin/* usr/bin/ -r

 

[#123#23:37:50 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS]$mkdir lib 
[#124#23:38:30 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS]$sudo cp ~/SDK2015/lin/arm-xilinx-linux-gnueabi/libc/lib/* lib -r 
[#125#23:38:33 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS]$sudo cp ~/SDK2015/lin/arm-xilinx-linux-gnueabi/libc/sbin/* sbin -r
[#126#23:38:35 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS]$sudo cp ~/SDK2015/lin/arm-xilinx-linux-gnueabi/libc/usr/bin/* usr/bin/ -r

  

在usr目录下创建lib目录

 

[#125#23:38:33 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS]$cd usr/
[#126#23:42:37 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr]$ls 
bin  sbin
[#127#23:42:39 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr]$mkdir lib 
[#128#23:42:43 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr]$ls 
bin  lib  sbin

  

sudo cp ~/ SDK2015 /lin/arm-xilinx-linux-gnueabi/libc/usr/lib/* usr/lib/ -r

进入到usr/lib路径下,删除

sudo rm -rf locale

sudo rm -rf audit

sudo rm -rf bin

sudo rm -rf gconv

sudo rm *.a

sudo rm *.o

 

[#132#23:43:42 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS]$sudo cp ~/SDK2015/lin/arm-xilinx-linux-gnueabi/libc/usr/lib/* usr/lib/ -r
[#133#23:45:12 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS]$cd usr/lib/
[#134#23:46:52 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr/lib]$sudo rm -rf locale
[#135#23:47:00 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr/lib]$sudo rm -rf audit
[#136#23:47:00 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr/lib]$sudo rm -rf bin
[#137#23:47:00 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr/lib]$sudo rm -rf gconv
[#138#23:47:00 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr/lib]$sudo rm *.a
[#139#23:47:00 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr/lib]$sudo rm *.o
[#140#23:47:00 FPGADeveloper@ubuntu ~/Zybo_Demo/XilinxFS/RootFS/usr/lib]$

  

在文件根目录下运行

mkdir dev etc etc/dropbear etc/init.d mnt opt proc root sys tmp var var/log var/www

其中文件都用Xilinx提供的ramdisk里面的文件,并拷贝到相关文件夹中

创建"etc/fstab"文件,内容如下

touch etc/fstab

 

touch etc/fstab                                             
echo "LABEL=/ / tmpfs defaults 0 0            " >> etc/fstab
echo "none /dev/pts devpts gid=5,mode=620 0 0 " >> etc/fstab
echo "none /proc proc defaults 0 0            " >> etc/fstab
echo "none /sys sysfs defaults 0 0            " >> etc/fstab
echo "none /tmp tmpfs defaults 0 0            " >> etc/fstab

  

创建"etc/inittab"文件,内容如下

 

touch etc/inittab                                                  
echo "::sysinit:/etc/init.d/rcS                    " >> etc/inittab
echo "# /bin/ash                                   " >> etc/inittab
echo "#                                            " >> etc/inittab
echo "# Start an askfirst shell on the serial ports" >> etc/inittab
echo "ttyPS0::respawn:-/bin/ash                    " >> etc/inittab
echo "# What to do when restarting the init process" >> etc/inittab
echo "::restart:/sbin/init                         " >> etc/inittab
echo "# What to do before rebooting                " >> etc/inittab
echo "::shutdown:/bin/umount -a -r                 " >> etc/inittab

  

创建"etc/passwd"文件,内容如下

 

touch etc/passwd                                                                     
echo "root:$1$qC.CEbjC$SVJyqm.IG.gkElhaeM.FD0:0:0:root:/root:/bin/sh" >> etc/passwd  

  

创建文件"etc/init.d/rcS" ,内容如下

 

#!/bin/sh
echo "Starting rcS..."
echo "++ Mounting filesystem"
mount -t proc none /proc
mount -t sysfs none /sys
mount -t tmpfs none /tmp
echo "++ Setting up mdev"
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
mkdir -p /dev/pts
mkdir -p /dev/i2c
mount -t devpts devpts /dev/pts
echo "++ Starting telnet daemon"
telnetd -l /bin/sh
echo "++ Starting http daemon"
httpd -h /var/www
echo "++ Starting ftp daemon"
tcpsvd 0:21 ftpd ftpd -w /&
echo "++ Starting dropbear (ssh) daemon"
dropbear
echo "rcS Complete"

  

修改权限

sudo chmod 755 etc/init.d/rcS

sudo chown root:root etc/init.d/rcS

制作文件系统

dd if=/dev/zero of=ramdisknew.image bs=1024 count=32768
mke2fs -F ramdisknew.image -L "ramdisk" -b 1024 -m 0
tune2fs ramdisknew.image -i 0
chmod a+rwx ramdisknew.image
sudo mount -o loop ramdisknew.image tmp_mnt_new/
sudo cp -R /home/fpgadeveloper/Zybo_Demo/XilinxFS/RootFS/* tmp_mnt_new/
cd tmp_mnt_new
cd bin/
sudo cp -rf /home/fpgadeveloper/Zybo_Demo/UART_Tools/lrzsz-0.12.20/src/lrz .
sudo cp -rf /home/fpgadeveloper/Zybo_Demo/UART_Tools/lrzsz-0.12.20/src/lsz .
cd ..
cd ..
sudo umount tmp_mnt_new
gzip ramdisknew.image
mkimage -A arm -T ramdisk -C gzip -d ramdisknew.image.gz uramdisk.image.gz

拷贝uboot dtb *uramdisk.image.gz uImage等文件,在SDK环境下合并

可通过qspi flash 或者SD卡启动进行系统加载

[原创]基于Zynq Linux环境搭建(四)

标签:lag   cli   mode   src   before   tfs   sysinit   dem   PFS   

原文地址:https://www.cnblogs.com/ifpga/p/8182036.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!