Camera
The AM62x supports 2 camera interfaces:
UVC (Usb Video Class) cameras, which are mainly known as webcams.
Camera over CSI-2
This page will mainly describe Camera over CSI-2.
Note
Right now, only one YUV sensor is supported: The Omnivision OV5640.
Hardware setup
The following hardware is required to use the CSI-2 camera:
Plug the 15 pin FPC ribbon in J19
and on the camera module as following:
Software configuration
After flashing, make sure to halt in the U-Boot shell and run
=> env set adtbo_idx 2
=> saveenv
This ensures that the k3-am625-sk-csi2-ov5640.dtbo
device-tree overlay gets
applied by the bootloader.
With the applied overlay, the following drivers should probe:
ov5640
, which is the sensor drivercdns-csi2rx
which is the receiver (CSI2RX) driverj721e-csi2rx
which is a TI-specific glue betweencdns-csi2rx
and the DMA engine (SHIM)
Once booted to the home screen, we can start a capture session using the default AOSP provided camera app:
$ adb shell 'am start -a android.media.action.IMAGE_CAPTURE'
Debugging tips
Using the cam
commandline
cam
is a commandline utility to do low level captures and save them to disk.
Some useful cam
commands are:
$ adb wait-for-device root && adb wait-for-device
# get information about streams and formats
$ adb shell 'cam --camera 1 --info'
# take a 1920x1080 capture in yuyv
$ adb shell 'cam -c1 -C1 -s pixelformat=YUYV --file=/data/'
# pull it from the device and convert it to png using ffmpeg
$ adb pull '/data/frame-cam0-stream0-000000.bin'
$ ffmpeg -f rawvideo -s 1920x1080 -pix_fmt yuyv422 -i frame-cam0-stream0-000000.bin picture.png
Since the Android HAL has exclusive access to the camera, the camera app should
not be running when we try to run a capture with cam
.
Enabling additional kernel logs
v4l2
has its own logging system. To have additional logs in dmesg
, do the following:
$ adb wait-for-device root && adb wait-for-device
$ adb shell 'echo 0x3f > /sys/class/video4linux/video0/dev_debug'
$ adb shell 'echo 1 > /sys/module/videobuf2_common/parameters/debug'
Android specific tricks
List cameras from Android system
To list if the camera is enumerated by the Android system, run:
$ adb shell 'dumpsys media.camera'
Logging
To filter logs from logcat, use:
$ adb logcat | grep -i -e libcamera -e 'F DEBUG';
To change the log level for libcamera, edit the HAL’s init.rc
diff --git a/camera/android.hardware.camera.provider@2.5-service_64_am62x.rc b/camera/android.hardware.camera.provider@2.5-service_64_am62x.rc
index 4808aea8dcee..f4637d7213a8 100644
--- a/camera/android.hardware.camera.provider@2.5-service_64_am62x.rc
+++ b/camera/android.hardware.camera.provider@2.5-service_64_am62x.rc
@@ -16,5 +16,5 @@ service vendor.camera-provider-2-5 /vendor/bin/hw/android.hardware.camera.provid
capabilities SYS_NICE
task_profiles CameraServiceCapacity MaxPerformance
override
- setenv LIBCAMERA_LOG_LEVELS *:INFO
+ setenv LIBCAMERA_LOG_LEVELS *:DEBUG
setenv LIBCAMERA_LOG_FILE syslog
Incremental rebuilding
To quickly rebuild all libcamera components and restart the HAL, run:
$ export OUT_DIR=<your_out_dir>
$ source build/envsetup.sh && lunch am62x-ap4a-userdebug && \
m libcamera camera.libcamera cam libyuv_chromium libcameraservice
# libcamera
$ cd $OUT_DIR/target/product/am62x/ && adb root && adb remount && \
adb push vendor/lib/libcamera.so /vendor/lib && adb push vendor/lib64/libcamera.so /vendor/lib64
# camera.libcamera
$ adb push vendor/lib/hw/camera.libcamera.so /vendor/lib/hw && \
adb push vendor/lib64/hw/camera.libcamera.so /vendor/lib64/hw
# cam
$ adb push vendor/bin/cam /vendor/bin/cam
# libyuv_chromium
$ adb push system/lib/libyuv_chromium.so /system/lib/ && \
adb push system/lib64/libyuv_chromium.so /system/lib64/
# libcameraservice
$ adb push system/lib64/libcameraservice.so /system/lib64
# stop all possible camera related things
$ adb shell am force-stop com.android.camera2 && adb shell stop vendor.camera-provider-2-5 && adb shell stop cameraserver
# restart hal and camera server
$ adb shell start cameraserver && adb shell start vendor.camera-provider-2-5
The Camera app disappears after booting Android
The Android Camera app runs on the first Android boot to detect whether a physical camera sensor is present and useable by the device. If it can’t find one, it will disable itself and thus disappear from the launcher.
To re-enable it, use package manager via adb
:
$ adb root
$ adb shell pm enable com.android.camera2/com.android.camera.CameraLauncher