Install OpenPLC

This section provides step-by-step instructions for installing OpenPLC runtime, required dependencies, and the VisionFive.gpio library.

Prerequisites

Before installing OpenPLC, verify that the following conditions are met:

Table 1. Install Prerequisites
Prerequisite Details
Environment Requirements
  • Linux Kernel: Linux 6.6.20
  • OS: Debian 13
  • SBC: VisionFive 2 or VisionFive 2 Lite
  • SoC: JH-7110
Hardware Requirements
    • An Micro-SD card with a capacity of at least 32 GB
    • Micro-SD card reader
    • Computer (Windows/Mac OS/ Linux)
    • Network cable
    • Power adapter (5 V/ 3 A)
    • USB serial port converter
    • An HDMI display
    • An HDMI cable
    • A USB keyboard
    • A USB mouse
Software Flash the Debian OS image into VisionFive 2 or VisionFive 2 Lite. For details, see Flash OS to a Micro-SD Card.

Install Dependencies

Before installing OpenPLC, all required software packages must be installed. Execute the following command to install the dependencies:
sudo apt-get install -y curl git udev libxml2-dev autoconf automake autotools-dev icu-devtools libicu-dev libsigsegv2 m4 autoconf-archive gnu-standards libtool gettext m4 make cmake build-essential pkg-config bison flex libtool nodejs libbz2-dev sqlite3 libgdbm-dev openssl libexpat1-dev python3-dev python3 libxslt-dev libmodbus5 python3-venv libasio-dev
Note: The Python version used by the system can be verified with python3 -V. The official default version is 3.11.

Install OpenPLC Runtime

To install the OpenPLC runtime package:
  1. Download the Debian OpenPLC package from https://debian.starfivetech.com/(VisionFive2/Engineering Release/202409/debian-packs/openplc.zip).

  2. Navigate to the directory that contains the downloaded OpenPLC package and run the following command to install the package:
    sudo dpkg -i openplc-vf2.deb
  3. Create a Python virtual environment and install required Python packages:
    cd <openplc_v3 directory>
    sudo python3 -m venv .venv
    sudo .venv/bin/python3 -m pip install requests wget bs4 flask==2.3.3 werkzeug==2.3.7 flask-login==0.6.2 pyserial pymodbus==2.5.3

Install VisionFive.gpio Library

The VisionFive.gpio library provides GPIO control functionality required by OpenPLC. The OpenPLC runtime is installed under sudo, so VisionFive.gpio should also be installed with sudo.

  1. Run the following command to check the Python version and select the correct VisionFive.gpio wheel file (.whl)
    sudo .venv/bin/python3 -V
    If it is version 3.10, install the cp310 version; if it is version 3.11, install the cp311 version.
    Figure 1. whl File List
  2. Execute the following command to run the installation script Install_VisionFive_gpio.py:
    sudo .venv/bin/python3 -m pip install $(path_to_whl)/VisionFive.gpio-1.3.3-cp31x-cp31x-linux_riscv64.whl
    Where $(path_to_whl) is the path pointing to the VisionFive.gpioxxx.whl file. The x in VisionFive.gpio-1.3.3-cp31x-cp31x-linux_riscv64.whl depends on the Python version.
  3. Reboot the system.
    sudo reboot