Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 82185c80e7ec
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cb5ad42db8a2
Choose a head ref

Commits on Aug 3, 2019

  1. applet.interface.jtag_probe: disable autoflush.

    Potentially increases performance on large sequences of pipelined
    reads (not that we have a good way to submit such sequences yet.)
    whitequark committed Aug 3, 2019
    Copy the full SHA
    c70d1d3 View commit details
  2. applet.interface.spi_master: redesign command set to be like jtag_probe.

    The JTAG probe applet has a very nice orthogonal command set, more
    applets should be like it. In the future, the SS# line should be
    changed to be an ordinary aux signal, and all dependent applets with
    aux signals in registers should be redesigned to use those.
    whitequark committed Aug 3, 2019
    Copy the full SHA
    8c46f91 View commit details
  3. applet.interface.spi_master: remove length restrictions.

    These are however not removed downstream (mostly from memory-25x
    applet) because they are useful for progress indication.
    
    Also, this implementation does not take advantage of pipelining for
    transfers longer than 64K.
    whitequark committed Aug 3, 2019
    Copy the full SHA
    a2845aa View commit details

Commits on Aug 4, 2019

  1. Copy the full SHA
    abd4673 View commit details
  2. applet.program.xc9500xl: be more resistant to incorrect connections.

    Before this commit, if IR length does not match, identify() asserts.
    whitequark committed Aug 4, 2019
    Copy the full SHA
    c8ebd6b View commit details
  3. Copy the full SHA
    8a7e133 View commit details
  4. Copy the full SHA
    aef697b View commit details
  5. support.bits: allow signed values, if length is specified.

    This is a convenient way to get a long string of ones.
    whitequark committed Aug 4, 2019
    Copy the full SHA
    2d90a89 View commit details
  6. Copy the full SHA
    9c3c6ca View commit details
  7. Copy the full SHA
    0d997bf View commit details
  8. applet.interface.jtag_probe: add shift_dummy().

    Useful for shifting don't care headers and trailers.
    whitequark committed Aug 4, 2019
    Copy the full SHA
    8285eed View commit details
  9. Copy the full SHA
    290e1d0 View commit details
  10. Copy the full SHA
    15f0be0 View commit details
  11. applet.interface.jtag_probe: fix IR elision to respect elide=False.

    Also, add elide as an argument to TAPInterface.write_ir().
    Also, make it keyword-only.
    whitequark committed Aug 4, 2019
    Copy the full SHA
    4cc04a7 View commit details
  12. Copy the full SHA
    f9704f1 View commit details
  13. Copy the full SHA
    d3eced0 View commit details
  14. Copy the full SHA
    602d940 View commit details

Commits on Aug 5, 2019

  1. Copy the full SHA
    fdfaa27 View commit details
  2. Copy the full SHA
    af55b28 View commit details
  3. applet.interface.jtag_probe: set TRST# to inactive by default.

    I think this was a mistake, flipped polarity. The default applet flow
    does not pulse TRST#, which should be fine given that TRST# is rarely
    useful and not relying on it is a good idea; the main function of
    --pin-trst is for SVF and to drive it to inactive level.
    whitequark committed Aug 5, 2019
    Copy the full SHA
    d3b6e94 View commit details
  4. Copy the full SHA
    cba6848 View commit details
  5. Copy the full SHA
    0ee77f9 View commit details
  6. Copy the full SHA
    7ae30fb View commit details
  7. Copy the full SHA
    326d00b View commit details

Commits on Aug 6, 2019

  1. applet.program.xc6s: clock JSTART in RTI while polling.

    Otherwise, if DONE is low because JSTART is not finished yet (instead
    of because of a configuration error), it will never finish because it
    is clocked only in RTI.
    whitequark committed Aug 6, 2019
    Copy the full SHA
    ddcbb7d View commit details
  2. Copy the full SHA
    97a151b View commit details
  3. Copy the full SHA
    de89ab8 View commit details
  4. Copy the full SHA
    54abd25 View commit details
  5. Copy the full SHA
    8ef4bc8 View commit details
  6. software: only build the library part of libfx2.

    Building all of it wastes time and has problems in case some parts
    (not used in Glasgow) tickle compiler bugs.
    whitequark committed Aug 6, 2019
    Copy the full SHA
    650db96 View commit details
  7. Copy the full SHA
    b5c7f12 View commit details
  8. Copy the full SHA
    230e8e7 View commit details
  9. Copy the full SHA
    396ddaa View commit details
  10. interface.jtag_probe: simplify XR scanning.

    It's nice to not do so many roundtrips, and it also is less code and
    pollutes logs less.
    whitequark committed Aug 6, 2019
    Copy the full SHA
    6392af0 View commit details
  11. Copy the full SHA
    aca3597 View commit details
  12. Copy the full SHA
    6bbc527 View commit details
  13. Copy the full SHA
    ad30823 View commit details
  14. Copy the full SHA
    1639a25 View commit details
  15. cli: allow overriding revision requirement.

    This is useful for hacked revA/B devices that had the FXMA removed
    and replaced with a 0R bank, for 3V3 only operation.
    whitequark committed Aug 6, 2019
    Copy the full SHA
    9621694 View commit details

Commits on Aug 7, 2019

  1. Copy the full SHA
    96568aa View commit details
  2. Copy the full SHA
    9d49813 View commit details
  3. applet.audio.dac: add support for connecting to a PCM source socket.

    Works with Linux desktop!
    whitequark committed Aug 7, 2019
    Copy the full SHA
    c0a74e8 View commit details
  4. Copy the full SHA
    00591df View commit details
  5. Copy the full SHA
    c2b99cc View commit details

Commits on Aug 8, 2019

  1. Copy the full SHA
    4edf8bd View commit details
  2. Copy the full SHA
    67e610b View commit details
  3. Copy the full SHA
    3aed7c4 View commit details
  4. Copy the full SHA
    cd75a94 View commit details
  5. applet.internal.benchmark: fix unnecessarily r/w register to be r/o.

    To avoid hierarchy flattening.
    whitequark committed Aug 8, 2019
    Copy the full SHA
    984e8cb View commit details

Commits on Aug 9, 2019

  1. arch.nrf24l.rf: new arch.

    whitequark committed Aug 9, 2019
    Copy the full SHA
    9be2abe View commit details
Showing with 26,172 additions and 10,062 deletions.
  1. +2 −1 .gitignore
  2. +1 −1 .gitmodules
  3. +7 −5 .travis.yml
  4. +68 −14 README.md
  5. +2 −0 config/99-cypress.rules
  6. +1 −1 docs/archive
  7. +9 −3 examples/boilerplate.py
  8. +16 −0 examples/i2c-pcf8574.py
  9. +1 −0 firmware/.gitignore
  10. +7 −6 firmware/dac_ldo.c
  11. +7 −4 firmware/glasgow.h
  12. +36 −6 firmware/main.c
  13. +6 −9 hardware/boards/glasgow/glasgow-cache.lib
  14. +4 −4 hardware/boards/glasgow/glasgow.kicad_pcb
  15. +13 −5 hardware/boards/glasgow/glasgow.sch
  16. +8 −4 hardware/boards/glasgow/io_banks.sch
  17. +7 −3 hardware/boards/glasgow/io_buffer.sch
  18. +65 −65 hardware/boards/glasgow/revC1/bom.csv
  19. BIN hardware/boards/glasgow/revC1/fabrication.pdf
  20. BIN hardware/boards/glasgow/revC1/schematics.pdf
  21. +3 −0 hardware/boards/test-jig/fp-lib-table
  22. +686 −0 hardware/boards/test-jig/led-board.sch
  23. BIN hardware/boards/test-jig/pictures/render-bottom.jpg
  24. BIN hardware/boards/test-jig/pictures/render-leds.jpg
  25. BIN hardware/boards/test-jig/pictures/render-top1.jpg
  26. BIN hardware/boards/test-jig/pictures/render-top2.jpg
  27. +1,344 −0 hardware/boards/test-jig/port-connection.sch
  28. BIN hardware/boards/test-jig/schematics.pdf
  29. +3 −0 hardware/boards/test-jig/sym-lib-table
  30. +588 −0 hardware/boards/test-jig/test-jig-cache.lib
  31. +10,040 −0 hardware/boards/test-jig/test-jig.kicad_pcb
  32. +256 −0 hardware/boards/test-jig/test-jig.pro
  33. +1,953 −0 hardware/boards/test-jig/test-jig.sch
  34. +22 −0 hardware/footprints/Glasgow.pretty/Solderbridge-small-2pad.kicad_mod
  35. +52 −0 .../footprints/Glasgow.pretty/TerminalBlock_MetzConnect_AST04106_1x06_Lever_Clamp_45Degree.kicad_mod
  36. +6 −0 hardware/symbols/Glasgow.dcm
  37. +21 −0 hardware/symbols/Glasgow.lib
  38. +7 −0 kitspace.yml
  39. +0 −1 software/.gitattributes
  40. +11 −0 software/Makefile
  41. +5 −3 software/glasgow/__init__.py
  42. +0 −520 software/glasgow/_version.py
  43. +11 −3 software/glasgow/access/__init__.py
  44. +21 −5 software/glasgow/access/direct/arguments.py
  45. +57 −41 software/glasgow/access/direct/demultiplexer.py
  46. +64 −46 software/glasgow/access/direct/multiplexer.py
  47. +6 −2 software/glasgow/access/simulation/demultiplexer.py
  48. +2 −2 software/glasgow/access/simulation/multiplexer.py
  49. +57 −31 software/glasgow/applet/__init__.py
  50. +17 −6 software/glasgow/applet/all.py
  51. +1 −1 software/glasgow/applet/audio/__init__.py
  52. +74 −20 software/glasgow/applet/audio/dac/__init__.py
  53. +0 −882 software/glasgow/applet/audio/yamaha_opl/__init__.py
  54. +0 −368 software/glasgow/applet/audio/yamaha_opl/index.html
  55. +1,218 −0 software/glasgow/applet/audio/yamaha_opx/__init__.py
  56. +453 −0 software/glasgow/applet/audio/yamaha_opx/index.html
  57. +3 −4 software/glasgow/applet/control/tps6598x/__init__.py
  58. +2 −9 software/glasgow/applet/debug/arc/__init__.py
  59. +1 −1 software/glasgow/applet/debug/arm/swd.py
  60. +24 −20 software/glasgow/applet/debug/mips/__init__.py
  61. +360 −0 software/glasgow/applet/debug/msp430/__init__.py
  62. +2 −2 software/glasgow/applet/display/hd44780/__init__.py
  63. +6 −6 software/glasgow/applet/display/pdi/__init__.py
  64. +133 −0 software/glasgow/applet/interface/analyzer/__init__.py
  65. +75 −60 software/glasgow/applet/interface/{i2c_master → i2c_initiator}/__init__.py
  66. +257 −0 software/glasgow/applet/interface/i2c_target/__init__.py
  67. +147 −0 software/glasgow/applet/interface/jtag_openocd/__init__.py
  68. +2 −2 software/glasgow/applet/interface/jtag_pinout/__init__.py
  69. +216 −187 software/glasgow/applet/interface/jtag_probe/__init__.py
  70. +1 −1 software/glasgow/applet/interface/jtag_svf/__init__.py
  71. +3 −3 software/glasgow/applet/interface/ps2_host/__init__.py
  72. +129 −129 software/glasgow/applet/interface/sbw_probe/__init__.py
  73. +156 −142 software/glasgow/applet/interface/{spi_master → spi_controller}/__init__.py
  74. +32 −8 software/glasgow/applet/interface/uart/__init__.py
  75. +115 −80 software/glasgow/applet/internal/benchmark/__init__.py
  76. +31 −24 software/glasgow/applet/internal/selftest/__init__.py
  77. +66 −23 software/glasgow/applet/memory/_24x/__init__.py
  78. +24 −17 software/glasgow/applet/memory/_25x/__init__.py
  79. +30 −18 software/glasgow/applet/memory/floppy/__init__.py
  80. +1 −1 software/glasgow/applet/memory/floppy/mfm.py
  81. +3 −4 software/glasgow/applet/memory/onfi/__init__.py
  82. +872 −0 software/glasgow/applet/memory/prom/__init__.py
  83. +306 −1 software/glasgow/applet/program/avr/__init__.py
  84. +0 −454 software/glasgow/applet/program/avr/spi.py
  85. +314 −0 software/glasgow/applet/program/avr/spi/__init__.py
  86. +1 −0 software/glasgow/applet/program/avr/spi/fixtures/test_api_calibration.json
  87. +40 −0 software/glasgow/applet/program/avr/spi/fixtures/test_api_eeprom.json
  88. +37 −0 software/glasgow/applet/program/avr/spi/fixtures/test_api_fuses.json
  89. +15 −0 software/glasgow/applet/program/avr/spi/fixtures/test_api_lock_bits.json
  90. +403 −0 software/glasgow/applet/program/avr/spi/fixtures/test_api_program_memory.json
  91. +3 −0 software/glasgow/applet/program/avr/spi/fixtures/test_api_signature.json
  92. +10 −8 software/glasgow/applet/program/ice40_sram/__init__.py
  93. +491 −0 software/glasgow/applet/program/m16c/__init__.py
  94. +2 −3 software/glasgow/applet/program/mec16xx/__init__.py
  95. +98 −71 software/glasgow/applet/program/{nrf24l → nrf24lx1}/__init__.py
  96. +116 −0 software/glasgow/applet/program/xc6s/__init__.py
  97. +17 −23 software/glasgow/applet/program/xc9500xl/__init__.py
  98. +7 −0 software/glasgow/applet/radio/__init__.py
  99. +568 −0 software/glasgow/applet/radio/nrf24l01/__init__.py
  100. +0 −299 software/glasgow/applet/sensor/bmp280/__init__.py
  101. +480 −0 software/glasgow/applet/sensor/bmx280/__init__.py
  102. +220 −0 software/glasgow/applet/sensor/hx711/__init__.py
  103. +158 −0 software/glasgow/applet/sensor/ina260/__init__.py
  104. +170 −0 software/glasgow/applet/sensor/pmsx003/__init__.py
  105. +42 −19 software/glasgow/applet/sensor/scd30/__init__.py
  106. +2 −2 software/glasgow/applet/video/rgb_input/__init__.py
  107. +2 −2 software/glasgow/applet/video/vga_output/__init__.py
  108. +0 −2 software/glasgow/applet/video/vga_terminal/LICENSE.txt
  109. +0 −271 software/glasgow/applet/video/vga_terminal/__init__.py
  110. +0 −264 software/glasgow/applet/video/vga_terminal/cpu.py
  111. BIN software/glasgow/applet/video/vga_terminal/ibmvga8x14.bin
  112. BIN software/glasgow/applet/video/vga_terminal/ibmvga8x16.bin
  113. BIN software/glasgow/applet/video/vga_terminal/ibmvga8x8.bin
  114. BIN software/glasgow/applet/video/vga_terminal/ibmvga8x8hi.bin
  115. +14 −6 software/glasgow/applet/video/ws2812_output/__init__.py
  116. +0 −262 software/glasgow/arch/boneless/__init__.py
  117. +0 −144 software/glasgow/arch/boneless/instr.py
  118. +0 −75 software/glasgow/arch/boneless/opcode.py
  119. +2 −1 software/glasgow/arch/msp430/jtag.py
  120. +39 −0 software/glasgow/arch/nrf24l/__init__.py
  121. +202 −0 software/glasgow/arch/nrf24l/rf.py
  122. +72 −0 software/glasgow/arch/xilinx/xc6s.py
  123. +189 −104 software/glasgow/cli.py
  124. +2 −0 software/glasgow/database/microchip/avr.py
  125. 0 software/glasgow/{gateware/platform → database/ti}/__init__.py
  126. +459 −0 software/glasgow/database/ti/msp430.py
  127. +30 −0 software/glasgow/database/xilinx/xc6s.py
  128. +144 −98 software/glasgow/device/hardware.py
  129. +486 −0 software/glasgow/firmware.ihex
  130. +12 −2 software/glasgow/gateware/__init__.py
  131. +21 −14 software/glasgow/gateware/analyzer.py
  132. +0 −844 software/glasgow/gateware/boneless.py
  133. +1 −1 software/glasgow/gateware/clockgen.py
  134. +35 −65 software/glasgow/gateware/fx2_crossbar.py
  135. +82 −40 software/glasgow/gateware/i2c.py
  136. +11 −8 software/glasgow/gateware/lfsr.py
  137. +2 −13 software/glasgow/gateware/mpsse.py
  138. +23 −20 software/glasgow/gateware/pads.py
  139. +7 −11 software/glasgow/gateware/pll.py
  140. +18 −23 software/glasgow/gateware/registers.py
  141. +21 −13 software/glasgow/gateware/uart.py
  142. +0 −3 software/glasgow/platform/__init__.py
  143. +3 −0 software/glasgow/platform/all.py
  144. +35 −27 software/glasgow/{gateware/platform/lattice.py → platform/ice40.py}
  145. +0 −14 software/glasgow/platform/programmer.py
  146. +52 −58 software/glasgow/platform/rev_ab.py
  147. +121 −72 software/glasgow/platform/rev_c0.py
  148. +122 −72 software/glasgow/platform/rev_c1.py
  149. +24 −10 software/glasgow/protocol/gdb_remote.py
  150. +14 −12 software/glasgow/protocol/jesd3.py
  151. +3 −3 software/glasgow/protocol/jtag_svf.py
  152. +15 −8 software/glasgow/protocol/vgm.py
  153. +16 −0 software/glasgow/support/asignal.py
  154. +16 −4 software/glasgow/support/bits.py
  155. +33 −21 software/glasgow/support/bitstruct.py
  156. +233 −0 software/glasgow/support/data_logger.py
  157. +20 −2 software/glasgow/support/endpoint.py
  158. +45 −1 software/glasgow/support/logging.py
  159. +24 −11 software/glasgow/support/pyrepl.py
  160. +10 −9 software/glasgow/support/task_queue.py
  161. +4 −4 software/glasgow/target/analyzer.py
  162. +40 −66 software/glasgow/target/hardware.py
  163. +1 −1 software/glasgow/target/simulation.py
  164. +0 −7 software/setup.cfg
  165. +29 −46 software/setup.py
  166. +8 −0 software/test.py
  167. +0 −1,822 software/versioneer.py
  168. +1 −1 vendor/libfx2
  169. +0 −1,822 versioneer.py
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
__pycache__/
*.egg-info/
*.eggs/
dist/
build/
*.pyc
*.v
*.vcd
*.gtkw
*.ihex
*.log
*.*b[ac]k
_autosave-*
@@ -19,3 +19,4 @@ _autosave-*
/*.svf
/*.bit
/*.json
/*.csv
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@
url = https://github.com/whitequark/libfx2
[submodule "docs/archive"]
path = docs/archive
url = https://github.com/GlasgowEmbedded/Glasgow-Archive
url = https://github.com/GlasgowEmbedded/archive
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
dist: trusty
dist: xenial
sudo: required
language: python
python:
- "3.6"
- "3.7"
- "3.8"
addons:
apt:
update: true
before_install:
- sudo apt install sdcc
- pip install yowasp-yosys yowasp-nextpnr-ice40-5k yowasp-nextpnr-ice40-8k
- export YOSYS=yowasp-yosys NEXTPNR_ICE40=yowasp-nextpnr-ice40 ICEPACK=yowasp-icepack
install:
- "(cd vendor/libfx2/software && SDAR='sdcclib r' python setup.py install)"
script:
- "(cd software && python setup.py install)"
- "(cd software && python setup.py test)"
script:
- "(cd software && python -W ignore::DeprecationWarning test.py)"
82 changes: 68 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

**Want one? [Subscribe here](https://mailchi.mp/44980ff6f0ab/glasgow-announcements).**

**Let's chat! [Our IRC channel is #glasgow at freenode.net](https://webchat.freenode.net/?channels=glasgow).**
**Let's chat! Our IRC channel is [#glasgow at freenode.net](https://webchat.freenode.net/?channels=glasgow); our Discord channel is [#glasgow at 1BitSquared's Discord server](https://1bitsquared.com/pages/chat).**

**Important note: if you are looking to assemble boards yourself, use only revC1.**

@@ -26,13 +26,17 @@ Some of the tasks Glasgow can do well are:
* determine memory parameters via SFDP,
* read and write ONFI-compatible Flash memories,
* determine memory parameters via ONFI parameter page,
* read and write parallel 27/28/29-series EPROMs, EEPROMs and Flash memories,
* determine the extent of floating gate charge decay and rescue data,
* program and verify AVR microcontrollers with SPI interface,
* automatically determine unknown JTAG pinout,
* play back JTAG SVF files,
* debug ARC processors via JTAG,
* debug some MIPS processors via EJTAG,
* program and verify XC9500XL CPLDs via JTAG,
* synthesize sound using a Yamaha OPL chip and play it in real time on a webpage,
* communicate using nRF24L01(+) radios,
* program nRF24LE1 and nRF24LU1(+) microcontrollers,
* synthesize sound using a Yamaha OPLx/OPM chip and play it in real time on a webpage,
* read raw modulated data from 5.25"/3.5" floppy drives,
* ... and more!

@@ -58,13 +62,13 @@ Revisions A and B have not been produced in significant amounts, contain major d

![Overview of the Glasgow PCB](hardware/boards/glasgow/3drender-readme.png)

Revision C is the latest revision and is being prepared for mass production. It provides 16 I/O pins with a maximum frequency of approx. 100 MHz\*, independent direction control and independent programmable pull-up/pull-down resistors. The I/O pins are grouped into two I/O ports that can use any voltage from 1.8 V to 5 V, sense and monitor I/O voltage of the device under test, as well as provide up to 150 mA of power. The board uses USB 2 for power, configuration, and communication, achieving up to 336 Mbps (42 MB/s) of sustained combined throughput.
Revision C is the latest revision and is being prepared for mass production. It provides 16 I/O pins with a maximum data rate of approx. 200 Mbps/pin (100 MHz)\*, independent direction control and independent programmable pull-up/pull-down resistors. The I/O pins are grouped into two I/O ports, each of which can use any voltage from 1.8 V to 5 V, sense and monitor I/O voltage of the device under test, as well as provide up to 150 mA of power. The board uses USB 2 for power, configuration, and communication, achieving up to 336 Mbps (42 MB/s) of sustained combined throughput.

<sub>\* Maximum frequency achievable in practice depends on many factors and will vary greatly with specific interface and applet design. 24 MHz non-DDR can be achieved for most interfaces with minimal effort.</sub>
<sub>\* Maximum data rate achievable in practice depends on many factors and will vary greatly with specific interface and applet design. 12 Mbps/pin (6 MHz) can be achieved with minimal development effort; reaching higher data rates requires careful HDL coding and a good understanding of timing analysis.</sub>

## What software does Glasgow use?

Glasgow is written entirely in Python 3. The interface logic that runs on the FPGA is described using [Migen](https://m-labs.hk/migen/), which is a Python-based domain specific language. The supporting code that runs on the host PC is written in Python with [asyncio](https://docs.python.org/3/library/asyncio.html). This way, the logic on the FPGA can be assembled on demand for any requested configuration, keeping it as fast and compact as possible, and code can be shared between gateware and software, removing the need to add error-prone "glue" boilerplate.
Glasgow is written entirely in Python 3. The interface logic that runs on the FPGA is described using [nMigen](https://github.com/nmigen/nmigen/), which is a Python-based domain specific language. The supporting code that runs on the host PC is written in Python with [asyncio](https://docs.python.org/3/library/asyncio.html). This way, the logic on the FPGA can be assembled on demand for any requested configuration, keeping it as fast and compact as possible, and code can be shared between gateware and software, removing the need to add error-prone "glue" boilerplate.

Glasgow would not be possible without the [open-source iCE40 FPGA toolchain](http://www.clifford.at/icestorm/), which is not only very reliable but also extremely fast. It is so fast that FPGA bitstreams are not cached (beyond not rebuilding the bitstream already on the device), as it only takes a few seconds to build one from scratch for something like an UART. When developing a new applet it is rarely necessary to wait for the toolchain.

@@ -74,46 +78,96 @@ Debugging new applets can be hard, especially if bidirectional buses are involve

## How do I use Glasgow?

**If these instructions don't work for you, please file it as a bug, so that the experience can be made more smooth for everyone.**

### ... with Linux?

You will need Python 3.6 (or a newer version, in which case replace `3.6` with that version below) and sdcc. On a Debian or Ubuntu system these can be installed with:
You will need git and Python 3.7 (or a newer version, in which case replace `3.7` with that version below). On a Debian or Ubuntu system these can be installed with:

apt-get install --no-install-recommends git python3.7 python3-setuptools \
python3-libusb1 python3-aiohttp python3-bitarray python3-crcmod

apt-get install python3.6 sdcc
You will also need Yosys and nextpnr-ice40, both from the master branch. Follow the setup instructions for [Yosys](https://github.com/yosysHQ/yosys/#setup) and [nextpnr](https://github.com/YosysHQ/nextpnr/#nextpnr-ice40).

Obtain the source code:

git clone https://github.com/GlasgowEmbedded/Glasgow
cd Glasgow
git clone https://github.com/GlasgowEmbedded/glasgow
cd glasgow

Configure your system to allow unprivileged access (for anyone in the `plugdev` group) to the Glasgow hardware:

sudo cp config/99-glasgow.rules /etc/udev/rules.d

Install the dependencies and the binaries for the current user:
Install the dependencies and the scripts for the current user:

cd software
python3.6 setup.py develop --user
python3.7 setup.py develop --user

The binaries are placed in `$HOME/.local/bin`, so be sure to add that directory to the `PATH` environment variable; after this, you can run `glasgow` from a terminal. Instead of adjusting `PATH` it is also possible to use `python3.6 -m glasgow.cli`.
The scripts are placed in `$HOME/.local/bin`, so be sure to add that directory to the `PATH` environment variable; after this, you can run `glasgow` from a terminal. Instead of adjusting `PATH` it is also possible to use `python3.7 -m glasgow.cli`.

To update the source code, do:

cd Glasgow
cd glasgow
git pull

### ... with macOS?

If you haven't already, install [Homebrew](https://brew.sh/). Now:

brew install python
brew tap ktemkin/oss-fpga
brew install --HEAD icestorm yosys nextpnr-ice40

Obtain the source code:

git clone https://github.com/GlasgowEmbedded/glasgow
cd glasgow

Install the dependencies and the scripts for the current user:

cd software
python3.6 setup.py build_ext
python setup.py develop

The scripts will be installed in `/usr/local/bin`, which should already be in your `PATH`.

### ... with Windows?

Although first-class Windows support is an important goal and Glasgow already works on Windows, the installation process is not yet ready.

## How do I factory flash Glasgow?

"Factory flashing" refers to the process of assigning a brand new Glasgow board (that you probably just assembled) a serial number, as well as writing a few critical configuration options that will let the normal Glasgow CLI pick up this device. Barring severe and unusual EEPROM corruption, this process is performed only once for each board.

As a prerequisite to factory flashing, follow all steps from the "[How do I use Glasgow?](#how-do-i-use-glasgow)" section.

Any board that is factory flashed must have a blank FX2_MEM EEPROM. If the FX2_MEM EEPROM is not completely erased (all bytes set to `FF`), the factory flashing process may fail.

### ... with Linux?

Configure your system to allow unprivileged access (for anyone in the `plugdev` group) to any hardware that enumerates as the Cypress FX2 ROM bootloader:

sudo cp config/99-cypress.rules /etc/udev/rules.d

Note that this udev rule will affect more devices than just Glasgow, since the Cypress VID:PID pair is shared.

Plug in the newly assembled device. At this point, `lsusb | grep 04b4:8613` should list one entry. Assuming you are factory flashing a board revision C1, run:

glasgow factory --rev C1

Done! At this point, `lsusb | grep 20b7:9db1` should list one entry.

### ... with Windows?

See [above](#-with-windows).

## Who made Glasgow?

* [@whitequark](https://github.com/whitequark) came up with the design, coordinates the project and implements most of gateware and software;
* [@awygle](https://github.com/awygle) designed the power/analog port circuitry and helped with layout of revB;
* [@marcan](https://github.com/marcan) improved almost every aspect of hardware for revC;
* [@esden](https://github.com/esden) is handling batch manufacturing;
* [@smunaut](https://github.com/smunaut) provided advice crucial for stability and performance of USB communication;
* [@electronic_eel](https://github.com/electronic_eel) designed the test jig and advanced protection circuitry;
* ... and many [other people](https://github.com/GlasgowEmbedded/Glasgow/graphs/contributors).

## License
2 changes: 2 additions & 0 deletions config/99-cypress.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="8613", \
MODE="0660", GROUP="plugdev", TAG+="uaccess"
12 changes: 9 additions & 3 deletions examples/boilerplate.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import logging
import asyncio
from migen import *
from nmigen import *

from ... import *


class BoilerplateSubtarget(Module):
class BoilerplateSubtarget(Elaboratable):
def __init__(self, pads, in_fifo, out_fifo):
pass
self.pads = pads
self.in_fifo = in_fifo
self.out_fifo = out_fifo

def elaborate(self, platform):
m = Module()
return m


class BoilerplateApplet(GlasgowApplet, name="boilerplate"):
16 changes: 16 additions & 0 deletions examples/i2c-pcf8574.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
An example of a script that can be used with the run-script mode.
This will read and write the pins of a PCF8574. Once connected, run:
glasgow run-script i2c-pcf8574.py i2c-initiator -V 3.3
"""

# read pin values
print('I/O pin state: 0b{:08b}'.format((await iface.read(0x20, 1))[0]))

# write pin values
await iface.write(0x20, [ 0x55 ])

# power down the device after use
await device.set_voltage("AB", 0)
1 change: 1 addition & 0 deletions firmware/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ihex
13 changes: 7 additions & 6 deletions firmware/dac_ldo.c
Original file line number Diff line number Diff line change
@@ -15,16 +15,17 @@ static const struct buffer_desc buffers[] = {

void iobuf_init_dac_ldo() {
// Configure I/O buffer pins as open-source/open-drain; they have 100k pulls
IOD = IOD & ~((1<<PIND_ENVA)|(1<<PIND_ENVB)) | (1<<PIND_OEQ_N);
OED |= ((1<<PIND_ENVA)|(1<<PIND_ENVB) | (1<<PIND_OEQ_N));
IOD = IOD & ~((1<<PIND_ENVA)|(1<<PIND_ENVB)) | (1<<PIND_OEQ_N_REVAB);
OED |= ((1<<PIND_ENVA)|(1<<PIND_ENVB) | (1<<PIND_OEQ_N_REVAB));

// Enable I/O buffers
IOD &= ~ (1<<PIND_OEQ_N);
// Enable I/O buffers, just existing on revAB
IOD &= ~ (1<<PIND_OEQ_N_REVAB);
}

void iobuf_enable(bool on) {
if(on) IOD &= ~(1<<PIND_OEQ_N);
else IOD |= (1<<PIND_OEQ_N);
// I/O buffers just existing on revAB, pin is unconnected on revC
if(on) IOD &= ~(1<<PIND_OEQ_N_REVAB);
else IOD |= (1<<PIND_OEQ_N_REVAB);
}

static bool dac_start(uint8_t mask, bool read) {
11 changes: 7 additions & 4 deletions firmware/glasgow.h
Original file line number Diff line number Diff line change
@@ -3,8 +3,11 @@

#include <stdbool.h>

#define VID_QIHW 0x20b7
#define PID_GLASGOW 0x9db1
#define VID_CYPRESS 0x04b4
#define PID_FX2 0x8613

#define VID_QIHW 0x20b7
#define PID_GLASGOW 0x9db1

enum {
// Board revisions
@@ -32,7 +35,7 @@ enum {
#define PIND_LED_ACT 4
#define PIND_LED_ERR 5
#define PIND_ENVB 6
#define PIND_OEQ_N 7
#define PIND_OEQ_N_REVAB 7

enum {
// I2C addresses (unshifted)
@@ -63,7 +66,7 @@ enum {
#define BITSTREAM_ID_SIZE 16

__xdata __at(0x4000 - CONF_SIZE) struct glasgow_config {
char revision;
uint8_t revision;
char serial[16];
uint32_t bitstream_size;
char bitstream_id[BITSTREAM_ID_SIZE];
42 changes: 36 additions & 6 deletions firmware/main.c
Original file line number Diff line number Diff line change
@@ -127,7 +127,12 @@ usb_configuration_c usb_config_1_pipe = {
}
};

// check for "earlier than 3.5", but version macros shipped in 3.6
#if !defined(__SDCC_VERSION_MAJOR)
__code const struct usb_configuration *__code const usb_configs[] = {
#else
usb_configuration_set_c usb_configs[] = {
#endif
&usb_config_2_pipes,
&usb_config_1_pipe,
};
@@ -137,8 +142,8 @@ usb_ascii_string_c usb_strings[] = {
[1] = "Glasgow Debug Tool",
[2] = "XX-XXXXXXXXXXXXXXXX",
// Configurations
[3] = "Pipe Q at {2x512B EP2OUT/EP6IN}, R at {2x512B EP4OUT/EP8IN}",
[4] = "Pipe Q at {4x512B EP2OUT/EP6IN}",
[3] = "Pipe P at {2x512B EP2OUT/EP6IN}, Q at {2x512B EP4OUT/EP8IN}",
[4] = "Pipe P at {4x512B EP2OUT/EP6IN}",
// Interfaces
[5] = "Disabled",
[6] = "Double-buffered 512B",
@@ -253,6 +258,10 @@ static void descriptors_init() {
desc_serial[1] = '0' + (glasgow_config.revision & 0xF);
xmemcpy(&desc_serial[3], (__xdata void *)glasgow_config.serial,
sizeof(glasgow_config.serial));
if(glasgow_config.revision == GLASGOW_REV_NA) {
desc_device->idVendor = VID_CYPRESS;
desc_device->idProduct = PID_FX2;
}
}

enum {
@@ -419,6 +428,15 @@ void handle_pending_usb_setup() {
arg_chip = I2C_ADDR_ICE_MEM + 1;
page_size = 8;
break;
case 3:
// The HX8K bitstream is slightly (less than 4 KB) larger than the capacity of ICE_MEM,
// so we stuff the very tail end of the bitstream back into FX2_MEM. It's necessary to
// make sure the writes don't wrap, or we can overwrite the configuration info.
if(arg_addr <= 0x1000 && arg_len <= 0x1000 && (arg_addr + arg_len) <= 0x1000) {
arg_chip = I2C_ADDR_FX2_MEM;
page_size = 6; // 64 bytes
arg_addr += 0x7000;
}
}
}
pending_setup = false;
@@ -829,17 +847,29 @@ int main() {
if(length < chunk_len)
chunk_len = length;

if(!eeprom_read(chip, addr, (uint8_t *)&scratch, chunk_len, /*double_byte=*/true))
if(!eeprom_read(chip, addr, (uint8_t *)&scratch, chunk_len, /*double_byte=*/true)) {
latch_status_bit(ST_ERROR);
break;
}
fpga_load((__xdata uint8_t *)scratch, chunk_len);

length -= chunk_len;
addr += chunk_len;
if(addr == 0)
chip += 1; // address wraparound
if(addr == 0) {
// Advance to the next logical chip in case of address wraparound.
chip += 1;
if(chip == I2C_ADDR_ICE_MEM + 2) {
// See explanation in USB_REQ_EEPROM.
chip = I2C_ADDR_FX2_MEM;
addr += 0x7000;
}
}
}
if(length == 0)
if(length == 0) {
fpga_start();
if(!fpga_is_ready())
latch_status_bit(ST_ERROR);
}

led_act_set(false);
}
Loading