User avatar
HermannSW
Posts: 1760
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Hardware camera sync pulses

Fri Dec 06, 2019 3:30 pm

6by9 wrote:
Tue Nov 14, 2017 5:48 pm
Start with https://github.com/raspberrypi/firmware ... t-blob.dts which is the source for the blob that is built in to the firmware.
There is a section for Pi4B, but since CAMERA_0_LED is not existent on Pi4B it states:

Code: Select all

            [email protected]_0_LED {
               type = "absent";
            };

Does Pi4B allow for hardware camera sync pulses as well?
If so, just according the instructions in this thread, or differently?
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

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

Re: Hardware camera sync pulses

Fri Dec 06, 2019 4:07 pm

HermannSW wrote:
Fri Dec 06, 2019 3:30 pm
6by9 wrote:
Tue Nov 14, 2017 5:48 pm
Start with https://github.com/raspberrypi/firmware ... t-blob.dts which is the source for the blob that is built in to the firmware.
There is a section for Pi4B, but since CAMERA_0_LED is not existent on Pi4B it states:

Code: Select all

            [email protected]_0_LED {
               type = "absent";
            };

Does Pi4B allow for hardware camera sync pulses as well?
If so, just according the instructions in this thread, or differently?
It's the same code, you just can't use it on the default as there is no LED line. The same was true on the Pi3 as the camera LED GPIO is on the GPIO expander, and the hw sync pulse GPIO MUST be an internal one.

Define it to the GPIO you want and it should 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.

User avatar
HermannSW
Posts: 1760
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Hardware camera sync pulses

Fri Dec 06, 2019 5:59 pm

Thanks, I will try with the Pi4B.

In the meantime I switched to Pi2B and used that.
The sync pulses triggered an Arduino Uno to display "millis()" for few milliseconds on 8-digit 7-segment tube display after frame start (it acts on frame end, then waits for frame start).
That allowed to take 90fps global external shutter video with v1 camera (animation plays with 1fps):
https://forum.arduino.cc/index.php?topi ... msg4396851
Image
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

User avatar
HermannSW
Posts: 1760
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Hardware camera sync pulses

Mon Dec 16, 2019 11:20 pm

6by9 wrote:
Fri Dec 06, 2019 4:07 pm
Define it to the GPIO you want and it should work.
Until today I thought that I had killed all my Pi4B GPIOs -- luckily they all do work fine:
https://www.raspberrypi.org/forums/view ... 0#p1581680

So I did get dt-blob.dts from:
https://raw.githubusercontent.com/raspb ... t-blob.dts

Then I copied into dt-blob.18.dts (attached as well) and applied the changes for Pi4B:

Code: Select all

[email protected]:~ $ diff dt-blob.dts dt-blob.18.dts 
2124a2125
>             [email protected] { function = "output"; termination = "no_pulling"; }; // Camera LED (for hwsync)
2159c2160,2161
<                type = "absent";
---
>                type = "external";
>                number = <18>;
[email protected]:~ $ 
Then I did compile using the command you provided previously in this thread:

Code: Select all

[email protected]:~ $ sudo dtc -q -I dts -O dtb -o /boot/dt-blob.bin dt-blob.18.dts
[email protected]:~ $ 
Then I appended this line:

Code: Select all

[email protected]:~ $ tail -1 /boot/config.txt 
disable_camera_led=3
[email protected]:~ $ 


After reboot of the Pi4B I started raspivid

Code: Select all

[email protected]:~ $ raspivid -md 7 -w 640 -h 480 -t 0 -p 22,50,640,480 -o tst.h264
and captured GPIO18 with logic analyzer.

Unfortunately I do not see hardware camera sync pulses on logic analyzer (same procedure worked for Pi 2B/3B/3B+/3A).
What do I need to do differently to get hwsync pulses show up on GPIO18 for Pi4B?
Attachments
dt-blob.18.dts.zip
contains dt-blob.18.dts
(3.12 KiB) Downloaded 7 times
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

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

Re: Hardware camera sync pulses

Tue Dec 17, 2019 7:35 am

HermannSW wrote:
Mon Dec 16, 2019 11:20 pm
Then I copied into dt-blob.18.dts (attached as well) and applied the changes for Pi4B:

Code: Select all

[email protected]:~ $ diff dt-blob.dts dt-blob.18.dts 
2124a2125
>             [email protected] { function = "output"; termination = "no_pulling"; }; // Camera LED (for hwsync)
2159c2160,2161
<                type = "absent";
---
>                type = "external";
>                number = <18>;
[email protected]:~ $ 
Invalid GPIO defined.
The GPIO expander ("external") only has 8 lines, and is invalid for camera hardware sync pulses.
Please define it to a valid GPIO on the SoC (ie "internal").
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.

User avatar
HermannSW
Posts: 1760
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Hardware camera sync pulses

Tue Dec 17, 2019 3:14 pm

Thank you!

This is the diff that made hardware camera sync pulses work on Pi4B GPIO18 (in addition to the steps in previous posting):

Code: Select all

[email protected]:~ $ !dif
diff dt-blob.dts dt-blob.18.dts 
2124a2125
>             [email protected] { function = "output"; termination = "no_pulling"; }; // Camera LED (for hwsync)
2159c2160,2161
<                type = "absent";
---
>                type = "internal";
>                number = <18>;
[email protected]:~ $ 
The attached logic analyzer screenshot shows 90.14Hz average frequency for "raspivid -md 7 ... -fps 90 ..." command.
Attachments
hwsync.png
hwsync.png
hwsync.png (37.72 KiB) Viewed 172 times
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

Return to “Camera board”