Skip to content

Add quickfeather board#117

Merged
whitequark merged 3 commits intoamaranth-lang:masterfrom
antmicro:quicklogic
Nov 13, 2020
Merged

Add quickfeather board#117
whitequark merged 3 commits intoamaranth-lang:masterfrom
antmicro:quicklogic

Conversation

@kowalewskijan
Copy link
Copy Markdown
Contributor

@kowalewskijan kowalewskijan commented Oct 14, 2020

This PR introduces two boards which utilize the QuickLogic EOS-S3 platform: amaranth-lang/amaranth#504
The contents are:

  • support for QuickFeather board
  • support for programming the bitstream using OpenOCD

@kowalewskijan kowalewskijan changed the title Add chandalar and quickfeather boards Add quickfeather board Oct 15, 2020
@whitequark
Copy link
Copy Markdown
Member

Please submit the boards as separate PRs.

@kowalewskijan kowalewskijan force-pushed the quicklogic branch 2 times, most recently from d1bfc9b to 4b54ab7 Compare October 16, 2020 09:34
@kowalewskijan
Copy link
Copy Markdown
Contributor Author

I removed the chandalar board since it is an outdated device and it doesn't make sense to maintain it.
Also the CI failes for QuickFeather due to a syntax error in the platform definition - I added a fix for this here

@whitequark
Copy link
Copy Markdown
Member

Also the CI failes for QuickFeather due to a syntax error in the platform definition

In the future you should test the pull requests you send locally to avoid this sort of problem. (Ideally we would test toolchains on CI, but this is not practical to do for most toolchains.)

@kowalewskijan
Copy link
Copy Markdown
Contributor Author

I reworked board definition and tested two flows:

  • only build
  • build + programming the board

I also added a separate PR which contains a feature that will enable an internal SoC clock (link). I think it makes sense to enable internal clock by default in Quickfeather board, so the Blinky example could work out of the box.

@whitequark
Copy link
Copy Markdown
Member

I reworked board definition and tested two flows:

Thanks! I have a Quickfeather, so I'm looking forward to using nMigen with it.

@whitequark
Copy link
Copy Markdown
Member

@kowalewskijan Please apply the following patch (which requires up-to-date nMigen to work) and tell me if toolchain_program works for you. (I don't have an SWD programmer at the moment.)

commit 95a7eb03edd08ade54dd45dcab48377e5fb9a588 (HEAD -> pr/117)
Author: whitequark <whitequark@whitequark.org>
Date:   Fri Nov 13 05:44:35 2020 +0000

    Simplify Quickfeather toolchain_program().

diff --git a/nmigen_boards/quickfeather.py b/nmigen_boards/quickfeather.py
index 837e965..582bc69 100644
--- a/nmigen_boards/quickfeather.py
+++ b/nmigen_boards/quickfeather.py
@@ -59,37 +59,24 @@ class QuickfeatherPlatform(QuicklogicPlatform):
     # https://github.com/antmicro/openocd/tree/eos-s3-support
     def toolchain_program(self, products, name):
         openocd = os.environ.get("OPENOCD", "openocd")
-        with products.extract("{}.bit".format(name)) as bitstream_filename:
-            bitstream_folder = os.path.dirname(bitstream_filename)
-            top_ocd_path = os.path.join(bitstream_folder, "top.openocd")
-            subprocess.call([sys.executable, "-m",
-                             "quicklogic_fasm.bitstream_to_openocd",
-                             bitstream_filename, top_ocd_path])
-            # Merge IOMUX config with bitstream into one OpenOCD script
-            with products.extract("{}_iomux.openocd".format(name)) as iomux_filename:
-                merged_ocd_cfg = str()
-                merged_ocd_cfg_path = os.path.join(bitstream_folder, 'top_and_iomux.openocd')
-                with open(top_ocd_path, "r") as top_file:
-                    merged_ocd_cfg = top_file.read()[0:-2]
-                with open(iomux_filename, "r") as iomux_file:
-                    merged_ocd_cfg += iomux_file.read() + '}'
-                with open(merged_ocd_cfg_path, "w") as merged_ocd_cfg_file:
-                    merged_ocd_cfg_file.write(merged_ocd_cfg)
-                cfg_path = merged_ocd_cfg_path
-            try:
-                openocd_proc = subprocess.Popen([openocd, "-s", "tcl",
-                                                 "-f", "interface/ftdi/antmicro-ftdi-adapter.cfg",
-                                                 "-f", "interface/ftdi/swd-resistor-hack.cfg",
-                                                 "-f", "board/quicklogic_quickfeather.cfg",
-                                                 "-f", cfg_path,
-                                                 "-c", "init",
-                                                 "-c", "reset halt",
-                                                 "-c", "load_bitstream",
-                                                 "-c", "exit"])
-            except Exception as e:
-                openocd_proc.kill()
-                raise e
+        with products.extract("{}.openocd".format(name),
+                              "{}_iomux.openocd".format(name)) as \
+                (bitstream_openocd_filename, iomux_openocd_filename):
+            subprocess.check_call([
+                openocd,
+                "-s", "tcl",
+                "-f", "interface/ftdi/antmicro-ftdi-adapter.cfg",
+                "-f", "interface/ftdi/swd-resistor-hack.cfg",
+                "-f", "board/quicklogic_quickfeather.cfg",
+                "-f", bitstream_openocd_filename,
+                "-c", "init",
+                "-c", "reset halt",
+                "-c", "load_bitstream",
+                "-f", iomux_openocd_filename,
+                "-c", "exit"
+            ])
+
 
 if __name__ == "__main__":
     from .test.blinky import *
-    QuickfeatherPlatform().build(Blinky(), do_program=False)
+    QuickfeatherPlatform().build(Blinky())

Jan Kowalewski and others added 3 commits November 13, 2020 13:55
Co-Authored-By: Kamil Rakoczy <krakoczy@antmicro.com>
Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>
@whitequark whitequark merged commit 5591cd5 into amaranth-lang:master Nov 13, 2020
@whitequark
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants