1.内核编译选项增加
(1)Device Drivers/Memory Technology Device (MTD) support --->
(2)Device Drivers/Memory Technology Device (MTD) support /SPI-NOR device support --->
(3)Device Drivers/Memory Technology Device (MTD) support /SPI-NOR device support /Use small 4096 B erase sectors
(4)Device Drivers/Memory Technology Device (MTD) support /Self-contained MTD device drivers --->
(5)Device Drivers/Memory Technology Device (MTD) support /Self-contained MTD device drivers/Support most SPI Flash chips (AT26DF, M25P,W25X, ...)
2.设备树添加
(1)OK3568-C-common.dtsi
&spi0 {
status = "okay";
pinctrl-names = "default", "high_speed";
pinctrl-0 = <&spi0m1_cs0 &spi0m1_pins>;
pinctrl-1 = <&spi0m1_cs0 &spi0m1_pins_hs>;
cs-gpios = <&gpio2 RK_PD2 GPIO_ACTIVE_HIGH>;
m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "winbond,w25q256";
reg = <0>;
m25p,fast-read;
spi-max-frequency = <50000000>;
};
};
(2)rk3568-pinctrl.dtsi
将LCD中的SPI引脚注释掉。
3.操作测试
(1)echo “abcdefg” > /dev/mtd0 向mtd0写入数据
(2)cat /dev/mtd0 //读取mtd0数据,是乱码。
(3)有文件系统的操作
mkfs.vfat /dev/mtd0
mount -t vfat /dev/mtd0 /media/w25q80
cd /media/w25q80
echo "Hello World" > hello.txt