{"id":1917,"date":"2022-06-21T21:28:13","date_gmt":"2022-06-21T21:28:13","guid":{"rendered":"http:\/\/retroramblings.net\/?p=1917"},"modified":"2025-09-30T10:26:00","modified_gmt":"2025-09-30T10:26:00","slug":"installing-lattice-diamond-on-mint-20-3","status":"publish","type":"post","link":"http:\/\/retroramblings.net\/?p=1917","title":{"rendered":"Installing Lattice Diamond on Mint 20.3"},"content":{"rendered":"\n<p>I&#8217;ve been exploring Yosys \/ NextPnR \/ Project Trellis on some Lattice ECP5-based boards recently, and I&#8217;ve been very impressed and enthused by what I&#8217;ve seen.  I do have to admit, though, that it&#8217;s not &#8220;there&#8221; yet, especially when it comes to SystemVerilog and VHDL support through the ghdl-yosys-plugin.  Yes, you can develop and compile &#8220;real&#8221; projects with Yosys and friends, but you do have to keep the toolchain&#8217;s limitations in mind and design around them.<\/p>\n\n\n\n<p>For this reason I wanted to install and try the &#8220;official&#8221; software for ECP5 development, namely Lattice Diamond.  This left me with a slight problem in that it&#8217;s only available on Windows and Redhat Enterprise Linux 6 or 7, with the software distributed in RPM format.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Windows is not an option &#8211; I only have one Windows-equipped machine here, currently mothballed &#8211; and it only has XP anyway.  I run Mint 20.3 as a daily driver, which is a derivative of Ubuntu 20.04.  I did once attempt to install the RPM on an older Ubuntu-derivative using the &#8220;alien&#8221; tool, with no success, but I discovered more recently that RPMs can be converted easily to cpio archives.  There are two tools we need here, both of which are in the Ubuntu repositories, so we&#8217;ll install those with<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install cpio rpm2cpio<\/pre>\n\n\n\n<p>Having downloaded the RPM (version 3.12 at the time of writing), create a temporary directory somewhere, cd into it, and run the following commands to extract the files from the RPM package:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rpm2cpio \/path\/to\/diamond_3_12-base-240-2-x86_64-linux.rpm | cpio -idmv<\/pre>\n\n\n\n<p>We see a list of files being extracted within a usr\/local\/diamond\/3.12 directory tree beneath our temporary directory &#8211; and the last of them reads: .\/usr\/local\/diamond\/3.12\/tcltk\/tcltk.tar.gz<\/p>\n\n\n\n<p>So that will need extracting.  As it happens, so will a number of other .tar.gz files.  We can find them like so:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">find . -iname \\*.tar.gz<\/pre>\n\n\n\n<p>We could manually cd into each of those directories in turn, and extract the archives by hand&#8230; but where&#8217;s the fun in that?  Here&#8217;s a bash monstrosity to perform that task automatically:  [Edit: updated to replace the backticks which WordPress swallowed.]<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">for a in `find . -iname \\*.tar.gz`; do bash -c \"cd $(dirname $a); tar -xzvf $(basename $a)\"; done<\/pre>\n\n\n\n<p>(We spawn a subshell with bash -c just to prevent the effect of the cd command persisting between files.)<\/p>\n\n\n\n<p>Job done?<\/p>\n\n\n\n<p>Well, actually yes!  The answer used to be no, because there were a number of shell scripts which had a \/bin\/sh &#8220;shebang&#8221; but actually used bash syntax.  With Diamond version 3.11 it was necessary to fix this <a href=\"https:\/\/github.com\/emard\/ulx3s-bin\/tree\/master\/fpga\/diamond\/diamond-fix-scripts\/change-sh-to-bash\">using a handy script or two&#8230;<\/a><\/p>\n\n\n\n<p>But with 3.12 this seems to be fixed out-of-the-box, and Diamond should now be runnable from within the temporary directory, with the command<\/p>\n\n\n\n<p>.\/usr\/local\/diamond\/3.12\/bin\/lin64\/diamond<\/p>\n\n\n\n<p>It will ask for the license file on first run &#8211; a free node-locked license can be generated from the website, using the MAC address of your network card, but only after creating a user account, which will need to be activated.  I attempted to create such an account many months ago using my regular gmail address, and it was never activated, so I was never able to create a license file.  I tried again more recently, creating an account using an address on a private domain, and that actually worked.  It wasn&#8217;t instant, however &#8211; so I think a human is involved in the process of reviewing and activating new user accounts.<\/p>\n\n\n\n<p>Anyhow, once Diamond is up and running, you can move it to a more convenient location &#8211; I simply moved the .\/usr\/local\/diamond directory to \/opt<\/p>\n\n\n\n<p>You might also want to reclaim some disk space by deleting the .tar.gz files, since they&#8217;re no longer needed.  Either remove them manually or if you&#8217;re feeling brave enough to use rm within a for loop, use a variation of the command above!<\/p>\n\n\n\n<p>As a parting shot &#8211; I note that as well as the diamond GUI software, there&#8217;s also a diamondc Tcl shell.  My initial dislike of Tcl has in recent years given way, first to a grudging respect, and now some degree of admiration for such a minimalist language &#8211; it&#8217;s certainly possible to do some really neat things in Tcl, and as a way of remotely scripting events on an FPGA over JTAG it&#8217;s hard to beat for simplicity.  My first instinct on finding myself in the diamondc Tcl shell was to see if I could load my tcljtag extension&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">load \/home\/amr\/FPGA\/tools\/xc3sprog\/libtcljtag.so<\/pre>\n\n\n\n<p>Oh sweet summer child, did you forget so quickly the appalling state of binary software distribution under Linux?<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">couldn't load file \"\/home\/amr\/FPGA\/tools\/xc3sprog\/libtcljtag.so\": \/home\/amr\/Desktop\/diamond\/usr\/local\/diamond\/3.12\/bin\/lin64\/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by \/home\/amr\/FPGA\/tools\/xc3sprog\/libtcljtag.so)<\/pre>\n\n\n\n<p>&lt;sigh&gt;<\/p>\n\n\n\n<p>So it turns out Diamond ships a libstdc++ that&#8217;s incompatible with the systemwide version.  This doesn&#8217;t matter as long as nothing using one version attempts to link dynamically with something using the other version.  Unfortunately that&#8217;s exactly what I just attempted to do.<\/p>\n\n\n\n<p>Removing the version of the library shipped with Diamond fixes that particular problem but I haven&#8217;t yet tested widely enough to be sure it won&#8217;t have provoked any others!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been exploring Yosys \/ NextPnR \/ Project Trellis on some Lattice ECP5-based boards recently, and I&#8217;ve been very impressed and enthused by what I&#8217;ve seen. I do have to admit, though, that it&#8217;s not &#8220;there&#8221; yet, especially when it &hellip; <a href=\"http:\/\/retroramblings.net\/?p=1917\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,13],"tags":[],"class_list":["post-1917","post","type-post","status-publish","format-standard","hentry","category-fpga","category-linux"],"_links":{"self":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/1917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1917"}],"version-history":[{"count":5,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/1917\/revisions"}],"predecessor-version":[{"id":1922,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/1917\/revisions\/1922"}],"wp:attachment":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1917"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}