OpenSCADAWiki: Home Page En/Using/PLC/firmware ...

Home | Index | Changes | Comments | Users | Registration | Login  Password:  
 
This is an old revision of HomePageEn/Using/PLC/firmware from 2015-11-19 19:19:35..

Firmware and PLC program environment creation of architecture x86

The architecture x86 recently was positioned as embedded and it's real solutions into this industry rarely have resources (< i386), which is not enough for full-featured OS and advanced environment execution. For this reason and by reason of big the architecture unification the individual assemblies of kernel Linux and main programs of the OS environment performed rarely enough, and that typical mostly for the architecture ARM. More interest and practical for x86, for wide the hardware circle, it is assembling firmwares with compressing a root file-system (RFS). But still possible individual assembling by aid of the build systems as "BuildRoot" or "PTXDist", bottom. And also here possible direct installing a Linux distribution.

Instruments for assembling the firmware environments with the compressed RFS, based on distributive ALTLinux

The following requirements were pulled out to the implementation of the PLC firmware of the section:


Given the above requirements, for the creation of the firmware it was chosen the tool for creating the distributions mkimage of ALTLinux. mkimage is the tool for building Sisyphus-based system on basis of template. As an initial set of templates it was taken the set of templates of formation of ALTLinux distributions at git://git.altlinux.org/people/boyarsh/packages/mkimage-profiles-desktop by the command:

As the basis it was taken the "rescue" template, as the most compact and close to the target PLC.


Firstly building performed basing on the package base of the distributive ALTLinux 5.1, there is present the realtime kernel from XENOMAI. For obtaining some specific packages you need to connect the repository of packages "ALTLinux 5.1" from the OpenSCADA project:

rpm ftp://ftp.oscada.org/ALTLinux/5.1 openscada main

Assembling

Firstly it was created the configuration of PLC without local display in mind of the availability of this type of equipment and lack of equipment for the Touch-panels.


New PLC template was named "plc", it was tested on the boards of PC/104 form factor MOPSlcdLX of Kontron company, ATH400-128 of Diamond Systems company and modular PLC LP-8781 of the ICP DAS company. The archive of the resulting mkimage tree with the "plc" template can be downloaded here ftp://ftp.oscada.org/OpenSCADA/PLC (templates and materials of individual controllers are placed in their own directories).


The key points of the configuration of new template was the writing of the new init-script (rc.sysinit), the script of the after installation configuration of the firmware's image and the list of packages in the image of firmware.The first script is designed as the package "startup-plc". The second script was embedded in the template "plc" on the way: profiles/pls/image-scripts.d/01system. The list of packages was embedded in the template "plc" on the path: profiles/pkg/lists/plс.in.


The procedure of creating the firmware from the image is the following:


The result is an output directory in the "profiles/out/" have look:

Installation

It is possible to download the firmware to: USB-flash, IDE-flash and HDD. However, in the case of the USB-flash there is the problem with waiting for initialization of USB-subsystem and you'll have "to run" some dialogues.


The file system can be FAT or EXT2/3. In the case of EXT3 the root is mounted as in EXT2, because of problems in the initializer. In the case of EXT2/3 you'll need to use not the syslinux boot, but extlinux, the configuration of which is almost the same one.


Next, lets mount the medium and place the files from the output directory on it as follows.
In the case with FAT and syslinux:

In the case with EXT2/3 and extlinux:


To ensure the reliable operation of the operating data stored in the file "work" with the file system EXT3. The file-system of this file is checked for integrity at the initialization. This file is created as follows:


In the case of the file system EXT2/3 on the target disk the "work" file can not be created. In this case, the working data will be placed in the directory "root" of the target disk.

 (2 Kb) This is an unreliable solution because the root file system of the target disk is not static and its check is not possible, because of earlier mounting in the "ro" and the potential unreliability of the check of the file system, mounted at "ro", as well as because of the inability to remount as EXT3.

The next step is the configuration and initialization of the loader. To configure the loader it is necessary to edit the file "syslinux/syslinux.cfg" or "extlinux/extlinux.conf" as follows:


In the case of selection the identification of the bootable partition by the identifier you can get the ID of our partition with the command: blkid.


In the case of the label it is a bit harder and this is done for different file systems in different ways.


For the file-systems EXT2/3 it is done by the utility e2label. For example: e2label /dev/sdb1 PLC


For the FAT file system it does by the set of utilities that come with mtools or with parted, easier. With mtools you can do it as follows:


Now we can initialize the loader:


That is all with the boot and initialization of firmware. If the resulting disk is not loaded:

Result

The result is the firmware with the size from 30Mb to 100Mb, satisfying all announced requirements and it provides:

OpenSCADA

As the PLC runtime system the OpenSCADA is used. For this case we'll take the building with separate packages for each module and indicate to install the virtual package openscada-plc, which contains all the dependencies on all the OpenSCADA packages, typical used for this configuration. The package of gd2 graphics library has been rebuilt without the support of xpm graphic file format and library was called libgd2-noxpm. All this was done in order to avoid the heavy dependencies on the libraries of GUI XOrg.


The result is the runtime of the PLC with support:


The configuration of OpenSCADA runs in demon mode in locale "en_US.UTF-8" (also available "ru_RU.UTF-8" and "uk_UA.UTF-8") using the local database SQLite, providing the following default network services:

The implementation details

In this section let examine the details of the OS tree of the firmware, the initialization script rc.sysinit.plc and the script of preparation of the OS tree of the firmware.


To build the PLC firmware it was used the following list of packages:


List of the modules of the loader's system kernel with the purpose to reducing the initialization image size was decreased to the following ones:


To the script of the tree preparation there were added the following functions:


The initialization script (rc.sysinit.plc) was provided with the following functions:


As the result of these actions the mount table of the resulting PLC tree looks like:

Setting of the GUI

One option of the firmware is built with a graphical interface, which, however, necessary to configure for automatic startup with the visualization area of OpenSCADA. In addition, it should be noted that the firmware with a graphical interface does not contain all the drivers and you may have to rebuild it under the right equipment.


After downloading and logging to the console it is necessary to configure the XServer, automatic graphical login, start of the graphical environment and automatic startup of OpenSCADA from the IceWM environment:

Packages base of ALTLinux T6

Next stage of the firmwares creation was moving to the package base of distributive ALTLinux T6. On the whole firmwares creation concept saved, with bits changes, but there were added some improvements and expansions:


During the possibility of a free additional installation of needs packages direct from the repository gone needs to the separated built of the firmware with GUI. That is you can easy install the desired window manager (WM) or desktop environment include needed drivers, than create a separated firmware with a limited list of the drivers.


The script "startup-plc" was turned spare into the new firmwares besides the "root" FS remounting to writing does early on the initial sage. The script "profiles/plс/image-scripts.d/01system" renamed to "profiles/plс/image-scripts.d/init1-PLC", but it changed and expanded. The packages list of the firmware was left into "profiles/pkg/lists/plс.in" and some changed.


For get the some specific packages you have to connect the repository "ALTLinux T6" from the OpenSCADA project:

rpm ftp://ftp.oscada.org/ALTLinux/t6 openscada main

The firmware creation procedure mostly left unchanged:

# Creation of the configuration script "configure"
$ ./autoconf
# The builder configuration for the disk's images generation. The key "--with-imagetype" you can set to "iso", or pass
# for creation the combined ISO-image
$ ./configure --with-distro=kdesktop --with-branding=altlinux-kdesktop --with-version=6.0 --with-language=en_US --with-imagetype=flash
# The image assembling
$ make plc.cd


The output folder's content with the image and the firmware installing process to file system FAT and EXT2/3/4 different only by renaming the FS archive's file from "plc" to "live". Installing the ISO-image to USB-flash, HDD, SSD performs by the command dd:

$ dd if=LP8x81-ALTLinuxT6-OpenSCADA_0.8.0.6-i586-plc.iso of=/dev/sd{x} bs=4096

Instead the file "work" you should create partition EXT3 with the label "alt-live-storage", if it is not the ISO-image. The new partition creation you can do with the help of fdisk, if the FAT partition was not created to all allowed the storage space, or with help of parted where the FAT partition you allowed to change. To the details about a partition creation the reader will send to the documentation on fdisk or parted.


Configuration of files "syslinux/syslinux.cfg" and "extlinux/extlinux.conf" were not changed, besides the FS file archive's name changed from "plc" to "live".


At the result we get the firmware with size from which provides:


For the PLC firmware assembling used next packages list:


The Linux kernel modules list of the initial stage was some changed and include:


To the script of the tree preparation "profiles/plс/image-scripts.d/init1-PLC" performs the functions:

Real-time kernel

For a series of tasks are important, often also critical, criteria of the environment is the real-time handing level, then it is possibility of working the tasks according to the real-time priorities and provision of a reaction to events by that priorities.


The Linux kernel of itself provides POSIX real-time scheduling policies "SCHED_FIFO" and "SCHED_RR" with the priorities range (0...100). But the important criteria is "Timer frequency and the reaction to it" up to version of Linux kernel 2.6.24 was too low, for criteria of the real-time systems. In modern kernels of Linux (> 2.6.24) provided support for timers of the high-precision resolution (HPET), what decreased the reaction time to a timer up to 100 microseconds, but that time stability is not guaranteed. To ensure stability of reaction to a timer on level 60 microseconds, and also series of the other criteria of real-time, at the moment you need to assemble a kernel with one real-time extension.


The revision in progress


У дистрибутивах ALTLinux помічено ядро 2.6.29-rt-up, яке зібрано із розширенням реального часу XENOMAI. У інших дистрибутивах, наприклад OpenSuSE помічено навіть продукти з такими розширеннями.


На цей час більш високі показники реального часу забезпечує розширення The Real Time Preempt Patch, при увімкнені повної підтримки (CONFIG_PREEMPT_RT), процес складання та результати роботи Linux ядер з якими будуть відстежуватися у цьому розділі.


Для тестування рівня реального часу тих або інших ядер будемо користуватися утилітою "Cyclictest", типовий рядок виклику та аргументи будуть такими: "$ cyclictest -t1 -c1 -p 80 -n -i 200 -l 100000". Де:


Пара вимірів для ядер Linux загального призначення:

kernel-image-rt-up-2.6.29

Це ядро міститься у дистрибутиві ALTLinux 5.1, а також перенесено у локальний репозиторій проекту OpenSCADA, для ALTLinux T6. Це ядро зібрано із розширенням XENOMAI та AUFS, що дозволяє використовувати його у прошивках із упакованою КФС, що і зроблено для ПЛК LP-8x81.


Результати тестів цього ядра:


Як видно із результатів тесту, патч XENOMAI не забезпечує пристойного рівня реального часу при використані стандартних механізмів планування реального часу POSIX, в той час як ядра версії 3 навіть без наявності особливих розширень реального часу забезпечують помітно кращий результат.


Потреба складання саме цього ядра із патчем/параметром CONFIG_PREEMPT_RT стоїть через наявність низки бінарних модулів від ICP_DAS, для "LP8x81". Також стоїть питання збірки ядра 2.6.33 з тієї-ж причини, але для "LP8x81 Atom". Попередні збірки ядер 2.6.29 та 2.6.33 виявили низку проблем, які будуть тут описані. Розглядається також варіант збірки сучасного ядра із CONFIG_PREEMPT_RT, а потім запит на збірку бінарних модулів у "ICP DAS".


Процес складання та тестування:

  1. Патчі CONFIG_PREEMPT_RT та AUFS часів 2.6.29 конфліктують на функції "debug_mutex_set_owner()", у CONFIG_PREEMPT_RT видалена — замінено на "mutex_set_owner()".
  2. При складанні виявлено низку проблем із "# typedef void irqreturn_t;" — замінено на "#include <linux/irqreturn.h>".
  3. Перший запуск із CONFIG_PREEMPT_RT, але без AUFS пройшов вдало — результат вище.
  4. Запуск із AUFS виявив проблему виділення пам'яті AUFS у "aufs_mmap()" — робочий код AUFS взято цілком із попередньої збірки "rt-up-2.6.29.alt2".
  5. Запуск із AUFS виявив проблему зависання на корінні ФС у AUFS, схоже через можливість зациклювання/блокування RT-задачі — встановлено CONFIG_PREEMPT_NONE, на LP8781 та "AMD Turion" проблем не виявлено (можливо ця проблема через відсутність HPET на PLX8).
  6. На перший погляд ядро працює нормально, але помічено зісковзування на безперервне нарощування часу запізнення.
  7. Виконано адаптацію ядра для бінарної сумісності із модулями "slot" та "icp" від ICP_DAS. Модуль "8250_linpac" падає при завантажені, а "icpdas_8250" має безліч нерозв'язаних символів — потрібно ці модулі перескладати або пробувати інтерфейси > COM2 ініціювати через setserial — модулі перескладено, завдяки Golden Wang (тех. підтримка ICPDAS).
  8. Нове ядро встановлено під високе навантаження, конфігурацією проекту САУ кульових барабанних млинів?:
    • Збій мережі із драйвером "via_rhine", після 4 діб роботи — збій очікуваний, зібрано драйвер "rhinefet", випробування продовжено.
    • На драйвері "rhinefet" система під навантаженням пропрацювала три тижні. Однак помічено, що переривання 11, на якому висить майже все стандартне обладнання (USB, Ethernet та може ще чогось), вимикається та мережа працює у режимі "Pool", що повільніше. Можливо вимкнення цього переривання відбувається і з "via_rhine", а він не може працювати у режимі "Pool", чому і пакети у/із мережі не ходять. Проблема пов'язана із відмовою та генерацією необроблених переривань одним із обладнань на переривані 11.
    • Виправлено виключенням вимкнення переривань за допомогою параметра ядра Linux "noirqdebug".
    • Адаптацію вдало завершено та прошивки на основі цього ядра готові до промислової експлуатації!
    • 01.03.2015: Замість функції EnableWDT() використано EnableSysWDT(), у зв'язку із обмеженням до 30 секунд та циклічних перевантажень якщо не завантажується за 30 секунд (до трьох перевантажень).
    • 17.03.2015: При участі служби підтримки ICP_DAS виправлено проблему драйверу послідовних інтерфейсів більш за COM2, яка призводила до "замерзання" ядра Linux (схоже у зв'язку із блокуванням переривань) після закриття одного порту та активності на хоча-б одному іншому.
    • 29.07.2015: Виявлено ще одну проблему із мережею із схожими симптомами вимкнення переривання 11, але: переривання 11 не вимикається та всі інші пристрої на ньому працюють, відтворюється тільки на конфігураціях із використанням обох інтерфейсів мережі, причому можливе "гальмування" тільки одного із них. Проблема вирішується тільки перевантаженням "загальмованого" мережевого інтерфейсу, командою: ifdown eth0; ifup eth0. Для виявлення та перезапуску рекомендується на рівні OpenSCADA додавати контроль трафіку та безпосереднє перевантаження інтерфейсу за його відсутністю.

 (2 Kb) Отримане ядро, перейменовано у "kernel-image-rt1-up-2.6.29.alt1", можна використовувати для PLC із HPET або таймером високої роздільної здатності, а також у "LP-8x81" та "LP-8x81 Atom" (тільки одне ядро)!

kernel-image-rt1-up-2.6.33

Складання ядра версії 2.6.33 потрібне для контролерів фірми "ICP DAS" LP-8x81 та LP-8x81 Atom з причини наявності саме для нього, із патчем CONFIG_PREEMPT_RT, бінарних драйверів "ICP DAS", для LP-8x81 Atom.


Результати тестів цього ядра:


Процес складання та тестування:

  1. Збірка ядра із вихідних "ICP DAS" (2.6.33.7) та конфігурацією, успадкованою з ядра 2.6.29 (вихідні тексти містять підозріло багато *.rej файлів, а також "staging/comedi" не може бути складений) — вантажиться та в цілому працює; модулі "ipic" та "slot" вантажаться; модуль "8250_linpac" падає у функції "platform_device_add"; низка програм зависає на операціях із ФС, з повідомленням: "task openscada:2153 blocked for more than 120 seconds".
  2. Заміна AUFS на версію із 2.6.29-rt1 — падає у rtmutex прямо на завантажені; заміна на офіційну із git показала такий-же результат, від початку використано патч "aufs+sqfs4lzma-2.6.33.patch" від DLink.
  3. Збірка оригінального ядра з патчами CONFIG_PREEMPT та AUFS — проблема знову з AUFS, але тепер він "/sbin/mingetty" у кінці знайти не може.
  4. Збірка оригінального 2.6.33.9 ядра з патчами CONFIG_PREEMPT та AUFS — проблеми ті-ж.
  5. Збірка із вихідних "ICP DAS" (2.6.33.7) для SMP — модуль OpenSCADA DAQ.JavaLikeCalc падає за незрозумілою причиною.
  6. Збірка оригінального ядра з патчами CONFIG_PREEMPT та AUFS для SMP — та-ж проблема, що і без SMP, хіба-що тільки не одразу, а на приблизно п'ятому потоці.

 (2 Kb) На цей момент ядро 2.6.33 у зв'язці із CONFIG_PREEMPT_RT та AUFS неробоче. Відповідно якщо потрібна буде робота на "LP-8x81 Atom" то рекомендується використовувати оригінальне Linux оточення, зібравши та встановивши OpenSCADA туди.

iROBO-3000a

iROBO-3000a is a fanless industrial computer with Intel Atom D425 1.8 GHz с VGA, 2xGb LAN, 4xCOM, 4xUSB, 1GB RAM, 1x2.5" SATA HDD 120GB, Mini-PCIe, 4x4 DIO, CF slot, SIM Card slot, Audio, WDT on board, operating temperature range -5..+55°С. Performance of this computer is enough to run the functions of data acquisition, monitoring and control server, as well as the visualization station's functions. However, because of usage the non-productive Atom processor family, the implementation of mathematical models of processes will require almost all of the CPU resources. For example, during the performance of the AGLKS mathematical model, the CPU is loaded at 86%. The controller has been certified by "UKRSEPRO" that may be important for many users in the territory of Ukraine.



OpenSCADA operating environment for this computer was based on the packets base of the ALTLinux T6 distribution, as well as freshly-builded Trinity (TDE) desktop environment. Building of the environment was made using the above described conception with an updated profile of "mkimage". The "plc" objective has been added to the new profile, but its nature has changed in fact and has become a copy of the "live" target, which became possible thanks to the implementation in primary initialization stage the transparent mount of the partition with the "alt-live-storage" label as a reflection of a packed file system with random access to the modification. In general, it made possible to create the fixed core of the firmware with the basic set of software environment with the size of 300MB and with the possibility of free expansion by installing the necessary packages from the distribution.


The Trinity was selected as the desktop environment because of the presence of background artefacts problem in conjunction with XOrgServer 1.10 + QT4, as well as because of TDE low-resource with high maturity and stability.


Archive of the build profiles of the new environment is called mkimage-profiles-6-kdesktop-plc.tgz, and the latest build of the firmware ALTLinux6-OpenSCADA_0.7.2-i586-plcUI_TDE-generic.flash.tar.


 
There are no files on this page.[Display files/form]
There is no comment on this page. [Display comments/form]