Skip to content
Permalink
Browse files

add ceu_example

  • Loading branch information...
seebe committed Feb 11, 2018
1 parent 65e4668 commit 6cfd6f6758596b06c6adcb9af4583daf825e2d76
Showing with 2,809 additions and 0 deletions.
  1. +91 −0 ceu_example/Makefile
  2. +67 −0 ceu_example/README.txt
  3. +244 −0 ceu_example/ceu.c
  4. +41 −0 ceu_example/ceu.h
  5. +786 −0 ceu_example/ceu_omni.c
  6. +854 −0 ceu_example/ov7670.c
  7. +197 −0 ceu_example/ov7670.h
  8. +504 −0 ceu_example/ov7740.c
  9. +25 −0 ceu_example/ov7740.h
@@ -0,0 +1,91 @@
ifeq ("$(CROSS_COMPILE)","")
CC_CHECK:=echo !!ERROR!! CROSS_COMPILE not set
else
endif

ifeq ("$(BUILDROOT_DIR)","")
BR_CHECK:=echo !!ERROR!! BUILDROOT_DIR not set
else
endif

ifeq ($(S),1)
STATIC = -static
else
STATIC =
endif

all: default

#######################################################################
# Toolchain setup
#######################################################################

# You want to build apps with the same toolchain and libraries
# that you built your root file system with. We'll assume you
# are using Buildroot.
# Therefore, make sure BUILDROOT is defined before calling this
# Makefile.


# 'BUILDROOT_DIR' should be imported after running setup_env.sh

# Define the base path of the toolchain
TC_PATH:=$(BUILDROOT_DIR)/output/host/usr
export PATH:=$(TC_PATH)/bin:$(PATH)

# Find out what the prefix of the toolchain that is used for Buildroot
GCCEXE:=$(notdir $(wildcard $(TC_PATH)/bin/*abi*-gcc))
CROSS_COMPILE:=$(subst gcc,,$(GCCEXE))

# Find the location of the sysroot where all the libraries and header files are
SYSROOT:=$(shell find $(TC_PATH) -name sysroot)

# Manual setup if set_env.sh is not used
#TC_PATH=/home/renesas/toolchain/buildroot-2014.05/output/host/usr
#CROSS_COMPILE=arm-buildroot-linux-uclibcgnueabi-
ARCH:=arm


#######################################################################
# Application Specific setup
#######################################################################
app:=ceu_omni


CFLAGS:=-O2

# For adding in external libraries, you have 2 choices:
# 1. let them link in a run-time .so file
# 2. pull in all the code at build (no .so file needed at run-time)
#
# For 1:
# Link against libjpeg shared library
CFLAGS+=-ljpeg

#for debugging only
#CFLAGS+=-g

# For 2:
# Add libjpeg statically by specifying the lib directly at the end of the command line (after the .c files)
#LIBS=$(SYSROOT)/usr/lib/libjpeg.a

default:
@$(BR_CHECK)
$(CROSS_COMPILE)gcc $(STATIC) $(CFLAGS) --sysroot=$(SYSROOT) -o $(app) $(app).c ceu.c ov7670.c ov7740.c $(LIBS)

# Strip off debug symbols if not debugging (makes file size smaller)
strip:
$(CROSS_COMPILE)strip --strip-debug $(app)

install:
@# Copy to Buildroot overlay directory (only for Renesas BSP)
cp $(app) $(BUILDROOT_DIR)/output/rootfs_overlay/root/bin
@echo ''
@echo 'Please run Buildroot again to repackage the rootfs image.'
@echo 'For example:'
@echo ' $$ cd $$BUILDROOT_DIR'
@echo ' $$ make'

clean:
rm $(app)

@@ -0,0 +1,67 @@
This code demonstrates how to use the CEU to capture images from the camera.

This code works with Omnivision OV7670 or OV7740 cameras.

----------------------------------------
Building
----------------------------------------

In order to save image as JPEG files, libjpeg is required to build against.
Make sure you have BR2_PACKAGE_LIBJPEG or BR2_PACKAGE_JPEG_TURBO selected in buildroot menuconfig.
Location:
-> Target packages
-> Libraries
-> Graphics
-> jpeg variant
( ) jpeg
(X) jpeg-turbo


First set the BSP build environment

$ ./build.sh env
$ export ROOTDIR=$(pwd) ; source ./setup_env.sh

Then you can build the applicaiton:

$ make

By doing a 'make install' will copy to your buildroot overlay directory. But, make sure
to rebuild buildroot to add it to your image to program into the board. For example:
$ make install
$ cd ..
$ ./build.sh buildroot


----------------------------------------
Pin setup
----------------------------------------
This code assumes you have taken care of the CEU pin setup in u-boot or the kernel.


----------------------------------------
CEU Capture Buffer Address
----------------------------------------
Some setup is needed in the ceu_omni.c file for your board.

You must hard code a RAM location for the CEU to capture images to.
This is done at the top of the file:
static unsigned int cap_buf_addr = 0x60900000; /* 9MB offset in internal RAM */
static unsigned int cap_buf_size = (1*1024*1024); /* Capture buffer size */

You cannot simply 'malloc' this RAM in the application because you need to use a
physical RAM address (not virutal address) and the memory must be continuous (not paged)

Note when external SDRAM is used, it is easy to hard code the RAM loacion to internal RAM
because internal RAM is not used by the kernel.


----------------------------------------
Stream it Board
----------------------------------------
When running this code on a Stream it board, it will automatically detect that it is a stream it board
and adjust the settings for you. However, this assumes you have made the appropriate changes as
for a V2.3 board or later outlined here:
https://elinux.org/RZ-A/Boards/Stream-it


0 comments on commit 6cfd6f6

Please sign in to comment.
You can’t perform that action at this time.