HD and SD Streams from AR0521 camera

Hi @rudhi.tx I’m not using torizon os but have installed the necessary on our custom image now so will let you know how resetting the pin goes.

Ty

Hi @rudhi.tx we’ve had another crash and I’ve tried the reset, but don’t think I know the magic :slight_smile:

here’s the ouput from gpioinfo

 gpioinfo
gpiochip0 - 32 lines:
        line   0: "SODIMM_206"       unused   input  active-high
        line   1: "SODIMM_208"       unused   input  active-high
        line   2:      unnamed       unused   input  active-high
        line   3:      unnamed  "interrupt"   input  active-high [used]
        line   4:      unnamed    "sd-vsel"  output  active-high [used]
        line   5: "SODIMM_210"       unused   input  active-high
        line   6: "SODIMM_212"       unused   input  active-high
        line   7: "SODIMM_216" "ar0521_mipi_reset" output active-high [used]
        line   8: "SODIMM_218" "ar0521_mipi_pwdn" output active-high [used]
        line   9:      unnamed       unused  output  active-high
        line  10:      unnamed  "interrupt"   input  active-high [used]
        line  11:  "SODIMM_16"       unused   input  active-high
        line  12: "SODIMM_155" "regulator-usb1-vbus" output active-high [used]
        line  13: "SODIMM_157"       unused   input  active-high
        line  14: "SODIMM_185" "regulator-usb2-vbus" output active-high [used]
        line  15:  "SODIMM_91"       unused   input  active-high
        line  16:      unnamed       unused   input  active-high
        line  17:      unnamed       unused   input  active-high
        line  18:      unnamed       unused   input  active-high
        line  19:      unnamed       unused   input  active-high
        line  20:      unnamed       unused   input  active-high
        line  21:      unnamed       unused   input  active-high
        line  22:      unnamed       unused   input  active-high
        line  23:      unnamed       unused   input  active-high
        line  24:      unnamed       unused   input  active-high
        line  25:      unnamed       unused   input  active-high
        line  26:      unnamed       unused   input  active-high
        line  27:      unnamed       unused   input  active-high
        line  28:      unnamed       unused   input  active-high
        line  29:      unnamed       unused   input  active-high
        line  30:      unnamed       unused   input  active-high

When I perform commands like this

gpioset gpiochip0 7=0

I just get “device busy” presumably because I can’t actually unload that built in kernel module?

Hello @alan01252,

I thought you were using Torizon because you tagged “torizon” on the topic. Anyway, if you are using a Yocto built image based on the meta layers for the reference image BSP 6 from Toradex, you should already have the libgpiod library in it.

Do you see only the gpiochip0 lines when you run gpioinfo?

Also, could you try to set the ar0521_mipi_pwdn to 0? ie, gpioset 0 8=0

Whoops sorry about the Torizon tag @rudhi.tx , I’ll blame my lack of familiarity with the ecosystem when creating this thread for that one…

Unfortunately I get the same thing there too.

gpioset 0 8=0
gpioset: error setting the GPIO line values: Device or resource busy

I also tried removing the galcore and imx8_media_dev and killing anything that was using /dev/video but nothing seemed to work :frowning:

Module                  Size  Used by
imx8_media_dev         24576  0
galcore               393216  2

For completeness here’s the full gpioinfo

gpiochip0 - 32 lines:
        line   0: "SODIMM_206"       unused   input  active-high
        line   1: "SODIMM_208"       unused   input  active-high
        line   2:      unnamed       unused   input  active-high
        line   3:      unnamed  "interrupt"   input  active-high [used]
        line   4:      unnamed    "sd-vsel"  output  active-high [used]
        line   5: "SODIMM_210"       unused   input  active-high
        line   6: "SODIMM_212"       unused   input  active-high
        line   7: "SODIMM_216" "ar0521_mipi_reset" output active-high [used]
        line   8: "SODIMM_218" "ar0521_mipi_pwdn" output active-high [used]
        line   9:      unnamed       unused  output  active-high
        line  10:      unnamed  "interrupt"   input  active-high [used]
        line  11:  "SODIMM_16"       unused   input  active-high
        line  12: "SODIMM_155" "regulator-usb1-vbus" output active-high [used]
        line  13: "SODIMM_157"       unused   input  active-high
        line  14: "SODIMM_185" "regulator-usb2-vbus" output active-high [used]
        line  15:  "SODIMM_91"       unused   input  active-high
        line  16:      unnamed       unused   input  active-high
        line  17:      unnamed       unused   input  active-high
        line  18:      unnamed       unused   input  active-high
        line  19:      unnamed       unused   input  active-high
        line  20:      unnamed       unused   input  active-high
        line  21:      unnamed       unused   input  active-high
        line  22:      unnamed       unused   input  active-high
        line  23:      unnamed       unused   input  active-high
        line  24:      unnamed       unused   input  active-high
        line  25:      unnamed       unused   input  active-high
        line  26:      unnamed       unused   input  active-high
        line  27:      unnamed       unused   input  active-high
        line  28:      unnamed       unused   input  active-high
        line  29:      unnamed       unused   input  active-high
        line  30:      unnamed       unused   input  active-high
        line  31:      unnamed       unused   input  active-high
gpiochip1 - 32 lines:
        line   0:      unnamed       unused   input  active-high
        line   1:      unnamed       unused   input  active-high
        line   2:      unnamed       unused   input  active-high
        line   3:      unnamed       unused   input  active-high
        line   4:      unnamed       unused   input  active-high
        line   5:      unnamed       unused   input  active-high
        line   6: "SODIMM_143"       unused   input  active-high
        line   7: "SODIMM_141"       unused   input  active-high
        line   8:      unnamed       unused   input  active-high
        line   9:      unnamed       unused   input  active-high
        line  10: "SODIMM_161"         "id"   input  active-high [used]
        line  11:      unnamed "regulator-wifi-en" output active-high [used]
        line  12:  "SODIMM_84"         "cd"   input   active-low [used]
        line  13:  "SODIMM_78"       unused   input  active-high
        line  14:  "SODIMM_74"       unused   input  active-high
        line  15:  "SODIMM_80"       unused   input  active-high
        line  16:  "SODIMM_82"       unused   input  active-high
        line  17:  "SODIMM_70"       unused   input  active-high
        line  18:  "SODIMM_72"       unused   input  active-high
        line  19:      unnamed       unused   input  active-high
        line  20:      unnamed "regulator-module-eth1phy" output active-high [used]
        line  21:      unnamed       unused   input  active-high
        line  22:      unnamed       unused   input  active-high
        line  23:      unnamed       unused   input  active-high
        line  24:      unnamed       unused   input  active-high
        line  25:      unnamed       unused   input  active-high
        line  26:      unnamed       unused   input  active-high
        line  27:      unnamed       unused   input  active-high
        line  28:      unnamed       unused   input  active-high
        line  29:      unnamed       unused   input  active-high
        line  30:      unnamed       unused   input  active-high
        line  31:      unnamed       unused   input  active-high
gpiochip2 - 32 lines:
        line   0:  "SODIMM_52" "red:debug-1" output active-high [used]
        line   1:  "SODIMM_54" "green:debug-1" output active-high [used]
        line   2:      unnamed       unused   input  active-high
        line   3:      unnamed       unused   input  active-high
        line   4:      unnamed       unused   input  active-high
        line   5:      unnamed       unused   input  active-high
        line   6:  "SODIMM_56" "blue:debug-1" output active-high [used]
        line   7:  "SODIMM_58" "red:debug-2" output active-high [used]
        line   8:  "SODIMM_60" "green:debug-2" output active-high [used]
        line   9:  "SODIMM_62" "blue:debug-2" output active-high [used]
        line  10:      unnamed       unused   input  active-high
        line  11:      unnamed       unused   input  active-high
        line  12:      unnamed       unused   input  active-high
        line  13:      unnamed       unused   input  active-high
        line  14:  "SODIMM_66"       unused   input  active-high
        line  15:      unnamed       unused   input  active-high
        line  16:  "SODIMM_64"       unused   input  active-high
        line  17:      unnamed       unused   input  active-high
        line  18:      unnamed       unused   input  active-high
        line  19:  "SODIMM_34"       unused   input  active-high
        line  20:  "SODIMM_19"       unused   input  active-high
        line  21:      unnamed       unused   input  active-high
        line  22:  "SODIMM_32"       unused   input  active-high
        line  23:      unnamed       unused   input  active-high
        line  24:      unnamed       unused   input  active-high
        line  25:  "SODIMM_30"       unused   input  active-high
        line  26:  "SODIMM_59"       unused   input  active-high
        line  27:  "SODIMM_57"       unused   input  active-high
        line  28:  "SODIMM_63"       unused   input  active-high
        line  29:  "SODIMM_61"       unused   input  active-high
        line  30:      unnamed       unused   input  active-high
        line  31:      unnamed       unused   input  active-high
gpiochip3 - 32 lines:
        line   0: "SODIMM_252"    "Wake-Up"   input   active-low [used]
        line   1: "SODIMM_222"       unused   input  active-high
        line   2:  "SODIMM_36"       unused   input  active-high
        line   3: "SODIMM_220"       unused   input  active-high
        line   4: "SODIMM_193"       unused   input  active-high
        line   5: "SODIMM_191"       unused   input  active-high
        line   6: "SODIMM_201"       unused   input  active-high
        line   7: "SODIMM_203"       unused   input  active-high
        line   8: "SODIMM_205"       unused   input  active-high
        line   9: "SODIMM_207"       unused   input  active-high
        line  10: "SODIMM_199"       unused   input  active-high
        line  11: "SODIMM_197"       unused   input  active-high
        line  12: "SODIMM_221"       unused   input  active-high
        line  13: "SODIMM_219"       unused   input  active-high
        line  14: "SODIMM_217"       unused   input  active-high
        line  15: "SODIMM_215"       unused   input  active-high
        line  16: "SODIMM_211"       unused   input  active-high
        line  17: "SODIMM_213"       unused   input  active-high
        line  18: "SODIMM_189"       unused   input  active-high
        line  19: "SODIMM_244"       unused  output  active-high
        line  20:  "SODIMM_38"       unused   input  active-high
        line  21:      unnamed       unused   input  active-high
        line  22:  "SODIMM_76" "regulator-usdhc2" output active-high [used]
        line  23: "SODIMM_135"       unused   input  active-high
        line  24: "SODIMM_133"       unused   input  active-high
        line  25:  "SODIMM_17"       unused   input  active-high
        line  26:  "SODIMM_24"       unused   input  active-high
        line  27:  "SODIMM_26"       unused   input  active-high
        line  28:  "SODIMM_21"       unused   input  active-high
        line  29: "SODIMM_256" "CTRL_SLEEP_MOCI#" output active-high [used]
        line  30:  "SODIMM_48"       unused   input  active-high
        line  31:  "SODIMM_44"       unused   input  active-high
gpiochip4 - 32 lines:
        line   0:  "SODIMM_42"       unused   input  active-high
        line   1:  "SODIMM_46"       unused   input  active-high
        line   2: "SODIMM_187"       unused   input  active-high
        line   3:  "SODIMM_20"       unused   input  active-high
        line   4:  "SODIMM_22"       unused   input  active-high
        line   5:  "SODIMM_15"       unused   input  active-high
        line   6: "SODIMM_196"       unused   input  active-high
        line   7: "SODIMM_200"       unused   input  active-high
        line   8: "SODIMM_198"       unused   input  active-high
        line   9: "SODIMM_202"       unused   input  active-high
        line  10:      unnamed       unused   input  active-high
        line  11:      unnamed       unused   input  active-high
        line  12:      unnamed       unused   input  active-high
        line  13:      unnamed       unused   input  active-high
        line  14:      unnamed        "scl"  output  active-high [used open-drain]
        line  15:      unnamed        "sda"   input  active-high [used open-drain]
        line  16:  "SODIMM_55"        "scl"  output  active-high [used open-drain]
        line  17:  "SODIMM_53"        "sda"   input  active-high [used open-drain]
        line  18:  "SODIMM_95"        "scl"  output  active-high [used open-drain]
        line  19:  "SODIMM_93"        "sda"   input  active-high [used open-drain]
        line  20:  "SODIMM_14"        "scl"  output  active-high [used open-drain]
        line  21:  "SODIMM_12"        "sda"   input  active-high [used open-drain]
        line  22: "SODIMM_129"       unused   input  active-high
        line  23: "SODIMM_131"       unused   input  active-high
        line  24: "SODIMM_137"       unused   input  active-high
        line  25: "SODIMM_139"       unused   input  active-high
        line  26: "SODIMM_147"       unused   input  active-high
        line  27: "SODIMM_149"       unused   input  active-high
        line  28: "SODIMM_151"       unused   input  active-high
        line  29: "SODIMM_153"       unused   input  active-high
        line  30:      unnamed       unused   input  active-high
        line  31:      unnamed       unused   input  active-high

Thanks again for all your help on this!

Hello @alan01252,

I want to confirm that we were able to reproduce the camera freeze in our testing.

Also, upon further investigation, the driver requires ownership of the reset and power down GPIOs to function.
Therefore, removing those GPIOs from the ar0521 device tree node is not possible and this makes it impossible to toggle these GPIOs outside of the driver.

Another detail which we initially missed when thinking about this workaround is that the ar0521 driver is built-in to the kernel, and does not work if built as an external module.
This means that we have no way to unload this driver at runtime.

I will raise this internally so we solve this problem.
Just to confirm, do you plan to use the AR0521 camera module in your product?

Best Regards,
Bruno

Really appreciate this Bruno. I am actually having my longest run right now ever at 2024-07-07 08:46 UTC start time without a hang…

Do you have any idea what the cause might be at the moment.

Just to confirm, do you plan to use the AR0521 camera module in your product?

I guess the answer to this is whether we think this crashing is specific to this hardware/driver combination…

We are looking at other sensors but these don’t have the “out of the box” support that this one should have and we’re likely going to require external consultancy firm to write the drivers to support it.

Hello @alan01252,

Unfortunately no specific cause is clear at the moment.
It may be related to the camera module’s firmware or the driver.
What I can say is that I had conducted tests with this camera driver for several days with previous versions of the Toradex BSP in the past without issues, so it may also be related to a change done to the BSP.


Noted, we will conduct additional tests and look into what may be the problem here.
There is some work being done to support more camera modules on the Verdin iMX8MP, so there may be alternatives very soon.
What are your requirements in terms of the image resolution and focus?

Best Regards,
Bruno

Hello @alan01252,

We have found a possible workaround to the problem.
It does not solve the issue but could allow the camera to be reset after the problem is encountered.

The next time you face this problem, can you try to unbind and bind the driver with the following commands?

echo 2-0042 > /sys/bus/i2c/drivers/ar0521/unbind
echo 2-0042 > /sys/bus/i2c/drivers/ar0521/bind

Best Regards,
Bruno

@bruno.tx thanks so much :slight_smile:

I’ll give it a go and see what happens. Been crash free for about 40 hours atm…

@bruno.tx I can confirm this allows me to get the stream working again after a hang without requiring a hard reboot.

Any more clues about what the root cause might be?

Ty

Hello @alan01252,

Thanks for the update.

Unfortunately not yet.
We will escalate this problem to the camera manufacturer, as they provided the driver.

Best Regards,
Bruno

Hello @alan01252,

I just wanted to give you an update: we are actively working with the camera manufacturer to get this issue resolved.

Best Regards,
Bruno

1 Like

Hi there,

Has this issue been resolved ?

We are desperately needing this bug fixed ASAP.

Kind regards

Hello @btj2,

The camera manufacturer has sent us an updated driver this week.
I will do some initial validation tests and make it available in a separate branch of meta-toradex-econ.

When it is available there, I will send an update here.

Best Regards,
Bruno

Hi Bruno,

Thanks for that! is there any ETA on when the driver will be available? Communicating with Jung Jeong, he mentioned it would be ready soon?

Kind regards,
Ben

Hello @alan01252 and @btj2,

I was able to do some initial tests with the new driver and it works with the Verdin iMX8MP.
Please note that long term tests are ongoing and it is possible the driver still has some issues after a long runtime.

To use the new driver, you simply need to use the dev-6.7.0 branch of meta-toradex-econ in your build.

Please note that this update includes a firmware upgrade, so the first boot will take 4-5 minutes.
**Do not turn off or reset the module during the firmware update**.

If you have any issues with this new driver please let me know.
I will update this thread with the results of the long term testing once enough time has elapsed.

Best Regards,
Bruno

1 Like

Hello @btj2,

I am just having trouble building the dev image via the instructions on the toradex page. Would you by any chance have a latest development image with the latest driver installed to run the camera, from your testing? If you could share that, it would be much appreciated.

Can you open another topic to go over these issues?
Even if we provide an image, you will eventually need to be able to build your own, so it would be important to enable you to do so.

Best Regards,
Bruno

Hi Bruno,

Is there any update on the long term functioning of the AR0521 camera layer? I got the image to build with it added finally with torizon-core-docker dev 6.8.0

Kind regards,

Ben

@btj2, there has been not enough time elapsed to conclude anything yet.
So far there have been no problems with over 48h+ of continuous runtime.

I will give an update if it crashes or if it works continuously without issues for 7 days or longer.

Best Regards,
Bruno

Hi Bruno,
It does not appear to be working long term for us as it failed within a matter of hours last night. We are using verdin imx8mp with a torizon application ide v2 in debug. Is that a problem? would a production image make it more reliable etc.

Kind regards