WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Targeting the VideoCore IV GPU on RPi  (Read 2841 times)

Offline obutk

  • Newbie
  • *
  • Posts: 8
Targeting the VideoCore IV GPU on RPi
« on: April 30, 2022, 05:00:51 PM »
Is it possible to use the Videocore IV hardware when developing programs in tinycore? I have to perform image processing on the RPi, and I thought maybe I could get some speed boost by targeting the GPU.

I have tried using two C/C++ libraries for creating programs to run on the VideoCore GPU. While I was able to compile them, they always fail at runtime (segfault or a generic error).

For reference, these are the libraries I've tried:
https://github.com/wimrijnders/V3DLib
https://github.com/doe300/VC4CL

Is there any kind of configuration (bootcode or config.txt) or package that I should be using to make this possible?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Targeting the VideoCore IV GPU on RPi
« Reply #1 on: May 01, 2022, 04:08:17 AM »
I played around with gpu hardware acceleration using piCore64 on an RPi4 - I believe this is VideoCore VI.

Code: [Select]
glxinfo | grep -i gpu
    GL_EXT_gpu_program_parameters, GL_EXT_gpu_shader4,

..and this plays a video using hardware acceleration:
Code: [Select]
ffplay -i test_video.mp4 -vcodec h264_v4l2m2m
If you let me know how you tested https://github.com/wimrijnders/V3DLib I can give it a try although it might not be relevent to VideoCore IV...

Offline gadget42

  • Hero Member
  • *****
  • Posts: 826
Re: Targeting the VideoCore IV GPU on RPi
« Reply #2 on: May 01, 2022, 04:43:36 AM »
The fluctuation theorem has long been known for a sudden switch of the Hamiltonian of a classical system Z54 . For a quantum system with a Hamiltonian changing from... https://forum.tinycorelinux.net/index.php/topic,25972.msg166580.html#msg166580

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Targeting the VideoCore IV GPU on RPi
« Reply #3 on: May 01, 2022, 06:18:08 AM »
I built v3dlib on piCore64 - all the tests pass and ./obj/qpu-debug/bin/GCD runs.

Code: [Select]
sudo ./obj/qpu-debug/bin/detectPlatform
Platform    : Raspberry Pi 4 Model B Rev 1.4
Model Number: BCM2711
Revision    : d03114
This is a pi platform.
GPU: v3d (VideoCore VI)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Targeting the VideoCore IV GPU on RPi
« Reply #4 on: May 01, 2022, 07:56:56 AM »
On piCore/RPi3 several of the tests fail with:
Code: [Select]
FATAL: Failed to allocate vc4 shared  memory..but that might be addressed with something in config.txt

Code: [Select]
sudo ./obj/qpu-debug/bin/detectPlatform
Platform    : Raspberry Pi 3 Model B Rev 1.2
Model Number: BCM2837
Revision    : a02082
This is a pi platform.
GPU: vc4 (VideoCore IV)

Offline obutk

  • Newbie
  • *
  • Posts: 8
Re: Targeting the VideoCore IV GPU on RPi
« Reply #5 on: May 01, 2022, 08:04:35 AM »
If you let me know how you tested https://github.com/wimrijnders/V3DLib I can give it a try although it might not be relevent to VideoCore IV...

I'm using a RPi02W (armv7) with PiCore 13.

My cmdline.txt:
Code: [Select]
zswap.compressor=lz4 zswap.zpool=z3fold console=tty0 root=/dev/ram0 elevator=deadline rootwait quiet nortc loglevel=3 noembed

My onboot.lst: https://pastebin.com/VkBcqcUJ

My config.txt: https://pastebin.com/5nVHnVui

Here is what I did. Loading the programming packages:
Code: [Select]
#loading general programming packages
tce-load -i compiletc git
#loading specific packages used by V3DLib
tce-load -i expat2-dev rpi-vc-dev

Then I cloned V3DLib and its dependency CmdParameter, and I applied the change described in https://github.com/wimrijnders/V3DLib/issues/7

Compiling:
Code: [Select]
#compiling CmdParameter
cd CmdParameter
make DEBUG=1 all
cd ..
#compiling V3DLib and running the tests (all tests fail)
cd V3DLib
make QPU=1 DEBUG=1 test
#running the tests as root (to see if there is any difference. also fail)
sudo su
./obj/qpu-debug/bin/runTests

Here are the results of the tests: https://pastebin.com/uqbZWLhc

detectPlatform seems to work:

Code: [Select]
sudo ./obj/qpu-debug/bin/detectPlatform
Platform    : Raspberry Pi Zero 2 W Rev 1.0
Model Number: BCM2837
Revision    : 902120
This is a pi platform.
GPU: vc4 (VideoCore IV)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Targeting the VideoCore IV GPU on RPi
« Reply #6 on: May 01, 2022, 08:13:04 AM »
Do you need graphics-KERNEL loaded and the following in config.txt:

Code: [Select]
[PI02]
dtoverlay=vc4-kms-v3d

..maybe also rpi-vc?

Offline obutk

  • Newbie
  • *
  • Posts: 8
Re: Targeting the VideoCore IV GPU on RPi
« Reply #7 on: May 01, 2022, 08:30:54 AM »
Do you need graphics-KERNEL loaded and the following in config.txt:

Code: [Select]
[PI02]
dtoverlay=vc4-kms-v3d

..maybe also rpi-vc?


I tried adding:

Code: [Select]
graphics-5.10.77-piCore-v7.tcz
rpi-vc.tcz

at the top of my onboot.lst file, and:

Code: [Select]
dtoverlay=vc4-kms-v3d
gpu_mem=256

at the bottom of my config.txt.

The "ioctl_set_msg failed: -1" error message and memory allocation problems seem to have disappeared, but the tests are still failing:

Code: [Select]
ERROR: test case THREW exception: FATAL: Unable to enable QPUs. Check your firmware is latest.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Targeting the VideoCore IV GPU on RPi
« Reply #8 on: May 01, 2022, 08:53:19 AM »
After adding gpu_mem=128 I get the same firmware error on the RPi3/piCore.

On the RPi4/piCore64 all tests pass.

Maybe you could report it as an issue at https://github.com/wimrijnders/V3DLib/issues
« Last Edit: May 01, 2022, 09:11:57 AM by Juanito »

Offline obutk

  • Newbie
  • *
  • Posts: 8
Re: Targeting the VideoCore IV GPU on RPi
« Reply #9 on: May 01, 2022, 03:14:37 PM »
Maybe you could report it as an issue at https://github.com/wimrijnders/V3DLib/issues

I think it is a good idea, but first it would nice to test it with Raspbian 10 Buster to verify if this issue is not related to tinycore. E.g. maybe graphics-KERNEL.tcz or rpi-vc.tcz could be updated? I'm gonna try it with my Pi if I have some time.
« Last Edit: May 01, 2022, 03:22:20 PM by obutk »