Difference between revisions of "X630-Software"

From Geekworm Wiki
Jump to navigation Jump to search
Line 46: Line 46:
  
 
1. Once booted, update your Raspberry Pi by running the following commands in a terminal window:
 
1. Once booted, update your Raspberry Pi by running the following commands in a terminal window:
  sudo apt-get-update
+
  sudo apt-get update
 
  sudo apt-get upgrade -y
 
  sudo apt-get upgrade -y
  

Revision as of 16:17, 21 December 2021

This wiki describes how to use x630 on the Raspberry Pi OS.

For Raspberry Pi OS

X630 has two reset mode: Hardware reset and Software reset modes, we strongly recommend you use software reset mode if you use it on raspberry pi hardware or raspberry pi os, software reset uses GPIO 509 to reset operation through GPIO, which can prevent you from restarting the Raspberry Pi repeatedly, which is very convenient. And on other hardware platforms, X630 actually reserves pins to facilitate you to use custom GPIO pin to implement software reset operations or use directly hardware reset mode.

First, please choose your reset mode based on your hardware and OS (default is software reset mode), you can skip this step if you use software reset, it should be noted that disconnect power supply to the Raspberry Pi before changing dip switch positions.

PS:

We found that some users prefer hardware mode, so our factory default settings have been changed to hardware mode

dip switch

Disconnect power to the Raspberry Pi before changing dip switch positions!!!

SELECTION SWITCH SETTINGS
Hardware reset HW = 1 SW = 0
Software reset HW = 0 SW = 1
X630 dip switch setting

Explain:

  • Hardware reset: After starting RASPISTILL or RASPIVID once then you will need to reboot Raspberry Pi to restart it again (Please use when operating system cannot control the X630 module via GPIO509)
  • Software reset: Starting RASPISTILL or RASPIVID multiple times and don't need to reboot Raspberry Pi (Recommend)
  • Default setting is 'Software reset';
  • Please remove the yellow protective film before change dip switch.

Notes & Known issues

(1) If using GStreamer or PiKVM, please change to Hardware reset mode. Otherwise, the X630 won't be detected and there will be no video.

(2) An accessory board (X630-A2) for audio capturing & reset is being developed and will be available in Nov 2021.

(3) Currently the software reset mode can only support RASPISTILL or RASPIVID.

(4) If GStreamer is installed in Raspberry Pi OS, RASPISTILL & RASPIVID are no longer worked.


Preparations:

1. Once booted, update your Raspberry Pi by running the following commands in a terminal window:

sudo apt-get update
sudo apt-get upgrade -y

2. Run the following command to go into the Raspberry Pi configuration tool

sudo raspi-config

Raspi-config-1.jpg

3. Navigate to 'Interfacing Options' and hit Enter. Now select the 'Camera' option, and hit the Enter key to enable it. Select “Finish” and select to reboot your Raspberry Pi. Raspi-config-2.jpg

Setting for Software Reset - Starting RASPISTILL or RASPIVID multiple times and no need to reboot Raspberry Pi

4. Once rebooted, You will need to edit /etc/rc.local to execute CAM GPIO initialization at startup

IMPORTANT PROCEDURE!!! Your X630 cannot work if this is not edited correctly.

sudo nano /etc/rc.local 

Scroll down, and just before the exit 0 line, enter the following:

echo "509" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio509/direction
echo "1" > /sys/class/gpio/gpio509/value

X630

Save and exit with ctrl + x, followed by y when prompted to save, and then enter.

5. Reboot your Raspberry Pi to verify that the CAM LED lights up.

sudo reboot

X630

6. Once rebooted, you need to make sure that the ‘/dev/video0’ device is available. Use this command to check:

ls /dev/video0

Raspi-config-3.jpg

If you see anything other than ‘file not found‘, then it’s available.

7. Create a script to reset the X630 module

sudo nano reset.sh

enter the following:

echo "0" > /sys/class/gpio/gpio509/value
sleep 1
echo "1" > /sys/class/gpio/gpio509/value

Save and exit with ctrl + x, followed by y when prompted to save, and then enter.

8. Reboot your Raspberry Pi

sudo reboot

9. To take first photo with the X630 Module

sudo bash reset.sh
raspistill -o image1.jpg

Here, "image1" is the name of your image that will be saved to your Raspberry Pi

10. To take second photo with the X630 Module

sudo bash reset.sh
raspistill -o image2.jpg

Here, "image2" is the name of your image that will be saved to your Raspberry Pi.

11. Record first video with the X630 module

sudo bash reset.sh
raspivid -o video1.h264 -t 10000

Here, "video1" is the name of your video and "10000" is the number of milliseconds.

12. Record second video with the X630 module

sudo bash reset.sh
raspivid -o video2.h264 -t 10000

Here, "video2" is the name of your video and "10000" is the number of milliseconds.

Note: "sudo bash reset.sh" is always required to execute before starting RASPISTILL or RASPIVID. the CAM LED will go off for 1second then turn on.


For Hardware Reset - Starting RASPISTILL or RASPIVID once then reboot your Raspberry Pi.

(Please use when operating system cannot control the X630 module via GPIO509)

13. To take a photo with the X630 Module

raspistill -o image.jpg

Here, "image" is the name of your image that will be saved to your Raspberry Pi

14. If you need to take second image, then you will need to reboot the Raspberry Pi and execute the "raspistill" again

sudo reboot
	 

15. To record a video with the X630 module

raspivid -o video.h264 -t 10000

Here, "video" is the name of your video and "10000" is the number of milliseconds.

16. If you need to record second video, then you will need to reboot the Raspberry Pi and execute the "raspivid" again

sudo reboot

For Hardware Reset - Starting RASPISTILL or RASPIVID once then reboot your Raspberry Pi

Please use the following guide if your dip switch is changed to 'Hardware reset' position.

17. To take a photo with the X630 Module

raspistill -o image.jpg

Here, "image.jpg" is the name of your image that will be saved to your Raspberry Pi

18. If you need to take second image, then you will need to reboot the Raspberry Pi and execute the "raspistill" again.

sudo reboot

19. To record a video with the X630 module

raspivid -o video.h264 -t 10000

Here, "video" is the name of your video and "10000" is the number of milliseconds.

20. If you need to record second video, then you will need to reboot the Raspberry Pi and execute the "raspivid" again.

sudo reboot

Audio & Video capturing using GStreamer

Capturing stereo audio with the X630-A2(will release soon) from the HDMI source is supported.

If you need to run RASPISTILL or RASPIVID again after the GStreamer is installed. You will need to reinstall a fresh Raspberry Pi OS and follow above instructions.

(1) Once booted, update your Raspberry Pi by running the following commands in a terminal window:

sudo apt-get update
sudo apt-get upgrade -y

(2) Install necessary dependency and remaining plugins for GStreamer

sudo apt-get install libx264-dev libjpeg-dev
sudo apt-get install libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev \
gstreamer1.0-plugins-ugly \
gstreamer1.0-tools

(3) With all GStreamer modules installed let's test the installation with (not via SSH)

gst-launch-1.0 --version
gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
TestRPi-X630.png

(4) Edit /boot/config.txt and enter the following

sudo nano /boot/config.txt
dtoverlay=tc358743
dtoverlay=tc358743-audio
dtoverlay=cma,cma-128
	

Save and exit with ctrl + x, followed by y when prompted to save, and then enter.

(5) Reboot the Raspberry Pi

sudo reboot

(6) Once rebooted and check that the audio drivers / card is available to ALSA.

arecord  -l

If the X630 module and drivers have been installed correctly you should see something similar to:

Arecord-X630.jpg

Note: card 2 means that the card number for the TC358743XBG is "2" and it might be different.

(7) Create an EDID file so it can be loaded into the chip to allow it to tell the HDMI source what resolutions are supported.

sudo nano edid.txt

enter the following:

00ffffffffffff005262888800888888
1c150103800000780aEE91A3544C9926
0F505400000001010101010101010101
010101010101011d007251d01e206e28
5500c48e2100001e8c0ad08a20e02d10
103e9600138e2100001e000000fc0054
6f73686962612d4832430a20000000FD
003b3d0f2e0f1e0a202020202020014f
020321434e041303021211012021a23c
3d3e1f2309070766030c00300080E300
7F8c0ad08a20e02d10103e9600c48e21
0000188c0ad08a20e02d10103e960013
8e210000188c0aa01451f01600267c43
00138e21000098000000000000000000
00000000000000000000000000000000
00000000000000000000000000000028

Save and exit with ctrl + x, followed by y when prompted to save, and then enter.

(8) Push this to the device using

v4l2-ctl --set-edid=file=edid.txt --fix-edid-checksums
	 

(9) To print the currently detected timings

v4l2-ctl --query-dv-timings
	 

(10) To select the currently detected timings

v4l2-ctl --set-dv-bt-timings query
	 

(11) Capture the incoming audio (no video)

arecord -D hw:x,0 -V stereo -r 48000 -f S16_LE -c 2 audio.wav

Note: hw:x - You must replace "x" with correct audio card number.

Press ctrl + c to finish a recording, the file will be saved to /home/pi

(12) Capture the incoming video and audio


gst-launch-1.0 v4l2src io-mode=0 ! video/x-raw, format=UYVY, framerate=25/1 ! v4l2h264enc output-io-mode=4 ! video/x-h264,profile=high ! h264parse ! queue ! matroskamux name=mux ! filesink location=video.mkv alsasrc device=hw:2 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux.

Note: alsasrc device=hw:2 - "2" means the audio card number, You must change to correct audio card number.

Press ctrl + c to finish a recording, the file will be saved to /home/pi

How to check kernel version

Please run the following command to get the linux kernel version

uname -a

Raspi-kernel-version.jpg

Maybe you can refer to TC358743 HDMI to CSI-2 install instructions if your kernel version is lower than 5.X.


Return to X630

Add your comment
Geekworm Wiki welcomes all comments. If you do not want to be anonymous, register or log in. It is free.