linux只W25Q256驱动,使用m25p80,支持w25q系列nor flash

1.内核编译选项增加

(1)Device Drivers/Memory Technology Device (MTD) support --->linux只W25Q256驱动,使用m25p80,支持w25q系列nor flash_第1张图片

(2)Device Drivers/Memory Technology Device (MTD) support /SPI-NOR device support --->linux只W25Q256驱动,使用m25p80,支持w25q系列nor flash_第2张图片

(3)Device Drivers/Memory Technology Device (MTD) support /SPI-NOR device support /Use small 4096 B erase sectors

linux只W25Q256驱动,使用m25p80,支持w25q系列nor flash_第3张图片

(4)Device Drivers/Memory Technology Device (MTD) support /Self-contained MTD device drivers --->

linux只W25Q256驱动,使用m25p80,支持w25q系列nor flash_第4张图片

(5)Device Drivers/Memory Technology Device (MTD) support /Self-contained MTD device drivers/Support most SPI Flash chips (AT26DF, M25P,W25X, ...)

linux只W25Q256驱动,使用m25p80,支持w25q系列nor flash_第5张图片

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 

你可能感兴趣的:(linux,linux,microsoft,运维)