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

ifconfig -a (不加-a参数,只能查启用的网卡) 例如:网卡名 eth0 启用网卡命名 ifconfig eth0 up 禁用网卡命名 ifconfig eth0 down 验证了 suse系统/redhat系统/ubuntu系统/Frdora系统/CentOS系统,均能使用。

这一问题来自项目中一个实际的需求:

我需要在Linux启动之后,确认我指定的芯片寄存器是否与我在uboot的配置一致。

举个例子:

寄存器地址:0x20000010负责对DDR2的时序配置,该寄存器是在uboot中设置,现在我想在Linux运行后,读出改寄存器的值,再来检查该寄存器是否与uboot的配置一致。

Linux应用程序运行的是虚拟空间,有没有什么机制可以是完成我提到的这一需求。若行,还请附些测试代码。

谢谢!

这个需要用mmap()函数将寄存器物理地址映射用户空间的虚拟地址,即将寄存器的那段内存映射到用户空间,函数介绍如下:

void*

mmap(void

*

addr,

size_t

len,

int

prot,

int

flags,

int

fd,

off_t

offset)

该函数映射文件描述符

fd

指定文件的

[offset,

offset

+

len]

物理内存区至调用进程的

[addr,

addr

+

len]

的用户空间虚拟内存区,通常用于内存共享或者用户空间程序控制硬件设备,函数的返回值为最后文件映射到用户空间的地址,进程可直接 *** 作该地址。下面是测试代码(仅供参考):

#define

DDR2_REG_BASE

(0x20000000)

#define

MAP_SIZE

4096UL

#define

MAP_MASK

(MAP_SIZE

-

1)

static

unsigned

int

pTestRegBase

static

int

dev_fd

dev_fd

=

open("/dev/mem",

O_RDWR

|

O_NDELAY)

if

(dev_fd

<</SPAN>

0)

{

LOGE("open(/dev/mem)

failed.")

return

}

pTestRegBase

=

(void

*)mmap(NULL,

MAP_SIZE,

PROT_READ

|

PROT_WRITE,

MAP_SHARED,

dev_fd,DDR2_REG_BASE

&

~MAP_MASK)

if

(MAP_FAILED

==

pTestRegBase)

{

printf("mmap

failed.

fd(%d),

addr(0x%x),

size(%d)\n",

dev_fd,

DDR2_REG_BASE,

MAP_SIZE)

}

else

{

unsigned

int

reg_value

=

*((volatile

unsigned

int

*)(pTestRegBase

+

10))

printf("reg_value

=

0xx\n",

reg_value)

munmap((void*)pTestRegBase,

MAP_SIZE)

}

pTestRegBase

=

0

if(dev_fd)

close(dev_fd)

这里将DDR2_REG_BASE开始大小为1个page的物理地址映射到了用户空间,然后就可以用pTestRegBase作为起始地址 *** 作寄存器了。


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

原文地址: http://outofmemory.cn/yw/8292055.html

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

发表评论

登录后才能评论

评论列表(0条)

保存