pcb-rnd knowledge pool
Import schematics: how to switch over
isch_switch by Tibor 'Igor2' Palinkas on 2020-02-01 | Tags: howto, import, sch, schematics |
Abstract: The new import schematics feature does a few things sligthly differently, and there are also a few new options. This article attempts to ease the transition.
Know your workflow options
There are multiple ways to work with pcb-rnd:
- without a netlist
- with netlist drawn/created within pcb-rnd
- using manual netlist import: LoadFrom(netlist, ...) or any format-specific item in file menu, import
- using gsch2pcb-rnd
- manually running scripts or Makefiles that produce netlists or action scripts that are then loaded into pcb-rnd
- using the ImportSch() action from CLI or GUI
The current change and affects only ImportSch() and LoadFrom(netlist, ...). However, LoadFrom(netlist, ...) is only extended with support for more file formats, in a backward compatible manner, with no action syntax change. Thus this document focuses on ImportSch() changes.
Re-import
Once set up (see below), doing a new forward annotation (re-import), can be done by either executing the ImportSch action without arguments or by selecting menu item File/Import/Import schematics.
Menu changes
The File/import menu has the new ImportSch() call. The rest of the format-specific manual imports are split in different groups depending on whether they are netlist/sch imports or other imports.
Action changes
The Import() and ImportGUI() actions are deprecated, both will be removed soon, please stop using them.
The new action that replaces both is called ImportSch().
Removed enviornment variable based configuration
The new import schematics does not read pcb-rnd's environmental variables for config. This means the following env vars will have no effect on how the import is performed:
- PCB_MAKE_PROGRAM - configure cmd's command line to include the right make program
- PCB_GNETLIST - use conf node plugins/import_gnetlist/gnetlist_program
Deprecated board attributes
The new import schematics uses the unified conf tree for storing all the configuration. It does not ever update board attributes. Normally it does not even read board attributes.
There is one special case toe ase transition: if you run the new ImportSch() with no arguments for the first time, there is no config available. If the code finds there are old "import::" attributes present, it will read them and create the initial configuration.
This is a special, one-way compatibility feature.
Note: the new conf tree solution works only if your board is in the lihata board format. If you use a different board format, you will either need to reconfigure import schematics before each session, or you should choose a different forward annotation path.
Setting up for tEDAx netlists
Assumes an external tool, not ran from within pcb-rnd, generates a tEDAx netlist.
The easiest way to set this up is using the CLI:
ImportSch(setup, tEDAx, foo.sch)
An alternative way to setup is using the GUI:
ImportSch(dialog)
First select the format on the top of the dialog (tEDAx), then fill in the file path (or use the browse button to get a GUI file selector do that). An import can be done by clicking the "Import!" button. The config is preserved even if the dialog is closed (but the board has to be saved because the config is stored in the board).
Setting up for gnetlist
Assumes gEDA schematics; in a single step runs gnetlist from within pcb-rnd to generate the netlist and loads the netlist.
The easiest way to set this up is using the CLI:
ImportSch(setup, gnetlist, foo.sch)
or if there are multiple schematics sheets:
ImportSch(setup, gnetlist, foo.sch, bar.sch, baz.sch)
An alternative way to setup is using the GUI:
ImportSch(dialog)
First select the format on the top of the dialog (gnetlist), then fill in the file path (or use the browse button to get a GUI file selector do that). An import can be done by clicking the "Import!" button. The config is preserved even if the dialog is closed (but the board has to be saved because the config is stored in the board).
Note: the name (or full path) of the gnetlist program can be configured in the normal conf tree: plugins/import_gnetlist/gnetlist_program - if not configured, plain "gnetlist" is used, assuming the search path will reach it.
Setting up for custom command
Assumes an external software that generates the netlist, in any of the supported formats. Runs the software and loads the generated netlist.
The easiest way to set this up is using the CLI:
ImportSch(setup, cmd, foo.net, 'netlist.sh foo.sch -o foo.net')
The first argument after cmd is the name of the netlist file the command is going to generate. The second argument is a full command line, in shell syntax.
An alternative way to setup is using the GUI:
ImportSch(dialog)
First select the format on the top of the dialog (cmd), then click on the "One more" button to get a second argument. Fill in the netlist file name and the command line. An import can be done by clicking the "Import!" button. The config is preserved even if the dialog is closed (but the board has to be saved because the config is stored in the board).
Before the external command is executed, the following environmental variables are set:
- IMPORT_NET_CMD_PCB: the name of the board file
- IMPORT_NET_CMD_OUT: the name of the output netlist (passed as first argument after cmd)
If the output file name argument is a single dash character ("-"), a temp file name is automatically generated. In this case the external command must read $IMPORT_NET_CMD_OUT to know where to generate the output.
Setting up for make
Follow the steps described above for 'Setting up for custom command', using the cmd file format. Examples on the second argument after cmd (the command line):
make foo.net make -f Makefile.annotate foo.net PCB=foo.lht SILENT=1
You will need to revise your Makefile, it is very likely that you need to make minor modifications to it:
- there is no SRCLIST env var set; use the command line to pass file names
- the PCB env var got renamed to IMPORT_NET_CMD_PCB
- the OUT env var got renamed to IMPORT_NET_CMD_OUT