项目作者: piotr-wiszowaty

项目描述 :
Atari XL/XE SD cartridge
高级语言: C
项目地址: git://github.com/piotr-wiszowaty/atari_xlxe_sd_cartridge.git
创建时间: 2013-08-16T13:05:30Z
项目社区:https://github.com/piotr-wiszowaty/atari_xlxe_sd_cartridge

开源协议:GNU General Public License v3.0

下载


Atari XL/XE SD cartridge

Atari XL/XE SD cartridge is a device allowing access (read and write) to FAT32 formatted
SD cards by Atari 8-bit computers.

Atari-side interface

The cartridge occupies address space $8000..$BFFF. Read and write operations
are controlled through 8 registers mapped to $D5E8..$D5EF. Each read/write
operates on SD card sectors <SECTOR_NUM>..<SECTOR_NUM>+<SECTOR_COUNT>-1 and
RAM region $8000+512*<OFFSET>..$8000+512*(<OFFSET>+<SECTOR_COUNT>)-1.
Additionaly read operation may be performed using single register - read address
is automatically incremented after performing the operation.

$D5E8 :

  • bit0=1 - read sectors from SD card into buffer RAM; reset after the operation is completed
  • bit1=1 - write data from buffer RAM to SD card; reset after the operation is completed
  • bit5..bit2 - unused
  • bit6=1 - flag: last operation succeeded
  • bit7=1 - flag: last operation failed

$D5E9 :

  • bit5..bit0 - <OFFSET>; data offset from $8000; measured in 512-byte blocks
  • bit7..bit4 - unused

$D5EA :

  • bit5..bit0 - <SECTOR_COUNT>; number of 512-byte sectors to read/write
  • bit7..bit6 - unused

$D5EB :

  • bit7..bit0 - <SECTOR_NUM> bits 7..0

$D5EC :

  • bit7..bit0 - <SECTOR_NUM> bits 15..8

$D5ED :

  • bit7..bit0 - <SECTOR_NUM> bits 23..16

$D5EE :

  • bit7..bit0 - <SECTOR_NUM> bits 31..24

$D5EF (write):

  • bit4..bit0 - <READ_ADDRESS> - offset from $8000; measured in 512-byte blocks
  • bit5 - unused
  • bit6=1 - turn on cartridge memory $8000..$9FFF
  • bit7=1 - turn on cartridge memory $A000..$BFFF

$D5EF (read):

  • bit7..bit0 - data in cartridge memory at current <READ_ADDRESS>; the
    1. address is automatically incremented by 1 after read

Example usage

Read

  1. ; read 10 consecutive sectors from SD card starting from $00123456
  2. ; into buffer RAM starting at $8600 and wait for the
  3. ; operation to complete
  4. lda #$56
  5. sta $D5EB
  6. lda #$34
  7. sta $D5EC
  8. lda #$12
  9. sta $D5ED
  10. lda #$00
  11. sta $D5EE
  12. lda #3
  13. sta $D5E9
  14. lda #10
  15. sta $D5EA
  16. lda #1
  17. sta $D5E8
  18. lda #$C0
  19. wait
  20. bit $D5E8
  21. beq wait
  22. bmi error
  23. ok

Write

  1. ; fill 7 consecutive sectors on SD card starting from $00987654
  2. ; with data in buffer RAM starting at $a000 and wait for the
  3. ; operation to complete
  4. lda #$54
  5. sta $D5EB
  6. lda #$76
  7. sta $D5EC
  8. lda #$98
  9. sta $D5ED
  10. lda #$00
  11. sta $D5EE
  12. lda #16
  13. sta $D5E9
  14. lda #7
  15. sta $D5EA
  16. lda #2
  17. sta $D5E8
  18. lda #$C0
  19. wait
  20. bit $D5E8
  21. beq wait
  22. bmi error
  23. ok

Hardware

Main silicon components:

  • buffer RAM - 32 kB of 55 ns SRAM (16 kB + 256 B of which are actually used)
  • ARM Cortex-M0 microcontroller (NXP LPC1114)
  • MMU controlling access to SRAM from microcontroller and Atari (Xilinx XC95144XL CPLD)

Connectors:

  • SD card socket
  • SWD connector for programming/debugging the microcontroller
  • JTAG connector for programming the CPLD
  • UART connector (5V) for communication PC-microcontroller; may also be used for microcontroller flash programming
  • debug connector with two pins connected to the CPLD, and two pins connected to both the CPLD and the microcontroller
  • SPI header (for debugging communication between the microcontroller and the SD card)

LED indicators:

  • red : error occured (e.g. SD card not present, SD card read or write error)
  • yellow : SD card present

Software (microcontroller)

Boot algorithm:

  1. Write Atari bootstrap code to buffer RAM at $BF00
  2. Initialize SD card
  3. Find Atari executable file boot.obx on the SD card
  4. Write boot.obx first sector number to buffer RAM at $D5EB..$D5ED
  5. Execute main loop

Main loop:

  1. Execute command received through UART (if any):

    • echo
      UART —> microcontroller 'e'
      UART <— microcontroller 'e'

    • read data from buffer RAM (A, N - 16-bit little endian numbers)
      UART —> microcontroller 'r'
      UART —> microcontroller A
      UART —> microcontroller N
      UART <— microcontroller buffer_ram[A]
      UART <— microcontroller buffer_ram[A+1]

      UART <— microcontroller buffer_ram[A+N-1]

    • write data to buffer RAM (A, N - 16-bit little endian numbers)
      UART —> microcontroller 'w'
      UART —> microcontroller A
      UART —> microcontroller N
      UART —> microcontroller buffer_ram[A]
      UART —> microcontroller buffer_ram[A+1]

      UART —> microcontroller buffer_ram[A+N-1]
      UART <— microcontroller 'w'

  2. Execute operation read from register at $D5E8:

    • bit0=1 - read <SECTOR_COUNT> 512-byte sectors starting at sector <SECTOR_NUM>
      1. from SD card into buffer RAM at address `$8000+512*<OFFSET>`
    • bit1=1 - write <SECTOR_COUNT> 512-byte sectors from buffer RAM
      1. at `$8000+512*<OFFSET>` to SD card starting at sector `<SECTOR_NUM>`
      After operation is finished set success and error flags in register at $D5E8.

Sources

bootstrap/ - Atari bootstrap sources

cpld/ - MMU design files

pcb/ - PCB design files (gEDA) and gerbers

tools/ - programs to control the microcontroller through UART interface

uc/ - microcontroller firmware sources

video/ - video converter