How to use Radxa Camera 4K

i found out that rkaiq_3A_server does all stuff.
i`m on Debian 11 now and camera works fine if rkaiq_3A_server service is working.
But when rkaiq_3A_server service is stopped camera gives dark green as it was on Ubuntu.

I tried to start rkaiq_3A_server service on Ubuntu but it fails.
Should i take:
/usr/lib/librkaiq.so
/usr/bin/rkaiq_3A_server
from Debian and replace the same files on Ubuntu ?

in /etc/iqfiles i see:
imx415_CMK-OT2022-PX1_IR0147-50IRC-8M-F20.json
imx415_RADXA-CAMERA-4K_DEFAULT.json

should be copied to Ubuntu ?

The order of actions:

  1. Try just to copy JSON files to Ubuntu’s directory /etc/iqfiles and run rkaiq_3A_server.
  2. If rkaiq_3A_server crashes then check your DTS for module/lens names (see my post above) and try to rename some of JSON file as described in my post…
  3. If rkaiq_3A_server still crashes then copy both rkaiq_3A_server and librkaiq.so from working distro (Debian?) to some temporary directory in Ubuntu and run server manually:
    sudo LD_LIBRARY_PATH=. ./rkaiq_3A_server
    If it works then you can replace corresponding files in your Ubuntu.

i tried to replace rkaiq_3A_server and librkaiq.so from Debian to Ubuntu - rkaiq_3A_server doesnt start.
librkaiq.so - there was no such lib there so i just copied and chmod it.

but i got some result.
camera starts working after i just installed https://github.com/radxa/debos-radxa/raw/main/rootfs/packages/arm64/camera/camera-engine-rkaiq_3.0.2_arm64.deb

but after reboot i see again green ((

have a look results here please -

The official answer I got from radxa was “do not use ubuntu it doesn’t work”

Unfortunately, no enough information to understand what happens.
Did you check your DTS for module/lens names? If you have 2 or more JSON files for your camera (imx415), then you could try to rename them to fit DTS values. May be settings in one of these files are more correct.

It works on Ubuntu and Debian. most likely they are referring to some GUI apps or their updated engine.
See: IMX415 + NPU demo on ROCK 5B

The issue here looks like the 3A engine crashed on reboot. If i am not mistaken they reverted some of the new changes made (that was causing a crash?).

Unfortunately, the engine couldn’t be natively compiled, so I couldn’t do much with it, as I don’t cross-compile.

1 Like

I compiled rkaiq_3A_server from Firefly repo. It works on my NanoPC-T6 board. You can see
my exercises :slight_smile:. Server and library are in the second post there.

compiled on board?

Did you ask me? :slight_smile:
Yes, compiled on board. With small obvious changes (mostly concerning compiler and link flags).

Mind sharing a tar file of your complete build tree and command?

@sergei_gagarin
I clicked <-+ Reply button to reply, but this did not work.
If the tar file can’t be shared here, please use mega.nz or some other link to download, thanks.

Here are the files I edited and a small instruction how to compile server and library on your board.
build_rkaiq.zip (2.8 KB)

May be some standard packages are required (sure, gcc, cmake and so on are obligated).

Please note that I compiled it some months ago (that’s why “git reset” in instruction). Recently Firefly added some changes (new version 5 of rkaiq). I did not work with it. May be additional editing will be required in that case.

With that repo and your changes, i was able to compile. i did not have to follow your libdrm and librga changes:

rock@rock5b:/apps/rockchip/camera_engine_rkaiq/build/linux$ ldd output/aarch64/all_lib/RelWithDebInfo/librkaiq.so
	linux-vdso.so.1 (0x0000007f85983000)
	libdrm.so.2 => /lib/aarch64-linux-gnu/libdrm.so.2 (0x0000007f85300000)
	libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007f850d0000)
	libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f85030000)
	libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007f85000000)
	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f84e50000)
	/lib/ld-linux-aarch64.so.1 (0x0000007f8594a000)
rock@rock5b:/apps/rockchip/camera_engine_rkaiq/build/linux$ ldd output/aarch64/exe/RelWithDebInfo/rkaiq_3A_server
	linux-vdso.so.1 (0x0000007f91652000)
	librkaiq.so => /lib/librkaiq.so (0x0000007f90fb0000)
	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f90e00000)
	/lib/ld-linux-aarch64.so.1 (0x0000007f91619000)
	libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f90de0000)
    libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007f90bb0000)
	libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f90b10000)
	libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007f90ae0000)

The next step is to check if it works :grin:, thanks.

Just for the record.
I am on Ubuntu:

lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy

the new version:

sudo /usr/bin/rkaiq_3A_server
Cound not find rkisp dev names, skipped /dev/media0
ERR: Bad media topology for: /dev/media0
DBG: get rkisp-isp-subdev devname: /dev/v4l-subdev3
DBG: get rkisp-input-params devname: /dev/video19
DBG: get rkisp-statistics devname: /dev/video18
DBG: get rkisp_mainpath devname: /dev/video11
rkaiq log level ff0

************************** VERSION INFOS **************************
version release date: 2022-09-20
         AIQ:       AIQ v3.0x9.1
   IQ PARSER:       Calib v1.4.8,magicCode:1170944
************************ VERSION INFOS END ************************
ERR: Bad media topology for: /dev/media2
ERR: Bad media topology for: /dev/media3
ERR: Bad media topology for: /dev/media4
ERR: Bad media topology for: /dev/media5
ERR: Bad media topology for: /dev/media6
ERR: Bad media topology for: /dev/media7
ERR: Bad media topology for: /dev/media8
ERR: Bad media topology for: /dev/media9
ERR: Bad media topology for: /dev/media10
ERR: Bad media topology for: /dev/media11
ERR: Bad media topology for: /dev/media12
ERR: Bad media topology for: /dev/media13
ERR: Bad media topology for: /dev/media14
ERR: Bad media topology for: /dev/media15
Segmentation fault

the old unknown version:

sudo /usr/bin/rkaiq_3A_server
media get entity by name: stream_cif_dvp_id0 is null
media get entity by name: stream_cif_dvp_id1 is null
media get entity by name: stream_cif_dvp_id2 is null
media get entity by name: stream_cif_dvp_id3 is null
media get entity by name: rkcif-mipi-luma is null
media get entity by name: rkcif-lvds-subdev is null
media get entity by name: rkcif-lite-lvds-subdev is null
media get entity by name: rockchip-mipi-dphy-rx is null
media get entity by name: stream_cif is null
media get entity by name: rkcif-dvp-sof is null
media get entity by name: rkisp-csi-subdev is null
media get entity by name: rkisp-mpfbc-subdev is null
media get entity by name: rkisp_rawwr0 is null
media get entity by name: rkisp_rawwr1 is null
media get entity by name: rkisp_rawwr2 is null
media get entity by name: rkisp_rawwr3 is null
media get entity by name: rkisp_dmapath is null
media get entity by name: rkisp-mipi-luma is null
media get entity by name: rockchip-mipi-dphy-rx is null
media get entity by name: rockchip-csi2-dphy0 is null
media get entity by name: rkcif_dvp is null
media get entity by name: rkcif_dvp is null
media get entity by name: rkcif_lite_mipi_lvds is null
media get entity by name: rkcif_mipi_lvds is null
media get entity by name: rkcif_mipi_lvds1 is null
media get entity by name: rkcif_mipi_lvds2 is null
media get entity by name: rkcif_mipi_lvds3 is null
media get entity by name: rkcif_mipi_lvds4 is null
media get entity by name: rkcif_mipi_lvds5 is null
media get entity by name: rkcif-mipi-lvds is null
media get entity by name: rkcif-mipi-lvds1 is null
media get entity by name: rkcif-mipi-lvds3 is null
media get entity by name: rkcif-mipi-lvds4 is null
media get entity by name: rkcif-mipi-lvds5 is null
media get entity by name: rkisp-isp-subdev is null
media get entity by name: rkisp-input-params is null
media get entity by name: rkisp-statistics is null
media get entity by name: rkisp_mainpath is null
Cound not find rkisp dev names, skipped /dev/media0
ERR: Bad media topology for: /dev/media0
DBG: get rkisp-isp-subdev devname: /dev/v4l-subdev3
DBG: get rkisp-input-params devname: /dev/video19
DBG: get rkisp-statistics devname: /dev/video18
DBG: get rkisp_mainpath devname: /dev/video11
ERR: Bad media topology for: /dev/media2
ERR: Bad media topology for: /dev/media3
ERR: Bad media topology for: /dev/media4
ERR: Bad media topology for: /dev/media5
ERR: Bad media topology for: /dev/media6
ERR: Bad media topology for: /dev/media7
ERR: Bad media topology for: /dev/media8
ERR: Bad media topology for: /dev/media9
ERR: Bad media topology for: /dev/media10
ERR: Bad media topology for: /dev/media11
ERR: Bad media topology for: /dev/media12
ERR: Bad media topology for: /dev/media13
ERR: Bad media topology for: /dev/media14
ERR: Bad media topology for: /dev/media15
[11:59:50.553631][XCORE]:XCAM ERROR rk_aiq_user_api_sysctl.cpp:392: Should use json instead of xml
[11:59:50.631867][XCORE]:XCAM ERROR RkAiqCalibDbV2.cpp:253: write /tmp/iq_dump.json failed!
[11:59:50.631915][XCORE]:XCAM ERROR rk_aiq_user_api_sysctl.cpp:408: Failed to find params of : scene in json, using default scene
[11:59:50.635584][XCORE]:XCAM ERROR socket_server.cpp:481: Error bind Address already in use

[11:59:50.635913][CAMHW]:XCAM ERROR SensorHw.cpp:1321: failed to set hdr mode 0
[11:59:50.635942][CAMHW]:XCAM ERROR SensorHw.cpp:1291: failed to set sync mode 0
[11:59:50.636741][ADEHAZE]:XCAM ERROR rk_aiq_adehaze_algo.cpp:2177: AdehazeGetCurrData:PreResBuf is NULL!

DBG: subscribe events from /dev/video19 success !
DBG: /dev/media1: wait stream start event...

Looks like it can’t find the config file.

I am upgrading to rkr4.1 and see what i get…

i moved from Debian to /etc/iqfiles Ubuntu 2 files:

  • imx415_CMK-OT2022-PX1_IR0147-50IRC-8M-F20.json
  • imx415_RADXA-CAMERA-4K_DEFAULT.json
    restarted and checked.
    As there was no result i renamed imx415_CMK-OT2022-PX1_IR0147-50IRC-8M-F20.json to imx415_RADXA-CAMERA-4K_DEFAULT.json
    and restarted to check again - no result.

rkaiq_3A.service not crashing but gives some errors as i think:

rkaiq_3A.service - rkisp 3A engine
Loaded: loaded (/lib/systemd/system/rkaiq_3A.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-08-04 22:03:00 MSK; 21h ago
Process: 886 ExecStart=/etc/init.d/rkaiq_3A.sh start (code=exited, status=0/SUCCESS)
Tasks: 7 (limit: 4370)
Memory: 19.6M
CGroup: /system.slice/rkaiq_3A.service
├─889 /usr/bin/rkaiq_3A_server
└─890 logger -t rkaiq

авг 04 22:15:30 rock rkaiq[890]: DBG: device manager start
авг 04 22:15:30 rock rkaiq[890]: DBG: rkisp_init engine succeed
авг 04 22:15:30 rock rkaiq[890]: DBG: /dev/media1: wait stream stop event…
авг 04 22:15:30 rock rkaiq[890]: [22:15:30.564231][CAMHW]:XCAM ERROR Isp20Params.cpp:4036: get blc params fa>
авг 04 22:15:30 rock rkaiq[890]:
авг 04 22:16:25 rock rkaiq[890]: DBG: /dev/media1: wait stream stop event success …
авг 04 22:16:25 rock rkaiq[890]: [22:16:25.063288][CAMHW]:XCAM ERROR SensorHw.cpp:1291: failed to set sync m>
авг 04 22:16:25 rock rkaiq[890]: DBG: subscribe events from /dev/video19 success !
авг 04 22:16:25 rock rkaiq[890]: DBG: subscribe events from /dev/video19 success !
авг 04 22:16:25 rock rkaiq[890]: DBG: /dev/media1: wait stream start event…

i also tried to go on with this issue - Has anyone actually succeeded in getting hardware video encoding working?
but only i got - working OBS studio. not bad as Kasam not working there recording just black screen.

i tried to compile but at the last step:
./make-Makefiles-aarch64.bash
i see:

./make-Makefiles-aarch64.bash
~/Downloads/test/camera_engine_rkaiq/build/linux/output/aarch64 ~/Downloads/test/camera_engine_rkaiq/build/linux
CMake Deprecation Warning at CMakeLists.txt:11 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.

Update the VERSION argument value or use a … suffix to tell
CMake that the project does not need compatibility with older versions.

– The C compiler identification is unknown
– The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:13 (PROJECT):
The CMAKE_C_COMPILER:

/home/camera/camera/rk356x_linux/buildroot/output/rockchip_rk3566/host/bin/aarch64-buildroot-linux-gnu-gcc

is not a full path to an existing compiler tool.

Tell CMake where to find the compiler by setting either the environment
variable “CC” or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists.txt:13 (PROJECT):
The CMAKE_CXX_COMPILER:

/home/camera/camera/rk356x_linux/buildroot/output/rockchip_rk3566/host/bin/aarch64-buildroot-linux-gnu-g++

is not a full path to an existing compiler tool.

Tell CMake where to find the compiler by setting either the environment
variable “CXX” or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.

– Configuring incomplete, errors occurred!
See also “/home/rock/Downloads/test/camera_engine_rkaiq/build/linux/output/aarch64/CMakeFiles/CMakeOutput.log”.
See also “/home/rock/Downloads/test/camera_engine_rkaiq/build/linux/output/aarch64/CMakeFiles/CMakeError.log”.
~/Downloads/test/camera_engine_rkaiq/build/linux

Looks like they are hardcoding paths to their executables. Sloppy

FYI, this version worked for my kernel:

************************** VERSION INFOS **************************
version release date: 2023-03-02
         AIQ:       AIQ v5.0x1.2-rc2
   IQ PARSER:       Calib v1.4.8,magicCode:1170944
************************ VERSION INFOS END ************************

Looks like you did not un-tar archive changed.tgz (or un-tared it in wrong directory).

Try to use the library and server from here: https://disk.yandex.ru/d/tPnXrLB5xSy0vg
(ignore JSON-file in this archive).

overwrited and reboot - server is not starting at all:

./rkaiq_3A_server
Cound not find rkisp dev names, skipped /dev/media0
ERR: Bad media topology for: /dev/media0
DBG: get rkisp-isp-subdev devname: /dev/v4l-subdev3
DBG: get rkisp-input-params devname: /dev/video19
DBG: get rkisp-statistics devname: /dev/video18
DBG: get rkisp_mainpath devname: /dev/video11
rkaiq log level ff0

************************** VERSION INFOS **************************
version release date: 2022-09-20
AIQ: AIQ v3.0x9.1
IQ PARSER: Calib v1.4.8,magicCode:1170944
************************ VERSION INFOS END ************************
ERR: Bad media topology for: /dev/media2
ERR: Bad media topology for: /dev/media3
ERR: Bad media topology for: /dev/media4
ERR: Bad media topology for: /dev/media5
ERR: Bad media topology for: /dev/media6
ERR: Bad media topology for: /dev/media7
ERR: Bad media topology for: /dev/media8
ERR: Bad media topology for: /dev/media9
ERR: Bad media topology for: /dev/media10
ERR: Bad media topology for: /dev/media11
ERR: Bad media topology for: /dev/media12
ERR: Bad media topology for: /dev/media13
ERR: Bad media topology for: /dev/media14
ERR: Bad media topology for: /dev/media15
Segmentation fault (core dumped)