How-to
Exporting the GSDML for a CODESYS PROFINET device
Short answer
Export the installed PROFINET device entry from the CODESYS Device Repository: the export writes a ZIP archive whose XML is the GSDML to install in the controller's engineering tool. Then reproduce the module arrangement there and match the device name and subnet before downloading.
On this page
- Where does the GSDML for a CODESYS PROFINET device come from?
- How do you export a GSDML from the CODESYS Device Repository?
- How do you install the exported GSDML in TIA Portal?
- What has to match between the two projects before you download?
- Why does the connection fail after a clean GSDML import?
- Can CODESYS generate a GSDML from the configured project?
- Which route fits your controller and device pairing?
- Questions asked
A CODESYS runtime that acts as a PROFINET IO device is described to a Siemens controller by the GSDML that comes out of the Device Repository export. Select the installed PROFINET device entry in the repository, run its export, and open the ZIP archive the export writes: the XML inside, for example GSDML-V2.42-CODESYS-CODESYS PLC-20210927.xml, is the file the controller's engineering tool installs. Nothing in the project tree generates that file. After the import, the controller side reproduces the module arrangement by hand and matches the device name and subnet before the download. The sections below walk the export, the install, what must match, and how to read the diagnostics when the connection still does not come up.
Where does the GSDML for a CODESYS PROFINET device come from? #
It comes out of the Device Repository, not out of the project tree: select the installed PROFINET device entry in the repository, run its export, and the XML inside the resulting ZIP archive is the description file the controller's engineering software installs.
A GSDML is the General Station Description Markup Language: an XML description that tells an IO controller's engineering software what the device is, its identity and its catalog of supported modules with each module's input and output lengths. The file uses XML syntax, so an arbitrary XML export of the application or the hardware tree is not a substitute; the description is what controller tools parse.
The repository entry exists because the PROFINET device package for the runtime is installed on that machine, so the export describes the generic device the package provides, not one project's configured slots. In the pairing this article covers, the Siemens PLC is the PROFINET IO controller and the CODESYS runtime, for example on a ctrlX controller, is the IO device; the description serves the controller side of that pairing, and it restores no program — a project archive does that.
How do you export a GSDML from the CODESYS Device Repository? #
The export is four steps — open the Device Repository, select the installed PROFINET device entry, run the export, open the ZIP — and the fourth step matters because engineering tools will not install a description straight from an archive.
- Open the Device Repository in the CODESYS engineering IDE. The PROFINET device entry sits there because the runtime's PROFINET device package is installed; if the list shows no such entry, install that package first — a project change or a network setting cannot create the entry.
- Select the installed PROFINET device entry and run the repository's export command on it. The export writes a ZIP archive to the folder you choose; it hands over an archive, not a bare XML.
- Open the archive and confirm the description is inside. The file name carries the schema version and the package build date; one installation produced
GSDML-V2.42-CODESYS-CODESYS PLC-20210927.xml. - Keep any accompanying files together with the XML and copy both to the controller engineering station. If the importing tool later complains about a missing resource, re-extract from the archive you kept.
The whole export runs offline at an engineering desk: the description ships inside the installed package, so no connection to the running runtime is needed.
How do you install the exported GSDML in TIA Portal? #
Install the extracted XML in TIA Portal through Options → Manage general station description files, then drag the imported entry from the hardware catalog onto the PROFINET network below the IO controller.
That dialog installs the file into the tool's GSD library, and the device then appears in the hardware catalog like any vendor device. The 2.42 in the example file name is the GSDML schema release the description follows, and current controller engineering tool releases read that schema. If an import fails, read the message instead of renaming the file or editing its version text to force acceptance: an import that passes only because the file was edited moves the fault from the dialog into online diagnostics, where it costs far more time to find.
What has to match between the two projects before you download? #
Three things must match before any download: the module arrangement (same modules, same slot order, same input and output lengths), the device name assigned to the CODESYS runtime, and the IP addresses and subnet on both projects.
The exported description lists the catalog of modules the generic device can serve; the CODESYS project picked some of them, and the controller project must insert the same ones in the same slot order. Identifying numbers and data lengths ride inside the description, so a matched arrangement matches lengths automatically — nobody sizes a module by hand. That is what makes a byte-for-byte comparison of the two configurations the download gate rather than a nicety.
Worked example with illustrative values: the CODESYS project holds one 2-byte input module, one 4-byte input module and one 2-byte output module under the PROFINET device. The controller therefore expects 2 + 4 = 6 input bytes and 2 output bytes. Inserting the same three catalog modules in the same order in the controller project gives it the same 6 bytes in and 2 bytes out, and the configuration check passes. Shift the 2-byte module to another slot or pick a different length by mistake and the controller announces a configuration fault instead of data. The module sizes here are an example — read your own arrangement from the two projects and add the lengths the same way.
The device name is the second gate. A PROFINET IO controller connects to a device by its station name, so the name configured in the controller project must equal the name the CODESYS runtime announces, and both stations must sit on the same subnet with consistent IP addresses. One safety note: run the download when the machine cannot act unexpectedly, because a changed module arrangement reassigns the process image and outputs can switch state as the new configuration takes effect.
Why does the connection fail after a clean GSDML import? #
Most post-import failures are naming or arrangement faults, not description faults: a controller only announces the device when the station name resolves on its subnet and every requested module matches, so work the diagnostics in that order before touching application logic.
An import fault appears before any cyclic data exists: the tool refuses or warns while parsing the file, so the description itself is the object. A name fault comes next: the controller diagnostics leave the device unresolved, which points at the station-name assignment or at subnet membership, not at the GSDML. A configuration fault follows: the requested module arrangement differs from what the runtime serves, so compare slots and lengths slot by slot.
Only after all three pass do cyclic values exist, and wrong values at that stage are a mapping question. Compare the raw bytes at both ends before interpreting a multibyte word, and read directions from the controller's view: outputs leave the controller and inputs arrive from the device. Engineering tools label these fields differently, so two screens that both say input can point at opposite directions. Keep the file families straight too: a PROFINET controller consumes a GSDML, and an IODD, the description format for IO-Link devices and masters, has no place in this import — the reverse mismatch is covered in why an IODD file will not plug into a PROFINET IO-Link master.
Can CODESYS generate a GSDML from the configured project? #
No — there is no command that turns a configured project tree into a GSDML; the export always describes the installed generic PROFINET device, which is exactly why the module arrangement has to be rebuilt by hand on the controller side.
Two mechanisms exist and both point the other way. The repository export you already ran turns an installed device package into a description file. The Generate PROFINET Device from GSDML command does the opposite: it builds a CODESYS device description from a GSDML you supply, and its documentation notes that the exported generic GSDML can be extended with your own modules when you build a custom CODESYS-based device. Neither command reads your configured slots and emits a project-specific file, so the arrangement you configured exists only in your project and has to be carried across by hand.
When the traffic runs the other direction entirely — a vendor GSDML installed into the repository so a CODESYS runtime can act as the IO controller — the install route decides which repository entries appear; that mechanism is covered in why the GSDML install route decides CODESYS device repository entries.
Which route fits your controller and device pairing? #
Commit to one route per case: repository export when a CODESYS runtime is the IO device behind a standard controller; a vendor GSDML installed into the repository when CODESYS is the controller; the device vendor's own file when the hardware ships one.
- A CODESYS runtime as the IO device behind a Siemens or other standard controller: export the repository entry, install the GSDML in the controller tool, rebuild the module arrangement, set the device name and subnet, download, and let the controller diagnostics confirm every module healthy.
- A CODESYS runtime as the IO controller with a third-party device: install the device vendor's GSDML into the repository instead; the export in this article does not apply to that direction.
- A device that ships its own description file: use the vendor's file. The generic CODESYS PROFINET device description serves CODESYS-based runtimes; it is not a substitute for a vendor description of other hardware.
- No PROFINET device entry in the repository: treat it as an installation question and install the runtime's PROFINET device package. No network, IP or project change creates the entry.
After a clean import and a matched arrangement, the controller's online diagnostics are the verdict: they name an unresolved device, a configuration fault or healthy cyclic data, and each of those names points at exactly one of the checks above.
Questions asked
Is the exported GSDML a backup of my CODESYS project?
No. A GSDML describes the device for the controller's engineering tool: its identity, its supported modules and their data lengths. It carries no program logic, variables or project settings, so it cannot restore anything after a disk failure or a bad download. Keep a project archive as your backup and reserve the GSDML export for making the runtime visible to controllers.
Does the Device Repository entry exist on every installation?
Only where the PROFINET device package for that runtime is installed. The repository lists installed device packages, so a station without the PROFINET device component shows no entry to export, and installing that package is what creates the entry. Network settings, IP addresses and project files cannot create it.
Can the same exported file be reused on other engineering stations?
Yes. The file describes the device, not one project, so every engineering station that needs to configure a connection installs the same XML. What differs per project is the arrangement you build and the device name you type; the name belongs to the physical runtime, so every controller connecting to that runtime must configure the same name.
Should I edit the exported XML when an import fails?
No. Renaming the file or editing its schema version and module numbers can make an import pass while the controller then requests an arrangement the runtime never serves, and the fault moves from the import dialog into online diagnostics. Read the tool's import message instead; it names the structure or schema range it refuses.