Debugging CSI/VI interface (TC358743 connected to Toradex Apalis TK1)

Hello Forum!

For quite some time I now try to get a TC358743 HDMI-to-CSI-2 adapter working (with a Non-Jetson board). I first tried with an T30, but now switched to a Tegra K1 due to the newer available kernel.
However, I can not get video output, a captured file always only contains zeroes (0x00), which gives a dark green image when rendered as a YUV image.

My current setup is as follows:

Whatever I try, I was not able to get something different than zeros (or prefilled buffer data) in the captured file when using the HDMI adapter. I tried with tegra_camera’s tpg_mode, which works just fine. The resulting image then can be rendered as a colourful checker pattern.
I added some more debugging to the TC358743 driver and tegra_camera to hopefully find the problem. I configured CSI debug counter 0 to count PPA line packets and counter 1 for frame starts.
This is what I get in the kernel log when I run

./yavta /dev/video0 -c1 -n1 -Fhdmi.rgba

==========
[ 2324.234137] tc358743_s_fmt: Resetting…
[ 2325.866007] tc358743_s_fmt: Setting HDMI…
[ 2326.115252] Image is 640x480@60, ~295 Gbps bandwidth (~148MHz/lane)
[ 2326.115431] Setting pll to frequency 500 (500) MHz
[ 2326.125300] tc358743_s_fmt: Starting stream
[ 2326.129046] tc358743 2-000f: -----Chip status-----
[ 2326.135190] tc358743 2-000f: Chip ID: 0x00
[ 2326.140737] tc358743 2-000f: Chip revision: 0x00
[ 2326.146658] tc358743 2-000f: Reset: IR: 0, CEC: 0, CSI TX: 0, HDMI: 0
[ 2326.154297] tc358743 2-000f: Sleep mode: off
[ 2326.159871] tc358743 2-000f: Cable detected (+5V power): yes
[ 2326.166711] tc358743 2-000f: DDC lines enabled: no
[ 2326.172645] tc358743 2-000f: Hotplug enabled: no
[ 2326.179136] tc358743 2-000f: CEC enabled: no
[ 2326.184391] tc358743 2-000f: -----Signal status-----
[ 2326.190215] tc358743 2-000f: TMDS signal detected: yes
[ 2326.196216] tc358743 2-000f: Stable sync signal: yes
[ 2326.201974] tc358743 2-000f: PHY PLL locked: yes
[ 2326.207427] tc358743 2-000f: PHY DE detected: yes
[ 2326.215691] tc358743 2-000f: Detected format: 640x480p60.0 (800x525)
[ 2326.222954] tc358743 2-000f: horizontal: fp = 0, -sync = 160, bp = 0
[ 2326.230780] tc358743 2-000f: vertical: fp = 0, -sync = 45, bp = 0
[ 2326.238805] tc358743 2-000f: pixelclock: 25200000
[ 2326.244497] tc358743 2-000f: standards (0x0):
[ 2326.250027] tc358743 2-000f: -----CSI-TX status-----
[ 2326.256076] tc358743 2-000f: Lanes in use: 2
[ 2326.261404] tc358743 2-000f: Waiting for particular sync signal: no
[ 2326.268773] tc358743 2-000f: Transmit mode: no
[ 2326.274424] tc358743 2-000f: Receive mode: no
[ 2326.279830] tc358743 2-000f: Stopped: no
[ 2326.285183] tc358743 2-000f: -----HDMI status-----
[ 2326.290726] tc358743 2-000f: HDCP encrypted content: no
[ 2326.296812] tc358743 2-000f: Input color space: RGB full range
[ 2326.303620] tc358743 2-000f: VI_MUTE: 0xc0
[ 2326.308399] tc358743 2-000f: AV Mute: off
[ 2326.313272] tc358743 2-000f: Deep color mode: 8-bits per channel
[ 2326.321672] vi vi.0: tegra_camera_videobuf_prepare (vb=0xec9a6000) 0xf0b01000 614400
[ 2326.333995] vi vi.0: Failed to create debugfs directory
[ 2326.343546] vi vi.0: MIPI calibration for CSI is done
[ 2326.374781] vi vi.0: syncpt reached, status:
[ 2326.400803] TEGRA_CSI_DEBUG_COUNTER_0 0x000001e0
[ 2326.406351] TEGRA_CSI_DEBUG_COUNTER_1 0x00000001
[ 2326.412001] TEGRA_CSI_DEBUG_COUNTER_2 0x00000000
[ 2326.417652] TEGRA_CSI_CSI_CIL_A_STATUS 0x00000000
[ 2326.423341] TEGRA_CSI_CSI_CILA_STATUS 0x00000000
[ 2326.428729] TEGRA_CSI_CSI_CIL_B_STATUS 0x00000000
[ 2326.434312] TEGRA_CSI_CSI_CIL_C_STATUS 0x00000000
[ 2326.439702] TEGRA_CSI_CSI_CIL_D_STATUS 0x00000000
[ 2326.445265] TEGRA_CSI_CSI_CIL_E_STATUS 0x00000000
[ 2326.450648] TEGRA_CSI_CSI_PIXEL_PARSER_A_STATUS 0x00000000
[ 2326.456915] TEGRA_CSI_CSI_PIXEL_PARSER_B_STATUS 0x00000000
[ 2326.463030] TEGRA_VI_CSI_0_ERROR_STATUS 0x00000000
[ 2326.468416] TEGRA_VI_CSI_1_ERROR_STATUS 0x00000000

Yavta shows the following output:

Device /dev/video0 opened: vi ().
Video format: UYVY (59565955) 640x480
1 buffers requested.
length: 614400 offset: 0
Buffer 0 mapped at address 0xb6d7c000.
0 (0) 0 614400 bytes 1474031924.002136 1474031924.002268
Captured 0 frames in 0.032367 seconds (0.000000 fps, 18982296.783761 B/s).
1 buffers released.

This looks perfectly good to me: No error flags set, 480 line packets and one frame start received. Now I do not know whether the HDMI bridge is just outputting all zeroes or whether the data is lost somewhere else…
I tried to configure the test pattern generator inside the TC358743, but the functional specification I have was not very helpful. I tried register value sets from an older version of the Antmicro driver, but the result was the same: All 0s, green image…

I am currently at a loss. I do not know what else I could try to debug the issue. I once had the CSI data- and clock lines connected to an oscilloscope, but due to the high speed nature of the signals I was not really able to manually decode whether there are really just zeroes beeing sent. Sadly, the scope is now quite a few kilometres away.

Do you have any other ideas what to test? Thank you!

I’m sorry for the rather long text, but I tried to include all the information I currently have.

Kind regards,
Stefan

If you didn’t get any “syncpt timeout” message from the vi.c that means TK1 already received the frame without problem. You can try program the TC358743 don’t output data to confirm it. After confirm it you need to debug the TC358743 to fixed the problem.

Make sure bit 24 of TEGRA_VI_CSI_n_IMAGE_DEF is not set in vi2.c.

Thank you for your reply!
I checked the source and I am certain that bit 24 only gets set when the TPG is enabled - which is not the case in my tests with the adapter connected.
I did not try to output the actual state of the register somewhere, but I do not see any place elsewhere in the code where the bit might get set. And the reset default is also 0…

Any other ideas?

Kind regards,
Stefan

For your case the CSI_CIL_X_STATUS all zero that mean TK1 didn’t receive any data from the mipi bus. You need to measure the mipi signal to make sure it match the mipi spec.

[ 2326.400803] TEGRA_CSI_DEBUG_COUNTER_0 0x000001e0
[ 2326.406351] TEGRA_CSI_DEBUG_COUNTER_1 0x00000001
[ 2326.412001] TEGRA_CSI_DEBUG_COUNTER_2 0x00000000
[ 2326.417652] TEGRA_CSI_CSI_CIL_A_STATUS 0x00000000
[ 2326.423341] TEGRA_CSI_CSI_CILA_STATUS 0x00000000
[ 2326.428729] TEGRA_CSI_CSI_CIL_B_STATUS 0x00000000
[ 2326.434312] TEGRA_CSI_CSI_CIL_C_STATUS 0x00000000
[ 2326.439702] TEGRA_CSI_CSI_CIL_D_STATUS 0x00000000
[ 2326.445265] TEGRA_CSI_CSI_CIL_E_STATUS 0x00000000
[ 2326.450648] TEGRA_CSI_CSI_PIXEL_PARSER_A_STATUS 0x00000000
[ 2326.456915] TEGRA_CSI_CSI_PIXEL_PARSER_B_STATUS 0x00000000
[ 2326.463030] TEGRA_VI_CSI_0_ERROR_STATUS 0x00000000
[ 2326.468416] TEGRA_VI_CSI_1_ERROR_STATUS 0x00000000

By chance I today discovered that Toradex provides an updated version of their BSP for the module:
http://developer.toradex.com/files/toradex-dev/uploads/media/Colibri/Linux/Images/Apalis_TK1_LinuxImageV2.6.1Beta2_20161122.tar.bz2

In the relase notes it said:

integrate ADV7280-M, AP1302, OV5640 and TC358743 camera support

So of course I had to try that - and to my (very big) enjoyment it WORKED!
With that image I only had to do

modprobe tegra_camera

and then

./yavta /dev/video0 -c1 --file=hdmi.rgba

finally produced a file that could be parsed into an image. :) Hooray!

I did not yet check what’s the difference between the new BSP and my attempts. The basic driver seems to be the same one (from Antmicro)…

Kind regards,
Stefan