爱板网论坛

查看: 202|回复: 0

[资料] 【EVB-335X-II】Yocto环境的建立及Rootfs的构建与使用

[复制链接]

408

主题

92

好友

5642

积分

状元

Rank: 6Rank: 6

  • TA的每日心情
    郁闷
    10 小时前
  • 签到天数: 500 天

    连续签到: 82 天

    [LV.9]以坛为家II

    发表于 2018-1-16 17:14:05 |显示全部楼层
    本帖最后由 feixiang20 于 2018-1-16 17:19 编辑

    Yocto基本meta的获取
    我们需要好几个meta与poky
    首先需要保证至少有65GB的Free磁盘空间或者更多,创建一个目录:
    mkdir Yocto
    然后clone各个meta与poky
    第一个是meta-bbb:
    git clone git://github.com/jumpnow/meta-bbb -b original/jethro
    然后是poky与其他的:
    git clone git://git.yoctoproject.org/poky.git -b original/jethro
    git clone git://git.openembedded.org/meta-openembedded -b original/jethro
    有了这些后我们就可以开始构建了。
    在构建之前,我们需要安装必要的文件与库:
    sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
         build-essential chrpath socat libsdl1.2-dev xterm
    这里面我使用的Ubuntu版本是Ubuntu 14.04 X64, 如果其他老的Ubuntu那么是Yocto官方不支持的,需要自己升级对应的软件包才能用。

    创建编译目录
    因为Yocto默认就含有AM335X的BSP支持,我们这里就直接使用它的,这里面使用的是BeagleBone的。
    建立构建目录
    source poky/oe-init-build-env evb335xii_build
    然后我们就自动进入到了后面参数的目录中,接下来我们还需要配置。
    配置板子
    更改conf/local.conf文件:

    1.png


    修改layer
    layer相当于是多个recipes的集合,而meta是多个layer的集合,关于这些概念可以看我以前写的博客Yocto tips,或者是到Yocto官方查看文档。
    修改文件conf/bblayer.conf
    修改后的文件如下所示:

    2.png


    构建系统
    我们这里选择使用最小的系统来构建,作为第一个目标,使用的命令如下:
    bitbake core-image-minimal
    构建完成后类似下图:

    3.png


    构建出来的文件位于:
    tmp/deploy/images/beaglebone/
    最后的产物如下:

    4.png


    可以看到这里面有uboot与kernel以及rootfs,但是这里的uboot与kernel不适合我们的板子,暂时我们只用rootfs。因为现在板子是默认从nand启动的,为了方便,我们直接使用nfs来使用rootfs。
    关于如何搭建nfs server,大家可以参考其他的文章。

    NFS启动准备
    将前面Yocto编译出来的Rootfs解压到NFS的目录中
    首先创建目录:
    mkdir evb335xii_mini
    然后解压:
    tar xf tmp/deploy/images/beaglebone/core-image-minimal-beaglebone.tar.bz2 -C ~/nfs/evb335xii_mini/ && sync

    TFTP准备在Ubuntu 14.04中,安装使用tftpd-hpa然后出问题,因此我们使用tftpd和openbsd-init,安装配置过程如下:
    sudo apt-get install tftpd tftp openbsd-inetd

    然后更改配置文件/etc/inetd.conf, 将里面的路径换成我们的,例如/home/XXX/tftpboot,最好再重启service即可:
    sudo service openbsd-inetd restart
    最后我们在tftpboot中放入一个文件作为测试:
    touch ~/tftpboot/abc
    然后测试一下:

    5.png


    同时将uImage拷贝进去。

    本地网络的配置
    我们将本地的网卡配置成static IP,这样子不需要每一次都去查询:
    我们直接使用GUI来配置:

    6.png


    然后确定配置成功:

    7.png


    然后在uboot中ping进行测试,命令如下:
    set ipaddr 192.168.1.111;set serverip 192.168.1.100
    ping 192.168.1.100

    效果如下:

    8.png


    如果是alive即说明OK。

    使用TFTP与NFS启动Yocto Rootfs
    做好了所有准备工作之后,我们对板子上电,然后启动起来,并让其停留在uboot命令行中,然后我们使用下面命令来启动板子:
    set ipaddr 192.168.1.111;set serverip 192.168.1.100
    set bootargs 'console=ttyO0,115200n8 ip=192.168.1.111 root=/dev/nfs nfsroot=192.168.1.100:/home/hexiongjun/nfs/evb335xii_mini rootwait'
    tftp 82000000 uImage; bootm 82000000

    需要注意的是那个tftp的地址不能与load地址重合,否则会无法启动。

    启动后的log如下:
    U-Boot SPL 2014.04-rc2 (Jul 11 2015 - 11:06:52)

    U-Boot 2014.04-rc2 (Jul 11 2015 - 11:06:52)

    I2C:   ready
    DRAM:  128 MiB
    NAND:  256 MiB
    MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
    *** Warning - bad CRC, using default environment

    Net:   cpsw
    Hit any key to stop autoboot:  0
    U-Boot# set ipaddr 192.168.1.111;set serverip 192.168.1.100
    U-Boot# set bootargs 'console=ttyO0,115200n8 ip=192.168.1.111 root=/dev/nfs nfsroot=192.168.1.100:/home/hexiongjun/nfs/evb335xii_mini rootwait'
    U-Boot# tftp 82000000 uImage; bootm 82000000
    link up on port 0, speed 100, full duplex
    Using cpsw device
    TFTP from server 192.168.1.100; our IP address is 192.168.1.111
    Filename 'uImage'.
    Load address: 0x82000000
    Loading: #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             ############################################################
             3.3 MiB/s
    done
    Bytes transferred = 2966384 (2d4370 hex)
    ## Booting kernel from Legacy Image at 82000000 ...
       Image Name:   Linux-3.2.0-ga74cead
       Image Type:   ARM Linux Kernel Image (uncompressed)
       Data Size:    2966320 Bytes = 2.8 MiB
       Load Address: 80008000
       Entry Point:  80008000
       Verifying Checksum ... OK
       Loading Kernel Image ... OK

    Starting kernel ...

    [    0.000000] Linux version 3.2.0-ga74cead (hexiongjun@hexiongjun-i7) (gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) ) #1 Sun Jul 24 15:06:31 CST 2016
    [    0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7d
    [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
    [    0.000000] Machine: com335x
    [    0.000000] Memory policy: ECC disabled, Data cache writeback
    [    0.000000] AM335X ES2.1 (neon )
    [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
    [    0.000000] Kernel command line: console=ttyO0,115200n8 ip=192.168.1.111 root=/dev/nfs nfsroot=192.168.1.100:/home/hexiongjun/nfs/evb335xii_mini rootwait
    [    0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)
    [    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
    [    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
    [    0.000000] Memory: 128MB = 128MB total
    [    0.000000] Memory: 123796k/123796k available, 7276k reserved, 0K highmem
    [    0.000000] Virtual kernel memory layout:
    [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    [    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    [    0.000000]     vmalloc : 0xc8800000 - 0xff000000   ( 872 MB)
    [    0.000000]     lowmem  : 0xc0000000 - 0xc8000000   ( 128 MB)
    [    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
    [    0.000000]       .text : 0xc0008000 - 0xc0537000   (5308 kB)
    [    0.000000]       .init : 0xc0537000 - 0xc0571000   ( 232 kB)
    [    0.000000]       .data : 0xc0572000 - 0xc05c92e8   ( 349 kB)
    [    0.000000]        .bss : 0xc05c930c - 0xc05f7ee4   ( 187 kB)
    [    0.000000] NR_IRQS:396
    [    0.000000] IRQ: Found an INTC at 0xfa200000 (revision 5.0) with 128 interrupts
    [    0.000000] Total of 128 interrupts on 1 active controller
    [    0.000000] OMAP clockevent source: GPTIMER2 at 24000000 Hz
    [    0.000000] omap_dm_timer_switch_src: Switching to HW default clocksource(sys_clkin_ck) for timer1, this may impact timekeeping in low power state
    [    0.000000] OMAP clocksource: GPTIMER1 at 24000000 Hz
    [    0.000000] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956ms
    [    0.000000] Console: colour dummy device 80x30
    [    0.000187] Calibrating delay loop... 795.44 BogoMIPS (lpj=3977216)
    [    0.087382] pid_max: default: 32768 minimum: 301
    [    0.087494] Security Framework initialized
    [    0.087588] Mount-cache hash table entries: 512
    [    0.087949] CPU: Testing write buffer coherency: ok
    [    0.088674] devtmpfs: initialized
    [    0.107938] omap_hwmod: gfx: failed to hardreset
    [    0.123811] omap_hwmod: pruss: failed to hardreset
    [    0.124868] print_constraints: dummy:
    [    0.125221] NET: Registered protocol family 16
    [    0.127347] OMAP GPIO hardware version 0.1
    [    0.129789] omap_mux_init: Add partition: #1: core, flags: 0
    [    0.131636]  omap_i2c.1: alias fck already exists
    [    0.132286] omap-gpmc omap-gpmc: GPMC revision 6.0
    [    0.132303] Registering NAND on CS0
    [    0.132859]  omap_hsmmc.0: alias fck already exists
    [    0.134071]  d_can.0: alias fck already exists
    [    0.134262] com335x: mcasp1 init
    [    0.134344]  davinci-mcasp.1: alias fck already exists
    [    0.134968]  omap_i2c.3: alias fck already exists
    [    0.135881]  omap2_mcspi.1: alias fck already exists
    [    0.136106]  omap2_mcspi.2: alias fck already exists
    [    0.136358]  edma.0: alias fck already exists
    [    0.136377]  edma.0: alias fck already exists
    [    0.136394]  edma.0: alias fck already exists
    [    0.154307] bio: create slab <bio-0> at 0
    [    0.156289] SCSI subsystem initialized
    [    0.158123] usbcore: registered new interface driver usbfs
    [    0.158416] usbcore: registered new interface driver hub
    [    0.158614] usbcore: registered new device driver usb
    [    0.158911] registerd cppi-dma Intr @ IRQ 17
    [    0.158924] Cppi41 Init Done Qmgr-base(c887a000) dma-base(c8878000)
    [    0.158932] Cppi41 Init Done
    [    0.158956] musb-ti81xx musb-ti81xx: musb0, board_mode=0x13, plat_mode=0x3
    [    0.159227] musb-ti81xx musb-ti81xx: musb1, board_mode=0x13, plat_mode=0x1
    [    0.177400] omap_i2c omap_i2c.1: bus 1 rev2.4.0 at 400 kHz
    [    0.178046] tps65217 1-0024: TPS65217 ID 0xe version 1.2
    [    0.178963] print_constraints: DCDC1: 900 <--> 1800 mV at 1500 mV
    [    0.179932] print_constraints: DCDC2: 900 <--> 3300 mV at 1275 mV
    [    0.180875] print_constraints: DCDC3: 900 <--> 1500 mV at 1125 mV
    [    0.181794] print_constraints: LDO1: 1000 <--> 3300 mV at 1800 mV
    [    0.182717] print_constraints: LDO2: 900 <--> 3300 mV at 3300 mV
    [    0.183655] print_constraints: LDO3: 1800 <--> 3300 mV at 1800 mV
    [    0.184581] print_constraints: LDO4: 1800 <--> 3300 mV at 3300 mV
    [    0.197403] omap_i2c omap_i2c.3: bus 3 rev2.4.0 at 400 kHz
    [    0.198899] Advanced Linux Sound Architecture Driver Version 1.0.24.
    [    0.200060] Switching to clocksource gp timer
    [    0.216447] musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
    [    0.216639] musb-hdrc musb-hdrc.0: dma type: dma-cppi41
    [    0.216958] MUSB0 controller's USBSS revision = 4ea20800
    [    0.216988] musb0: Enabled SW babble control
    [    0.217829] musb-hdrc musb-hdrc.0: USB OTG mode controller at c884a000 using DMA, IRQ 18
    [    0.217985] musb-hdrc musb-hdrc.1: dma type: dma-cppi41
    [    0.218266] MUSB1 controller's USBSS revision = 4ea20800
    [    0.218291] musb1: Enabled SW babble control
    [    0.218694] musb-hdrc musb-hdrc.1: MUSB HDRC host driver
    [    0.218798] musb-hdrc musb-hdrc.1: new USB bus registered, assigned bus number 1
    [    0.218923] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
    [    0.218937] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
    [    0.218949] usb usb1: Product: MUSB HDRC host driver
    [    0.218958] usb usb1: Manufacturer: Linux 3.2.0-ga74cead musb-hcd
    [    0.218968] usb usb1: SerialNumber: musb-hdrc.1
    [    0.219835] hub 1-0:1.0: USB hub found
    [    0.219865] hub 1-0:1.0: 1 port detected
    [    0.220502] musb-hdrc musb-hdrc.1: USB Host mode controller at c884c800 using DMA, IRQ 19
    [    0.220935] NET: Registered protocol family 2
    [    0.221125] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
    [    0.221391] TCP established hash table entries: 4096 (order: 3, 32768 bytes)
    [    0.221470] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
    [    0.221518] TCP: Hash tables configured (established 4096 bind 4096)
    [    0.221529] TCP reno registered
    [    0.221540] UDP hash table entries: 256 (order: 0, 4096 bytes)
    [    0.221560] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
    [    0.221744] NET: Registered protocol family 1
    [    0.221983] RPC: Registered named UNIX socket transport module.
    [    0.221996] RPC: Registered udp transport module.
    [    0.222003] RPC: Registered tcp transport module.
    [    0.222011] RPC: Registered tcp NFSv4.1 backchannel transport module.
    [    0.222222] NetWinder Floating Point Emulator V0.97 (double precision)
    [    0.222244] Error: Driver 'omap-gpmc' is already registered, aborting...
    [    0.229165] VFS: Disk quotas dquot_6.5.2
    [    0.229231] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
    [    0.229741] msgmni has been set to 241
    [    0.230512] io scheduler noop registered
    [    0.230524] io scheduler deadline registered
    [    0.230584] io scheduler cfq registered (default)
    [    0.233607] omap_uart.0: ttyO0 at MMIO 0x44e09000 (irq = 72) is a OMAP UART0
    [    0.916776] console [ttyO0] enabled
    [    0.921091] omap_uart.1: ttyO1 at MMIO 0x48022000 (irq = 73) is a OMAP UART1
    [    0.928914] omap_uart.2: ttyO2 at MMIO 0x48024000 (irq = 74) is a OMAP UART2
    [    0.936766] omap_uart.3: ttyO3 at MMIO 0x481a6000 (irq = 44) is a OMAP UART3
    [    0.944590] omap_uart.4: ttyO4 at MMIO 0x481a8000 (irq = 45) is a OMAP UART4
    [    0.962212] brd: module loaded
    [    0.970242] loop: module loaded
    [    0.973605] at24 1-0050: 32768 byte 24c256 EEPROM, writable, 64 bytes/write
    [    0.983216] mtdoops: mtd device (mtddev=name/number) must be supplied
    [    0.990368] omap2-nand driver initializing
    [    0.994963] ONFI flash detected
    [    0.998365] ONFI param page 0 valid
    [    1.002047] NAND device: Manufacturer ID: 0x2c, Chip ID: 0xda (Micron MT29F2G08ABAEAWP)
    [    1.010630] Creating 9 MTD partitions on "omap2-nand.0":
    [    1.016194] 0x000000000000-0x000000020000 : "SPL"
    [    1.022625] 0x000000020000-0x000000040000 : "SPL.backup1"
    [    1.029573] 0x000000040000-0x000000060000 : "SPL.backup2"
    [    1.036601] 0x000000060000-0x000000080000 : "SPL.backup3"
    [    1.043773] 0x000000080000-0x000000260000 : "U-Boot"
    [    1.050965] 0x000000260000-0x000000280000 : "U-Boot Env"
    [    1.057774] 0x000000280000-0x000000580000 : "logo"
    [    1.065288] 0x000000580000-0x000000a80000 : "Kernel"
    [    1.073815] 0x000000a80000-0x000010000000 : "File System"
    [    1.181978] OneNAND driver initializing
    [    1.187315] CAN device driver interface
    [    1.191365] CAN bus driver for Bosch D_CAN controller 1.0
    [    1.197786] d_can d_can.0: device registered (irq=52, irq_obj=53)
    [    1.250133] davinci_mdio davinci_mdio.0: davinci mdio revision 1.6
    [    1.256601] davinci_mdio davinci_mdio.0: detected phy mask fffffffe
    [    1.263972] davinci_mdio.0: probed
    [    1.267532] davinci_mdio davinci_mdio.0: phy[0]: device 0:00, driver SMSC LAN8710/LAN8720
    [    1.276263] PPP generic driver version 2.4.2
    [    1.281177] PPP BSD Compression module registered
    [    1.286097] PPP Deflate Compression module registered
    [    1.291597] usbcore: registered new interface driver zd1201
    [    1.297595] usbcore: registered new interface driver cdc_ether
    [    1.303859] usbcore: registered new interface driver cdc_eem
    [    1.309910] usbcore: registered new interface driver dm9601
    [    1.315788] cdc_ncm: 04-Aug-2011
    [    1.319304] usbcore: registered new interface driver cdc_ncm
    [    1.325411] usbcore: registered new interface driver cdc_acm
    [    1.331340] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
    [    1.339708] Initializing USB Mass Storage driver...
    [    1.345018] usbcore: registered new interface driver usb-storage
    [    1.351313] USB Mass Storage support registered.
    [    1.356464] usbcore: registered new interface driver usbserial
    [    1.362711] USB Serial support registered for generic
    [    1.368135] usbcore: registered new interface driver usbserial_generic
    [    1.374974] usbserial: USB Serial Driver core
    [    1.379650] USB Serial support registered for GSM modem (1-port)
    [    1.386182] usbcore: registered new interface driver option
    [    1.392024] option: v0.7.2:USB Driver for GSM modems
    [    1.397762] mousedev: PS/2 mouse device common for all mice
    [    1.404273] input: ti-tsc as /devices/platform/omap/ti_tscadc/tsc/input/input0
    [    1.413016] input: ft5x06_ts as /devices/virtual/input/input1
    [    1.471658] rtc-ds1307 1-0068: rtc core: registered ds1339 as rtc0
    [    1.478272] i2c /dev entries driver
    [    1.484875] cpuidle: using governor ladder
    [    1.489596] cpuidle: using governor menu
    [    1.498275] usbcore: registered new interface driver usbhid
    [    1.504148] usbhid: USB HID core driver
    [    1.508796] tiadc tiadc: attached adc driver
    [    1.515476] _regulator_get: 1-001b supply IOVDD not found, using dummy regulator
    [    1.523316] _regulator_get: 1-001b supply DVDD not found, using dummy regulator
    [    1.531014] _regulator_get: 1-001b supply AVDD not found, using dummy regulator
    [    1.538687] _regulator_get: 1-001b supply DRVDD not found, using dummy regulator
    [    1.548870] asoc: tlv320aic3x-hifi <-> davinci-mcasp.1 mapping ok
    [    1.559602] ALSA device list:
    [    1.562764]   #0: COM335X EVM
    [    1.565863] oprofile: hardware counters not available
    [    1.571151] oprofile: using timer interrupt.
    [    1.575638] nf_conntrack version 0.5.0 (1934 buckets, 7736 max)
    [    1.582280] ip_tables: (C) 2000-2006 Netfilter Core Team
    [    1.587943] TCP cubic registered
    [    1.591350] NET: Registered protocol family 17
    [    1.596003] can: controller area network core (rev 20090105 abi 8)
    [    1.602550] NET: Registered protocol family 29
    [    1.607224] can: raw protocol (rev 20090105)
    [    1.611700] can: broadcast manager protocol (rev 20090105 t)
    [    1.617652] Registering the dns_resolver key type
    [    1.622652] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
    [    1.630683] ThumbEE CPU extension supported.
    [    1.635207] mux: Failed to setup hwmod io irq -22
    [    1.640770] Power Management for AM33XX family
    [    1.645420] pm: Err (-22) setting core voltage setting
    [    1.651017] Trying to load am335x-pm-firmware.bin (60 secs timeout)
    [    1.657683] Copied the M3 firmware to UMEM
    [    1.662038] Cortex M3 Firmware Version = 0x184
    [    1.669860] clock: disabling unused clocks to save power
    [    1.677483] Detected MACID=ec:24:b8:b1:f2:38
    [    1.683936] rtc-ds1307 1-0068: setting system clock to 2016-07-14 13:50:15 UTC (1468504215)
    [    1.695691] net eth0: CPSW phy found : id is : 0x7c0f1
    [    1.701865] PHY 0:01 not found
    [    5.690645] PHY: 0:00 - Link is Up - 100/Full
    [    5.720110] IP-Config: Guessing netmask 255.255.255.0
    [    5.725532] IP-Config: Complete:
    [    5.728905]      device=eth0, addr=192.168.1.111, mask=255.255.255.0, gw=255.255.255.255,
    [    5.737217]      host=192.168.1.111, domain=, nis-domain=(none),
    [    5.743507]      bootserver=255.255.255.255, rootserver=192.168.1.100, rootpath=
    [    5.757059] VFS: Mounted root (nfs filesystem) on device 0:15.
    [    5.763600] devtmpfs: mounted
    [    5.767031] Freeing init memory: 232K
    INIT: version 2.88 booting
    Starting udev
    [    6.424949] udevd[654]: starting version 182
    bootlogd: cannot allocate pseudo tty: No such file or directory
    INIT: Entering runlevel: 5
    Configuring network interfaces... ifup skipped for nfsroot interface eth0
    run-parts: /etc/network/if-pre-up.d/nfsroot exited with code 1
    Starting syslogd/klogd: done

    Poky (Yocto Project Reference Distro) 2.0.2 beaglebone /dev/ttyO0

    beaglebone login: root
    root@beaglebone:~#
    从log中我们可以看到内核的时间,以及rootfs的启动,但是我们发现启动不久后就重启了,那是因为watch dog的原因。

    到这里,我们就构建了基本的环境与系统了。我们在接下来的文章中将继续使用Yocto等来构建与开发。

    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    关闭

    站长推荐上一条 /4 下一条

    手机版|爱板网 |网站地图  

    GMT+8, 2018-2-20 10:06 , Processed in 0.389372 second(s), 12 queries , Memcache On.

    苏公网安备 32059002001056号

    Powered by Discuz!

    回顶部