From OpenSCADAWiki
Jump to: navigation, search

Begin: 29 (Jul) 2019
Participants: Roman Savochenko
Description: The Netgear R6220 is a simultaneous dual band WIFI router with AC1200 WiFi - 300+867 Mbps (2.4 & 5 GHz) speeds. It contains non-removable external antennas. The router features 4 Gbit LAN and one Gbit WAN port. It comes with a large 128 MB NAND ROM with space for many packages and a single core (dual thread) MIPS CPU powered by 128 MB RAM.
Materials: OpenSCADA packages and different data
OpenSCADA expanding during implementation:

  • building without internationalisation in whole by true LibIntl detection; building without functions clock_nanosleep(), pthread_rwlock_timedwrlock(), newlocale();
  • finishing in support of OpenSCADA building to single binary openscada with including all modules.

State of the support:

+ OEM > building some test programs and noting the process on the page "OpenSCADA generic embedding and programmable logical controllers (PLC)"
* OEM > building, starting and testing OpenSCADA
- OpenWrt > installing the OpenWrt firmware
- OpenWrt > testing the generic finctions
- OpenWrt > building, starting and testing OpenSCADA
NETGEAR R6220.png
Hardware features
Hardware platform: MIPS1004Kc
Central processor: MediaTek MT7621ST (2 Threads)
Memory: 128 MB DDR2/3
Solid memory: 128NAND
Electrical power: 12 VDC, 1.5 A
Interfaces: WLAN2.4 300 Mbps b/g/n, WLAN5.0 867 Mbps a/n/ac, 5x RJ-45 Gigabit Ethernet, USB 2.0, Serial (for solder)
Weight: 385.17 g.
Size: 239.65 x 159.45 x 40.6 mm
Conditions of exploitation: 0° ... 40°C
Hardware CPU Entry into JavaLikeCalc, us Operation sin(Pi) [in JavaLikeCalc], us Operation pow(Pi,2) [in JavaLikeCalc], us Model AGLKS [Vision, main mnemo], %(core) Extra tests and notes
NetGear R6220 MIPS1004Kc, MediaTek MT7621ST, 55nm, 880 MHz, 2 Threads 0.84 13 [14.5] 0.99 [4.09] - Productivity of the mathematical operations is VERY low.

The WIFI router purchased purposively for OpenSCADA adaption to very tightly MIPS architecture which has comparing big resources in 128 RAM and 128 NAND. The router is also supported on high level by the OpenWrt project, see the NETGEAR R6220 page.

NETGEAR provides officially the building tool chains of the used Linux evironment, so primarily there is going to perform of OpenSCADA adation for the official OEM enveronment and next that will be updated to OpenWrt and the adaption performed there also.

1 NETGEAR OEM environment

The environment has free about 62 MB RAM and 42 MB NAND, that must be enough for storing and running OpenSCADA PLC environment with no GUI.

Remote access to the environment is possible only through telnet, what also must be enabled through opening the router URL, and next you connect by using the administrative authentication (admin) of your router:

#> Trying
#> Connected to
#> Escape character is '^]'.
#> R6220 login: admin
#> Password:
#> Welcome to ...

Root access is provided at connection by Administrator (admin).

OpenSCADA installation and building will be performed for the partition /tmp/RWFS with about 42 MB space and for transferring files there will be used whether USB or wget.

Building the toolchain and SDK
The official SDK is the raw mix of building tools, which preconfigured for very different environments of the Netgear firm, which must be hardly hacked for build an environment of building third part software, then I doubt the ready firmwares will work. Moreover, the tools is a very old one, that is based on buildroot from 2012.11.1, so for that building we need for an old chroot like to Fedora 12 or Debian 7 and for the chroot execution themself we need for an environment with kernel not newer than in Debian 9. Next we perform the steps:

  • unpack the SDK in a chroot folder "/root":
cd /root; tar xvf R6220_R6230_V1.1.0.114_1.0.1_GPL.txz
  • change the current directory to the SDK folder and unpack buildroot
cd R6220_V1.1.0.114_src; tar xvf buildroot-gcc463-src-offlinebuild_NPTLSHAREDLIBGCC.tar.bz2
  • change the current directory to the buildroot and start the toolchain building, buildroot is used here only for the toolchain building
cd buildroot-2012.11.1; make
  • some fixes of the SDK before building by the toolchain
# some programs call the chroot as buildroot-gcc463
ln -s buildroot-gcc463_NPTLSHAREDLIBGCC /opt/buildroot-gcc463;

# replacing static folders for our one
sed -i "s/\\/home\\/disk2\\/keiko\\/project\\/release\\/R6220_v1.1.0.114\\/R6215/\\/root\\/R6220_V1.1.0.114_src/" \
    sdk4210/lib/e2fsprogs-1.41.3/lib/et/compile_et apps/mediaserver/library/ffmpeg-0.5.1/config.mak

# replacing old buildroot-gcc342 and the prefix mipsel-linux-uclibc
sed -i "s/buildroot-gcc342/buildroot-gcc463/" apps/apple/mxml-2.8/Makefile apps/iptables-1.4.10/{Makefile,libtool}
sed -i "s/mipsel-linux-uclibc-/mipsel-linux-/" apps/apple/mxml-2.8/Makefile apps/iptables-1.4.10/{Makefile,libtool}
sed -i "s/buildroot-gcc463\\/bin\\/mipsel-linux-/buildroot-gcc463\\/usr\\/bin\\/mipsel-linux-/" \
    apps/apple/mxml-2.8/Makefile apps/iptables-1.4.10/{Makefile,libtool}

# autotools regeneration
cd apps/apple/sqlite-autoconf-3130000; autoreconf -ivf; cd ../../..
  • building the SDK
cd ..; make

Building OpenSCADA can be performed in an environment of the specially created script, which specifies paths to the toolchain and SDK. Before the OpenSCADA building there are performed of building some extra libraries as static ones and OpenSCADA building performed as the single binary file openscada with including all modules' code here:

  • PCRE (pcre) — that is an obligatory dependence of OpenSCADA for Regular Expressions:
cd ../sdk4210/lib/pcre-8.01/
./configure --host=mipsel-buildroot-linux-uclibc --disable-cpp --enable-utf8 --enable-unicode-properties --enable-shared=no
cp {pcre.h,pcreposix.h} ../include; cp .libs/*.a ../lib

Since the MIPS hardware and ucLibC are very pure and ucLibC has no locales support, there also performed of some adaption the OpenSCADA building system and code:

  • checking of the internationalisation expanded by testing the symbol "bindtextdomain" in the system library and next "libintl_bindtextdomain" in LibIntl with disabling the internationalisation at missing such libraries;
  • the functions lock_nanosleep(), pthread_rwlock_timedwrlock(), newlocale() appended for testing their declaration and for disabling them in the source code at missing.

OpenSCADA building:

cd openscada
./configure --host=mipsel-buildroot-linux-uclibc --prefix=/tmp/RWFS --enable-CoreLibStatic --disable-AllModuls \
    --enable-SQLite=incl --enable-DBF=incl \
    --enable-Sockets=incl --enable-Serial=incl --enable-SSL=incl --enable-SelfSystem=incl --enable-UserProtocol=incl --enable-HTTP=incl \
    --enable-JavaLikeCalc=incl --enable-LogicLev=incl --enable-BlockCalc=incl --enable-System=incl --enable-DAQGate=incl --enable-ModBus=incl --enable-DCON=incl \
    --enable-FSArch=incl \
    --enable-WebCfg=incl --enable-WebCfgD=incl --enable-WebUser=incl \
    --enable-FLibSYS=incl --enable-SystemTests=incl --enable-FLibMath=incl --enable-FLibComplex1=incl
strip src_call/openscada

After the building we obtained the single binary file openscada with size 7.7MB and which contains all 23 modules and running it consumes about 1.5MB without configuration. The binary can be placed and started from any place, but the configuration file "oscada.xml" is checked in "/tmp/RWFS/etc/", so there was prepared the archive "openscada-1.tar" with images and icons for downloading to "/tmp/RWFS/", that you can obtain, extract and start in the background by the commands:

cd /tmp/RWFS/
tar xvf openscada-1.tar
bin/openscada &

2 OpenWrt


3 Links