树莓派3代B型开发板资料地址: http://www.yahboom.com/study/raspberry密码:cf0p
ssh连接 pi raspberry

触摸屏配置

//使用7寸触摸在/boot/config.text 追加
dtparam=audio=on
max_usb_current=1
hdmi_force_hotplug=1 强制树莓派使用HDMI端口
config_hdmi_boost=3 范围从1(用于短电缆)到7(用于长电缆)
hdmi_group=2
hdmi_mode=87
hdmi_cvt 1024 600 60 6 0 0 0

设置时区

sudo dpkg-reconfigure tzdata

更换数据源

树莓派官方有提供的镜像列表:http://www.raspbian.org/RaspbianMirrors
更改 /etc/apt/sources.list 中的源地址

安装VNC远程桌面

http://www.tightvnc.com/download.php

1
2
3
apt-get install tightvncserver
启动 tightvncserver 输入2次密码
tightvncserver 树莓派启动

安装vim 编辑器

1
2
3
apt-get update 
apt-get upgrade
apt-get vim

Vim有一个带图形界面的版本,可以分别安装。这个版本打开一个支持鼠标操作的新窗口

1
apt-get install vim-gnome

//设置WIFI /etc/wpa_/wpa_
添加

1
2
3
4
5
6
7
8
country=CN
network={
ssid="sss"
psk="mmmm"
key_mgmt=WPA-PSK
priority=2 #连接优先级,数字越大优先级越高(不可以是负数)
# scan_ssid=0 连接隐藏WiFi时需要指定该值为1
}

/etc/network/interfaces

开机启动

/etc/rc.local
scim 启动输入法

支持库安装

一 安装Wiring http://www.waveshare.net/study/article-742-1.html

  1. 通过GIT获得wiringPi的源码

    1
    2
    3
    1 git clone git://git.drogon.net/wiringPi
    2 cd wiringPi
    3 ./build
  2. 解压

    1
    2
    3
    1tar -zxvf wiringPi-xxx.tar.gz
    2cd wiringPi
    3./build

二 安装BCM2583
从bcm22835官网下载最新版本的库,然后解压安装。

1
2
3
4
5
6
tar -zxvf bcm2835-1.xx.tar.gz
cd bcm2835-1.xx
./configure
make
sudo make check
sudo make install

三、python
1、安装RPi.GPIO
(1)先安装python-dev,输入以下指令。
sudo apt-get install python-dev
(2)安装RPi.GPIO和spidev,先下载安装包(RPi.GPIO安装包和spidev安装包,
参见:https://pypi.python.org/pypi/RPi.GPIOhttps://pypi.python.org/pypi/spidev ),
然后通过samba等方式把下载好的文件解压到树莓派上。

四 串口SPI 等等
https://www.cnblogs.com/lulipro/p/5992172.html

Python 支持库 /root/
wpi BCM /

内核模块编译

参考
启动系统后,输入命令uname -a,可以得到输出:

Linux raspberrypi 4.4.34-v7+ #930 SMP Wed Nov 23 15:20:41 GMT 2016 armv7l GNU/Linux

可以知道linux版本是4.4.34-v7+。

编译内核模块需要kernel-headers。输入命令sudo apt-cache search kernel-headers,搜索合适的kernel-headers。结果如下:

raspberrypi-kernel-headers - Header files for the Raspberry Pi Linux kernel

输入命令 sudo apt-get install raspberrypi-kernel-headers,下载安装树莓派kernel-headers。

安装成功后可以在/usr/src目录下生成两个文件夹linux-headers-4.4.34+ 和 linux-headers-4.4.34-v7+,

我们需要使用 linux-headers-4.4.34-v7+。
做make menuconfig时没有看到上面的画面,而是看到一堆英文,则一般是没有安装libncurses5-dev开发库,
使用apt-get install libncurses5-dev来安装就行了
下面是编写模块源码,如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
static int hello_init(void)
{
printk("Hi,raspi linux kernel,i am a hello world module.\n");
return 0;
}
static void hello_exit(void)
{
printk("Goodbye,raspi linux kernel.\n");
}

module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");

接着编写Makefile,内容如下:

1
2
3
4
5
6
KERNEL_DIR:=/usr/src/linux-headers-4.4.34-v7+
obj-m:=hello.o
default:
$(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules
clean:
$(RM) .*.cmd *.mod.c *.o *.ko -r .tmp

输入make命令编译后,生成内核模块文件hello.ko。
输入sudo insmod hello.ko安装模块。
输入sudo rmmod hello卸载模块。
尝试安装和卸载,输入dmesg命令可以在末尾看到:
[ 5137.447586] Hi,raspi linux kernel,i am a hello world module.
[ 5157.380482] Goodbye, raspi linux kernel.

证明模块安装和卸载成功。