Zynq 7015 linux跑起来之SD分区并放入对应的文件

现在所要的文件基本上已都有了,怎么样来放到SD卡里来让系统运行起来呢?这里主要介绍Linux下面的方法,Windows下面用工具分就不说了。

sudo fdisk /dev/sdx(这里根据实情情况来) fdisk 的使用在网上找。这里主要是建立两个分区。
然后进行格式化,一个FAT32格式,一个EXT4格式。

U-Boot 2016.07 (Dec 16 2016 - 15:04:03 +0800)

Model: Zynq PicoZed Board
Board: Xilinx Zynq
DRAM: ECC disabled 1 GiB
MMC: sdhci@e0100000: 0
Using default environment

In: serial@e0001000
Out: serial@e0001000
Err: serial@e0001000
Model: Zynq PicoZed Board
Board: Xilinx Zynq
Net: ZYNQ GEM: e000b000, phyaddr 0, interface rgmii-id
PHY is not detected
GEM PHY init failed
No ethernet found.
Hit any key to stop autoboot: 0
Device: sdhci@e0100000
Manufacturer ID: 3
OEM: 5344
Name: SU04G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 3.7 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading uEnv.txt
** Unable to read file uEnv.txt **
Copying Linux from SD to RAM...
reading uImage
3448056 bytes read in 617 ms (5.3 MiB/s)
reading devicetree.dtb
9660 bytes read in 19 ms (496.1 KiB/s)
reading uramdisk.image.gz
3694108 bytes read in 674 ms (5.2 MiB/s)
## Booting kernel from Legacy Image at 02080000 ...
Image Name: Linux-3.18.0-xilinx
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3447992 Bytes = 3.3 MiB
Load Address: 02080000
Entry Point: 02080000
Verifying Checksum ... OK
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid

这里用的文件系统是直接用的zedboard里面带的,直接用是用不了的,简单改名也行不能,那么怎么办呢?

gavin@zynq# print
baudrate=115200
bitstream_image=system.bit.bin
boot_image=BOOT.bin
boot_size=0xF00000
bootcmd=run $modeboot
bootdelay=2
bootenv=uEnv.txt
devicetree_image=devicetree.dtb
devicetree_load_address=0x2000000
devicetree_size=0x20000
dfu_mmc=run dfu_mmc_info && dfu 0 mmc 0
dfu_mmc_info=set dfu_alt_info ${kernel_image} fat 0 1\\;${devicetree_image} fat 0 1\\;${ramdisk_image} fat 0 1
dfu_ram=run dfu_ram_info && dfu 0 ram 0
dfu_ram_info=set dfu_alt_info ${kernel_image} ram 0x3000000 0x500000\\;${devicetree_image} ram 0x2A00000 0x20000\\;0
ethaddr=00:0a:35:00:01:22
fdt_high=0x20000000
fdtcontroladdr=3ff95c10
fileaddr=4000000
filesize=385e1c
importbootenv=echo Importing environment from SD ...; env import -t ${loadbootenv_addr} $filesize
initrd_high=0x20000000
jtagboot=echo TFTPing Linux to RAM... && tftpboot ${kernel_load_address} ${kernel_image} && tftpboot ${devicetree_l}
kernel_image=uImage
kernel_load_address=0x2080000
kernel_size=0x500000
loadbit_addr=0x100000
loadbootenv=load mmc 0 ${loadbootenv_addr} ${bootenv}
loadbootenv_addr=0x2000000
mmc_loadbit=echo Loading bitstream from SD/MMC/eMMC to RAM.. && mmcinfo && load mmc 0 ${loadbit_addr} ${bitstream_i}
modeboot=sdboot
nandboot=echo Copying Linux from NAND flash to RAM... && nand read ${kernel_load_address} 0x100000 ${kernel_size} &}
norboot=echo Copying Linux from NOR flash to RAM... && cp.b 0xE2100000 ${kernel_load_address} ${kernel_size} && cp.}
preboot=if test $modeboot = sdboot && env run sd_uEnvtxt_existence_test; then if env run loadbootenv; then env run
qspiboot=echo Copying Linux from QSPI flash to RAM... && sf probe 0 0 0 && sf read ${kernel_load_address} 0x100000 }
ramdisk_image=uramdisk.image.gz
ramdisk_load_address=0x4000000
ramdisk_size=0x5E0000
rsa_jtagboot=echo TFTPing Image to RAM... && tftpboot 0x100000 ${boot_image} && zynqrsa 0x100000 && bootm ${kernel_}
rsa_nandboot=echo Copying Image from NAND flash to RAM... && nand read 0x100000 0x0 ${boot_size} && zynqrsa 0x10000}
rsa_norboot=echo Copying Image from NOR flash to RAM... && cp.b 0xE2100000 0x100000 ${boot_size} && zynqrsa 0x10000}
rsa_qspiboot=echo Copying Image from QSPI flash to RAM... && sf probe 0 0 0 && sf read 0x100000 0x0 ${boot_size} &&}
rsa_sdboot=echo Copying Image from SD to RAM... && load mmc 0 0x100000 ${boot_image} && zynqrsa 0x100000 && bootm $}
sd_uEnvtxt_existence_test=test -e mmc 0 /uEnv.txt
sdboot=if mmcinfo; then run uenvboot; echo Copying Linux from SD to RAM... && load mmc 0 ${kernel_load_address} ${ki
stderr=serial@e0001000
stdin=serial@e0001000
stdout=serial@e0001000
thor_mmc=run dfu_mmc_info && thordown 0 mmc 0
thor_ram=run dfu_ram_info && thordown 0 ram 0
uenvboot=if run loadbootenv; then echo Loaded environment from ${bootenv}; run importbootenv; fi; if test -n $uenvci
usbboot=if usb start; then run uenvboot; echo Copying Linux from USB to RAM... && load usb 0 ${kernel_load_address}i

Environment size: 4851/131068 bytes
这是直接在之前的文件系统基础上面改的。
gunzip ramdisk8M.image.gz
mkimage -n 'uboot ext2 ramdisk' -A arm -O linux -T ramdisk -C gzip -d ramdisk8M.image uramdisk.image.gz

U-Boot 2016.07 (Dec 16 2016 - 15:04:03 +0800)

Model: Zynq PicoZed Board
Board: Xilinx Zynq
DRAM: ECC disabled 1 GiB
MMC: sdhci@e0100000: 0
Using default environment

In: serial@e0001000
Out: serial@e0001000
Err: serial@e0001000
Model: Zynq PicoZed Board
Board: Xilinx Zynq
Net: ZYNQ GEM: e000b000, phyaddr 0, interface rgmii-id
PHY is not detected
GEM PHY init failed
No ethernet found.
Hit any key to stop autoboot: 0
Device: sdhci@e0100000
Manufacturer ID: 3
OEM: 5344
Name: SU04G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 3.7 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading uEnv.txt
** Unable to read file uEnv.txt **
Copying Linux from SD to RAM...
reading uImage
3448056 bytes read in 618 ms (5.3 MiB/s)
reading devicetree.dtb
9660 bytes read in 18 ms (523.4 KiB/s)
reading uramdisk.image.gz
8388672 bytes read in 1505 ms (5.3 MiB/s)
## Booting kernel from Legacy Image at 02080000 ...
Image Name: Linux-3.18.0-xilinx
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3447992 Bytes = 3.3 MiB
Load Address: 02080000
Entry Point: 02080000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 04000000 ...
Image Name: uboot ext2 ramdisk
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 8388608 Bytes = 8 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 02000000
Booting using the fdt blob at 0x2000000
Loading Kernel Image ... OK
Loading Ramdisk to 1f800000, end 20000000 ... OK
Loading Device Tree to 1f7fa000, end 1f7ff5bb ... OK

Starting kernel ...
到这一步,基本上就离成功不远了,我就不一一分析了 http://blog.csdn.net/luhao806/article/details/7338465 ,但直觉告诉我,应该是串口没有设对。所以我直接去到内核源码中,修改dts文件,直接将串口1改为0,然后 重新生成devcietree.dtb文件,然后替换掉SD卡里面的就OK了。下面是完整的打印信息。

U-Boot 2016.07 (Dec 16 2016 - 15:04:03 +0800)

Model: Zynq PicoZed Board
Board: Xilinx Zynq
DRAM: ECC disabled 1 GiB
MMC: sdhci@e0100000: 0
Using default environment

In: serial@e0001000
Out: serial@e0001000
Err: serial@e0001000
Model: Zynq PicoZed Board
Board: Xilinx Zynq
Net: ZYNQ GEM: e000b000, phyaddr 0, interface rgmii-id
PHY is not detected
GEM PHY init failed
No ethernet found.
Hit any key to stop autoboot: 0
Device: sdhci@e0100000
Manufacturer ID: 3
OEM: 5344
Name: SU04G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 3.7 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading uEnv.txt
** Unable to read file uEnv.txt **
Copying Linux from SD to RAM...
reading uImage
3448056 bytes read in 618 ms (5.3 MiB/s)
reading devicetree.dtb
9133 bytes read in 24 ms (371.1 KiB/s)
reading uramdisk.image.gz
8388672 bytes read in 1504 ms (5.3 MiB/s)
## Booting kernel from Legacy Image at 02080000 ...
Image Name: Linux-3.18.0-xilinx
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3447992 Bytes = 3.3 MiB
Load Address: 02080000
Entry Point: 02080000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 04000000 ...
Image Name: uboot ext2 ramdisk
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 8388608 Bytes = 8 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 02000000
Booting using the fdt blob at 0x2000000
Loading Kernel Image ... OK
Loading Ramdisk to 1f800000, end 20000000 ... OK
Loading Device Tree to 1f7fa000, end 1f7ff3ac ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 3.18.0-xilinx (gavin@oscom) (gcc version 4.9.2 (Sourcery CodeBench Lite 2015.05-17) ) #1 SMP PREEMPT 6
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Zynq PicoZed Board
cma: Reserved 16 MiB at 0x3f000000
Memory policy: Data cache writealloc
PERCPU: Embedded 10 pages/cpu @7e7d1000 s8768 r8192 d24000 u40960
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260096
Kernel command line: console=ttyPS0,115200 root=/dev/ram rw earlyprintk
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 1007836K/1048576K available (4646K kernel code, 258K rwdata, 1616K rodata, 216K init, 219K bss, 40740K rese)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xffe00000 (2048 kB)
vmalloc : 0x80800000 - 0xff000000 (2024 MB)
lowmem : 0x40000000 - 0x80000000 (1024 MB)
pkmap : 0x3fe00000 - 0x40000000 ( 2 MB)
modules : 0x3f000000 - 0x3fe00000 ( 14 MB)
.text : 0x40008000 - 0x40625b04 (6263 kB)
.init : 0x40626000 - 0x4065c000 ( 216 kB)
.data : 0x4065c000 - 0x4069cb60 ( 259 kB)
.bss : 0x4069cb60 - 0x406d3a78 ( 220 kB)
Preemptible hierarchical RCU implementation.
Dump stacks of tasks blocking RCU-preempt GP.
RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
NR_IRQS:16 nr_irqs:16 16
L2C-310 erratum 769419 enabled
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 ID prefetch enabled, offset 1 lines
L2C-310 dynamic clock gating enabled, standby mode enabled
L2C-310 cache controller enabled, 8 ways, 512 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76360001
slcr mapped to 80804000
zynq_clock_init: clkc starts at 80804100
Zynq clock init
sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 3298534883328ns
timer #0 at 80806000, irq=43
Console: colour dummy device 80x30
Calibrating delay loop... 1332.01 BogoMIPS (lpj=6660096)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x466698 - 0x4666f0
CPU1: Booted secondary processor
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
Brought up 2 CPUs
SMP: Total of 2 processors activated.
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
regulator-dummy: no parameters
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0x80880000
VCCPINT: 1000 mV
vgaarb: loaded
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
media: Linux media interface: v0.10
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti
PTP clock support registered
EDAC MC: Ver: 3.0.0
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource arm_global_timer
NET: Registered protocol family 2
TCP established hash table entries: 8192 (order: 3, 32768 bytes)
TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP: reno registered
UDP hash table entries: 512 (order: 2, 16384 bytes)
UDP-Lite hash table entries: 512 (order: 2, 16384 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.
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (junk in compressed archive); looks like an initrd
Freeing initrd memory: 8192K (5f800000 - 60000000)
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
futex hash table entries: 512 (order: 3, 32768 bytes)
jffs2: version 2.2. (NAND) (SUMMARY) ?© 2001-2006 Red Hat, Inc.
msgmni has been set to 2016
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.dmac: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
xuartps e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82, base_baud = 3125000) is a xuartps
console [ttyPS0] enabled
xdevcfg f8007000.devcfg: ioremap 0xf8007000 to 8086c000
[drm] Initialized drm 1.1.0 20060810
brd: module loaded
loop: module loaded
m25p80 spi0.0: found s25fl256s1, expected n25q128a11
m25p80 spi0.0: s25fl256s1 (32768 Kbytes)
5 ofpart partitions found on MTD device spi0.0
Creating 5 MTD partitions on "spi0.0":
0x000000000000-0x000000100000 : "qspi-fsbl-uboot"
0x000000100000-0x000000600000 : "qspi-linux"
0x000000600000-0x000000620000 : "qspi-device-tree"
0x000000620000-0x000000c00000 : "qspi-rootfs"
0x000000c00000-0x000001000000 : "qspi-bitstream"
CAN device driver interface
e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
e1000e: Copyright(c) 1999 - 2014 Intel Corporation.
libphy: XEMACPS mii bus: probed
xemacps e000b000.ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
zynq-dr e0002000.usb: Unable to init USB phy, missing?
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
zynq-edac f8006000.memory-controller: ecc not enabled
Xilinx Zynq CpuIdle Driver started
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
sdhci-arasan e0100000.sdhci: No vmmc regulator found
sdhci-arasan e0100000.sdhci: No vqmmc regulator found
mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP: cubic registered
NET: Registered protocol family 17
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
Registering SWP/SWPB emulation handler
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
ALSA device list:
No soundcards found.
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 8192KiB [1 disk] into ram disk... -
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SU04G 3.69 GiB
mmcblk0: p1 p2

done.
EXT2-fs (ram0): warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem) on device 1:0.
devtmpfs: mounted
Freeing unused kernel memory: 216K (40626000 - 4065c000)
Starting rcS...
++ Mounting filesystem
++ Setting up mdev
++ Configure static IP 192.168.1.10
xemacps e000b000.ethernet: eth0: no PHY found
xemacps e000b000.ethernet: XEMACPS mii bus mii_probe fail.
ifconfig: SIOCSIFFLAGS: No such device or address
++ Starting telnet daemon
++ Starting http daemon
++ Starting ftp daemon
++ Starting dropbear (ssh) daemon
random: dropbear urandom read with 1 bits of entropy available
++ Starting OLED Display
insmod: can't read '/lib/modules/3.18.0-xilinx/pmodoled-gpio.ko': No such file or directory
++ Exporting LEDs & SWs
/etc/init.d/rcS: line 46: can't create /sys/class/gpio/gpio61/direction: nonexistent directory
/etc/init.d/rcS: line 46: can't create /sys/class/gpio/gpio62/direction: nonexistent directory
/etc/init.d/rcS: line 46: can't create /sys/class/gpio/gpio63/direction: nonexistent directory
/etc/init.d/rcS: line 46: can't create /sys/class/gpio/gpio64/direction: nonexistent directory
/etc/init.d/rcS: line 46: can't create /sys/class/gpio/gpio65/direction: nonexistent directory
/etc/init.d/rcS: line 46: can't create /sys/class/gpio/gpio66/direction: nonexistent directory
/etc/init.d/rcS: line 46: can't create /sys/class/gpio/gpio67/direction: nonexistent directory
/etc/init.d/rcS: line 46: can't create /sys/class/gpio/gpio68/direction: nonexistent directory
rcS Complete
zynq>

从打印信息来看,目前网卡和USB还没有起来,待我慢慢查出来,后面还有很多,我都会记录下来!

本文转载自:Gavin.Jing