Microzed Board

From wiki.openedev
Jump to: navigation, search

Board Info

  • CPU Zynq-7000 AP SoC XC7Z010-CLG400-1
  • DDR 1G DDR3
  • QSPI 128MB Flash
  • GMAC 10/100/1000 Ethernet
  • USB 2.0
  • USB to UART

Tools setup

  • Setup buildman
 bash> git clone https://github.com/openedev/u-boot-zynq.git
 bash> ~/.buildman
 [toolchain]
 root: /
 rest: /toolchains/*
 eldk: /opt/eldk-4.2
 arm: /opt/linaro/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux
 aarch64: /opt/linaro/gcc-linaro-aarch64-none-elf-4.8-2013.10_linux
 [toolchain-alias]
 x86: i386
 blackfin: bfin
 nds32: nds32le
 openrisc: or1k
  • Install armv7 toochain
 bash> ./tools/buildman/buildman --fetch-arch arm
  • Export the toolchain
 bash> export PATH=~/.buildman-toolchains/gcc-4.9.0-nolibc/arm-unknown-linux-gnueabi/bin:$PATH
 bash> export CROSS_COMPILE=arm-unknown-linux-gnueabi-

Getting start with Linux

Build U-Boot

  • Configure u-boot for microzed board
 bash> git clone https://github.com/openedev/u-boot-zynq.git
 bash> make zynq_microzed_defconfig
  • Build and copy the image into sd boot partition
 bash> make DEVICE_TREE=zynq-microzed
 bash> cp u-boot-dtb.bin /media/boot

Build Linux

  • Build Linux and copy to sd card boot partition
 bash> git clone https://github.com/openedev/linux-zynq.git
 bash> make ARCH=arm zynq_defconfig
 bash> make ARCH=arm LOADADDR=0x8000 uImage 
 bash> cp arch/arm/boot/uImage /media/boot

Build devicetree

  • Build microzed devicetree and copy to sd card boot partition
 bash> make ARCH=arm DEVICETREE=zynq-microzed
 bash> cp arch/arm/boot/dts/zynq-microzed.dtb /media/boot/devicetree.dtb

Build Ramdisk

  • Download ramdisk from xilinx wiki ramdisk
  • Create uramdisk.image.gz and copy into sdcard boot partition
 bash> mkimage -A arm -T ramdisk -C gzip -d arm_ramdisk.image.gz uramdisk.image.gz
 Image Name:   
 Created:      Thu Sep 22 17:08:51 2016
 Image Type:   ARM Linux RAMDisk Image (gzip compressed)
 Data Size:    5309954 Bytes = 5185.50 kB = 5.06 MB
 Load Address: 00000000
 Entry Point:  00000000
 bash> cp  /media/boot

Setup SD Boot

Set the board to any bootmode which have prebuilt images to boot

zynq-uboot> 
zynq-uboot> fatload mmc 0:1 0x4000000 u-boot-dtb.bin
reading u-boot-dtb.bin
462525 bytes read in 70 ms (6.3 MiB/s)
zynq-uboot> go 0x4000000
## Starting application at 0x04000000 ...
U-Boot 2016.09-00103-gfe4753c (Sep 22 2016 - 14:41:48 +0530)
Model: Zynq MicroZED Board
Board: Xilinx Zynq
DRAM:  ECC disabled 1 GiB
MMC:   [email protected]: 0
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
In:    [email protected]
Out:   [email protected]
Err:   [email protected]
Model: Zynq MicroZED Board
Board: Xilinx Zynq
Net:   ZYNQ GEM: e000b000, phyaddr 0, interface rgmii-id
eth0: [email protected]
Hit any key to stop autoboot:  0 
Zynq> mmcinfo 
Device: [email protected]
Manufacturer ID: 12
OEM: 3456
Name: MS    
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
Zynq> run sdboot 
reading uImage
3636016 bytes read in 322 ms (10.8 MiB/s)
reading devicetree.dtb
7839 bytes read in 17 ms (450.2 KiB/s)
reading uramdisk.image.gz
5310018 bytes read in 475 ms (10.7 MiB/s)
## Booting kernel from Legacy Image at 02080000 ...
  Image Name:   Linux-4.8.0-rc7-xilinx-00043-g20
  Image Type:   ARM Linux Kernel Image (uncompressed)
  Data Size:    3635952 Bytes = 3.5 MiB
  Load Address: 00008000
  Entry Point:  00008000
  Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 04000000 ...
  Image Name:   
  Image Type:   ARM Linux RAMDisk Image (gzip compressed)
  Data Size:    5309954 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 1faef000, end 1ffff602 ... OK
  Loading Device Tree to 1faea000, end 1faeee9e ... OK
Starting kernel ...
Booting Linux on physical CPU 0x0
.....
...
++ Setting up mdev
++ Starting telnet daemon
++ Starting http daemon
++ Starting ftp daemon
++ Starting ssh daemon
random: sshd: uninitialized urandom read (32 bytes read)
rcS Complete
zynq> scsi 0:0:0:0: Direct-Access     MXT-USB  Storage Device   1308 PQ: 0 ANSI: 0 CCS
sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] No Caching mode page found
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda: sda1 sda2
sd 0:0:0:0: [sda] Attached SCSI removable disk
zynq> fdisk -l
Disk /dev/mmcblk0: 3945 MB, 3945791488 bytes
4 heads, 16 sectors/track, 120416 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
       Device Boot      Start         End      Blocks  Id System
/dev/mmcblk0p1   *          33        2080       65536   b Win95 FAT32
/dev/mmcblk0p2            2081      120416     3786752  83 Linux
zynq> ifconfig eth0 192.168.1.90 netmask 255.255.255.0 up
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
zynq> macb e000b000.ethernet eth0: link up (1000/Full)
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
zynq> 
zynq> ping 192.168.1.100
PING 192.168.1.100 (192.168.1.100): 56 data bytes
64 bytes from 192.168.1.100: seq=0 ttl=64 time=0.527 ms
64 bytes from 192.168.1.100: seq=1 ttl=64 time=2.153 ms
64 bytes from 192.168.1.100: seq=2 ttl=64 time=0.341 ms
64 bytes from 192.168.1.100: seq=3 ttl=64 time=0.290 ms

FIT

Create keys

 $ mkdir mykeys
 $ openssl genrsa -F4 -out mykeys/eng.key 2048
 $ openssl req  -batch -new -x509 -key mykeys/eng.key -out mykeys/eng.crt

Build the u-boot

 $ make zynq_microzed_defconfig
 $ make

Create its, fit input file

  • Create vmlinux.bin.gz
 $ arm-linux-gnueabi-objcopy -O  binary -S vmlinux vmlinux.bin
 $ gzip -f9 vmlinux.bin
  • Download rootfs here
  • dtb from linux build
 $ cp arch/arm/boot/dts/zynq-microzed.dtb zynq-microzed-pubkey.dtb
  • Edit FIT input image
  • Create FIT output
 $ mkimage -f kernel_fdt.its -K zynq-microzed-pubkey.dtb -k mykeys/ -r zynq-fit.img
  • Build u-boot with public key
 $ make DEV_TREE_BIN=../zynq-microzed-pubkey.dtb
  • Boot U-boot and load FIT image
 Zynq> fatload mmc 0:1 0x2000000 zynq-fit-new.img
 reading zynq-fit-new.img
 9205482 bytes read in 815 ms (10.8 MiB/s)
 Zynq> printenv bootargs 
 bootargs=console=ttyPS0,115200 root=/dev/ram rw earlyprintk
 Zynq> iminfo 0x2000000
 ## Checking Image at 02000000 ...
    FIT image found
    FIT description: Verified RSA image with single Linux kernel and FDT blob
    Image 0 ([email protected])
    Description:  Zynq Linux kernel
    Type:         Kernel Image
    Compression:  gzip compressed
    Data Start:   0x020000f0
    Data Size:    3881823 Bytes = 3.7 MiB
    Architecture: ARM
    OS:           Linux
    Load Address: 0x00008000
    Entry Point:  0x00008000
    Hash algo:    md5
    Hash value:   a52d121736b7dd89646478c4db7dcbbb
    Hash algo:    sha1
    Hash value:   dca7700db8feac7741267c820845787902546633
    Sign algo:    sha1,rsa2048:eng
    Sign value:   2be1a06512191f167b7395a0dc49b95329a68a620a5a9fa8cc7d5820cc3af7790cf3b2f32fb7f4f87070ee478bae2825a57e8f4ecbcdbe7a6560b0d3bab9a004636fa
   Image 1 ([email protected])
    Description:  Microzed Devicetree blob
    Type:         Flat Device Tree
    Compression:  uncompressed
    Data Start:   0x023b3f20
    Data Size:    9328 Bytes = 9.1 KiB
    Architecture: ARM
    Hash algo:    md5
    Hash value:   42505bf26bcf15c84db549318a46d886
    Hash algo:    sha1
    Hash value:   6e358615030a64b1479453ec75efcbdb9cf64afe
    Sign algo:    sha1,rsa2048:eng
    Sign value:   600cdda90d8625c949a9f7b100a439c6dae1c35df7a6788dc093b56124e0917ab2d7c295db1bcdcabf95c820cd418094b2281ad8c3e4e232f0399812d13d57ed611db
   Image 2 ([email protected])
    Description:  Ramdisk Image
    Type:         RAMDisk Image
    Compression:  gzip compressed
    Data Start:   0x023b6624
    Data Size:    5309954 Bytes = 5.1 MiB
    Architecture: ARM
    OS:           Linux
    Load Address: unavailable
    Entry Point:  unavailable
    Hash algo:    md5
    Hash value:   0451bc5662010828b4ae6b810348648d
    Hash algo:    sha1
    Hash value:   816103db0b28b9d5b76ebf112d98258202d2a250
    Sign algo:    sha1,rsa2048:eng
    Sign value:   78a2692894a7a241e8b85e40741371fe8fd68eb14a5ca3626d2a408dc45d4638d414c9df6d2744e39af67d4d5a693028b7140bfc0aa5cfae5d553ea98b44f49f672f2
   Default Configuration: [email protected]'
   Configuration 0 ([email protected])
    Description:  Boot Linux kernel with FDT blob and ramdisk
    Kernel:       [email protected]
    Init Ramdisk: [email protected]
    FDT:          [email protected]
 ## Checking hash(es) for FIT Image at 02000000 ...
  Hash(es) for Image 0 ([email protected]): md5+ sha1+ sha1,rsa2048:eng- 
  Hash(es) for Image 1 ([email protected]): md5+ sha1+ sha1,rsa2048:eng- 
  Hash(es) for Image 2 ([email protected]): md5+ sha1+ sha1,rsa2048:eng- 
 Zynq> bootm 0x2000000
 ## Loading kernel from FIT Image at 02000000 ...
  Using [email protected]' configuration
  Verifying Hash Integrity ... OK
  Trying [email protected]' kernel subimage
    Description:  Zynq Linux kernel
    Type:         Kernel Image
    Compression:  gzip compressed
    Data Start:   0x020000f0
    Data Size:    3881823 Bytes = 3.7 MiB
    Architecture: ARM
    OS:           Linux
    Load Address: 0x00008000
    Entry Point:  0x00008000
    Hash algo:    md5
    Hash value:   a52d121736b7dd89646478c4db7dcbbb
    Hash algo:    sha1
    Hash value:   dca7700db8feac7741267c820845787902546633
    Sign algo:    sha1,rsa2048:eng
    Sign value:   2be1a06512191f167b7395a0dc49b95329a68a620a5a9fa8cc7d5820cc3af7790cf3b2f32fb7f4f87070ee478bae2825a57e8f4ecbcdbe7a6560b0d3bab9a004636fa
  Verifying Hash Integrity ... md5+ sha1+ sha1,rsa2048:eng- OK
 ## Loading ramdisk from FIT Image at 02000000 ...
  Using [email protected]' configuration
  Trying [email protected]' ramdisk subimage
    Description:  Ramdisk Image
    Type:         RAMDisk Image
    Compression:  gzip compressed
    Data Start:   0x023b6624
    Data Size:    5309954 Bytes = 5.1 MiB
    Architecture: ARM
    OS:           Linux
    Load Address: unavailable
    Entry Point:  unavailable
    Hash algo:    md5
    Hash value:   0451bc5662010828b4ae6b810348648d
    Hash algo:    sha1
    Hash value:   816103db0b28b9d5b76ebf112d98258202d2a250
    Sign algo:    sha1,rsa2048:eng
    Sign value:   78a2692894a7a241e8b85e40741371fe8fd68eb14a5ca3626d2a408dc45d4638d414c9df6d2744e39af67d4d5a693028b7140bfc0aa5cfae5d553ea98b44f49f672f2
  Verifying Hash Integrity ... md5+ sha1+ sha1,rsa2048:eng- OK
 ## Loading fdt from FIT Image at 02000000 ...
  Using [email protected]' configuration
  Trying [email protected]' fdt subimage
    Description:  Microzed Devicetree blob
    Type:         Flat Device Tree
    Compression:  uncompressed
    Data Start:   0x023b3f20
    Data Size:    9328 Bytes = 9.1 KiB
    Architecture: ARM
    Hash algo:    md5
    Hash value:   42505bf26bcf15c84db549318a46d886
    Hash algo:    sha1
    Hash value:   6e358615030a64b1479453ec75efcbdb9cf64afe
    Sign algo:    sha1,rsa2048:eng
    Sign value:   600cdda90d8625c949a9f7b100a439c6dae1c35df7a6788dc093b56124e0917ab2d7c295db1bcdcabf95c820cd418094b2281ad8c3e4e232f0399812d13d57ed611db
  Verifying Hash Integrity ... md5+ sha1+ sha1,rsa2048:eng- OK
  Booting using the fdt blob at 0x23b3f20
  Uncompressing Kernel Image ... --bootm_decomp_image: unc_len = 0x3c00000, image_len = 03b3b5f
 ++bootm_decomp_image: unc_len = 0x3c00000, image_len = 0a31c20
OK
  Loading Ramdisk to 1faef000, end 1ffff602 ... OK
  Loading Device Tree to 1fae9000, end 1faee46f ... OK
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 4.6.0-xilinx ([email protected]) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG linaro-1.13.1-2012.04-20120426 - Linaro GCC 6
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Zynq MicroZED Development Board