OrangePi 香橙派 开启 I2C 和 SPI

硬件准备:Orangepi-PC 香橙派 (早期的型号,1G RAM ,资源还是很丰富的)

软件准备:Debian_jessie_mini.img (来自官网的系统),MobaXterm

Orangepi-PC 香橙派 默认开启I2C-0和spidev0,如果你有多个设备,可能就有些不太方便了,下面我们来开启全部的I2C和SPI。

首先,安装git和libusb

apt-get install git libusb-1.0

然后下载sunxi-tools并编译

git clone git://github.com/linux-sunxi/sunxi-tools.git
cd sunxi-tools
make

再ls查看你就会看见fex2bin 和 bin2fex了

将script.bin复制到当前目录下

cp /media/boot/script.bin ./

再将script.bin转成fex格式

./bin2fex script.bin > ./script.fex

其实script.fex就是文本文件,用记事本打开,找到如下字段并修改

[boot_init_gpio]
used = 0
gpio0 = port:PA15<1><1>
gpio1 = port:PG11<1><1>
[twi0]
twi_used = 1
twi_scl = port:PA11<2>
twi_sda = port:PA12<2>

[twi1]
twi_used = 1
twi_scl = port:PA18<3>
twi_sda = port:PA19<3>

[twi2]
twi_used = 1
twi_scl = port:PE12<3>
twi_sda = port:PE13<3>
[spi1]
spi_used = 1
spi_cs_bitmap = 1
spi_cs0 = port:PA13<2><1>
spi_sclk = port:PA14<2>
spi_mosi = port:PA15<2>
spi_miso = port:PA16<2>

[spi_devices]
spi_dev_num = 2

为了启用SPI1,还需要添加一段

[spi_board1]
modalias = "spidev"
max_speed_hz = 33000000
bus_num = 1
chip_select = 0
mode = 0
full_duplex = 1
manual_cs = 0

将修改过的script.fex转回script.bin并放回原处

./fex2bin script.fex > ./script.bin
cp ./script.bin /media/boot/

最后,重启系统,就可以看到全部的I2C和SPI都启用了

root@OrangePI:/home# ls /dev |grep i2c
i2c-0
i2c-1
i2c-2
root@OrangePI:/home# ls /dev |grep spi
spidev0.0
spidev1.0

 

你可能感兴趣的:(香橙派,linux)