opcua - zivku/MPU GitHub Wiki
OPC UA Build Environment Setup for Buildroot on Microchip MPU
本說明文件記錄了如何在 Buildroot 環境中建置 OPC UA 支援,包含 open62541
、libmodbus
、mosquitto
、paho-mqtt
等元件,並在 Microchip 的 Linux MPU 平台(如 SAMA5D27/SAM9X60)上進行交叉編譯與測試。
Buildroot 設定
- 進入 Buildroot 環境後,透過
menuconfig
勾選以下套件 :
cd buildroot-mchp
make menuconfig
- 參照以下勾選 :
Target packages --->
Libraries --->
Networking --->
[*] libmodbus
[*] libmodsecurity
[*] open62541
-*- paho-mqtt-c
[*] paho-mqtt-cpp
Networking applications --->
[*] mosquitto
[*] install the mosquitto broker
- 儲存離開後 :
make
外部 OPC UA 開發套件編譯
- 進入自訂義位置後建立開發目錄 :
cd ~/git
mkdir opcua
cd opcua
- 安裝 libmodbus :
git clone https://github.com/stephane/libmodbus.git
cd libmodbus
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
cd ..
- 安裝 open62541 :
git clone https://github.com/open62541/open62541.git -b v1.3.4
cd open62541
git submodule update --init --recursive
mkdir build
cd build
- 安裝 cmake :
sudo apt update
sudo apt install cmake
- 使用交叉編譯器進行建置:
sudo cmake .. -DUA_ENABLE_AMALGAMATION=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=/home/zivku/git/sam9x60_hobby_202404/buildroot-mchp/output/host/bin/arm-buildroot-linux-gnueabi-gcc
sudo make
專案整合與自訂程式編譯
- 下載CMake配置文件與example code :
- 回到OPCUA目錄後,將CMakeLists.txt與example code的src資料夾整個複製進來 :
cd ~/git/opcua
需要更改CMakeLists.txt中compiler路徑
cp /mnt/share/holystone/OPCUA/CMakeLists.txt .
cp -r /mnt/share/holystone/OPCUA/src/ .
- 編譯example code :
mkdir bin
cmake .
make
bin路徑下會生成編譯好的執行檔