OpenCPLC ⚒️ Forge
Forge is a console app that makes working with OpenCPLC easier.
Its job is to set up your environment so you can focus on building apps instead of fighting with configs and compilation.
Available as a Python pip package or standalone opencplc.exe from 🚀Releases (in that case add its location to system PATH manually).
pip install opencplc
Pick a folder (your workspace), open CMD and type:
opencplc -n <project_name> -b <board>
opencplc -n myapp -b uno
This creates projects/<project_name> (nested folders when the name holds /).
Inside it Forge creates main.c and main.h, all a project needs.
Don't delete them or move them to subfolders.
When you have more projects, you can switch between them freely:
opencplc <project_name>
opencplc myapp
You can also pick projects by number from the list:
opencplc -l # show project list
opencplc 3 # load project #3 from list
Every project owns its makefile and flash.ld, and makefile in the workspace root points at the active one.
Loading a project regenerates these files, which turn all sources (project and framework .c, .h, .s) into .bin and .hex files ready to flash.
Changing PRO_x values in main.h or project structure (adding, moving, deleting or renaming files) needs a reload.
make does it by itself: when main.h or any source is newer than makefile, it runs Forge first and then builds.
Editing function bodies needs no reload, make handles that on its own.
You can also reload by hand, without the project name when it's active or when you're inside its folder:
opencplc <project_name>
opencplc -r
Flags such as -m and -o configure a project only when it's created.
Later configuration lives in main.h: edit it and reload.
-b and -c also build an existing project for other hardware, with its memory and clock, while main.h stays as it is:
opencplc test/flash -c STM32WB55
make keeps that choice until you load the project without them.
Tests and demos for any board leave PRO_BOARD, PRO_CHIP and memory out of main.h, so every load names the hardware.
📂 Local project
A project can live outside the workspace, in a repository of its own.
A path names it, ./app or D:/repos/app, while a plain name stays a project of the workspace:
cd C:/workspace
opencplc D:/repos/app
cd D:/repos/app
make
The first load runs in the workspace, since nothing ties the project to it before then.
From then on its makefile names the workspace, so make and opencplc -r work in its folder.
It builds with the framework of the workspace into its own folder under build/local/ and never becomes the active project.
Forge writes makefile, flash.ld and .vscode/ into its folder, overwriting them as it does in the workspace.
They hold paths of this computer, so the repository of the project should ignore them.
opencplc -n D:/repos/app creates a new local project.
📄 Your files
main.c is yours and Forge never overwrites it.
A PLC board project starts from this skeleton:
#include <opencplc.h>
static void loop(void)
{
while(1) {
RGB_Set(&RGB, RGB_Green);
delay(1000);
RGB_Rst(&RGB);
delay(1000);
}
}
stack(stack_plc, 256);
stack(stack_dbg, 256);
stack(stack_loop, 1024);
int main(void)
{
thread(PLC_Main, stack_plc); // PLC thread
thread(DBG_Loop, stack_dbg); // logs and console
thread(loop, stack_loop); // your application
vrts_init(); // start thread switching
while(1);
}
Your application runs as a VRTS thread next to PLC and debugger threads (logs and console). Add your own modules as more files in the project folder and its subfolders.
main.h holds configuration Forge reads on every load.
PRO_* definitions describe board, chip, PLC layer, framework version and memory sizes, while LOG_LEVEL and SYS_CLOCK_FREQ are yours to change.
Extra framework drivers go there too: #define PRO_DRIVERS "shtc3, hd44780".
Here (roughly) ends Forge's job, and further work goes like any embedded project, with ✨Make.
✨ Make
With makefile generated by ⚒️Forge, open a console in your workspace to build the program and flash the PLC:
make build # build C project to binary
make flash # upload binary to PLC memory
# or
make run # run = build + flash
make in workspace root works on the active project.
Any project can be built directly, independently of the active one: make -C projects/myapp.
Full list of targets:
make buildor justmake: Builds C project to.bin,.hex,.elffilesmake flash: Uploads program to PLC (microcontroller) memorymake run: Doesmake build, thenmake flashmake test: Builds every.tests/*.cinto a program for this computer and runs it, see Tests;make test T=nameruns onemake lint: Checks the build with Forge rules, cppcheck and gcc analyzer, see Lintmake cleanormake clr: Removes built files of the projectmake clean_allormake clr_all: Removes built files of all projectsmake dist: Packs the release into the project folder:.hexfor programmers and, under the bootloader,.binfor updates;make dist TAG=1.2.0names them<name>-1.2.0.hexand.bin, andCIPHER=encrypts the.binwith a cipher keymake update: Sends the update image of the build over the console (under the bootloader, withCMD_BOOT ON);FILE=sends another image,PORT=picks the portmake erase: Completely wipes microcontroller memory (erase full chip; on STM32WB the radio stack stays)make stack: Flashes radio stack of the second core (STM32WB);make stack FUS=1also provisions a factory-fresh board, once and irreversibly
Built files land in build/projects/<project_name>/: .elf, .hex, .bin and .map next to opencplc/ with framework objects and project/ with yours.
Programmers flash -dist.hex, and under the bootloader -dist.bin beside it carries updates.
Every project compiles the framework on its own, so switching projects never links objects built with another configuration.
After linking Forge reports memory use, including stack of each thread against the limit its margin allows:
FLASH 70.7kB / 72kB (98%)
RAM 34.3kB / 36kB (95%)
STACK loop 556B / 2048B (28%, max 75%)
🥾 Bootloader
A project whose main.h includes boot.h runs behind Core's bootloader, which Forge builds with it, and takes updates without a programmer; -B sets this up for new projects.
opencplc --sign acme 3 adds product keys to BOOT_KEYS in boot.h, and from then on the bootloader starts only images signed with them.
opencplc --cipher acme-enc makes a cipher key, and make dist CIPHER=acme-enc encrypts the update file with it, so nobody reads it on its way to devices.
--lock closes the board to programmers for production, with or without bootloader.
Both and their security: 🥾 Bootloader and 🔒 lock.
⚙️ Config
With the first project ⚒️Forge creates config file opencplc.json.
It contains:
version: Default OpenCPLC framework version for new projects. Valuelatestmeans newest stable version.stlink: Programmer bound to a project, somake flashhits the right board when several ST-Links are connected. Set it withopencplc myapp -s <serial>, clear it withopencplc myapp -s. Read the serial from OpenOCD log ofmake flashwith one programmer connected.ignore: Projects left off-land its numbers, as.gitignorepatterns, e.g.["demo/"]hides all demos. Projects named directly still load. Add this key by hand when needed.available-versions: List of all available framework versions. Set automatically, used offline.
Workspace layout is fixed: projects/ with your projects, opencplc/ with framework versions and build/ with built files.
Copy project folders by hand, and Forge finds them on its next run.
🤔 How works?
Who does what: Forge prepares the environment, Make builds and flashes, you write code.
flowchart LR
CORE[repo Core] -->|clone| FW["opencplc/0.4.3"]
FORGE[Forge] --> GEN["projects/myapp/makefile, flash.ld"]
FW --> GEN
YOU[your code] --> PRO["projects/myapp/main.c"]
GEN --> MAKE[make]
PRO --> MAKE
MAKE --> BIN["build/projects/myapp/myapp.hex"]
On Windows ⚒️Forge brings its own Make, GNU Arm Embedded Toolchain, OpenOCD and MinGW into %LOCALAPPDATA%\OpenCPLC, no admin rights needed, and Git through winget.
After the first run open a new console, so make is on PATH.
On Linux tools come from your distribution.
Then, when needed, it clones OpenCPLC framework from its repository into opencplc/<version>.
New projects take their version from opencplc.json, or from -f --framework:
opencplc <project_name> --new -f 0.4.3
opencplc <project_name> --new -f develop
Alone the flag only downloads, so you can read a version before any project points at it:
opencplc -f develop
📌 Project versioning
Each project keeps in main.h the framework version it was created with (PRO_FRAMEWORK).
That version builds it and gets cloned when missing, so old projects compile even after framework updates.
If cloning fails, Forge warns and builds with the workspace default.
To try another version without touching main.h, pass -f when loading: the project builds with that version until a load without -f, and Forge says so.
Projects inside a framework version, such as its compile tests, load by path: opencplc opencplc/develop/.tests/g081.
They have no PRO_FRAMEWORK and build with the framework they lie in, into build/opencplc/develop/.tests/g081/.
opencplc opencplc/develop loads the framework itself, and make test runs its tests.
🧩 Boards
Boards come from the framework: each brd/<board>/ folder with an .ini manifest is one.
Its manifest gives new projects their defaults: whether the board needs the PLC layer, chip, initial memory and clock, and drivers:
name = Uno
chip = STM32G0C1
plc = true
flash_kB = 492
ram_kB = 144
clock_Hz = 59904000
reserve_kB = 20
drivers = max31865
reserve_kB is optional: flash the board keeps for itself, taken off the top like the third value of -m, so projects start with what is left.
name is how the board reads in main.h and messages, PRO_BOARD_Uno, while its folder name stays in paths.
The two compare without case or underscores, so CardG0 and card_g0 are one board, and None means no board.
Adding boards means adding folders to the framework, with no change in Forge.
These are defaults, not rules: -c swaps chips (memory follows the chip, clock stays with the board), and --plc adds the PLC layer to boards without it.
Only plc = true binds: such boards do not build without their layer.
Without a board main.h holds PRO_BOARD_None, and PRO_PLC decides the rest:
-c <chip> alone is bare metal (HAL and libraries only), -c <chip> -P adds the PLC layer on your own hardware, where peripheral mapping and PLC_Main are yours to write.
Device drivers live in drv/, outside the PLC layer, so any project can use them.
Folders under drv/ group them by kind: temp/ for thermometers, acc/ for accelerometers, disp/ for displays.
A driver goes by its file name, wherever it sits.
Boards take the ones their manifests name, and projects add more with --drv at creation or in main.h: #define PRO_DRIVERS "shtc3, hd44780".
Only named drivers reach the build.
Above all, Forge writes these files:
projects/<name>/flash.ld: defines RAM and FLASH memory layout (overwrites, STM32 only)projects/<name>/makefile: contains build, clean and flash rules (overwrites)makefile: points at the active project (overwrites)c_cpp_properties.json: sets header paths and IntelliSense config in VS Code (overwrites)launch.json: configures debugging in VSCode (overwrites)tasks.json: describes tasks like compile or flash (overwrites)settings.json: sets local editor preferences (creates once, not overwritten)extensions.json: suggests useful VSCode extensions (creates once, not overwritten)
More helpers come through 🚩flags.
🗂️ Workspace structure
workspace/
├─ opencplc.json # workspace config
├─ makefile # active project (generated by Forge)
├─ .vscode/ # VSCode config (generated by Forge)
├─ opencplc/ # framework (downloaded automatically)
│ ├─ 0.4.3/
│ └─ develop/
├─ projects/ # user projects
│ ├─ myapp/
│ │ ├─ main.c
│ │ ├─ main.h
│ │ ├─ .tests/ # tests on the computer, `make test`
│ │ ├─ makefile # generated by Forge
│ │ └─ flash.ld # generated by Forge, STM32 only
│ ├─ firm/app/ # projects can be nested
│ └─ demo/ # projects from the Demo repository, `opencplc -e`
└─ build/ # compiled binary files
├─ projects/myapp/
└─ local/ # local projects, a folder each
If IntelliSense stops working, use F1 → C/C++: Reset IntelliSense Database.
🖥️ Host
Forge supports Host platform for developing and testing code on a PC (Windows/Linux) without embedded hardware:
opencplc -n myapp -c host # desktop project
Such a project compiles with native GCC (MinGW on Windows) instead of ARM toolchain, and make run starts the program.
Useful for:
- Testing algorithms and logic without hardware
- Developing protocol parsers and data processing
- Unit testing framework components
- Quick prototyping before deploying to PLC
Host platform provides stubs for hardware modules (GPIO, timers, etc.), so code stays compatible with STM32 targets.
🧪 Tests
Every .c file directly in .tests/ of a project is a test program, which make test builds and runs on this computer, in STM32 projects too.
Tests include the modules they check, so they run firmware code itself.
One workflow file runs the same on GitHub on every push.
Writing, running and CI: 🧪 Tests.
🔍 Lint
make lint checks a chip build: Forge rules on VRTS, thread stacks, values and headers, then cppcheck and gcc -fanalyzer.
Findings print like compiler warnings and cite norms behind their rules, such as CWE, CERT C or MISRA C.
Projects turn on extra rules in their lint.yaml, such as no-heap, and keep exceptions there with reasons.
Rules, norms and exceptions: 🔍 Lint.
🚩 Flags
Beyond flags above, a few more are worth knowing. Full list:
Basic
name: Project name, the default first argument. It also sets project pathprojects/name, and output files (.bin,.hex,.elf) follow it. A number from-lworks too. A path,./apporD:/repos/app, loads a local project.-n --new: Creates a new project with that name.-e --demo: Downloads Demo repository intoprojects/demo. Load a demo like any project:opencplc demo/blinky.-r --reload: Regenerates project files. Withoutnameit takes the active project, or the one whose folder you're in.-d --delete: Deletes projectname.-g --get: Downloads a project from Git (GitHub, GitLab, ...) or a remote ZIP as a new project. A second argument after the link picks a reference (branch,tag). Withoutnameit reads@namefrommain.h.
Hardware config
-b --board: Board from the framework (uno). It sets chip, memory, clock and PLC layer of new projects;-cand--plcoverride that. On an existing project it picks another board until a load without it.-c --chip: Microcontroller or platform:STM32G081,STM32G0C1,STM32WB55,HOST(compile for PC). Without-b --boarda project has no PLC layer, only HAL and standard framework libraries, as on Nucleo boards or custom hardware. On an existing project it picks another chip until a load without it.-P --plc: Adds PLC layer to projects without a board, on your own hardware.-D --drv: Framework drivers of a new project, comma separated (shtc3, hd44780). Later ones go intoPRO_DRIVERSinmain.h.-B --boot: Puts new projects behind Core's bootloader:boot.hbesidemain.hand its#include, see Bootloader.-m --memory: Memory in kB:FLASH RAM [RESERVED].RESERVEDis memory for config and EEPROM, taken off FLASH in linker fileflash.ld(STM32 only).
Build config
-f --framework: Framework version:latest,develop,0.4.3. For new projects it becomesPRO_FRAMEWORK, existing ones build with that version until a load without it, and alone it only clones the version intoopencplc/.-o --opt-level: Compiler optimization level:O0,Og(default),O1,O2,O3,Os. LevelsO2andO3show a warning for STM32 (timing, debugging).-s --stlink: Binds ST-Link serial to the project,-salone clears it.
Info
-l --list: Lists existing projects.-i --info: Basic info of the given or active project, project and framework versions included.-F --framework-versions: Lists all available OpenCPLC framework versions.-v --version: Shows ⚒️Forge version and repository link.
Tools
-a --assets: Downloads helper materials (chip documents and errata, board pinouts, style guides of Core). Optionally takes a destination folder.-u --update: Replaces Forge executable with the given version (default:latest), whilepipinstalls update throughpip.--program: Sends a.hexto the board through the programmer. Alone it takes whatmake distleft in the active project, the newest of several after confirmation.--sign: Makes or takes product keyNAMEwith spares,COUNTkeys in all (default 1), and adds their public parts toBOOT_KEYSinboot.hof the active project, with an optional password, see Bootloader.--cipher: Makes cipher keyNAMEof a product, or shows its fingerprint and, once confirmed, the key; withFILEencrypts that update image,make dist CIPHER=uses it, see Bootloader.--upload: Sends update imageFILEover the console, optionally toPORT;make updateuses it.--lock: Locks the board for production: RDP1 by default,2for good,0unlocks and erases flash, see Lock.-p --pack: Packs the image for flash: under the bootloader with it in front and CRC and signature behind, with update binary beside;makeuses it after linking.-z --size: Reports FLASH and RAM use of an.elf, and, given CPU, Core and project, stack of each thread;makeuses it after linking.--test: Runs test programs, each in a clean folder of its own with one minute to finish;make testuses it.--lint: Checks the project's build with Forge rules, cppcheck and gcc analyzer;make lintuses it.-y --yes: Auto-confirms all prompts (non-interactive mode).
Hash utilities
-hl --hash-list: Generates an enum with DJB2 hashes from a tag list.-ht --hash-title: Enum type name for the hash generator.-hd --hash-define: Uses#defineinstead ofenumfor hash output.
🗑️ Delete and 💾 copy projects directly in your file manager.
Each project keeps everything it needs in main.h, and Forge finds it on startup.
📟 Console
⚒️Forge and ✨Make are console programs. Essential for working with OpenCPLC.
Many apps give you a system console: Command Prompt, PowerShell, Git Bash, even the terminal of VSCode. Forge finds its workspace from any folder inside, so a project folder works as well.
When something goes wrong:
- Forge lands in a wrong workspace: a stray
opencplc.jsonsits between your project and the real root, remove it. makenot found right after the first run: the console still has oldPATH, open a new one.- A tool misbehaves: remove
%LOCALAPPDATA%\OpenCPLCand run Forge again, it reinstalls its packages. makestops atopencplc -rwith an error about version or board:main.hpoints at something this framework lacks, fix that entry and runmakeagain.- A project is missing from
-l: its folder has nomain.h.
📋 Usage examples
# Creating new project
opencplc -n myapp -b uno # project for OpenCPLC Uno board
opencplc -n myapp -b uno -m 128 36 # project for Uno with 128kB/36kB memory
opencplc -n myapp -c STM32G081 --plc # own hardware with PLC layer (no peripheral mapping)
opencplc -n myapp -c STM32G081 # bare-metal project for STM32G081 (e.g. Nucleo)
opencplc -n myapp -c STM32G081 --drv shtc3 # bare metal with the shtc3 driver
opencplc -n myapp -c host # desktop project (Windows/Linux)
# Managing projects
opencplc myapp # load project 'myapp'
opencplc 3 # load project #3 from list
opencplc -r # reload active project
opencplc -l # list all projects
opencplc -i # info about active project
opencplc myapp -s 066AFF49 # bind ST-Link to 'myapp'
# Demo projects
opencplc -e # download Demo to projects/demo
opencplc demo/blinky # load project 'blinky'
# Downloading projects
opencplc -g https://github.com/user/repo
opencplc -g https://github.com/user/repo v1.0.0
# Updates
opencplc -u # update Forge to latest version
opencplc -F # show available Core versions
Metadata
Release files for opencplc 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opencplc-0.6.0.tar.gz | 222.8 kB | With provenance | Details for opencplc-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opencplc-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for opencplc-0.6.0-py3-none-any.whl |
Total release size: 393.3 kB
Release files / opencplc-0.6.0.tar.gz
| Download URL | opencplc-0.6.0.tar.gz |
|---|---|
| Size | 222.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
703b895d955badd132c179045db16d1b9b23eeefdee8cce3f6334a1224b457ef
|
|
BLAKE2b-256 checksum How to use checksums |
7f39f5d4c9df4cdcbd8e272a18f02c9423ffe3aa59db6e3fb7d2f1b0344c1a5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / opencplc-0.6.0-py3-none-any.whl
| Download URL | opencplc-0.6.0-py3-none-any.whl |
|---|---|
| Size | 170.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a251474010e046caec0b23fcf293d1733a69f9f042193f67319472365cdba21a
|
|
BLAKE2b-256 checksum How to use checksums |
9ca8b7d15152763ccd7591be63008259ca7ef2c0c03d83a52b8c44cf1e23c8b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for opencplc 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for opencplc-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.