etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Tue Oct 29, 2019 6:36 pm

HermannSW wrote:
Tue Oct 29, 2019 1:33 pm
https://pinout.xyz/#
BCM16 is pin 36.

If you don't see sync pulses, please use raspivid instead of picamera.
Here you can see a test procedure that does work even without a logic analyzer:
https://www.raspberrypi.org/forums/view ... 0#p1512529

Logic analyzer is preferrable as it eg. uncovers that raspivid does the first frames with preview framerate (40fps) and only later switches to framerate configured with "-fps" ...
Okay my final follow up is that I followed the instructions listed from the above link, and I am still getting all 0s even when I have raspivid running.

Here are my most recent steps for trying to get this hardware camera sync working:
1. Ran raspi-gpio get, and saw that from BANK1 GPIO 29 is an output pin that doesn't have a specific function listed besides output. In the device tree however, I did see a comment that it is for a GREEN LED, which might be a problem but I tried it anyway.
2. Changed my dt-blob.dts file so that under the 3bplus section (since I'm using the Raspberry Pi 3 Model B+) under the CAMERA_0_LED section to instead have "internal" and the pin number be 29. I made sure that pin 29 was set to "output" and "no_pulling" above.
3. Next I ran these lines at the terminal
---------------"while true; do gpio -g read 29; done", which showed always 0
---------------"raspivid -md 7 -t 0 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 & " in background (I also tried other variation of this command, such as not specifying a fps or b or p, still to no avail)
----------------"while true; do gpio -g read 29; done" then still showed all 0s :(
4. Double checked that in my config.txt file it says "disable_camera_led = 3"

Is there something I'm missing?
If anyone has input or can help in any way with troubleshooting I would really appreciate it. I feel like I'm so close.

Thank you all.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Tue Oct 29, 2019 7:14 pm

Drop back a level. Modify dt-blob.dts and compile it to dt-blob.bin with your preferred gpio choice.
Leave disable_camera_led alone.
When you start the camera it should turn that line on, and turn it off when the camera is closed. Until you have that working there is no point chasing your tale in trying to look for sync pulses.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Tue Oct 29, 2019 7:29 pm

6by9 wrote:
Tue Oct 29, 2019 7:14 pm
Drop back a level. Modify dt-blob.dts and compile it to dt-blob.bin with your preferred gpio choice.
Leave disable_camera_led alone.
When you start the camera it should turn that line on, and turn it off when the camera is closed. Until you have that working there is no point chasing your tale in trying to look for sync pulses.
Thank you this is a good idea, and I just tried it, but unfortunately I'm still getting all zeros. Is it possible I'm editing my dt-blob.dts file somehow incorrectly?

By leave disable_camera_led alone, I assume you meant comment it out.
I commented it out of the config.txt file, then I kept my dt-blob.dts file the same (using pin 29) since I already compiled it into a .bin file from earlier.
Then I ran in the terminal:
---------------"while true; do gpio -g read 29; done", which showed always 0
---------------"raspivid -md 7 -t 0 -w 640 -h 480 -p 0,0,640,480 & " in background
----------------then while raspivid was still runnning: "while true; do gpio -g read 29; done" still showed all 0s.....

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Tue Oct 29, 2019 8:34 pm

Something is obviously wrong in your dt-blob then. Reading back you say you're using NOOBS, and that's probably the issue (it normally is).

Looking at the PiCamera docs you quote, I'm not sure they're right in wanting to update the recovery partition. AIUI the partition mounted as /boot is the one with the active config.txt etc for your Raspbian install, and it is the same one that also needs dt-blob.bin. Try copying it in there instead.

And, yes, I meant to leave disable_camera_led either absent or set to 0.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Wed Oct 30, 2019 1:00 pm

6by9 wrote:
Tue Oct 29, 2019 8:34 pm
Something is obviously wrong in your dt-blob then. Reading back you say you're using NOOBS, and that's probably the issue (it normally is).

Looking at the PiCamera docs you quote, I'm not sure they're right in wanting to update the recovery partition. AIUI the partition mounted as /boot is the one with the active config.txt etc for your Raspbian install, and it is the same one that also needs dt-blob.bin. Try copying it in there instead.

And, yes, I meant to leave disable_camera_led either absent or set to 0.
Thank you for following up on this. I tried what you said, and after compiling instead placed it in /boot/ using "sudo cp dt-blob.bin /boot/" and yet after running the below, I still got all zeros. I even tried doing wget again to get a clean dt-blob.dts file from https://raw.githubusercontent.com/raspb ... t-blob.dts
I tried not adding any extra pin lines and just changing 29 to be the camera_0_LED pin with "internal" specified and I also tried again adding in like [email protected] and changing the camera_0_LED pin to 16. Still to no avail. If the issue is with my dt-blob.dts- is there somewhere else I should be getting it from with wget?

---------------"while true; do gpio -g read 29; done", which showed always 0
---------------"raspivid -md 7 -t 0 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 & " in background
----------------"while true; do gpio -g read 29; done" then still showed all 0s

Thank you, your help is much appreciated.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Wed Oct 30, 2019 1:06 pm

etest wrote:
Wed Oct 30, 2019 1:00 pm
6by9 wrote:
Tue Oct 29, 2019 8:34 pm
Something is obviously wrong in your dt-blob then. Reading back you say you're using NOOBS, and that's probably the issue (it normally is).

Looking at the PiCamera docs you quote, I'm not sure they're right in wanting to update the recovery partition. AIUI the partition mounted as /boot is the one with the active config.txt etc for your Raspbian install, and it is the same one that also needs dt-blob.bin. Try copying it in there instead.

And, yes, I meant to leave disable_camera_led either absent or set to 0.
Thank you for following up on this. I tried what you said, and after compiling instead placed it in /boot/ using "sudo cp dt-blob.bin /boot/" and yet after running the below, I still got all zeros. I even tried doing wget again to get a clean dt-blob.dts file from https://raw.githubusercontent.com/raspb ... t-blob.dts
I tried not adding any extra pin lines and just changing 29 to be the camera_0_LED pin with "internal" specified and I also tried again adding in like [email protected] and changing the camera_0_LED pin to 16. Still to no avail. If the issue is with my dt-blob.dts- is there somewhere else I should be getting it from with wget?

---------------"while true; do gpio -g read 29; done", which showed always 0
---------------"raspivid -md 7 -t 0 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 & " in background
----------------"while true; do gpio -g read 29; done" then still showed all 0s

Thank you, your help is much appreciated.
Nevermind! I rebooted and the simple test of checking that I get all 1s after changing the camera_0_LED to pin 16 worked!! You were right that I needed to instead do "sudo cp dt-blob.bin /boot/". Thank you!
Next to test out disable_camera_led in the config.txt file!

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Wed Oct 30, 2019 1:50 pm

etest wrote:
Wed Oct 30, 2019 1:06 pm
etest wrote:
Wed Oct 30, 2019 1:00 pm
6by9 wrote:
Tue Oct 29, 2019 8:34 pm
Something is obviously wrong in your dt-blob then. Reading back you say you're using NOOBS, and that's probably the issue (it normally is).

Looking at the PiCamera docs you quote, I'm not sure they're right in wanting to update the recovery partition. AIUI the partition mounted as /boot is the one with the active config.txt etc for your Raspbian install, and it is the same one that also needs dt-blob.bin. Try copying it in there instead.

And, yes, I meant to leave disable_camera_led either absent or set to 0.
Thank you for following up on this. I tried what you said, and after compiling instead placed it in /boot/ using "sudo cp dt-blob.bin /boot/" and yet after running the below, I still got all zeros. I even tried doing wget again to get a clean dt-blob.dts file from https://raw.githubusercontent.com/raspb ... t-blob.dts
I tried not adding any extra pin lines and just changing 29 to be the camera_0_LED pin with "internal" specified and I also tried again adding in like [email protected] and changing the camera_0_LED pin to 16. Still to no avail. If the issue is with my dt-blob.dts- is there somewhere else I should be getting it from with wget?

---------------"while true; do gpio -g read 29; done", which showed always 0
---------------"raspivid -md 7 -t 0 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 & " in background
----------------"while true; do gpio -g read 29; done" then still showed all 0s

Thank you, your help is much appreciated.
Nevermind! I rebooted and the simple test of checking that I get all 1s after changing the camera_0_LED to pin 16 worked!! You were right that I needed to instead do "sudo cp dt-blob.bin /boot/". Thank you!
Next to test out disable_camera_led in the config.txt file!
After testing disable_camera_led = 3 in the config.txt file, I noticed that the signal goes high and stays high for the entire during of capturing images. For example if I have a loop doing multiple separate captures, the signal goes high and stays high for all captures and only goes low when all captures end. Is there a way to get frame start/stop per capture? I've tried camera.capture() with camera.start_preview() and stop preview, and I've tried capture_continuous() but none of the options seem to allow for seeing the start/stop of frame per capture. I'd like to see the signal go high and low per image. I know that it is a rolling shutter so I would eventually need a PIC processor to synchronize illumination properly with exposure time later on.
Thank you for the help so far!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Wed Oct 30, 2019 2:16 pm

vcgencmd get_config int
Does it return 3 for disable_camera_led? If not then you haven't edited the right config.txt (I really hate noobs)
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Wed Oct 30, 2019 2:48 pm

6by9 wrote:
Wed Oct 30, 2019 2:16 pm
vcgencmd get_config int
Does it return 3 for disable_camera_led? If not then you haven't edited the right config.txt (I really hate noobs)
Thanks again for the follow up. When I tried that, disable_camera_led isn't even listed as a variable...
I was editing config.txt in /boot/config.txt
Where is the correct config.txt file to edit?

Thank you!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Wed Oct 30, 2019 3:02 pm

If it isn't listed then it isn't set and will adopt the value of 0.
I can only suggest double checking spelling.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Wed Oct 30, 2019 3:26 pm

6by9 wrote:
Wed Oct 30, 2019 3:02 pm
If it isn't listed then it isn't set and will adopt the value of 0.
I can only suggest double checking spelling.
Double checked spelling, but is my config.txt location correct?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Wed Oct 30, 2019 3:40 pm

etest wrote:
Wed Oct 30, 2019 3:26 pm
Double checked spelling, but is my config.txt location correct?
As far ar as I know, yes, but I don't work with noobs.
Try altering something like gpu_mem and confirming that setting is reflected through.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

gordon77
Posts: 4368
Joined: Sun Aug 05, 2012 3:12 pm

Re: Hardware camera sync pulses

Wed Oct 30, 2019 3:59 pm

Is it possible to get sync pulses on a Pi4?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Wed Oct 30, 2019 4:15 pm

gordon77 wrote:
Wed Oct 30, 2019 3:59 pm
Is it possible to get sync pulses on a Pi4?
Yes. Same approach as all platforms, but there isn't a camera led defined by default, so you must define it for yourself via dt-blob.bin.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Wed Oct 30, 2019 4:21 pm

6by9 wrote:
Wed Oct 30, 2019 3:40 pm
As far ar as I know, yes, but I don't work with noobs.
Try altering something like gpu_mem and confirming that setting is reflected through.
gpu_mem also doesn't show up as a variable yet it is listed in my config file..odd.
Could you point me to a forum post or provide a NOOBS support contact that might be able to help with this?
Thanks again for all of your help.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Wed Oct 30, 2019 4:55 pm

Bad choice by me. Gpu_mem is processed by the early bootloader, not the main firmware, so doesn't show up directly. It will via "vcgencmd get_mem gpu" though.

Personally I'd recommend just reinstalling with a native raspbian install and ditching noobs totally.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Wed Oct 30, 2019 5:01 pm

6by9 wrote:
Wed Oct 30, 2019 4:55 pm
Bad choice by me. Gpu_mem is processed by the early bootloader, not the main firmware, so doesn't show up directly. It will via "vcgencmd get_mem gpu" though.

Personally I'd recommend just reinstalling with a native raspbian install and ditching noobs totally.
Okay, so just to confirm: if I reinstalled raspbian, I would follow all of the steps I did before, including using "sudo cp dt-blob.bin /boot/" for mounting. And hopefully then, when I edit the config file, I should be able to do vcgencmd get_config int to see it changing.

Thank you for all of the help!!

gordon77
Posts: 4368
Joined: Sun Aug 05, 2012 3:12 pm

Re: Hardware camera sync pulses

Fri Nov 01, 2019 1:19 pm

6by9 wrote:
Wed Oct 30, 2019 4:15 pm
gordon77 wrote:
Wed Oct 30, 2019 3:59 pm
Is it possible to get sync pulses on a Pi4?
Yes. Same approach as all platforms, but there isn't a camera led defined by default, so you must define it for yourself via dt-blob.bin.
Thanks.

I modifed the Pi4 section to...

Code: Select all

};
            [email protected]_0_LED {
               type = "external";
               number = <20>;
and added...

Code: Select all

[email protected] { function = "output"; termination = "no_pulling"; }; // Camera LED
I then compiled with sudo dtc -I dts -O dtb -o /boot/dt-blob.bin /home/pi/Documents/dt-blob.dts
which gave loads of warnings like..
/boot/dt-blob.bin: Warning (unit_address_vs_reg): /videocore/pins_2b2/pin_config/[email protected]: node has a unit name, but no reg property

Connected a led to GPIO #20 but it doesn't light when I use raspistill.

What am I missing ?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Fri Nov 01, 2019 2:16 pm

gordon77 wrote:
Fri Nov 01, 2019 1:19 pm

Code: Select all

};
            [email protected]_0_LED {
               type = "external";
               number = <20>;
External means on the GPIO expander rather than "internal" to the SoC. The GPIO expander starts at 128, and only has 8 outputs.
Use

Code: Select all

            [email protected]_0_LED {
               type = "internal";
               number = <20>;
            };
and I'd expect it to work.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Fri Nov 01, 2019 2:20 pm

One additional question I have is: Would this hardware camera sync work for using the Raspberry Pi 3 Module B+ with a global shutter camera such as the Arducam?
If not, would it "Using Flash with the Camera" ( from https://picamera.readthedocs.io/en/rele ... ipes2.html ) work with the Arducam?

Does RPi offer any MIPI global shutter cameras that I could use this hardware camera sync with?

Thank you.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Fri Nov 01, 2019 3:06 pm

etest wrote:
Fri Nov 01, 2019 2:20 pm
One additional question I have is: Would this hardware camera sync work for using the Raspberry Pi 3 Module B+ with a global shutter camera such as the Arducam?
The sync pulse output is a function of the firmware camera stack. Any sensors other than Sony IMX219 or Omnivision OV5647 do not use the firmware camera stack, they only receive the raw Bayer data and leave all other processing to that application, or possibly a library provided by the vendor.

It may be possible to extend the rawcam component to also control the led GPIO, but it's not something I was planning to add.

The kernel driver for the CSI2 receiver is all open source, so you could make your own modifications to that to control GPIOs in exactly the way you wish. https://github.com/raspberrypi/linux/bl ... cam.c#L721 is the frame start interrupt handler, whilst the "if (ista & UNICAM_FEI..." clause 8 lines later is the end of frame signal.
etest wrote:If not, would it "Using Flash with the Camera" ( from https://picamera.readthedocs.io/en/rele ... ipes2.html ) work with the Arducam?
The flash driver is again a function of the firmware camera stack.
etest wrote:Does RPi offer any MIPI global shutter cameras that I could use this hardware camera sync with?
No.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

gordon77
Posts: 4368
Joined: Sun Aug 05, 2012 3:12 pm

Re: Hardware camera sync pulses

Fri Nov 01, 2019 4:00 pm

6by9 wrote:
Fri Nov 01, 2019 2:16 pm
gordon77 wrote:
Fri Nov 01, 2019 1:19 pm

Code: Select all

};
            [email protected]_0_LED {
               type = "external";
               number = <20>;
External means on the GPIO expander rather than "internal" to the SoC. The GPIO expander starts at 128, and only has 8 outputs.
Use

Code: Select all

            [email protected]_0_LED {
               type = "internal";
               number = <20>;
            };
and I'd expect it to work.
Thanks, sorted.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Fri Nov 01, 2019 4:03 pm

Thank you for your response, that is very helpful to know.

etest
Posts: 19
Joined: Thu Oct 24, 2019 7:40 pm

Re: Hardware camera sync pulses

Tue Nov 05, 2019 4:59 pm

6by9 wrote:
Wed Oct 30, 2019 4:55 pm
Bad choice by me. Gpu_mem is processed by the early bootloader, not the main firmware, so doesn't show up directly. It will via "vcgencmd get_mem gpu" though.

Personally I'd recommend just reinstalling with a native raspbian install and ditching noobs totally.
Hi, I did the above and imaged a new micro SD with the raspbian install to avoid noobs. I followed all of my same steps as before and I can get flash strobe working fine, but the hardware camera sync signal still only goes high once (and the beginning of multiple captures) and then goes low at the end of all of the captures.
I checked using vcgencmd get_config int as you mentioned, and I still don't see disable_camera_led as a parameter in the list.
Is there any other location the config file could be or any other edits I should make?
Can anyone point me to a support page or support contact for this issue?

Any help would be much appreciated! Thanks.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7707
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hardware camera sync pulses

Tue Nov 05, 2019 5:14 pm

Code: Select all

vcgencmd get_config disable_camera_led
should return the value even if it is 0. If the token name is unknown then it will tell you.

I've inserted "disable_camera_led=3" into /boot/config.txt on my system here, and I get it back fine via vcgencmd get_config.
Sorry, there really is very little I can do from this end. Ensure you don't have any typos is all I can really recommend, or post the complete contents of your config.txt (preferably using code tags to make it nicely formatted).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”