Now that we have finished the program we need to compile it and get it on the BB. Finally we want the program to run on start-up. If that’s done we finally have a working “smart” Wireless IP Camera!
We’ll start with compiling the program:
1 2 3 4 5 6 7 |
CC = ~/biffdev/openwrt/staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/bin/i486-openwrt-linux-gcc motion-detect: $(CC) -mtune=i386 motion-detectd.c ../motion-detect-project/motion-detect.c ../motion-detect-project/motion-detect.h -o motion-detectd motion-detect-dev: gcc -g -o motion-detectd motion-detectd.c ../motion-detect-project/motion-detect.c ../motion-detect-project/motion-detect.h |
In the Makefile I start with setting up the cross-compiler. Your OpenWRT build environment contains the toolchain to cross-compile for the BB.
The Makefile can be called with two arguments motion-detect and motion-detect-dev. The first one compiles for the BB the second compiles for my development machine achitecture.
As you can see the BB toolchain is based on gcc using the micro C library (uClibc) which yields really tiny programs. The end result, after compilation, yields our program at a whopping 9 kilobytes! Even the little ram on the BB seems spacious at that size.
To install the progam you’ll need to make sure that:
- fswebcam can be called from “/”
- the path where you want to store images is writable
- your email setup is correct this code uses mutt to mail from the command line
Next, just add a start-up script in /etc/init.d
Use enable/disable to add the script to the startup sequence of your BB.
And that concludes the software side of our smart camera! I hope you got some use out of these posts and feel free to send me a picture of your own IP camera! I’ll post it here.
Thanks for sharing nice information.