From 942fa9f6429a046b4b3eacb26a7970cdfa7f46c1 Mon Sep 17 00:00:00 2001
From: "orphee.antoniad" <orphee.antoniadis@hesge.ch>
Date: Mon, 14 Jun 2021 15:57:04 +0200
Subject: [PATCH] Add a shell script to rootfs to stream one frame from camera

---
 scalp_mipi/.petalinux/metadata                |  2 +-
 scalp_mipi/project-spec/configs/config        |  2 ++
 scalp_mipi/project-spec/configs/rootfs_config |  1 +
 .../meta-user/conf/user-rootfsconfig          |  1 +
 .../recipes-apps/pcam5c-stream/.gdbinit       |  3 ++
 .../recipes-apps/pcam5c-stream/README         | 30 +++++++++++++++++++
 .../pcam5c-stream/files/pcam5c-stream         |  7 +++++
 .../pcam5c-stream/pcam5c-stream.bb            | 18 +++++++++++
 8 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/.gdbinit
 create mode 100644 scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/README
 create mode 100644 scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/files/pcam5c-stream
 create mode 100644 scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/pcam5c-stream.bb

diff --git a/scalp_mipi/.petalinux/metadata b/scalp_mipi/.petalinux/metadata
index 7171bed..221c446 100644
--- a/scalp_mipi/.petalinux/metadata
+++ b/scalp_mipi/.petalinux/metadata
@@ -2,5 +2,5 @@ PETALINUX_VER=2020.2
 VALIDATE_HW_CHKSUM=1
 HARDWARE_CHECKSUM=6c31bbdb75a850f24b76171de480c2fd
 YOCTO_SDK=5ff8fc5f85d1566b314bb73eaa378212
-RFSCONFIG_CHKSUM=73a7b476af699308716d5ab0c11a867f
+RFSCONFIG_CHKSUM=234f2f09c23647961a2fbda891ad049b
 HARDWARE_PATH=/home/scalpuser/Desktop/scalp/scalp_firmware/designs/vivado/scalp_mipi/2020.2/lin64/scalp_mipi/scalp_mipi.xsa
diff --git a/scalp_mipi/project-spec/configs/config b/scalp_mipi/project-spec/configs/config
index 392676e..b5f4675 100644
--- a/scalp_mipi/project-spec/configs/config
+++ b/scalp_mipi/project-spec/configs/config
@@ -256,4 +256,6 @@ CONFIG_YOCTO_NETWORK_SSTATE_FEEDS_URL="http://petalinux.xilinx.com/sswreleases/r
 # User Layers
 #
 CONFIG_USER_LAYER_0=""
+
+
 CONFIG_SUBSYSTEM_BOOTARGS_GENERATED="console=ttyPS0,115200 earlycon"
diff --git a/scalp_mipi/project-spec/configs/rootfs_config b/scalp_mipi/project-spec/configs/rootfs_config
index c97a29e..bb422cb 100644
--- a/scalp_mipi/project-spec/configs/rootfs_config
+++ b/scalp_mipi/project-spec/configs/rootfs_config
@@ -4026,6 +4026,7 @@ CONFIG_bitstream-conf=y
 CONFIG_bitstream-init=y
 # CONFIG_gpio-demo is not set
 CONFIG_i2c1-test=y
+CONFIG_pcam5c-stream=y
 # CONFIG_peekpoke is not set
 CONFIG_rgbleds-ctrl=y
 CONFIG_sja1105-conf=y
diff --git a/scalp_mipi/project-spec/meta-user/conf/user-rootfsconfig b/scalp_mipi/project-spec/meta-user/conf/user-rootfsconfig
index 7c1347b..58548f0 100644
--- a/scalp_mipi/project-spec/meta-user/conf/user-rootfsconfig
+++ b/scalp_mipi/project-spec/meta-user/conf/user-rootfsconfig
@@ -9,3 +9,4 @@ CONFIG_bitstream-init
 CONFIG_bitstream-conf
 CONFIG_rgbleds-ctrl
 CONFIG_i2c1-test
+CONFIG_pcam5c-stream
diff --git a/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/.gdbinit b/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/.gdbinit
new file mode 100644
index 0000000..760896a
--- /dev/null
+++ b/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/.gdbinit
@@ -0,0 +1,3 @@
+# Load the PetaLinux SDK main gdbinit script
+source plnx_gdbinit
+
diff --git a/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/README b/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/README
new file mode 100644
index 0000000..fcc6a28
--- /dev/null
+++ b/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/README
@@ -0,0 +1,30 @@
+PetaLinux User Application Template
+===================================
+
+This directory contains a PetaLinux user application created from a template.
+
+You can easily import any already built application or script by copying
+it into this directory, and editing the automatically generated Makefile 
+as described below.
+
+Modify the "install:" target in Makefile to use $(TARGETINST) to install your
+prebuilt application or script to the host copy of the target file system
+referring to the comments of the "install:" target.
+
+Before building the application, you will need to enable the application
+from PetaLinux menuconfig by running:
+    "petalinux-config -c rootfs"
+You will see your application in the "apps --->" submenu.
+
+To install your prebuilt application or script to the target file system
+copy on the host, simply run the command.
+    "petalinux-build -c rootfs/pcam5c-stream"
+
+You will also need to rebuild PetaLinux bootable images so that the images
+is updated with the updated target filesystem copy, run this command:
+    "petalinux-build -c rootfs"
+
+You can also run one PetaLinux command to install the application to the
+target filesystem host copy and update the bootable images as follows:
+    "petalinux-build"
+
diff --git a/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/files/pcam5c-stream b/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/files/pcam5c-stream
new file mode 100644
index 0000000..4a6733c
--- /dev/null
+++ b/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/files/pcam5c-stream
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY/'640x480'@1/'30' field:none]'
+media-ctl -d /dev/media0 -V '"43c20000.mipi_csi2_rx_subsystem":0 [fmt:UYVY/'640x480' field:none]'
+v4l2-ctl -d /dev/video0 --set-fmt-video=width=640,height=480,pixelformat=UYVY
+v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=1 --stream-to=test.raw
+
diff --git a/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/pcam5c-stream.bb b/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/pcam5c-stream.bb
new file mode 100644
index 0000000..cae491d
--- /dev/null
+++ b/scalp_mipi/project-spec/meta-user/recipes-apps/pcam5c-stream/pcam5c-stream.bb
@@ -0,0 +1,18 @@
+#
+# This file is the pcam5c-stream recipe.
+#
+
+SUMMARY = "Simple pcam5c-stream application"
+SECTION = "PETALINUX/apps"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI = "file://pcam5c-stream \
+	"
+
+S = "${WORKDIR}"
+
+do_install() {
+	     install -d ${D}/${bindir}
+	     install -m 0755 ${S}/pcam5c-stream ${D}/${bindir}
+}
-- 
GitLab