Clone wiki

beremiz / Build minimal Beremiz runtime with Buildroot


This article will describe how to create the minimal GNU/Linux image with Beremiz runtime. For that purpose Buildroot will be used. All steps are done on GNU/Linux machine. It's expected that make, gcc, g++, autotools and other tools usually needed to build software for host machine are installed. On Debian-based system (like Ubuntu) this can be done by installing 'build-essentials' package.

Base setup

  1. Create directory, where all work will be done
$ mkdir beremiz_image
  1. Clone Buildroot repository
$ cd beremiz_image && git clone git://

Next steps will describe buildroot configuration. Image will be build for x86 architecture, default kernel configuration from upstream is used and rootfs is packaged into cpio. All this configuration can be easily tested on host machine using qemu.

Overlay for rootfs

Overlay are files that are copied into target image. Overlay will contain Beremiz_service and some requirements that are missing in buildroot currently.

$ cd ..
$ mkdir beremiz_overlay
  • Add minimal set of files needed to run only
$ cd beremiz_overlay && mkdir root && cd root
$ wget
$ tar -xv --wildcards --no-wildcards-match-slash -f tip.tar.bz2 '*/' '*/runtime' '*/util/' '*/'
$ rm tip.tar.bz2
$ mv * beremiz
$ cd ../

This is the set of files required by

$ find
  • Add missing in buildroot python zeroconf package
$ mkdir -p usr/lib/python2.7/site-packages && usr/lib/python2.7/site-packages
$ wget -O zeroconf.tar.gz
$ tar --wildcards --no-wildcards-match-slash --strip=1 -xvf zeroconf.tar.gz  '*/'
$ rm zeroconf.tar.gz
$ cd ../../../../

Buildroot configuration

  • Create file named 'beremiz_i386_defconfig' in beremiz_image directory with following content
  • Build rootfs image.
make defconfig BR2_DEFCONFIG=../beremiz_i386_defconfig
make -j$(nproc)

This will take time, because cross-toolchain, kernel and all corresponding software will be downloaded and build from source. At the end

  • Check size of generated image
$ ls -lh output/images/
total 44M
-rw-r--r-- 1 developer developer 6.9M Jul 24 16:52 bzImage
-rw-r--r-- 1 developer developer  18M Jul 24 16:52 rootfs.cpio
-rw-r--r-- 1 developer developer  19M Jul 24 16:52 rootfs.tar

Run generated image

qemu-system-i386 -enable-kvm -nic user,hostfwd=tcp::3000-:3000 -initrd output/images/rootfs.cpio -kernel output/images/bzImage -no-reboot -serial stdio -display none --append 'console=ttyS0,115200'

Beremiz_service isn't started automatically. To start it run following commands:

Welcome to Buildroot
buildroot login: root
# cd beremiz
# ./ -t 0 -x 0 -a 1
Pyro port : 3000
Current working directory : /root/beremiz

Connect to running Beremiz_service

qemu-system-i386 command used in previous step forwards connection to TCP port 3000 on host to port 3000 on guest. It makes possible to connect to Beremiz_service running inside guest system from host system. Open Beremiz IDE on host machine. Open for example 'first_steps' project and set URI_location to point to 'PYRO://'. If your host system is 64-bit architecture, then you have to set CFLAGS and LDFLAGS to generate 32-bit code, because guest system is 32-bit.

Project settings are displayed below. Screenshot from 2018-07-24 17-36-53.png

Beremiz_service log during connection from host Beremiz IDE:

# ./ -t 0 -x 0 -a 1
[   24.573888] random: python: uninitialized urandom read (2500 bytes read)
[   24.592664] random: python: uninitialized urandom read (2500 bytes read)
Pyro port : 3000
Current working directory : /root/beremiz
PLCobject : NewPLC (9d6123759abd9a3da3c94c43b8dcbbc2)
PLCobject : PLC started
PLCobject : PLC stopped