zynq linux 201704

官网下载kernel u-boot rootfs 设备树的扳机支持包

arm_ramdisk.image.gz 
device-tree-xlnx-xilinx-v2017.4.tar.gz 
u-boot-xlnx-master.zip                    
linux-xlnx-master.zip
解压内核和u-boot 直接进入内核和u-boot根目录的
vim Makefile 在开始的地方直接添加两个变量
ARCH = arm
CROSS_COMPILE = arm-linux-gnueabihf-
我用的是petalinux自带的交叉工具链 所以是arm-linux-gnueabihf-而不是arm-linux-gnueabi-
source petalinux 安装目录下的setting.sh

进入内核根目录

sudo apt-get install u-boot-tools

要不然会出现如下错误提示

"mkimage" command not found - U-Boot images will not be built

arch/arm/boot/Makefile:79: recipe for target 'arch/arm/boot/uImage' failed

make[1]: *** [arch/arm/boot/uImage] Error 1

arch/arm/Makefile:329: recipe for target 'uImage' failed

make: *** [uImage] Error 2

安装完编译工具后
linux-xlnx-master$ make distclean
make xilinx_zynq_defconfig

linux-xlnx-master$ make UIMAGE_LOADADDR=0x8000 uImage -j8

  OBJCOPY arch/arm/boot/zImage

  Kernel: arch/arm/boot/zImage is ready

  UIMAGE  arch/arm/boot/uImage

Image Name:   Linux-4.9.0-xilinx

Created:      Thu Jul  5 20:03:03 2018

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    3745912 Bytes = 3658.12 kB = 3.57 MB

Load Address: 00008000

Entry Point:  00008000

  Kernel: arch/arm/boot/uImage is ready

内核初步编译完成

进入u-boot目录

Sudo apt-get install libssl-dev不然会出现以下错诶

In file included from tools/atmelimage.c:11:0:

include/image.h:1024:27: fatal error: openssl/evp.h: No such file or directory

compilation terminated.

......

Makefile:1220: recipe for target 'tools' failed

make: *** [tools] Error 2

然后

sudo apt-get install device-tree-compiler不然会出现以下错误

dtc: not found

vim Makefile 在开始的地方直接添加两个变量
ARCH = arm
CROSS_COMPILE = arm-linux-gnueabihf-

u-boot-xlnx-master$ make distclean

vim include/configs/zynq_common.h

增加对网路的配置信息,因为我要用tftp下载镜像,jtag下载镜像然后sf从qspi启动太浪费时间了,不利于调试错误。

#define CONFIG_SERVERIP 192.168.0.100
#define CONFIG_IPADDR 192.168.0.10
#define CONFIG_GATEWAYIP 192.168.0.1
#define CONFIG_NETMASK 255.255.255.0

u-boot-xlnx-master$ make zynq_zed_defconfig

u-boot-xlnx-master$ make -j8

u-boot-xlnx-master$ cp u-boot u-boot.elf

接下来用SDK做镜像和设备树,这个地方要说一下,如果是最新版本的u-boot会发现,include/configs目录只有一个,zynq-common.h,之前的zynq-zed.h已经不在了,所以内存大小串口信息的宏定义没地方定义,后来折腾了之后向导设备树arch/arm/dts/zynq-zed.dts文件可以更改串口(因为我用的是uart0,zedboard都是默认uart1),网口和mmc的信息

解压官网设备树的2bsp包,打开SDK点击windows的preference选项 点击new找到设备树bsp目录即可


点击rescan repositories apply ok 关闭对话框

建立板级支持包


复制所有.dtsi .dts文件到scripts/dtc目录,并进入该目录执行,官方提供教程里面找不到目录,可能是17.4的bug

这里最重要的是填写bootargs 点击设备树bsp->system.mss->修改设备树设置->device tree

console=ttyPS0,115200  root=/dev/ram0 rw  earlyprintk

dtc -I dts -O dtb -o devicetree.dtb system-top.dts

用SDK提供的镜像制作工具制作只有fsbl和u-boot.elf的BOOT.bin文件,只做启动用,然后烧写到qspi flash里面,17.4版本的SDK烧写不了qspi flash,windows版本和linux版本都一样,懒得重新下了,应该也是个bug,但是有的人却可以,郁闷,


注意FSBL File不是灰色的,加载fsbl后可以烧写但是会出错,我就不黏贴了

直接在虚拟机以外的windows10上安装15.4烧写,很小很快。

把arm_ramdisk.image.gz 改成ramdisk.image.gz 在当前目录执行

mkimage -n 'uboot ext2 ramdisk' -A arm -O linux -T ramdisk -C gzip -d ramdisk.image.gz uramdisk.image.gz

然后在windows下 下载tftp32 安装 设置文件夹 然后把devicetree.dtb uImage urandisk.image.gz 拷贝到tftp目录下

接下来就要做的是启动板子的linux挂载文件系统了 ,但是悲剧的是我的是米联的702板子,串口用着不是太顺,得打开板子电源,然后快速的点击secureCRT链接才能链接上串口,链不好secureCRT还会崩溃,只能重启电脑,用串口调试助手也是一样,必须很短的时间内上电和链接掌握得恰到好处才行,否则什么输出都没有,linux下使用minicom同样悲剧的情况,售后返厂换了个底板,还是老样子,又一个郁闷啊,调试下就可以必须让板子供电稳定了,串口才能好好输出,取巧办法,直接sdk调试fsbl,然后


如图那样在读取启动模式寄存器的地方打断点,0是JTAG,1是QSPI然后修改成1,fsbl我开了FSBL_DEBUG_INFO打印的宏,打印出来的信息判断正好就是我刚才制作的fsbl加u-boot的信息,pintenv查看了一下IP信息,原本是没有的,确定设置正确继续

Xilinx First Stage Boot Loader 
Release 2017.4 Jan 14 2018-18:41:24
Devcfg driver initialized 
Silicon Version 3.1
Boot mode is QSPI
Single Flash Information
FlashID=0x1 0x2 0x19
SPANSION 256M Bits
QSPI is in single flash connection
QSPI is in 4-bit mode
QSPI Init Done 
Flash Base Address: 0xFC000000
Reboot status register: 0x60580002
Multiboot Register: 0x0000C000
Image Start Address: 0x00000000
Partition Header Offset:0x00000C80
Partition Count: 2
Partition Number: 1
Header Dump
Image Word Len: 0x00016C7E
Data Word Len: 0x00016C7E
Partition Word Len:0x00016C7E
Load Addr: 0x04000000
Exec Addr: 0x04000000
Partition Start: 0x000055D0
Partition Attr: 0x00000010
Partition Checksum Offset: 0x00000000
Section Count: 0x00000001
Checksum: 0xF7FB6254
Application
Handoff Address: 0x04000000
In FsblHookBeforeHandoff function 
SUCCESSFUL_HANDOFF
FSBL Status = 0x1

然后调试secureCRT点击链接,然后继续跑。

U-Boot 2017.01 (Jan 16 2018 - 15:37:43 +0800)


Model: Zynq Zed Development Board
Board: Xilinx Zynq
DRAM:  ECC disabled 512 MiB
SF: Detected s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
*** Warning - bad CRC, using default environment


In:    serial@e0001000
Out:   serial@e0001000
Err:   serial@e0001000
Model: Zynq Zed Development Board
Board: Xilinx Zynq
Net:   ZYNQ GEM: e000b000, phyaddr 0, interface rgmii-id
eth0: ethernet@e000b000
Hit any key to stop autoboot:  2 1 0 
TFTPing Linux to RAM...
ethernet@e000b000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Zynq> run jtagboot
TFTPing Linux to RAM...
ethernet@e000b000 Waiting for PHY auto negotiation to complete.... done
Using ethernet@e000b000 device
TFTP from server 192.168.0.100; our IP address is 192.168.0.10
Filename 'uImage'.
Load address: 0x2080000
Loading: *
ARP Retry count exceeded; starting again
Zynq> run jtagboot
TFTPing Linux to RAM...
Using ethernet@e000b000 device
TFTP from server 192.168.0.100; our IP address is 192.168.0.10
Filename 'uImage'.
Load address: 0x2080000
Loading: *#################################################################
#################################################################
#################################################################
#############################################################
2.9 MiB/s
done
Bytes transferred = 3745952 (3928a0 hex)
Using ethernet@e000b000 device
TFTP from server 192.168.0.100; our IP address is 192.168.0.10
Filename 'devicetree.dtb'.
Load address: 0x2000000
Loading: *#
2.2 MiB/s
done
Bytes transferred = 9115 (239b hex)
Using ethernet@e000b000 device
TFTP from server 192.168.0.100; our IP address is 192.168.0.10
Filename 'uramdisk.image.gz'.
Load address: 0x4000000
Loading: *#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#####################################
2.9 MiB/s
done
Bytes transferred = 5310063 (51066f hex)
## Booting kernel from Legacy Image at 02080000 ...
   Image Name:   Linux-4.9.0-xilinx
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3745888 Bytes = 3.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   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:    5309999 Bytes = 5.1 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 1e62b000, end 1eb3b62f ... OK
   Loading Device Tree to 1e625000, end 1e62a39a ... OK


Starting kernel ...


Booting Linux on physical CPU 0x0
Linux version 4.9.0-xilinx (hello@hello-virtual-machine) (gcc version 6.2.1 20161114 (Linaro GCC Snapshot 6.2-2016.11) ) #1 SMP PREEMPT Tue Jan 16 15:03:09 CST 2018
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt:Machine model: xlnx,zynq-7000
earlycon: cdns0 at MMIO 0xe0001000 (options '115200n8')
bootconsole [cdns0] enabled
cma: Reserved 16 MiB at 0x1f000000
Memory policy: Data cache writealloc
percpu: Embedded 14 pages/cpu @debcc000 s25932 r8192 d23220 u57344
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttyPS0,115200  root=/dev/ram0 rw  earlyprintk earlycon
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 487852K/524288K available (6144K kernel code, 199K rwdata, 1456K rodata, 1024K init, 230K bss, 20052K reserved, 16384K cma-reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
    lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc0700000   (7136 kB)
      .init : 0xc0900000 - 0xc0a00000   (1024 kB)
      .data : 0xc0a00000 - 0xc0a31e00   ( 200 kB)
       .bss : 0xc0a31e00 - 0xc0a6b618   ( 231 kB)
Preemptible hierarchical RCU implementation.
Build-time adjustment of leaf fanout to 32.
RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
NR_IRQS:16 nr_irqs:16 16
efuse mapped to e0800000
slcr mapped to e0802000
L2C: platform modifies aux control register: 0x72360000 -> 0x72760000
L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
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 0x76760001
zynq_clock_init: clkc starts at e0802100
Zynq clock init
sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398046511103ns
clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x4ce07af025, max_idle_ns: 440795209040 ns
Switching to timer-based delay loop, resolution 3ns
clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
timer #0 at e080a000, irq=17
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 666.66 BogoMIPS (lpj=3333333)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x100000 - 0x100058
CPU1: failed to come online
Brought up 1 CPUs
SMP: Total of 1 processors activated (666.66 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
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 @ 0xe0840000
zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 25, base_baud = 6249999) is a xuartps
k讒W/LW怸稾倍ed
console [ttyPS0] enabled
bootconsole [cdns0] disabled
bootconsole [cdns0] disabled
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 <giometti@linux.it>
PTP clock support registered
EDAC MC: Ver: 3.0.0
FPGA manager framework
fpga-region fpga-full: FPGA Region probed
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm_global_timer
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 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 (no cpio magic); looks like an initrd
Freeing initrd memory: 5188K (de62b000 - deb3c000)
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
futex hash table entries: 512 (order: 3, 32768 bytes)
workingset: timestamp_bits=30 max_order=17 bucket_order=0
jffs2: version 2.2. (NAND) (SUMMARY)  漏 2001-2006 Red Hat, Inc.
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
[drm] Initialized
brd: module loaded
loop: module loaded
libphy: Fixed MDIO Bus: probed
CAN device driver interface
libphy: MACB_mii_bus: probed
macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 27 (00:0a:35:00:01:22)
Marvell 88E1510 e000b000.etherne:00: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.etherne:00, irq=-1)
e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer at e0942000 with timeout 10s
EDAC MC: 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
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
NET: Registered protocol family 10
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
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 20161123 t)
can: netlink gateway (rev 20130117) max_hops=1
Registering SWP/SWPB emulation handler
hctosys: unable to open rtc device (rtc0)
of_cfs_init
of_cfs_init: OK
ALSA device list:
  No soundcards found.
RAMDISK: gzip image found at block 0
EXT4-fs (ram0): couldn't mount as ext3 due to feature incompatibilities
EXT4-fs (ram0): mounted filesystem without journal. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 1:0.
devtmpfs: mounted
Freeing unused kernel memory: 1024K (c0900000 - c0a00000)
Starting rcS...
++ Mounting filesystem
mount: mounting /dev/mmcblk0p1 on /mnt failed: No such file or directory
mount: mounting /dev/mmcblk0 on /mnt failed: No such file or directory
++ Setting up mdev
++ Starting telnet daemon
++ Starting http daemon
++ Starting ftp daemon
++ Starting ssh daemon
random: sshd: uninitialized urandom read (32 bytes read)

但是不知道为什么只启动了一个cpu,可能是设备树的问题没写好。

对比了一下petalinux生产的设备树,反向编译dts信息

cpus {
#address-cells = <0x1>;
#size-cells = <0x0>;
cpu@0 {
compatible = "arm,cortex-a9";
device_type = "cpu";
reg = <0x0>;
clocks = <0x1 0x3>;
clock-latency = <0x3e8>;
cpu0-supply = <0x2>;
operating-points = <0xa2c2a 0xf4240 0x51615 0xf4240>;
};
cpu@1 {
compatible = "arm,cortex-a9";
device_type = "cpu";
reg = <0x1>;
clocks = <0x1 0x3>;
};
};

这个后来发现是因为插着jtag启动的原因,会导致cpu1 起不来,即使启动停在uboot,拔掉jtag后依旧是这样,玩板子也不容易。



  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值