Fbcp fails in RPi 3 Container



Dear resin-fellows,

I have a huge problem and cannot wrap my mind aroudn that, so maybe you could help? :confused:

Currently I am working on using an IL9341 display as primary display from one of my Docker Containers, which worked out great (basically I was using my own write up from https://www.nico-maas.de/?p=1646 as a starting point and worked from that…)

I did manage to make that work following way:

added to /mnt/boot/config.txt


changed in /usr/share/X11/xorg.conf.d/99-fbturbo.conf the fb dev to 1

Section "Device"
    Identifier      "Allwinner A10/A13 FBDEV"
    Driver          "fbturbo"
    Option          "fbdev" "/dev/fb1"
    Option          "SwapbuffersWait" "true"

and added /usr/share/X11/xorg.conf.d/99-calibration.conf

Section "InputClass"
   Identifier      "calibration"
   MatchProduct    "ADS7846 Touchscreen"
  Option  "Calibration"   "373 3876 3771 171"
  Option  "SwapAxes"      "0"

for the touchscreen after installing xserver-xorg-input-evdev.

So that works, primary display was the TFT and everythings great.

However, as this display only drives at 320x240 pixels and I need the doubled size, I thought about virtually resizing it with xandr which failed very much: Turned out, due to the LCD driver, this is not supported / notros fbtft does not gives and possibilty to use that.

The last straw which I turned to is the old famous fbcp: So I undid all changes and only did following in the config.txt:


with this, I set my HDMI display to 640x480, which is now my primary screen again.
I downloaded https://github.com/tasanakorn/rpi-fbcp and build it, which worked - and installed rsyslog to get a syslog server. If I turn on my basic app as shown in my weblog entry above, everything works on the main HDMI screen: It comes on at 640x480, shows the app, everything alright, even the TFT/LCD screen has backlight on and both /dev/fb0 and /dev/fb1 show up in the container. However - starting fbcp results in the program directly stopping. With or without DISPLAY=:0 as variable ( DISPLAY=:0 fbcp ) -and syslogs shows follwing error:

fbcp[207]: Unable to open primary display

Any idea on how to get this working?
I am out of options here and have no clue what to do… :confused:
Maybe @petrosagg knows something :(?

Thank you all and have a great day!


Hello @nmaas87,
Sounds a very cool project. I have looked into the error you got from fbcp.

As you probably have seen by yourself from the fbcp source the call to vc_dispmanx_display_open fails.

Can you please also share the value of the ENV variable VC_DISPLAY?


Thank you @yossi - as a matter of fact, VC_DISPLAY is not set, neither in the Docker Container itself, nor in resinOS. I tried to set it with export VC_DISPLAY=0 or export VC_DISPLAY=5 in the Container, but it did not change a thing, fbcp still did not work. Which should be the correct value for said variable? Do I need to install libraspberrypi-bin or include Userland somehow to make it work and if so, which would be the best way to achieve that? :slight_smile:
Thanks a lot for your help!


Ok, @yossi and I have been researching a bit, so thats what we came up with so far:

Using my basic https://github.com/nmaas87/docker-raspbian_pywebview/tree/master/pywebview_latest example, I created an RPi 3 App on resin.io and started that. Then I added the following lines to the config.txt of the resin SD Card:


and added the rpi-display-woutts to the overlay folder, which can be found here:

(It is basically the rpi-display file only without the touchscreen which I added later with ads7846 - which actually achieves the same thing, as rpi-display includes ads7846 - but I did seperate it as the pure ads7846 dtb takes more options and I thought I would need them - so… for the sake of completeness I put that here - but you could also use rpi-display to achieve the same thing :wink: )

After that, the whole thing booted and showed my Python/Flask App in 640x480 on my HDMI Output, while the Display stayed on - but without showing anything on the screen.

However, I could do some basic testing like outputing randomness

cat /dev/urandom > /dev/fb0
cat /dev/urandom > /dev/fb1

or pictures (after installing fbi)

fbi -d /dev/fb0 /usr/share/icons/gnome/256x256/emotes/face-smile.png -T 1
fbi -d /dev/fb1 /usr/share/icons/gnome/256x256/emotes/face-smile.png -T 1

to both screens - independently. So both framebuffers are perfectly working.

Now I want to use fbcp to copy all infos from fb0 (HDMI) to fb1 (TFT Display)

So I did following:

apt-get update
apt-get --yes --force-yes install build-essential cmake unzip libraspberrypi-dev rsyslog
cd /tmp
curl -LO https://github.com/tasanakorn/rpi-fbcp/archive/master.zip
unzip master.zip
cd rpi-fbcp-master
mkdir build
cd build
cmake ..
install fbcp /usr/local/bin/fbcp
chmod +x /usr/local/bin/fbcp

which installed fbcp (and syslog as it was not available in my image :wink: )
but starting fbcp turned out in it terminating the same moment.

tail /var/log/syslog just tells me:
fbcp[207]: Unable to open primary display

And env

SSH_CLIENT= 4337 22

gives me not much to work with. Especially no VC_DISPLAY. However, I did try to set VC_DISPLAY to all values from 0 - 5, started fbcp again, and it did not work.

I also tried raspi2fb from Andrew:

apt-get install libbsd-dev
curl -LO https://github.com/AndrewFromMelbourne/raspi2fb/archive/master.zip
unzip master.zip
cd raspi2fb-master/
mkdir build
cd build
cmake …
chmod +x raspi2fb

Which also resulted in a

raspi2fb[2072]:error:cannot open display

So, it is a really tough problem. Both screens work, however, the system does not recognize that…


Thank you for the update. I think that vc_dispmanx_display_open fails. All it does is to read the integer value of the environment var VC_DISPLAY. I am sorry we couldn’t make it work today. Hopefully when we are all back from the weekend tomorrow we will get better suggestions.


With loads of work from the awesome @yossi - I got it working.
The simple and downright stupid truth was that one (me :wink: ) did miss the most obvious thing:
resinOS is wonderfully (really!) optimized and sets the default for gpu_mem=16 (16 MB). This is great for headless systems, however it does not give enough room for using i.e. a second Framebuffer and copy with fbcp successfully. So the really downright-stupid-easy solution was: remove gpu_mem=16, set gpu_mem=32 or more and you’re set :wink: . Thanks a lot to @yossi for the imense help! :slight_smile:


That’s great to hear @nmaas87! Yeah, a lot of things depend on Raspberry Pi’s gpu_mem setting and can happen in not 100% straightforward settings (e.g. how the camera module needs pretty high value there…).