Kernel panic when using bayer "bggr" format

Hi nvidia,

My camera output format is Bayer BGGR 12-bit as following:

When I set pixel_phase = "bggr" in dts, and insmod camer driver module, Kernel panic is happening.

[   95.110755] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
[   95.110762] Mem abort info:
[   95.110764]   ESR = 0x0000000096000004
[   95.110766]   EC = 0x25: DABT (current EL), IL = 32 bits
[   95.110769]   SET = 0, FnV = 0
[   95.110770]   EA = 0, S1PTW = 0
[   95.110772]   FSC = 0x04: level 0 translation fault
[   95.110773] Data abort info:
[   95.110774]   ISV = 0, ISS = 0x00000004
[   95.110776]   CM = 0, WnR = 0
[   95.110777] user pgtable: 4k pages, 48-bit VAs, pgdp=000000010a718000
[   95.110781] [0000000000000000] pgd=0000000000000000, p4d=0000000000000000
[   95.110790] Internal error: Oops: 0000000096000004 [#1] PREEMPT_RT SMP
[   95.110795] Modules linked in: nv_ox03c10(OE+) nvidia_modeset(O) tegra_pcie_dma_test(O) tegra_pcie_edma(O) xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink ip6table_nat ip6table_filter ip6_tables iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c xt_addrtype iptable_filter br_netfilter lzo_rle lzo_compress zram zsmalloc bridge stp llc usb_f_ncm snd_soc_tegra186_asrc(O) snd_soc_tegra210_admaif(O) snd_soc_tegra210_mixer(O) snd_soc_tegra_pcm snd_soc_tegra210_ope(O) snd_soc_tegra210_mvc(O) snd_soc_tegra186_arad(O) snd_soc_tegra210_afc(O) snd_soc_tegra186_dspk(O) snd_soc_tegra210_dmic(O) snd_soc_tegra210_adx(O) snd_soc_tegra210_amx(O) snd_soc_tegra210_sfc(O) snd_soc_tegra210_i2s(O) tegra210_adma snd_soc_tegra210_ahub(O) usb_f_acm u_serial spidev nvvrs_pseq_rtc(O) usb_f_rndis rfkill joydev u_ether cdc_acm ramoops reed_solomon snd_soc_tegra_machine_driver(O) snd_soc_tegra_utils(O) crct10dif_ce tegra234_oc_event(O) snd_soc_simple_card_utils tegra23x_perf_uncore(O)
[   95.110874]  nvpmodel_clk_cap(O) tegra_mce(O) mttcan(O) snd_hda_codec_hdmi thermal_trip_event(O) tegra_cactmon_mc_all(O) nvethernet(O) tegra234_aon(O) can_dev tegra_aconnect nvpps(O) phy_tegra194_p2u snd_soc_rt5640 snd_hda_tegra pwm_tegra_tachometer(O) snd_hda_codec snd_soc_rl6231 at24 snd_hda_core gpio_sgm4591q tegra_xudc spi_tegra114 i2c_nvvrs11(O) nvidia(O) lm90 mc_hwpm(O) host1x_fence(O) nvidia_vrs_pseq(O) pcie_tegra194 tegra_dce(O) nvhost_vi5(O) nvhost_isp5(O) nvhost_nvcsi_t194(O) tegra_camera(O) v4l2_dv_timings nvhost_nvcsi(O) libcomposite tegra_camera_platform(O) capture_ivc(O) tegra_camera_rtcpu(O) ivc_bus(O) governor_userspace hsp_mailbox_client(O) ivc_ext(O) v4l2_fwnode v4l2_async videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 tegra_drm(O) videobuf2_common videodev nvhost_pva(O) nvhost_nvdla(O) tegra_wmark(O) tsecriscv(O) mc nvhost_capture(O) cec tegra_se(O) nvhwpm(O) drm_kms_helper crypto_engine host1x_nvhost(O) nvidia_p2p(O) ina3221 nvgpu(O) governor_pod_scaling(O)
[   95.110959]  host1x(O) mc_utils(O) nvmap(O) drm nvsciipc(O) fuse ip_tables x_tables ipv6 pwm_fan pwm_tegra tegra_bpmp_thermal
[   95.110977] CPU: 1 PID: 2380 Comm: insmod Tainted: G           OE     5.15.136-rt-tegra #1
[   95.110982] Hardware name: NVIDIA NVIDIA Jetson AGX Orin Developer Kit/Jetson, BIOS 36.3.0-gcid-36191598 05/06/2024
[   95.110985] pstate: a0400009 (NzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   95.110990] pc : camera_common_g_fmt+0x4c/0xb0 [tegra_camera]
[   95.111029] lr : camera_common_g_fmt+0x30/0xb0 [tegra_camera]
[   95.111056] sp : ffff8000142734c0
[   95.111057] x29: ffff8000142734c0 x28: ffff0000aeee8c88 x27: 0000000000000038
[   95.111063] x26: ffffca0ada3ab910 x25: ffffca0ada3ab900 x24: ffff00008e842ab8
[   95.111067] x23: ffffca0ada305df0 x22: ffff0000d3f150b8 x21: ffff800014273578
[   95.111071] x20: ffff0000866d0420 x19: ffff800014273608 x18: ffffffffffffffff
[   95.111076] x17: 000000040044ffff x16: ffffca0b334d2f40 x15: ffff8000142734b8
[   95.111080] x14: ffffffffffffffff x13: 0000000000000000 x12: 0000000000000027
[   95.111084] x11: 0101010101010101 x10: ffff0000d3f15208 x9 : 7f7f7f7f7f7f7f7f
[   95.111089] x8 : fefeff2f64636e6c x7 : 0000000001808080 x6 : 0000000100000000
[   95.111093] x5 : 8080800000000000 x4 : 8000000000000000 x3 : 0000000000000001
[   95.111097] x2 : ffff0000d3f15080 x1 : 0000000000000000 x0 : 0000000000000000
[   95.111102] Call trace:
[   95.111104]  camera_common_g_fmt+0x4c/0xb0 [tegra_camera]
[   95.111130]  v4l2sd_get_fmt+0x30/0x40 [tegra_camera]
[   95.111157]  call_get_fmt+0x7c/0xa0 [videodev]
[   95.111187]  tegra_channel_fmts_bitmap_init+0x1b0/0x2b0 [tegra_camera]
[   95.111215]  tegra_channel_init_subdevices+0x18c/0x790 [tegra_camera]
[   95.111241]  tegra_vi_graph_notify_complete+0x2fc/0x670 [tegra_camera]
[   95.111266]  v4l2_async_notifier_try_complete.part.0+0x70/0x80 [v4l2_async]
[   95.111274]  v4l2_async_register_subdev+0x11c/0x1e0 [v4l2_async]
[   95.111280]  tegracam_v4l2subdev_register+0x104/0x180 [tegra_camera]
[   95.111306]  ox03c10_probe+0x118/0x168 [nv_ox03c10]
[   95.111315]  i2c_device_probe+0x2fc/0x340
[   95.111326]  really_probe.part.0+0xac/0x320
[   95.111337]  __driver_probe_device+0xa4/0x170
[   95.111342]  driver_probe_device+0x54/0x190
[   95.111348]  __driver_attach+0xa8/0x1b0
[   95.111353]  bus_for_each_dev+0x84/0xe0
[   95.111357]  driver_attach+0x38/0x50
[   95.111362]  bus_add_driver+0x118/0x210
[   95.111367]  driver_register+0x80/0x140
[   95.111373]  i2c_register_driver+0x5c/0xe0
[   95.111377]  ox03c10_i2c_driver_init+0x30/0x1000 [nv_ox03c10]
[   95.111384]  do_one_initcall+0x54/0x2e0
[   95.111391]  do_init_module+0x54/0x250
[   95.111400]  load_module+0x2148/0x2530
[   95.111406]  __do_sys_finit_module+0xa4/0xf0
[   95.111412]  __arm64_sys_finit_module+0x30/0x40
[   95.111415]  invoke_syscall+0x5c/0x130
[   95.111422]  el0_svc_common.constprop.0+0x64/0x110
[   95.111428]  do_el0_svc+0x74/0xa0
[   95.111434]  el0_svc+0x28/0x80
[   95.111443]  el0t_64_sync_handler+0xa4/0x130
[   95.111446]  el0t_64_sync+0x1a4/0x1a8
[   95.111451] Code: 540002e0 f9401041 52800023 52800000 (b9400024)
[   95.111458] ---[ end trace 0000000000000002 ]---

But when I set pixel_phase = "rggb" in dts, everything works fine, except that red and blue are swapped in images.

SDK release info is:
R36 (release), REVISION: 3.0, GCID: 36191598, BOARD: generic, EABI: aarch64, DATE: Mon May 6 17:34:21 UTC 2024

Appreciate your help.

Hi,

For the camera basic functionality first needs to check the device and driver configuration.
You can reference to below program guide for the detailed information of device tree and driver implementation.
https://docs.nvidia.com/jetson/archives/r36.3/DeveloperGuide/SD/CameraDevelopment/SensorSoftwareDriverProgramming.html?highlight=programing#sensor-software-driver-programming

Please refer to Applications Using V4L2 IOCTL Directly by using V4L2 IOCTL to verify basic camera functionality.
https://docs.nvidia.com/jetson/archives/r36.3/DeveloperGuide/SD/CameraDevelopment/SensorSoftwareDriverProgramming.html?highlight=programing#to-run-a-v4l2-ctl-test

Once confirm the configure and still failed below link help to get log and some information and some tips for debug.
https://elinux.org/Jetson/l4t/Camera_BringUp#Steps_to_enable_more_debug_messages

Thanks!

Hello @xinghui.g

Could you please share the full sensor device tree logs?

Regards!
Eduardo Salazar
Embedded SW Engineer at RidgeRun

Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com

Hi xxeevm,

We ran into this same issue on JetPack 6.0. The issue was the bayer_bggr12 pixel type in sensor_common.c did not have a matching camera_common_colorfmt entry in camera_common.c, leading to a null pointer dereference. You can fix it by upgrading to JetPack 6.1 or by applying this patch to JetPack 6.0’s sources:

--- a/nvidia-oot/drivers/media/platform/tegra/camera/camera_common.c
+++ b/nvidia-oot/drivers/media/platform/tegra/camera/camera_common.c
@@ -1,8 +1,18 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * camera_common.c - utilities for tegra camera driver
+// SPDX-License-Identifier: GPL-2.0 only
+/* SPDX-FileCopyrightText: Copyright (c) 2015-2024 NVIDIA CORPORATION & AFFILIATES.
+ * All rights reserved.
  *
- * Copyright (c) 2015-2023, NVIDIA CORPORATION.  All rights reserved.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 #include <linux/types.h>
 #include <media/tegra-v4l2-camera.h>
@@ -44,6 +54,11 @@ static const struct camera_common_colorfmt camera_common_color_fmts[] = {
 		V4L2_COLORSPACE_SRGB,
 		V4L2_PIX_FMT_SGBRG12
 	},
+	{
+		MEDIA_BUS_FMT_SBGGR12_1X12,
+		V4L2_COLORSPACE_SRGB,
+		V4L2_PIX_FMT_SBGGR12
+	},
 	{
 		MEDIA_BUS_FMT_SRGGB10_1X10,
 		V4L2_COLORSPACE_SRGB,

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.