PYNQ Z2 - hoglet67/BeebFpga GitHub Wiki

PYNQ-Z2 BeebFpga Target

This page describes the PYNQ-Z2 BeebFpga target.

Features

  • Master 128 with 256KB of ROM and 128KB of RAM
  • MMFS support, using a seperate SD card connected to PMODB
  • ICE-T65 Debugger, via the USB UART
  • Internal 4MHz 65C02 Co Pro with 64KB of RAM
  • External PiTubeDirect Co Pro (using the dedicated Pi connector)
  • Music 5000
  • Beeb SID
  • Video NuLA
  • HDMI video and audio
  • 24-bit PCM audio
  • PS/2 Keyboard
  • Original BBC Model B Keyboard

Usage

  • SW0 - enabled HDMI debug mode

  • SW1 - enables support for Co Processors (power-up reset required)

  • BTN0 - Force a power-up reset

  • BTN1 - not used

  • BTN2 - not used

  • BTN3 - not used

  • LED0 - on when reset is asserted

  • LED1 - CAPS LOCK LED

  • LED2 - SHIFT LOCK LED

  • LED3 - Co Processor support enabled

  • USB UART gives access to the ICE-T65 Debugger at 115,200 baud

  • PS/2 keyboard, connected to PMODB upper pins

    • pin 1: unused (right most pin)
    • pin 2: ununed
    • pin 3: CLK
    • pin 4: DATA
    • pin 5: GROUND
    • pin 6: VCC (supplying 3V3 to PS/2 may or may not work!)
  • SD card for MMFS, connected to PMODB lower pins

    • pin 7: CS
    • pin 8: MISO
    • pin 9: MOSI
    • pin 10: SDK
    • pin 11: GROUND
    • pin 12: 3V3
  • Dedicate Pi Connector can be used to connect to a Pi Zero running PiTubeDirect:

    • connect a Pi Zero using a short 40-pin to 40-pin cable, or
    • solder a 40-pin female header onto the solder side of the Pi Zero
    • select using *CONFIGURE EXTUBE
  • A Model B BBC keyboard can be connected to the Arduino Headers:

    • 17 LED2 -> A (Caps Lock)
    • 16 LED1 -> AR[0] (Shift Lock)
    • 15 VCC -> 3V3 (important - don't connect to 5V!!!!)
    • 14 CA2 -> AR[1]
    • 13 LED3 -> AR[2] (Motor)
    • 12 PA7 -> AR[3]
    • 11 PA3 -> AR[4]
    • 10 PA2 -> AR[5]
    • 9 PA1 -> AR[6]
    • 8 PA0 -> AR[7]
    • 7 PA6 -> AR[8]
    • 6 PA5 -> AR[9]
    • 5 PA4 -> AR[10]
    • 4 nKBEN -> AR[11]
    • 3 1MHz -> AR[12]
    • 2 nRST -> AR[13]
    • 1 GND -> G
  • 24 bit audio out through the 3.5mm headphone jack

  • HDMI out (including audio) through the HDMI Tx connector

For PMOD numbering see the PYNQ-Z2 manual: https://dpoauwgwqsy2x.cloudfront.net/Download/PYNQ_Z2_User_Manual_v1.1.pdf#page=23

Known Issues

  • The PYNQ-Z2 board can be partly reverse powered through the HDMI connector. Don't leave the HDMI connector plugged in with the TV powered on and the FPGA board powered off. I don't think any damage will occur, but this doesn't seem good! The Spectrum Next suffers from exactly the same problem.

  • The HDMI Audio is rather ropey, because it's converted to 48KHz without proper resampling filters. The 3.5mm audio output should sound much better.

Binary release

TODO - add BOOT.bin to github releases

Building from source

Important: These instructions are for Vivado 2019.1 and will NOT work with later versions, because Xilinx have replaced the SDK with a new tool called Vitis. They also assume Linux is being used, so will need to be adapted to Windows.

Vivado 2019.1 can be downloaded from here: https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vivado-design-tools/archive.html

In a Bash shell

Start by cloning the BeebFpga project from git:

git clone [email protected]:hoglet67/BeebFpga.git

Checkout the dev branch:

cd BeebFpga
git checkout dev

Change directory to PYNZ-Z2 project:

cd xilinx/bbc_master_pynqz2/

(This makes using the TCL console easier)

Start Vivado:

source /tools/Xilinx/Vivado/2019.1/settings64.sh 
vivado

In Vivado

File/Project/Open and select bbc_master_pynqz2.xpr and click Open

In the TCL console tab at the bottom run:

source create_ps_block.tcl

(This will create the ProcessingSystemOnly block, which saves me checking a load of files into git)

File/Close Block Diagram

In the PROJECT MANAGER panel, click Generate Bitstream.

This will:

  • regenerate all IP (WatchEvents and ProcessingSystemOnly)
  • sythesise the design
  • implement the design
  • generate the bitstream

It takes about 15-20 minutes on my elderly workstation.

When the build is completed, click Cancel to dismiss the popup.

(There will be a small number of critical warnings, and a much larger number of warnings (TODO: be more specific here))

File/Export/Export Hardware... and make sure Include Bitstream is ticked.

(This creates a hardware definition file for the SDK that includes the bitstream)

File/Launch SDK to launch the Eclipse-based SDK.

In the SDK

File/Open Projects From File System...

Click the Directory button then navigate to the BeebFpga/xilinx/bbc_master_pynqz2/bbc_master_pynqz2.sdk directory and clock OK.

It should find 7 projects; click Deselect All, then manually select:

bbc_master_pynqz2.sdk/BeebFpgaApp
bbc_master_pynqz2.sdk/BeebFpgaApp_bsp
bbc_master_pynqz2.sdk/BeebFpgaLoader
bbc_master_pynqz2.sdk/BeebFpgaLoader_bsp

You'll see some errors, but wait a while for the workspace to rebuild and these errors should go away.

In the Project Explorer panel, right click on BeebFpgaApp and select Create Boot Image. The default settings should be correct, so don't change anything. Click Create Image to create the BOOT.bin file.

The BOOT.bin file is created in:

BeebFpga/xilinx/bbc_master_pynqz2/bbc_master_pynqz2.sdk/BeebFpgaApp/bootimage/BOOT.bin

The BOOT.bin file is the completed build of BeebFpga for PYNQ-Z2 that includes:

  • a first stage boot loader (BeebFpgaLoader)
  • a FPGA bit file
  • a second stage application (BeebFpgaApp)

Currently all BeebFpgaApp does is to cross-connect the two Zynq Processing System UARTs, so that you can interact with the ICE Debugger over the USB UART.

Programming BeebFpga into the PYNQ-Z2

The PYNQ-Z2 board can boot from the SD card or the QSPI FLASH.

There is a jumper marked SD|QSPI|JTAG which selects the boot mode.

Set this appropriately.

Booting from SD Card

Select the left position for the boot mode jumper (marked SD).

Copy BOOT.bin to the root of a FAT32 formatted SD card.

Put the SD card into the PYNZ-Z2.

Power up the PYNC-Z2 and after a couple seconds you should see the Beeb boot screen on HDMI.

Booting from SD Card

Select the middle position for the boot mode jumper (marked QSPI).

In the SDK, select Xilinx/Program Flash

In the dialog box, next to Image File, select Browse, locate BOOT.bin, then click OK. The BOOT.bin file is located here:

BeebFpga/xilinx/bbc_master_pynqz2/bbc_master_pynqz2.sdk/BeebFpgaApp/bootimage/BOOT.bin

In the dialog box, next to FSBL, select Browse, then locate BeebFpgaLoader.elf, then click OK. The BeebFpgaLoader.elf file is located

BeebFpga/xilinx/bbc_master_pynqz2/bbc_master_pynqz2.sdk/BeebFpgaLoader/Debug/BeebFpgaLoader.elf

Make sure Verify after Flash is ticked then click the Program button.

This takes a minute or so.

Power cycle the PYNC-Z2 and after a couple seconds you should see the Beeb boot screen on HDMI.