I am trying to set up dual MIPI cameras with a Firefly RK3399 development board running Android as 'demonstrated' here. The RK3399 has dual MIPI-CSI camera ports which can be used with an OV13850 camera board also sold by Firefly.

The Problem

I tried plugging in two of the OV13850 camera modules and using this cam_board.xml. I started by using the CameraExample app that comes on the Firefly Android build. It almost works with both cameras capturing video streams at the same time. However, the cameras cannot auto focus, nor do they seem to have auto white balance and auto exposure adjustment. In fact, both cameras will rapidly and indiscriminately cycle through different focuses, exposures and white balances. This is not acceptable for my application.

When I open the normal camera app, the cameras appear as front and rear (as expected). The difference in the normal camera app is only one camera is active at a time, and as a result, the cameras auto focus, white balance and exposure begin to work again (for both front and rear cameras).

My Hypothesis

As can be seen in Schematic 1, the camera uses I²C for control (which I assume includes auto focus, etc.). Schematic 2 shows that the dual cameras are placed on the same I²C line on the RK3399. Finally, I assume that identical OV13850 camera modules will use the same I²C address.

So, my theory is that the reason both cameras cannot focus (or anything else) at the same time, is because they have the same I²C address on the same I²C bus so they cannot be operated independently. In other words, all control commands going from the RK3399 go to both cameras at the same time.

I think this explains the rapid cycling of focus (etc.) as the cameras are supplying conflicting information about lighting conditions and are simultaneously being adjusted to better fit those conflicting conditions.

My Attempted Solution

So the obvious thing to do is to move the second camera to a different I²C bus. Table 1 shows the RK3399 has multiple different I²C buses available. The cameras currently use bus 1 and my attempted solution was to move the second camera to bus 4.

To change the bus I modified one of my OV13850 camera boards (Schematic 1) to disconnect I2C3_SDA and I2C3_SCL. I then attached new wires to the camera side of I2C3_SDA and I2C3_SCL (pins 19 and 20 of J23) as well as a third wire connecting to DOVVD_1V8.

At this stage I checked my modifications to make sure I hadn't broken the camera module. I did so by connecting the I2C3_SDA wire to pin 23 and the I2C3_SCL wire to pin 24 of the RK3399's GPIO interface (Schematic 3). Pins 23 and 24 correspond to I²C bus 1 thus recreating the connection I disconnected earlier. This test was successful in that I observed the exact same behaviour I observed "The Problem".

The next problem is that I²C bus 4 is 3.0V while I²C bus 1 is 1.8V (Table 1). To solve this I created the I²C level shiftier in Schematic 4. Looking through the RK3399 schematic I found that all the I²C lines are pulled up with 2.2kΩ resistors so that is why added 2.2kΩ resistors to the camera side of the level shifter.

I tested the circuit in Schematic 4 by supplying 1.8V to DOVVD_1V8 and (for testing only) adding some extra pull up resistors to 3V on the RK3399 side. I then grounded SCL, SDA and I2C3_SDA individually and then checked the respective other side by measuring the voltage and ensuring it was very close to 0V.

More Problems

All that was left at this point was to hook it all up and test it. First, the unmodified camera board was placed in to the first MIPI-CSI slot on the RK3399. Next the modified camera board was placed in to the second MIPI-CSI slot. The additional wires from the modified board were plugged into their respective locations in Schematic 4. Next SDA and SCL in Schematic 4 were connected to pins 25 and 26 on the RK3399's GPIO interface (Schematic 3). Finally, I modified cam_board.xml by changing the SensorI2cBusNum to 4 for the second camera only.

I restarted the RK3399 and opened the CameraExample app to find that only the video stream from the modified camera was appearing. But that one video stream focused and auto adjusted for exposure and white balance perfectly. The video stream from the unmodified camera was completely black however the app still displayed that the camera existed. I then opened the normal camera app and both cameras still appeared as front and rear and worked just as they did before any modification. So, I think this means that both cameras operate correctly (including independent focus, exposure and white balance) however I can not record two video streams at the same time.

I also tried swapping the modified and unmodified cameras around (so the modified camera was in the first MIPI-CSI port and the unmodified camera was in the second MIPI-CSI port). For this test I also swapped the SensorI2cBusNum values in cam_board.xml. This produced the surprising result that the CameraExample app displayed neither video stream with both appearing black. But, the normal camera app continued to operate perfectly with both cameras. So, I again think this means that both cameras operate correctly (including independent focus, exposure and white balance) however do not know why no video streams can be recorded in the CameraExample app.


Are my assumptions correct? Can I reroute an I²C bus used in a MIPI-CSI connector?

What are possible reasons I could have lost the ability to record two video streams simultaneously after my modification (especially seeing as both cameras work fine individually)?

I know my questions are kind of generic but I am really stuck and am looking for a lead as to why I can't record two video streams at once.

Finally, if there is a more appropriate Stack Exchange site for this question let me know.

Thanks, James


OV13850 camera board Schematic 1: OV13850 camera board

Dual MIPI-CSI connector on RK3399 Schematic 2: Dual MIPI-CSI connector on RK3399 (from RK3399 schematic page 29)

enter image description here Schematic 3: RK3399 GPIO interface (full document here)

My 1.8V ↔ 3.0V I²C level shiftier Schematic 4: My 1.8V ↔ 3.0V I²C level shiftier (2N2222A, 1N5711)

enter image description here Table 1: RK3399 I²C map (from RK3399 schematic page 2)


protected by Community Apr 1 at 11:48

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Browse other questions tagged or ask your own question.