UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
293 Views
Registered: ‎09-25-2007

Can't access QSPI from linux

Jump to solution

I have a Zynq-7030 device with a QSPI attached in QSPI single mode (S25FL256) on a custom board. I want to be able to flash the QSPI device from within linux using the 'flashcp' command in the MTD utils package but I'm having issues.

Some information:

- QSPI peripheral is enabled in block design Zynq IP core

- Can successfully program QSPI device from within SDK using qspi_single mode

- Zynq has boot mode pins set to boot from QSPI and does successfully launch u-boot from QSPI

- u-boot sees QSPI device and reports: "SF: Detected s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB"

- u-boot is able to perform all basic operations on the device read/write/erase

- Running Ubuntu 16.04 LTS (Linux 4.9.0-xilinx)

- Have CONFIG_SPI_ZYNQ_QSPI driver enabled (built-in) in kernel

- The default (untouched by me) zynq-7000.dtsi file included with the kernel contains the following:

		qspi: spi@e000d000 {
			clock-names = "ref_clk", "pclk";
			clocks = <&clkc 10>, <&clkc 43>;
			compatible = "xlnx,zynq-qspi-1.0";
			status = "disabled";
			interrupt-parent = <&intc>;
			interrupts = <0 19 4>;
			reg = <0xe000d000 0x1000>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

- I reviewed the above dtsi information and it all seems to check out and match what I can find on various other websites/tutorials and the Zynq TRM.

- In my DTS (which #include's the above dtsi) I have the following:

&qspi {
	u-boot,dm-pre-reloc;
	status = "okay";
	is-dual = <0>;
	num-cs = <1>;
	flash@0 {
		compatible = "s25fl256s1";
		reg = <0x0>;
		spi-max-frequency = <50000000>;
		#address-cells = <1>;
		#size-cells = <1>;
		partition@qspi-boot-bin {
			label = "qspi-boot-bin";
			reg = <0x0 0x2000000>;
		};
	};
};

- I have tried all sorts of various combinations of DTS parameters/values/partitions found on various websites but I still can't see the QSPI device from within linux.

- I have kernel debugging and earlyprintk enabled and I see nothing in the kernel boot log related to any qspi/mtd device. According to this () website I should see something similar to (although not exactly, e.g. different partitions) the following in the kernel boot log:

zynq-qspi e000d000.qspi: master is unqueued, this is deprecated
m25p80 spi0.0: s25fl256s1 (32768 Kbytes)
4 ofpart partitions found on MTD device spi0.0
Creating 4 MTD partitions on "spi0.0":
0x000000000000-0x000000100000 : "qspi-boot"
0x000000100000-0x000000450000 : "qspi-linux"
0x000000450000-0x000000470000 : "qspi-device-tree"
0x000000470000-0x000000d70000 : "qspi-rootfs"
zynq-qspi e000d000.qspi: at 0xE000D000 mapped to 0xE087A000, irq=51

- The kernel boot log reports no errors/warnings of any kind for any peripheral.

- Running 'ls /dev/mtd*' or 'cat /proc/mtd' returns nothing. The Zynq QSPI driver is clearly not loading.

I have never actually had this much trouble trying to get a Zynq peripheral to work. I think I must just be doing something really dumb or missing something very obvious. I've spent several hours trying to debug this already. I could use a fresh pair of eyes. Does anyone have any ideas? It really shouldn't be this hard...it has to be something simple.

-- Jonathon
0 Kudos
1 Solution

Accepted Solutions
Contributor
Contributor
207 Views
Registered: ‎09-25-2007

Re: Can't access QSPI from linux

Jump to solution

HA!! I got it working!! Once I started down the path of thinking "maybe there is something wrong with the MTD subsystem" that lead me to a VERY useful forum post that hadn't popped up in my previous searching!

https://forums.xilinx.com/t5/Embedded-Linux/Linux-kernel-cannot-access-QSPI-MTD/m-p/766109/highlight/true#M19794

All I had to do was enable CONFIG_MTD_M25P80 in the kernel. And like the author in the post above states I too used the "make xilinx_zynq_defconfig" and it does not enable the CONFIG_MTD_M25P80 option by default. That should really be fixed...

-- Jonathon
5 Replies
Xilinx Employee
Xilinx Employee
275 Views
Registered: ‎06-27-2017

Re: Can't access QSPI from linux

Jump to solution

Hi @jwdonal,

I would like to see whether you are using JFFS2 filesystem or initramfs from kernel command line.

Could you please share your complete boot log? 

Best Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.
0 Kudos
Xilinx Employee
Xilinx Employee
273 Views
Registered: ‎06-27-2017

Re: Can't access QSPI from linux

Jump to solution

@jwdonal,

could you please add compatible name as mentioned below,

compatible = "micron,m25p80"; 

Best Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.
0 Kudos
Contributor
Contributor
262 Views
Registered: ‎09-25-2007

Re: Can't access QSPI from linux

Jump to solution

I have attached boot log as requested. I also tried adding the compatible line you suggested and it did not make any difference, still no MTD devices being enumerated.

As far as file structure I have kernel/DTB on small FAT partition on eMMC and then root file system on EXT4 partition on eMMC. I did not specifically enable any JFFS anywhere that I know of. I am also not using initramfs. Here is the output of the mount command:

# mount
/dev/mmcblk0p2 on / type ext4 (rw,relatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=490176k,nr_inodes=122544,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mmcblk0p1 on /mnt/mysdcard_fat type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

Thank you so much for the quick response. I would appreciate it so much if you could help me get this working. It is really annoying me at this point.

-- Jonathon
0 Kudos
Contributor
Contributor
216 Views
Registered: ‎09-25-2007

Re: Can't access QSPI from linux

Jump to solution

Here is some more info. I placed debug dev_info() print statements within the 'probe' method of the drivers/spi/spi-zynq-qspi.c source file and it gets all the way through the probe function and returns 0 (success).  So the driver is in the kernel, it is probing, and it is returning success.

But the kernel is not reporting any MTD devices at all. I don't understand what's wrong. I also checked and I have the MTD subsystem enabled in the kernel as well.

  x Symbol: MTD [=y]                                                                                                               x
  x Type  : tristate                                                                                                               x
  x Prompt: Memory Technology Device (MTD) support                                                                                 x
  x   Location:                                                                                                                    x
  x (1) -> Device Drivers                                                                                                          x
  x   Defined at drivers/mtd/Kconfig:1                                                                                             x
  x   Depends on: GENERIC_IO [=y]

There are many other MTD options which are enabled as well. Maybe there is a specific MTD kernel config option that needs to be enabled?

Now that I see that the zynq QSPI kernel driver is indeed probing and returning success I am now at a total loss for what else to try.

-- Jonathon
0 Kudos
Contributor
Contributor
208 Views
Registered: ‎09-25-2007

Re: Can't access QSPI from linux

Jump to solution

HA!! I got it working!! Once I started down the path of thinking "maybe there is something wrong with the MTD subsystem" that lead me to a VERY useful forum post that hadn't popped up in my previous searching!

https://forums.xilinx.com/t5/Embedded-Linux/Linux-kernel-cannot-access-QSPI-MTD/m-p/766109/highlight/true#M19794

All I had to do was enable CONFIG_MTD_M25P80 in the kernel. And like the author in the post above states I too used the "make xilinx_zynq_defconfig" and it does not enable the CONFIG_MTD_M25P80 option by default. That should really be fixed...

-- Jonathon