Source Code Guide - simoninns/BeebSCSI GitHub Wiki
BeebSCSI Source Code
Getting the source code
The BeebSCSI source code, schematics and PCB design are available on GitHub; a link to the repository is given below:
Current build status
The current release version of BeebSCSI available on github is the latest, tested BeebSCSI revision. Non-release builds should be considered experimental.
The repository is in six parts; the AVR boot-loader, the AVR firmware, the Xilinx CPLD firmware, the KiCAD schematic and board files, the BeebSCSI ROM and the BBC BASIC FAT transfer utilities. The following versions of software should be used to compile the source code:
- Atmel Studio 7 for the AT90USB1287 GCC code (Boot-loader and firmware)
- Xilinx ISE 14.7 (nt64) Application version P20131013 for the XC9672XL-7-VQ64 Verilog code
- KiCAD 4.0.7 for the schematic and board files
- BeebASM for the BeebSCSI ROM
- Acorn BBC BASIC for the FAT file transfer utilities.
Each of the parts includes a complete project file (where appropriate); compilation requires loading the project file in the IDE stated above and following the usual build process for the IDE. The AVR firmware now produces a BEEBSCSI.BIN image that is to be used to program the BeebSCSI board using the bootloader (see below) - however the BeebSCSI board must first be programmed (with the bootloader firmware) directly using an AVR programmer (note: this is only required in order to program the bootloader - once the bootloader is in place all subsequent firmware programming does not require a dedicated programmer).
Programming a BeebSCSI board
Programming the BeebSCSI board requires 3 stages:
- Programming the CPLD
- Programming the AVR Bootloader
- Boot-loading the AVR firmware from an SD Card
Note: The BeebSCSI board must be powered in order to program. Ensure that the BeebSCSI board has a regulated 5V supply.
The BeebSCSI 7_7 PCB provides a common JTAG header for both the CPLD and the AVR microcontroller. There are two options for connecting programmers to the JTAG programming interface.
The first option is a standard 2.54mm pitch male header that used the standard JTAG pin out. Connection to this header is shown in the following picture:
BeebSCSI 7_7 - 2.54mm pitch 2x5 JTAG header
The second option is a Tag-Connect TC2050-IDC-NL programming cable. This connects directly to the board and does not require a header to be fitted to the PCB as shown in the following photograph:
BeebSCSI 7_7 - JTAG Tag-connect programming adapter
Programming the CPLD
Programming the CPLD requires the use of a Xilinx compatible JTAG programmer connected to the JTAG header of the PCB. Note that the CPLD is the second device in the JTAG-chain.
Once connected (and a green status light is shown on the programmer) use ISE iMPACT to program the CPLD in the usual manner.
Programming the AVR boot-loader
The BeebSCSI github repository contains both the AVR firmware and an AVR boot-loader. The AVR boot-loader allows the firmware to be flashed using only an SD card (containing the BEEBSCSI.BIN firmware image). This is to allow in-field upgrade of BeebSCSI without the need for programming equipment or technical knowledge of the AVR. However, before the boot-loader can be used to update the firmware, it must first be flashed to the AVR.
In order to flash the AVR, first connect a JTAG compatible AVR programmer (such as the Atmel-ICE) to the BeebSCSI board.
Once connected load the AVR Studio IDE and the supplied boot-loader project from GitHub. Before flashing the AVR it is important to ensure the fuse settings are correct. The following picture shows the fuse settings for the boot-loader within the AVR Studio device programming dialogue:
BeebSCSI boot-loader fuse settings
Once the fuses are set, program the device. Once programming is complete the status LED on the BeebSCSI board should be flashing on and off slowly. This indicates that the boot-loader is active, but is unable to boot the main firmware (as it hasn't been programmed yet).
Programming and upgrading the AVR firmware
In order to program the AVR firmware you will need a micro SD card formatted using FAT32 (i.e. 32GBs or less and formatted using FAT32 on a Windows or Linux PC). It is preferable to use a blank card.
You will need a copy of the latest firmware. This is available from the project Github in the zip file containing the release files:
Copy the BEEBSCSI.BIN file from the zip file to the SD card.
Power down the BeebSCSI board and insert the SD card containing the firmware image. Once powered up the status LED will remain off during programming. When programming is complete the status LED will flash rapidly to indicate success. To complete programming power down the BeebSCSI board and remove the SD card. If you want to reuse the SD card, simply delete the BEEBSCSI.BIN file from the card and reinsert. During the next power up, the BeebSCSI boot-loader will load the new firmware image and boot normally.
Note that the boot-loader does not provide any CRC checking of boot loader images. BeebSCSI boards can be upgrade and downgraded using the same procedure; it is even possible to load completely custom firmware images using the same technique. Boot-loading from an SD card cannot overwrite the boot-loader's own code, so there should be no risk of corrupting the AVR during the boot-loader firmware upgrade process.
The BeebSCSI ROM
The BeebSCSI ROM source can be compiled with BeebASM and produces a BBC Micro and BBC Master compatible paged ROM image. This image can either be soft-loaded (using a command such as *SRLOAD BSROM 8000 4 on the Master), or the image can be programmed onto a real EPROM that is then inserted in to the appropriate ROM slot in the Acorn computer.