pynq

Zynq-7000 Embedded Design Tutorial - (2)

ithryn 2022. 11. 15. 00:59

다음 예제를 진행하기 전에 pentalinux를 실행시킬 Linux환경이 필요하다.

이 환경은 PYNQ sdcard image rebuild하는 wiki를 참고하여 진행하였다.

https://pynq.readthedocs.io/en/latest/pynq_sd_card.html

 

PYNQ SD Card image — Python productivity for Zynq (Pynq)

Additional boards are supported through external board repositories. A board repository consists of a directory for each board consisting of a spec file and any other files. The board repository is treated the same way as the /boards directory. Board-speci

pynq.readthedocs.io

 . vagrant, VirtualBox 설치

 . PYNQ source code 에 Vagrant file이 있는데, 그 디렉토리로 가서  vagrant up  실행

  .vagrant reload bionic (또는 focal) 을 수행하여 재부팅후, 로그인 화면에서 id : vagrant, passwd : vagrant로 로그인

 

  . 실제 수행해보니, vagrant up 과정에서 재대로 수행이 안되서, 로그인은 가능하지만,

     X window실행이 안되는 상황이 되었다.  문제는 3가지 인데,

     1)  AMD가상화가 활성화 안되어있어서 , BIOS에서 CPU관련 SVM을 enable 시켜줌

     2)  VBoxClient 관련 libXst 찾을 수 없는 문제

       ; sudo apt-get install libxt6 libxmu6  을 수행. VBoxClient --version 수행시 버전이 보이면 OK

     3)  zlib1g:i386를 찾을수 없다고 나오는 문제

        ; sudo dpkg --add-architecture i386

        ; sudo apt-get install zlib1g:i386

     4) libwhoopsie 문제

       ; sudo apt-get install libwhoopsie0

 

   . 위 조치를 취한 후에, vagrant provision 을 실행하여 다시 설정시작함

 

  . 설치가 완료된 후, /pynq 디렉토리에서 윈도우즈와 파일 공유가 되어야 하는데, 안되어 있어서,

    vbox 설정 - 공유 디렉토리 설정에서 새롭게 해주었다. 

    리눅스에서 공유디렉토리는 vboxsf 그룹으로 생겨서 접근이 안되므로, 아래와 같이 그룹에 user id를 추가해서 

    접근하였다.

      sudo gpasswd -a vagrant vboxsf

 

  .  이제 vitis, petalinux 등을 /workspace에 설치한다.

      ; PYNQ 버전에 맞는 vivado 버전을 깔아야, 나중에 build할때 문제가 없다. 

      ; Xilinx 통합 installer 2020.2 버전을 받아서 설치한다.

      ; git clone https://github.com/Xilinx/PYNQ.git --branch v2.7.0

 

    .  sdbuild를 make하는데, 별 문제가 없어야 하지만, bitstream만드는데 정상진행이 안되었다.

       log를 보니, 아마도 vivado를 여러개 동시에 실행해서 잘 안된듯한데, 아뭏든 제대로 동작안한 부분을

       runme.sh 를 수동으로 돌리는 것을 반복하여 implementation까지 하고나서, 다시 script를 살짝 수정해서 돌렸다.

       package 컴파일에 또 문제가 생겼으나, 일단 아래 example에서 사용할 Pynq-Z2 BSP가 만들어졌으므로
        그만 수행하였다.

 

    보드 BSP는 아래 사항을 담고 있다.

  • Hardware: This design uses Vivado board presets with Zynq-7000 PS block (DDR, UART, SD, QSPI, Ethernet etc.) and AXI GPIO connected with led.
  • Software: FSBL, U-Boot, Linux, device-tree (includes open-amp), rootfs (minimal packages).
  • Pre-built Images: Ready to test images bitstream, FSBL, U-Boot, Linux and rootfs for booting U-Boot and Linux.

=================================================================================

< Example 4. Linux Image 만들기 >

  

   입력 : Hardware XSA (ex. system_wrapper.xsa)

              PentaLinux 보드 BSP

    출력 : Petalinux boot image (BOOT.bin, image.ub)

               Petalinux application (hello_linux)

 

   * PetaLinux Image 생성

petalinux-create -t project -s <path to the xilinx-zc702-v2022.1-final.bsp>

   ; PetaLinux project 디렉토리가 생성됨 

 

  * Reconfigure the project with system_wrapper.xsa

petalinux-config --get-hw-description=<path that contains system_wrapper.xsa>

      ; Exit - Enter

 

   * PetaLinux project 빌드

petalinux-build

    ; images/linux 디렉토리에 boot.scr (u-boot가 읽어서, 커널, rootfs등을 load) , image.ub (kernel imagek device tree, rootfs) 가 생성됨

 

   * Boot image 생성   

petalinux-package --boot --fsbl zynq_fsbl.elf --u-boot

;  /image/linux/BOOT.bin이 생성됨

petalinux-package --boot --fsbl zynq_fsbl.elf --fpga system.bit --u-boot u-boot.elf

 

  * target 보드에 linux booting 

   ; SD카드에 BOOT.bin, image.ub, boot.scr 카피.

   ; 보드 boot 모드를 SD로 설정

   ; Vitis에 있는 Serial Terminal을 열고, 보드 Power On.

   ; user name/passwd 둘다 root 를 넣고 로그인 가능.

 

=================================================================================

< Example 5. Linux 용 Hello World Application 만들기 >

  

* Linux domain 생성

  Vitis - Explorer view 에서 pynq_edt platform을 expand - platform.spr 더블클릭 -

   platform view에서 + 버튼 - Domain 창에서 name = linux_domain, OS = linux 등으로 설정하고 ok

   - 해머 아이콘 눌러서 platform build 

 

* Linux Application 생성

  File - New - Application Project - select pynq_edt -

  application project= hello_linjux, processor = ps7_cortexa9 SMP  - linux domain - Linux Hello World 템플릿 선택 -

  Finish - Explorer에서 hello_linux 선택하고 해머 아이콘 눌러서 빌드 

 

* Linux Agent 준비하기

 . TCF Agent : 보드에서 실행되어 Vitis IDE와 Ethernet 연결을 통해 통신 할 수 있음 (디버깅을 위해 보드에 application 을 다운로드 등)

 . 보드에서 ifconfig eth0 192.168.1.1 로 네트워크 IP 설정

 .  Host PC에서 제어판-네트워크 및 인터넷 - 네트워크 공유센터 - 어댑터 설정 변경 - Ethernet 오른쪽 클릭해서 속성

   - TCP/IPv4 에서 192.168.1.2  주소를 쓰게 함

  . Window - Show View - Target Connections 선택 - Linux TCF Agent - Linux Agent - 192.168.1.1  port 1534 로 설정

 

 * Linux Application 실행

   . hello_linux 오른클릭 - Run As - Run Configuration - Single Application Debug - Debugger_hello_linux-Default - Run

   . 종료시에는 Terminate - Disconnect 

 

 * Linux Application 디버그

   . hello_linux 오른클릭 - Debug As - Debug Configuration - Single Application Debug - Debugger_hello_linux-Default -  Debug

   . 종료시에는 Terminate - Disconnect