qemu中uboot用tftp加載內(nèi)核并用NFS作為根文件系統(tǒng)
作者 codercjg 在 20 八月 2015, 5:16 下午
1.****設置****nfs服務器
sudo apt-get install nfs-kernel-server
sudo vim /etc/exports 增加一行內(nèi)容:
/nfs *(rw,sync,no_root_squash)
其中/nfs表示作文根文件系統(tǒng)的目錄, *表示任何主機都可以訪問
重啟nfs服務:
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-kernel-server restart
然后把之前用busybox制作好的_install目錄下內(nèi)容全部拷到/nfs下
設置主機ip:
ifconfig eth0 192.168.5.1 netmask 255.255.255.0
2. 設置uboot
uboot中include/configs/versatile.h中設置參數(shù)和命令
define CONFIG_BOOTARGS"root=/dev/nfs nfsroot=192.168.5.1:/nfs "\
"nfsaddrs=192.168.5.3:192.168.5.1:192.168.5.2:255.255.255.0::eth0:off "\
"mem=128M "\
"netdev=25,0,0xf1010000,0xf1010010,eth0 "\
"console=ttyAMA0,38400n1"
define CONFIG_SMC91111_EXT_PHY
define CONFIG_NETMASK 255.255.255.0
define CONFIG_IPADDR 192.168.5.3
define CONFIG_SERVERIP 192.168.5.1
define CONFIG_INITRD_TAG
define CONFIG_BOOTCOMMAND \
"set ipaddr 192.168.5.3;"\
"set serverip 192.168.5.1;"\
"tftpboot 0x00008000 uImage;"\
"bootm 0x8000 "
uImage在/tftpboot下亡哄,要開啟tftp server服務
其中192.168.5.3為uboot ip, 192.168.5.2為qemu ip默怨,192.168.5.1為主機ip
3. 啟動uboot
qemu-system-arm加載uboot:
sudo modprobe tun
qemu-system-arm -M versatilepb -kernel u-boot -net nic,vlan=0,macaddr=00:4c:4c:00:00:01 -net tap,vlan=0 -nographic
這樣uboot啟動后就會通過tftp把主機上的/tftpboot目錄下的zImage下載到ram 0×8000處,并把主機中/nfs目錄作為根文件系統(tǒng)
手動啟動命令為:
tftp 0×8000 uImage
bootm 0×8000
如果tftp失敗冈绊,則添加一條路由 route add -host 192.168.5.3 gw 192.168.5.2
啟動日志:
U-Boot 2015.07 (Aug 20 2015 - 10:44:36 +0200)
DRAM: 128 MiB
WARNING: Caches not enabled
Flash: ## Unknown flash on Bank 1 - Size = 0x00000000 = 0 MB
*** failed ***
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: SMC91111-0
Warning: SMC91111-0 using MAC address from net device
Warning: Your board does not use generic board. Please read
doc/README.generic-board and take action. Boards not
upgraded by the late 2014 may break or be removed.
Hit any key to stop autoboot: 0
SMC91111: MAC 00:4c:4c:00:00:01
Using SMC91111-0 device
TFTP from server 192.168.5.1; our IP address is 192.168.5.3
Filename 'uImage'.
Load address: 0x8000
Loading: T #################################################################
#######################################################
321.3 KiB/s
done
Bytes transferred = 1756040 (1acb88 hex)
Booting kernel from Legacy Image at 00008000 ...
Image Name: Linux-3.2.0
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1755976 Bytes = 1.7 MiB
Load Address: 00008000
Entry Point: 00008000
Loading Kernel Image ... OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.2.0 (user@instant-contiki) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #6 Tue Aug 18 19:59:05 CEST 2015
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile PB
Memory policy: ECC disabled, Data cache writeback
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956ms
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: root=/dev/nfs nfsroot=192.168.5.1:/nfs nfsaddrs=192.168.5.3:192.168.5.1:192.168.5.2:255.255.255.0::eth0:off mem=128M netdev=25,0,0xf1010000,0xf1010010,eth0 console=ttyAMA0,38400n1
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 126444k/126444k available, 4628k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
vmalloc : 0xc8800000 - 0xd8000000 ( 248 MB)
lowmem : 0xc0000000 - 0xc8000000 ( 128 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.text : 0xc0008000 - 0xc030cf1c (3092 kB)
.init : 0xc030d000 - 0xc0329000 ( 112 kB)
.data : 0xc032a000 - 0xc03474a0 ( 118 kB)
.bss : 0xc03474c4 - 0xc0361444 ( 104 kB)
NR_IRQS:192
VIC @f1140000: id 0x00041190, vendor 0x41
Console: colour dummy device 80x30
Calibrating delay loop... 307.20 BogoMIPS (lpj=1536000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a PL011 rev1
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a PL011 rev1
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a PL011 rev1
fpga:09: ttyAMA3 at MMIO 0x10009000 (irq = 38) is a PL011 rev1
bio: create slab <bio-0> at 0
Switching to clocksource timer3
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 246
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
clcd-pl11x dev:20: PL110 rev0 at 0x10120000
clcd-pl11x dev:20: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80x60
brd: module loaded
physmap platform flash device: 04000000 at 34000000
physmap-flash physmap-flash.0: map_probe failed
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@fluxnic.net>
eth0: SMC91C11xFD (rev 1) at c8800000 IRQ 25 [nowait]
eth0: Ethernet addr: 00:4c:4c:00:00:01
mousedev: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
eth0: link up
IP-Config: Complete:
device=eth0, addr=192.168.5.3, mask=255.255.255.0, gw=192.168.5.2,
host=192.168.5.3, domain=, nis-domain=(none),
bootserver=192.168.5.1, rootserver=192.168.5.1, rootpath=
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input1
VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing init memory: 112K
Please press Enter to activate this console.
/ # ls
bin dev etc linuxrc proc sbin sys usr
主機、qemu和uboot三者的ip要設置為同一個網(wǎng)段埠啃。
qemu中實現(xiàn)uboot和主機網(wǎng)絡通信
作者 codercjg 在 19 八月 2015, 4:36 下午
1.修改u-boot/include/configs/versatile.h
define CONFIG_SMC91111_EXT_PHY
沒有這句ping時總會報“SMC91111: PHY auto-negotiate timed out”
然后重新編譯uboot
2.修改/etc/qemu-ifup
!/sbin/bash
ifconfig $1 192.168.5.2
3.啟動qemu
sudo modprobe tun
qemu-system-arm -M versatilepb -kernel u-boot -net nic,vlan=0,macaddr=00:4c:4c:00:00:01 -net tap,vlan=0 -nographic
3.設置主機IP添加路由表項
ifconfig eth0 192.168.5.1 netmask 255.255.255.0
route add -host 192.168.5.3 gw 192.168.5.2
route add -host 192.168.5.1 gw 192.168.5.2
可以用route -n 查看設置后的路由表
4.設置uboot IP
set ipaddr 192.168.5.3
set netmask 255.255.255.0
用print可以打印env查看設置的參數(shù):
VersatilePB # printbaudrate=38400bootargs=root=/dev/nfs mem=128M ip=dhcp netdev=25,0,0xf1010000,0xf1010010,eth0 console=ttyAMA0,38400n1bootdelay=2bootfile=/tftpboot/uImageethact=SMC91111-0ethaddr=00:4c:4c:00:00:01ipaddr=192.168.5.3netmask=255.255.255.0serverip=192.168.5.1stderr=serialstdin=serialstdout=serialverify=n
之后就可以在uboot中ping通主機了
VersatilePB # ping 192.168.5.1SMC91111: MAC 00:4c:4c:00:00:01Using SMC91111-0 devicehost 192.168.5.1 is alive
參考: 為qemu中的u-boot增加網(wǎng)絡支持http://blog.chinaunix.net/uid-20552523-id-2191633.html
ubuntu下tftp服務器的安裝死宣、配置、使用(轉)
作者 codercjg 在 18 八月 2015, 4:07 下午
安裝$ apt-get install tftp-hpa tftpd-hpa
建立目錄$ mkdir /tftpboot # 這是建立tftp傳輸目錄碴开。$ sudo chmod 0777 /tftpboot$ sudo touch test.txt # test.txt文件最好輸入內(nèi)容以便區(qū)分
配置$ sudo vi /etc/default/tftpd-hpa
TFTP_USERNAME=”tftp”** TFTP_DIRECTORY=”/tftpboot” # 這里是你的tftpd-hpa的服務目錄,這個想建立在哪里都行TFTP_ADDRESS=”0.0.0.0:69″** TFTP_OPTIONS=”-l -c -s” # 這里是選項,-c是可以上傳文件的參數(shù)毅该,-s是指定tftpd-hpa服務目錄博秫,上面已經(jīng)指定
重啟服務$ sudo service tftpd-hpa restart # 啟動服務,這里要注意眶掌,采用的獨立服務形式台盯。
測試$ tftp 127.0.0.1tftp>get test.txttftp>put test1.txttftp>qverbose可以開啟顯示詳細信息
原文地址:http://blog.chinaunix.net/uid-26495963-id-3206829.html
qemu 模擬arm跑linux
作者 codercjg 在 12 八月 2015, 3:32 下午
1.安裝qemu
sudo apt-get install qemu qemu-kvm qemu-kvm-extras
ubuntu us的源很慢,可以改成國內(nèi)阿里的源畏线。
sudo vim /etc/apt/sources.list
:%s/us.archive/cn.archive
安裝好后静盅,qemu-system-arm M ? 可以查看qemu支持的開發(fā)板
user@instant-contiki:~/qemu/busybox-1.23.2$ qemu-system-arm -M ?
Supported machines are:
beagle Beagle board (OMAP3530)
beaglexm Beagle board XM (OMAP3630)
collie Collie PDA (SA-1110)
nuri Samsung NURI board (Exynos4210)
smdkc210 Samsung SMDKC210 board (Exynos4210)
connex Gumstix Connex (PXA255)
verdex Gumstix Verdex (PXA270)
highbank Calxeda Highbank (ECX-1000)
integratorcp ARM Integrator/CP (ARM926EJ-S) (default)
mainstone Mainstone II (PXA27x)
musicpal Marvell 88w8618 / MusicPal (ARM926EJ-S)
n800 Nokia N800 tablet aka. RX-34 (OMAP2420)
n810 Nokia N810 tablet aka. RX-44 (OMAP2420)
n900 Nokia N900 (OMAP3)
sx1 Siemens SX1 (OMAP310) V2
sx1-v1 Siemens SX1 (OMAP310) V1
overo Gumstix Overo board (OMAP3530)
cheetah Palm Tungsten|E aka. Cheetah PDA (OMAP310)
realview-eb ARM RealView Emulation Baseboard (ARM926EJ-S)
realview-eb-mpcore ARM RealView Emulation Baseboard (ARM11MPCore)
realview-pb-a8 ARM RealView Platform Baseboard for Cortex-A8
realview-pbx-a9 ARM RealView Platform Baseboard Explore for Cortex-A9
akita Akita PDA (PXA270)
spitz Spitz PDA (PXA270)
borzoi Borzoi PDA (PXA270)
terrier Terrier PDA (PXA270)
lm3s811evb Stellaris LM3S811EVB
lm3s6965evb Stellaris LM3S6965EVB
tosa Tosa PDA (PXA255)
versatilepb ARM Versatile/PB (ARM926EJ-S)
versatileab ARM Versatile/AB (ARM926EJ-S)
vexpress-a9 ARM Versatile Express for Cortex-A9
vexpress-a15 ARM Versatile Express for Cortex-A15
z2 Zipit Z2 (PXA27x)
2.去官網(wǎng)下載uboot、linux內(nèi)核寝殴、busybox最新代碼還有arm-linux交叉編譯工具鏈
最好在~/.bashrc里加上兩句
export PATH=$PATH:/usr/local/arm-2014.05/bin
export CROSS_COMPILE=arm-none-linux-gnueabi-
方便后面編譯linux內(nèi)核和busybox.
然后source ~/.bashrc讓它生效
3.編譯linux內(nèi)核
在linux源碼目錄下
make versatile_defconfig ARCH=arm后生成.config文件
然后把.config文件修改下蒿叠,加上一句CONFIG_AEABI=y,不然后面加載initramfs會出錯
然后make -j12 all ARCH=arm
之后再arch/arm/boot下生存zImage
4.編譯busybox
make defconfig ARCH=arm
make menuconfig進入配置界面
build option下選擇生成靜態(tài)庫文件
make ARCH=arm
編譯完成后
make install會在busybox目錄下生成_install目錄蚣常,然后在該目錄下
mkdir dev etc proc sys etc/init.d市咽,之后_install目錄如下
bin dev etc linuxrc proc sbin sys usr
在init.d目錄下創(chuàng)建文件rcS, 內(nèi)容如下
!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s
給rcS加上可執(zhí)行權限 chmod +x rcS
生成ramdisk文件
在_insall目錄下執(zhí)行命令
find . | cpio -o --format=newc > ../initramfs
5.啟動linux
qemu-system-arm -M versatilepb -kernel arch/arm/boot/zImage -initrd ../busybox-1.23.2/initramfs -serial stdio -append “console=ttyAMA0 root=dev/arm rdinit=/sbin/init”
之后就能看到啟動Linux后的Please press Enter to activate this console.
其實也不一定就要使用busybox制作的ramfs文件系統(tǒng),也可以啟動一個簡單的hello world抵蚊。
參考:
http://blog.csdn.net/caspiansea/article/details/12361787
http://blog.csdn.net/caspiansea/article/details/12342053
linux用vsftpd搭建ftp服務器
作者 codercjg 在 11 八月 2015, 11:28 上午
網(wǎng)上說得太復雜施绎,我只需要簡單的文件傳輸功能。整個過程分五步:
1.安裝vsftpd
sudo apt-get install vsftpd
2.配置vsftpd
sudo vim /etc/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
local_root=/home/ftp
3.創(chuàng)建可訪問的目錄
sudo mkdir /home/ftp
sudo chmod a+w /home/ftp
4.創(chuàng)建可訪問的用戶
sudo useradd -d /home/ftp -M fuser
sudo passwd fuser
5.重啟vsftpd服務
sudo service vsftpd restart
就下來就可以在該linux上瀏覽器里用ftp://127.0.0.1測試, 或者在windows用cuteftp工具測試贞绳。