imx6ul 官方开发板qspi nor 启动linux 怎么 *** 作

imx6ul 官方开发板qspi nor 启动linux 怎么 *** 作,第1张

已经手动将ucl2.xml 中Quad Nor Flash 内容改成如下

<LIST name="Quad Nor Flash" desc="Choose Quad Nor flash as media">

<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6q%board%_%nor%.imx" ifdev="MX6Q">Loading U-boot</CMD>

<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6dl%board%_%nor%.imx" ifdev="MX6D">Loading U-boot</CMD>

<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6slevk_spi-nor.imx" ifdev="MX6SL">Loading U-boot</CMD>

<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6sx%sxuboot%_sd.imx" ifdev="MX6SX">Loading U-boot</CMD>

<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx7d%7duboot%_sd.imx" ifdev="MX7D">Loading U-boot</CMD>

<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6ulevk_qspi1.imx" ifdev="MX6UL">Loading U-boot</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage" address="0x12000000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6DL">Loading Kernel.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage" address="0x80800000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6SL MX6SX MX7D MX6UL">Loading Kernel.</CMD>

<CMD state="BootStrap" type="load" file="firmware/%initramfs%" address="0x12C00000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6DL">Loading Initramfs.</CMD>

<CMD state="BootStrap" type="load" file="firmware/%initramfs%" address="0x83800000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6SL MX6SX MX7D MX6UL">Loading Initramfs.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage-imx6q-%board%-%nordtb%.dtb" address="0x18000000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q">Loading device tree.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage-imx6dl-%board%-%nordtb%.dtb" address="0x18000000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6D">Loading device tree.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage-imx6sl-evk.dtb" address="0x83000000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6SL">Loading device tree.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage-imx6sx-%sxdtb%.dtb" address="0x83000000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6SX">Loading device tree.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage-imx7d-%7ddtb%.dtb" address="0x83000000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX7D">Loading device tree.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage-imx6ul-14x14-evk.dtb" address="0x83000000"

loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL">Loading device tree.</CMD>

<CMD state="BootStrap" type="jump" >Jumping to OS image. </CMD>

<CMD state="Updater" type="push" body="$ flash_erase /dev/mtd0 0 20">Erasing Boot partition</CMD>

<CMD state="Updater" type="push" body="send" file="files/u-boot-imx6q%board%_%nor%.imx" ifdev="MX6Q">Sending U-Boot</CMD>

<CMD state="Updater" type="push" body="send" file="files/u-boot-imx6dl%board%_%nor%.imx" ifdev="MX6D">Sending U-Boot</CMD>

<CMD state="Updater" type="push" body="send" file="files/u-boot-imx6slevk_spi-nor.imx" ifdev="MX6SL">Sending u-boot.bin</CMD>

<CMD state="Updater" type="push" body="send" file="files/u-boot-imx6sx%sxuboot%_%sxnor%.imx" ifdev="MX6SX">Sending u-boot.bin</CMD>

<CMD state="Updater" type="push" body="send" file="files/u-boot-imx7d%7duboot%_%7dnor%.imx" ifdev="MX7D">Sending u-boot.bin</CMD>

<CMD state="Updater" type="push" body="send" file="files/u-boot-im

首先是spidev,要在/dev/下面产生设备文件,需要spidev的支持

使用的是gpio模拟spi,gpio模拟spi的时序原理是bitbang文件实现的,所以这个也需要打开,如果是在openwrt下动态加载的话就是如下两个配置

如果是直接内核的话是如下两个

跟I2C的arch层一样,主要是devices的添加和board_info的添加,如下

对于platform_add_devices,因为是使用spi_gpio,所以name是"spi_gpio"这样才可以与driver里面的spi_gpio相互匹配probe到。

因为SPI是可以一个总线上面挂多个,然后通过片选脚CS进行硬件切换,所以这变有个num_chipselect需要设置,如果有2个设置就设置2,一个设备就设置1,这边设置好之后,后面board_info也要有对应的个数,而且片选引脚需要不同。

I2C是通过每个设备有自己不同的地址,通过地址来进行软件切换。

对于board_info使用的是spidev,drivers/spi/spidev.c文件,该文件的内容是注册一个spidev驱动。该驱动是一个字符设备驱动。

如果设备与驱动匹配,那么就会执行spidev_probe()的内容。在spidev_probe()函数中会调用device_create()成功后在 /dev 目录下就会生成 spidev 相关的设备节点。

这边有几个参数要注意:

调试过程想看一些细节的debug信息可以打开内核的动态debug信息,这个在以前的print system里面有

printk的等级设置成8.

开始

定位到是 spi_gpio_request 的时候报错

后面就将zkernel/3.10.49/arch/mips/mtk/ziroom/zrmt7628.c里面GPIO的信息调整下, 因为SPI的引脚和LED的引脚号一样 ,内核不知道哪里会检测到。

修改后打印如下:

之后在/dev/下面就生成了spidev1.0的设备

有了/dev/spidev1.0设备之后,就可以在应用成 *** 作改设备收发数据。

在drivers/spi/spidev.c里面已经封装好了ioctl的对应接口,根据这些接口就可以测试使用。

在Documentation/spi/spidev_test.c下面有个应用层的实例,打开看下就清除了。

$(cc) spidev_test.c -o spidev_test生成可执行文件spidev_test

然后拷贝到板子上,将MOSI和MISO短接就可以测试回环数据是否正常。

有逻辑分析仪的接上logic看波形就更加直观。

gpio模拟SPI:

https://blog.csdn.net/luckywang1103/article/details/70145870

在ARM Linux下使用GPIO模拟SPI时序详解:

https://blog.csdn.net/yangzheng_yz/article/details/50470577

linux SPI驱动:

https://www.cnblogs.com/xuyh/category/903809.html


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11780342.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存