Join me this Sunday at FOSDEM 2021 where I will explain how I developed the CADSTAR importer for KiCad and provide you with details to develop your own importer!
Importing into KiCad from CADSTAR
…and how you can develop your own importer
Sunday 7th February 2021 @ 13:50 CET (Brussels Time)
@Qbort Thank you for the great job. Seems to be a good option to import CADSTAR files to KiCAD. I’m using different versions of CADSTAR since more than 13 years and I’m currently checking different options to migrate to another tool. Yesterday I made some tests with the nightly version of KiCAD and came to two questions you may support me.
First one: Is there a nightly version preferred for your Importer. Yesterday I checked the oldest and newest version available but both versions immediately shut down (no message) after the import is done. The newest version provides the import report but the oldest available one (beginning of January 2021) stops work directly after selecting the layer cross-reference.
Second one: I’m looking since years to find a tool that can generate 3D information from the CADSTAR layout export using the component height defined with the footprint. Will this information be available after import to KiCAD and will this provide a simple option to generate 3D files from my CADSTAR designs without using the Zuken 3D software I don’t have. Unfortunately I can’t test it myself because of the issues mentioned above.
I have a CADSTAR license of Version 18, Patch 2 and I can provide my support with different files.
Could you open two bugreports [1,2] for these issues?
If you are on linux, you could run kicad inside of gdb, do the actions that trigger the crash, and then post the backtrace.
In detail:
$ gdb kicad
(gdb) run
Do the actions that crash kicad (I emulated this by running $ killall kicad in a second terminal)
(gdb) bt
(gdb) quit
Full terminal output on my machine:
[cedric@cedric-p4 ~]$ gdb kicad
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from kicad...
(No debugging symbols found in kicad)
(gdb) run
Starting program: /usr/bin/kicad
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[Detaching after vfork from child process 2396532]
[Detaching after vfork from child process 2396534]
[Detaching after vfork from child process 2396536]
[Detaching after vfork from child process 2396538]
[Detaching after vfork from child process 2396540]
[Detaching after vfork from child process 2396544]
[Detaching after vfork from child process 2396548]
[Detaching after vfork from child process 2396552]
[New Thread 0x7ffff4099640 (LWP 2396573)]
[New Thread 0x7ffff3898640 (LWP 2396574)]
[New Thread 0x7ffff2c09640 (LWP 2396575)]
[New Thread 0x7ffff2408640 (LWP 2396576)]
[New Thread 0x7ffff1c07640 (LWP 2396577)]
[New Thread 0x7ffff1406640 (LWP 2396578)]
[Thread 0x7ffff2408640 (LWP 2396576) exited]
[Thread 0x7ffff2c09640 (LWP 2396575) exited]
[Thread 0x7ffff1406640 (LWP 2396578) exited]
[Thread 0x7ffff1c07640 (LWP 2396577) exited]
Thread 1 "kicad" received signal SIGTERM, Terminated.
0x00007ffff566c46f in poll () from /usr/lib/libc.so.6
(gdb) bt
#0 0x00007ffff566c46f in poll () at /usr/lib/libc.so.6
#1 0x00007ffff61a093f in () at /usr/lib/libglib-2.0.so.0
#2 0x00007ffff614bfd3 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#3 0x00007ffff69f022f in gtk_main () at /usr/lib/libgtk-3.so.0
#4 0x00007ffff7827b26 in wxGUIEventLoop::DoRun() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#5 0x00007ffff738537e in wxEventLoopBase::Run() () at /usr/lib/libwx_baseu-3.0.so.0
#6 0x00007ffff734b766 in wxAppConsoleBase::MainLoop() () at /usr/lib/libwx_baseu-3.0.so.0
#7 0x000055555571e3ca in ()
#8 0x00007ffff73ca199 in wxEntry(int&, wchar_t**) () at /usr/lib/libwx_baseu-3.0.so.0
#9 0x00005555556fe863 in ()
#10 0x00007ffff559f152 in __libc_start_main () at /usr/lib/libc.so.6
#11 0x000055555570f09e in _start ()
(gdb) quit
A debugging session is active.
Inferior 1 [process 2396528] will be killed.
Quit anyway? (y or n) y
[cedric@cedric-p4 ~]$
@MKnack thanks for your interest! You should always use the latest version KiCad nightly when testing.
[1] I believe I fixed all crash issues. If KiCad still crashes, please log an issue in gitlab so we can track it for v6 release. I will need you to attach a design which causes the crash.
[2] At the moment the importer does not import 3D models but it might be possible to do. However I will do that at the end. Right now I want to ensure that all copper elements import as close as possible to the original. Please also create an issue in Gitlab to request this addition.
You can create a new issue by clicking Help -> Report Bug. This will open a page in Gitlab and pre-populate it with your KiCad version and system information.
I would be very grateful if you could log issues for any specific import inaccuracies. E.g. if text elements aren’t positioned in the right place or incorrect widths assigned to a graphical element.
Edit: sorry @cedric I missed your message. Thanks for your help. The crash usually occurs somewhere else in KiCad due to a incorrect setting of objects by the importer, so unfortunately gdb does not give very useful information to fix the bugs.
For me the most useful thing is to have the original design that caused the crash.
thank you @Qbort. Actually I download the current 64bit night build again and everything seems fine. My steps after install are:
1.) Open KiCad
2.) Choose the CADSTAR import option and select the CPA file located on my desktop. This file is generated with the mentioned CADSTAR version and all export options are enabled.
3.) Choose the target, a folder located on the desktop as well.
4.) Pcbnew opens and I select automatic layer assignment and press ok.
5.) My PCB is visible and there is a kicad “Error” that said that import was successful and I can check errors and warnings if available.
6.) The report shows a lot of template warnings (yellow) and five red template errors.
7.) I close this message and have to select the Global or Project Library.
8.) My selection doesn’t matter, by pressing ok it takes about 5 seconds and than KiCad close completely. Windows 10 reports no response and close KiCAD, I see this also in the Windows Task Manager.
I havn’t use KiCAD before and all settings are standard. I have no idea if it’s an issue of the nightly version, the CADSTAR importer or something else. Until the shutdown, everything looks like expected. So maybe the issue isn’t the importer. What do you think? As the report is generated, maybe the importer is ready?
@MKnack if KiCad crashes without warning then definitely it is a serious bug. It is likely this is caused by the importer but it might be a different cause.
Please do report an issue in Gitlab with detailed steps to reproduce the issue (as you did above) and also attach the design which causes the crash. Let me know if you have any problems creating the report in Gitlab.
We need all bugs to be in Gitlab so that we can track their fixes.
Perfect! thank you very much for doing this. It seems the problem is in creating the project specific library. I will work on a fix and if I need anything I need anything else I will post a comment in the gitlab issue itself.
Your workaround is to use pcbnew standalone (i.e. close KiCad Project manager and open Pcbnew directly) and do File->Import Non-KiCad Board file…
Also, just to let you know that there also is a CADSTAR Schematic importer. So you can also try a *.csa file and import. I would like to ask if you might be able to import your schematics as well (open eeschema->File->Import Non-KiCad KiCad Schematic…) Please log issues in gitlab with any inaccuracies that you find during import (e.g. text not in the right position, line thicknesses looking different, etc.)
Thanks for watching! I think most people moved over to the KiCad backroom (which is understandable). Hopefully someone will see the recording and get motivated to write yet another importer!
@MKnack I Yes, that is definitely a fault with the importer.
If you could do as before and open a gitlab issue with a test file, that would be great! TRIANGLE is the shape of a symbol terminal (pin in KiCad). With the CADSTAR version that I have, TRIANGLE always has two parameters: a “left” and a “right” length. I am unable to generate a test file that only has one.
It is really hard to get an importer working 100% without test files, so your help with this is greatly appreciated!
@MKnack I just wanted to let you know that I fixed the bug that caused a crash for you. Also I think I applied a fix to the error message TRIANGLE you were getting.
If you could try again with the latest nightly version, that would be great (version r20846 or later). Your help in identifying problems with the importer is greatly appreciated. I am aware of a few bugs already that I am working to fix: https://gitlab.com/kicad/code/kicad/-/issues?scope=all&utf8=✓&state=opened&label_name[]=cadstar but if you do spot anything else please create a new issue with an example board.
Right now the KiCad importer does a better job of loading a CADSTAR design than Altium’s version of the importer, but I still want to make it as accurate as possible before KiCad v6 is released.
the pcb import works without a problem now. Thank you very much for your great work. Yes, you are right, your importer makes a ways better job than the Altium importer. Chapeau and thank you again!
I tried a schematic export as well generated myself using CADSTAR 18 but get the error:
Error loading schematic"…" Unknown node ‘TESTPOINT’ in ‘SYMBOLVARIANT’.
Most designs are confidential so it’s not so easy to upload them. If I find some time, I try to generate a minimized expert again.
@MKnack if you could create a gitlab issue with a screenshot of the error message you are getting, that would be good for now. Obviously a test design would save me a lot of work, but just with the error message I might be able to figure it out. It is a lot easier to keep track of all the issues if they are in one place.
We don’t use test points in any of our designs so it is likely that there are a lot of import errors here.
@MKnack Good to hear! I am also interested in fixing import inaccuracies. E.g. text that isnt placed in the correct location, incorrect orientation or even if there are some objects that you think might have a better KiCad equivalent.
e.g. Right now I import Cadstar “Signal references” as KiCad “ports” and Global references as KiCad “power symbols”) There might be other object types that could have a closer equivalent.
I appreciate any help you can give in testing the importer as much as possible. Please feel free to open issues with any aspects you think could be improved. My ultimate aim is to get the importer to open a cadstar design and be able to continue working on the design as if it had been created in KiCad.
There are some things that cannot be fixed perfectly due to differences between KiCad and CADSTAR. A few examples:
“new lines” in component attributes. CADSTAR allows this but KiCad does not, so the imported design will look ugly (as the importer has to replace new lines with “\n” to keep KiCad happy.
Pin swaps are handled correctly but if you “update from library”, any pin swaps will be reverted (I think cadstar does this too though)
Net list in Cadstar is global whereas in KiCad it can be global or local to the sheet. This means that the importer sometimes needs to add “tiny net labels” to ensure connectivity is kept.
Cadstar has a FROM_FILE token which allows loading the contents of a file as text. The importer instead loads this as a KiCad “Text Variable” embedded with the document (so no updates if the external file is updated)