Skip to content

Commit

Permalink
added some helper scripts for bringing up the camera module without t…
Browse files Browse the repository at this point in the history
…he kernel driver
  • Loading branch information
Demo User committed Aug 22, 2020
1 parent eac31ce commit 0680764
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 21 deletions.
56 changes: 56 additions & 0 deletions utils/enable-camera-gpio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
set -x

if [ $UID -ne 0 ]
then
echo ERROR: must be root
exit 1
fi

# pass the gpio # and the value to set
set_gpio() {
set -x
GPIO=$1
GPIOPATH=/sys/class/gpio/gpio$GPIO
VAL=$2

ls /sys/class/gpio/ | grep gpio$GPIO > /dev/null
# first export the GPIO is it isnt already
if [ $? -ne 0 ]; then
echo "File not found!"
echo $GPIO > /sys/class/gpio/export
fi

# set GPIO direction
echo out > $GPIOPATH/direction

# set GPIO value
echo $VAL > $GPIOPATH/value
}

# enable camera output active low
set_gpio 96 0

# enable camera clock clk active high
set_gpio 106 1

# disable reset active low (drive high)
set_gpio 84 1

# set i2c address with saddr line low (0x20)
set_gpio 83 0

# disable standby active high (drive low)
set_gpio 82 0

# no trigger active high
set_gpio 98 0

# enable voltage regulators on image sensor active high
set_gpio 100 1

# finally, enable image sensor control lines so all the
# above signals are sent to image sensor
set_gpio 85 0


32 changes: 32 additions & 0 deletions utils/i2c-16-read.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/python3

# This script writes the board ID to the EEPROM in the OSD3358 and reads
# it back afterwards. I ran it on another pocketbealge using i2c-2, but
# it would probably work on other boards with a i2c peripheral

import io
import fcntl
import sys

# i2c slave address is first argument
slave_addr = int(sys.argv[1], 16)

reg = int(sys.argv[2], 16)

addr_bu = (reg >> 8) & 0xff # address upper byte
addr_bl = reg & 0xff # address lower byte

# I think this is python ioctl/i2c specific magic bytes?
IOCTL_I2C_SLAVE = 0x0703

# open the I2C device and set it up to talk to the slave
f = io.open("/dev/i2c-2", "wb+", buffering=0)
fcntl.ioctl(f, IOCTL_I2C_SLAVE, slave_addr)

# write the register value
f.write(bytearray([addr_bu, addr_bl]))

# read back the register value
v = f.read(2)
print("Reg: ", hex(slave_addr), " Value: 0x", v.hex(), sep='')

21 changes: 0 additions & 21 deletions utils/i2c-read.py

This file was deleted.

50 changes: 50 additions & 0 deletions utils/standby-camera-gpio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -x

if [ $UID -ne 0 ]
then
echo ERROR: must be root
exit 1
fi

# pass the gpio # and the value to set
set_gpio() {
set -x
GPIO=$1
GPIOPATH=/sys/class/gpio/gpio$GPIO
VAL=$2

ls /sys/class/gpio/ | grep gpio$GPIO > /dev/null
# first export the GPIO is it isnt already
if [ $? -ne 0 ]; then
echo "File not found!"
echo $GPIO > /sys/class/gpio/export
fi

# set GPIO direction
echo out > $GPIOPATH/direction

# set GPIO value
echo $VAL > $GPIOPATH/value
}

# enable camera output active low
set_gpio 96 1

# enable camera clock clk active high
set_gpio 106 0

# disable reset active low
set_gpio 84 0

# disable standby active high
set_gpio 82 1

# enable voltage regulators on image sensor active high
set_gpio 100 0

# finally, enable image sensor control lines so all the
# above signals are sent to image sensor
set_gpio 85 0


0 comments on commit 0680764

Please sign in to comment.