linux筆記2

qemu中uboot用tftp加載內(nèi)核并用NFS作為根文件系統(tǒng)
作者 codercjg20 八月 2015, 5:16 下午

1.****設(shè)置****nfs服務(wù)器
sudo apt-get install nfs-kernel-server
sudo vim /etc/exports 增加一行內(nèi)容:
/nfs *(rw,sync,no_root_squash)
其中/nfs表示作文根文件系統(tǒng)的目錄, *表示任何主機(jī)都可以訪問
重啟nfs服務(wù):
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-kernel-server restart
然后把之前用busybox制作好的_install目錄下內(nèi)容全部拷到/nfs下
設(shè)置主機(jī)ip:
ifconfig eth0 192.168.5.1 netmask 255.255.255.0
2. 設(shè)置uboot
uboot中include/configs/versatile.h中設(shè)置參數(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服務(wù)
其中192.168.5.3為uboot ip, 192.168.5.2為qemu ip,192.168.5.1為主機(jī)ip
3. 啟動(dòng)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啟動(dòng)后就會(huì)通過tftp把主機(jī)上的/tftpboot目錄下的zImage下載到ram 0×8000處,并把主機(jī)中/nfs目錄作為根文件系統(tǒng)
手動(dòng)啟動(dòng)命令為:
tftp 0×8000 uImage
bootm 0×8000
如果tftp失敗,則添加一條路由 route add -host 192.168.5.3 gw 192.168.5.2
啟動(dòng)日志:
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

主機(jī)、qemu和uboot三者的ip要設(shè)置為同一個(gè)網(wǎng)段。

分類: Linux | 評(píng)論

qemu中實(shí)現(xiàn)uboot和主機(jī)網(wǎng)絡(luò)通信
作者 codercjg19 八月 2015, 4:36 下午

1.修改u-boot/include/configs/versatile.h

define CONFIG_SMC91111_EXT_PHY

沒有這句ping時(shí)總會(huì)報(bào)“SMC91111: PHY auto-negotiate timed out”
然后重新編譯uboot
2.修改/etc/qemu-ifup

!/sbin/bash

ifconfig $1 192.168.5.2
3.啟動(dòng)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.設(shè)置主機(jī)IP添加路由表項(xiàng)
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 查看設(shè)置后的路由表
4.設(shè)置uboot IP
set ipaddr 192.168.5.3
set netmask 255.255.255.0
用print可以打印env查看設(shè)置的參數(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通主機(jī)了
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)絡(luò)支持http://blog.chinaunix.net/uid-20552523-id-2191633.html

分類: Linux | 評(píng)論

ubuntu下tftp服務(wù)器的安裝、配置、使用(轉(zhuǎn))
作者 codercjg18 八月 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的服務(wù)目錄,這個(gè)想建立在哪里都行TFTP_ADDRESS=”0.0.0.0:69″** TFTP_OPTIONS=”-l -c -s” # 這里是選項(xiàng),-c是可以上傳文件的參數(shù),-s是指定tftpd-hpa服務(wù)目錄,上面已經(jīng)指定
重啟服務(wù)$ sudo service tftpd-hpa restart # 啟動(dòng)服務(wù),這里要注意,采用的獨(dú)立服務(wù)形式。
測(cè)試$ tftp 127.0.0.1tftp>get test.txttftp>put test1.txttftp>qverbose可以開啟顯示詳細(xì)信息

原文地址:http://blog.chinaunix.net/uid-26495963-id-3206829.html

分類: Linux | 評(píng)論

qemu 模擬arm跑linux
作者 codercjg12 八月 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會(huì)出錯(cuò)
然后make -j12 all ARCH=arm
之后再arch/arm/boot下生存zImage

4.編譯busybox
make defconfig ARCH=arm
make menuconfig進(jìn)入配置界面
build option下選擇生成靜態(tài)庫文件
make ARCH=arm
編譯完成后
make install會(huì)在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í)行權(quán)限 chmod +x rcS

生成ramdisk文件
在_insall目錄下執(zhí)行命令
find . | cpio -o --format=newc > ../initramfs

5.啟動(dòng)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”
之后就能看到啟動(dòng)Linux后的Please press Enter to activate this console.
其實(shí)也不一定就要使用busybox制作的ramfs文件系統(tǒng),也可以啟動(dòng)一個(gè)簡單的hello world。
參考:
http://blog.csdn.net/caspiansea/article/details/12361787
http://blog.csdn.net/caspiansea/article/details/12342053

分類: Linux | 評(píng)論

linux用vsftpd搭建ftp服務(wù)器
作者 codercjg11 八月 2015, 11:28 上午

網(wǎng)上說得太復(fù)雜,我只需要簡單的文件傳輸功能。整個(gè)過程分五步:
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服務(wù)
sudo service vsftpd restart
就下來就可以在該linux上瀏覽器里用ftp://127.0.0.1測(cè)試, 或者在windows用cuteftp工具測(cè)試。

分類: Linux | 評(píng)論

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1、交叉編譯 由于嵌入式系統(tǒng)資源匱乏,一般不能像 PC 一樣安裝本地編譯器和調(diào)試器,不能在本地編寫、編譯和調(diào)...
    不配野心閱讀 2,258評(píng)論 0 4
  • 寫在前面 分享我在學(xué)習(xí)Linux入門時(shí)的筆記,主要通過慕課網(wǎng)學(xué)習(xí)并記錄了如下筆記。適合初學(xué)者了解Linux的一些基...
    ZRay111閱讀 511評(píng)論 0 1
  • 在踏上旅行歸途的時(shí)候,突然心生恐慌,害怕回去,害怕面對(duì)日常生活的壓力和噪雜,害怕又回歸往日的窠臼。 總覺得自己應(yīng)該...
    Jessy自由行走的貓閱讀 303評(píng)論 0 0

友情鏈接更多精彩內(nèi)容