树莓派安装bcm2835库

树莓派安装bcm2835库

本文包含安装bcm2835的步骤以及测试案例

从http://www.airspayce.com/mikem/bcm2835/ 下载library库,可以直接在树莓派中下载或者宿主机上下载后sftp传给树莓派

加粗文本 加粗文本

下载压缩包后输入 tar zxvf bcm2835-1.56.tar.gz .如下图

pi@raspberrypi:~ $ tar zxvf bcm2835-1.56.tar.gz 

输入后显示下面内容

pi@raspberrypi:~ $ tar zxvf bcm2835-1.56.tar.gz 
bcm2835-1.56/
bcm2835-1.56/configure.ac
bcm2835-1.56/COPYING
bcm2835-1.56/examples/
bcm2835-1.56/examples/spi/
bcm2835-1.56/examples/spi/spi.c
bcm2835-1.56/examples/input/
bcm2835-1.56/examples/input/input.c
bcm2835-1.56/examples/event/
bcm2835-1.56/examples/event/event.c
bcm2835-1.56/examples/pwm/
bcm2835-1.56/examples/pwm/pwm.c
bcm2835-1.56/examples/gpio/
bcm2835-1.56/examples/gpio/gpio.c
bcm2835-1.56/examples/blink/
bcm2835-1.56/examples/blink/blink.c
bcm2835-1.56/examples/spin/
bcm2835-1.56/examples/spin/spin.c
bcm2835-1.56/examples/i2c/
bcm2835-1.56/examples/i2c/i2c.c
bcm2835-1.56/config.guess
bcm2835-1.56/NEWS
bcm2835-1.56/depcomp
bcm2835-1.56/configure
bcm2835-1.56/aclocal.m4
bcm2835-1.56/compile
bcm2835-1.56/INSTALL
bcm2835-1.56/Makefile.in
bcm2835-1.56/missing
bcm2835-1.56/config.sub
bcm2835-1.56/Makefile.am
bcm2835-1.56/ChangeLog
bcm2835-1.56/README
bcm2835-1.56/install-sh
bcm2835-1.56/config.h.in
bcm2835-1.56/src/
bcm2835-1.56/src/test.c
bcm2835-1.56/src/bcm2835.h
bcm2835-1.56/src/bcm2835.c
bcm2835-1.56/src/Makefile.in
bcm2835-1.56/src/Makefile.am
bcm2835-1.56/ltmain.sh
bcm2835-1.56/AUTHORS
bcm2835-1.56/doc/
bcm2835-1.56/doc/Doxyfile.in
bcm2835-1.56/doc/Makefile.in
bcm2835-1.56/doc/Makefile.am
bcm2835-1.56/test-driver

输入ls后再输入./configure,结果如图:

pi@raspberrypi:~/bcm2835-1.56 $ ls
aclocal.m4  ChangeLog  config.guess  config.sub  configure.ac  depcomp  examples  install-sh  Makefile.am  missing  README  test-driver
AUTHORS     compile    config.h.in   configure   COPYING       doc      INSTALL   ltmain.sh   Makefile.in  NEWS     src
pi@raspberrypi:~/bcm2835-1.56 $ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for clock_gettime in -lrt... yes
checking for doxygen... no
configure: WARNING: Doxygen not found - continuing without Doxygen support
checking for ranlib... ranlib
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: executing depfiles commands

输入make编译,结果如下

pi@raspberrypi:~/bcm2835-1.56 $ make
make  all-recursive
make[1]: Entering directory '/home/pi/bcm2835-1.56'
Making all in src
make[2]: Entering directory '/home/pi/bcm2835-1.56/src'
gcc -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT bcm2835.o -MD -MP -MF .deps/bcm2835.Tpo -c -o bcm2835.o bcm2835.c
mv -f .deps/bcm2835.Tpo .deps/bcm2835.Po
rm -f libbcm2835.a
ar cru libbcm2835.a bcm2835.o 
ar: `u' modifier ignored since `D' is the default (see `U')
ranlib libbcm2835.a
make[2]: Leaving directory '/home/pi/bcm2835-1.56/src'
Making all in doc
make[2]: Entering directory '/home/pi/bcm2835-1.56/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/pi/bcm2835-1.56/doc'
make[2]: Entering directory '/home/pi/bcm2835-1.56'
make[2]: Leaving directory '/home/pi/bcm2835-1.56'
make[1]: Leaving directory '/home/pi/bcm2835-1.56'
pi@raspberrypi:~/bcm2835-1.56 $ sudo make check
Making check in src
make[1]: Entering directory '/home/pi/bcm2835-1.56/src'
make  test
make[2]: Entering directory '/home/pi/bcm2835-1.56/src'
gcc -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT test.o -MD -MP -MF .deps/test.Tpo -c -o test.o test.c
mv -f .deps/test.Tpo .deps/test.Po
gcc  -g -O2   -o test test.o ./libbcm2835.a -lrt 
make[2]: Leaving directory '/home/pi/bcm2835-1.56/src'
make  check-TESTS
make[2]: Entering directory '/home/pi/bcm2835-1.56/src'
make[3]: Entering directory '/home/pi/bcm2835-1.56/src'
PASS: test
============================================================================
Testsuite summary for bcm2835 1.56
============================================================================
# TOTAL: 1
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
make[3]: Leaving directory '/home/pi/bcm2835-1.56/src'
make[2]: Leaving directory '/home/pi/bcm2835-1.56/src'
make[1]: Leaving directory '/home/pi/bcm2835-1.56/src'
Making check in doc
make[1]: Entering directory '/home/pi/bcm2835-1.56/doc'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/home/pi/bcm2835-1.56/doc'
make[1]: Entering directory '/home/pi/bcm2835-1.56'
make[1]: Leaving directory '/home/pi/bcm2835-1.56'

输入sudo make install

pi@raspberrypi:~/bcm2835-1.56 $ sudo make install
Making install in src
make[1]: Entering directory '/home/pi/bcm2835-1.56/src'
make[2]: Entering directory '/home/pi/bcm2835-1.56/src'/bin/mkdir -p '/usr/local/lib'/usr/bin/install -c -m 644  libbcm2835.a '/usr/local/lib'( cd '/usr/local/lib' && ranlib libbcm2835.a )/bin/mkdir -p '/usr/local/include'/usr/bin/install -c -m 644 bcm2835.h '/usr/local/include'
make[2]: Leaving directory '/home/pi/bcm2835-1.56/src'
make[1]: Leaving directory '/home/pi/bcm2835-1.56/src'
Making install in doc
make[1]: Entering directory '/home/pi/bcm2835-1.56/doc'
make[2]: Entering directory '/home/pi/bcm2835-1.56/doc'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/pi/bcm2835-1.56/doc'
make[1]: Leaving directory '/home/pi/bcm2835-1.56/doc'
make[1]: Entering directory '/home/pi/bcm2835-1.56'
make[2]: Entering directory '/home/pi/bcm2835-1.56'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/pi/bcm2835-1.56'
make[1]: Leaving directory '/home/pi/bcm2835-1.56'
pi@raspberrypi:~/bcm2835-1.56 $ 

输入cd LED/切换到该文件夹下,之后输入ls,再输入cd bcm2835/切换到bcm2835文件夹下,输入make,编译文件,输入./led,结果如下

pi@raspberrypi:~/Pioneer600 $ cd LED/
pi@raspberrypi:~/Pioneer600/LED $ ls
bcm2835  fs  python  shell  wiringPi
pi@raspberrypi:~/Pioneer600/LED $ cd bcm2835/
pi@raspberrypi:~/Pioneer600/LED/bcm2835 $ ls
led  led.c  Makefile
pi@raspberrypi:~/Pioneer600/LED/bcm2835 $ make
make: 'led' is up to date.
pi@raspberrypi:~/Pioneer600/LED/bcm2835 $ ./led
bcm2835_init: Unable to open /dev/mem: Permission denied
pi@raspberrypi:~/Pioneer600/LED/bcm2835 $ sudo ./led

看到LED灯亮起就是正确安装的


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部