linux笔记2

作者: codercjg | 来源:发表于2016-09-21 16:39 被阅读0次

    qemu中uboot用tftp加载内核并用NFS作为根文件系统
    作者 codercjg20 八月 2015, 5:16 下午

    1.****设置****nfs服务器
    sudo apt-get install nfs-kernel-server
    sudo vim /etc/exports 增加一行内容:
    /nfs *(rw,sync,no_root_squash)
    其中/nfs表示作文根文件系统的目录, *表示任何主机都可以访问
    重启nfs服务:
    sudo /etc/init.d/portmap restart
    sudo /etc/init.d/nfs-kernel-server restart
    然后把之前用busybox制作好的_install目录下内容全部拷到/nfs下
    设置主机ip:
    ifconfig eth0 192.168.5.1 netmask 255.255.255.0
    2. 设置uboot
    uboot中include/configs/versatile.h中设置参数和命令

    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目录作为根文件系统
    手动启动命令为:
    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要设置为同一个网段。

    分类: Linux | 评论

    qemu中实现uboot和主机网络通信
    作者 codercjg19 八月 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查看设置的参数:
    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增加网络支持http://blog.chinaunix.net/uid-20552523-id-2191633.html

    分类: Linux | 评论

    ubuntu下tftp服务器的安装、配置、使用(转)
    作者 codercjg18 八月 2015, 4:07 下午

    安装$ apt-get install tftp-hpa tftpd-hpa
    建立目录$ mkdir /tftpboot # 这是建立tftp传输目录。$ sudo chmod 0777 /tftpboot$ sudo touch test.txt # test.txt文件最好输入内容以便区分
    配置$ 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是可以上传文件的参数,-s是指定tftpd-hpa服务目录,上面已经指定
    重启服务$ 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

    分类: Linux | 评论

    qemu 模拟arm跑linux
    作者 codercjg12 八月 2015, 3:32 下午

    1.安装qemu
    sudo apt-get install qemu qemu-kvm qemu-kvm-extras
    ubuntu us的源很慢,可以改成国内阿里的源。
    sudo vim /etc/apt/sources.list

    :%s/us.archive/cn.archive

    安装好后,qemu-system-arm M ? 可以查看qemu支持的开发板
    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.去官网下载uboot、linux内核、busybox最新代码还有arm-linux交叉编译工具链
    最好在~/.bashrc里加上两句
    export PATH=$PATH:/usr/local/arm-2014.05/bin

    export CROSS_COMPILE=arm-none-linux-gnueabi-

    方便后面编译linux内核和busybox.
    然后source ~/.bashrc让它生效

    3.编译linux内核
    在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下选择生成静态库文件
    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目录下创建文件rcS, 内容如下

    !/bin/sh

    mount -t proc none /proc

    mount -t sysfs none /sys

    /sbin/mdev -s

    给rcS加上可执行权限 chmod +x rcS

    生成ramdisk文件
    在_insall目录下执行命令
    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文件系统,也可以启动一个简单的hello world。
    参考:
    http://blog.csdn.net/caspiansea/article/details/12361787
    http://blog.csdn.net/caspiansea/article/details/12342053

    分类: Linux | 评论

    linux用vsftpd搭建ftp服务器
    作者 codercjg11 八月 2015, 11:28 上午

    网上说得太复杂,我只需要简单的文件传输功能。整个过程分五步:
    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.创建可访问的目录
    sudo mkdir /home/ftp
    sudo chmod a+w /home/ftp
    4.创建可访问的用户
    sudo useradd -d /home/ftp -M fuser
    sudo passwd fuser
    5.重启vsftpd服务
    sudo service vsftpd restart
    就下来就可以在该linux上浏览器里用ftp://127.0.0.1测试, 或者在windows用cuteftp工具测试。

    分类: Linux | 评论

    相关文章

      网友评论

        本文标题:linux笔记2

        本文链接:https://www.haomeiwen.com/subject/dqpaettx.html