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: 
Highlighted
Adventurer
Adventurer
2,804 Views
Registered: ‎07-11-2018

Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi

 

I wanted to read and write to QSPI flash on my custom board(ZC702), for example storing the log, serial number etc.

Is there any Linux userspace examples to perform read and write to QSPI flash.

 

Please suggest.

0 Kudos
1 Solution

Accepted Solutions
Voyager
Voyager
2,710 Views
Registered: ‎09-14-2016

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi @umamahesh,

 

It will be my last message in this thread.

 

In my opinion you have all you need to do what you what.

 

I gave you all commands... You have just to code... And it's not our job to do that.

 

Last tips: 

http://www.wiki.xilinx.com/U-Boot+QSPI+Driver

http://www.wiki.xilinx.com/Zynq+QSPI+Driver

http://www.wiki.xilinx.com/Qspi

 

[EDIT]: In order to close the thread:

 

#include <mtd/mtd-user.h>

..

mtd_info_t mtd_info;

....

int fd = open("/dev/mtd0", O_RDWR); // open the mtd device

...

lseek...
read...
write...

 

Cheers,

Trigger

View solution in original post

9 Replies
Voyager
Voyager
2,795 Views
Registered: ‎09-14-2016

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution
0 Kudos
Adventurer
Adventurer
2,790 Views
Registered: ‎07-11-2018

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi Trigger,

 

I wanted to implement in my code, is there any APIs so that I can read and write to QSPI flash instead of running a command.

For example, from user there may a request to store log in QSPI flash, I need to design the code to store the log.

 

Please suggest.

0 Kudos
Voyager
Voyager
2,787 Views
Registered: ‎09-14-2016

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi @umamahesh,

 

Suggest what ?

 

We cannot help you if doesn't know exactly what you want to do...

 

I wanted to implement in my code

C/C++ ? python ? bash ? ...

 

 from user there may a request to store log in QSPI flash

o.0

 

Cheers,

Trigger

0 Kudos
Adventurer
Adventurer
2,774 Views
Registered: ‎07-11-2018

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi trigger,

 

I have to implement in C. For example I am running a series of test, the results I need to store in QSPI flash.

0 Kudos
Voyager
Voyager
2,734 Views
Registered: ‎09-14-2016

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi @umamahesh,

 

We have to know a little bit more about you want else it's to complicated to understand what you want to do ...

 

QSPI --> Ok

File system ? Y/N

If File system which one ? JFFS2 / UBIFS

Do you have partition(s) ?

 

So if you want help give us more input :)

 

Cheers,

Trigger

0 Kudos
Adventurer
Adventurer
2,730 Views
Registered: ‎07-11-2018

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi Trigger,

 

QSPI is enabled, not sure if filesystem is required for jut storing logs and some key code. In case filesystem jffs2 will be preferred.

Not sure on the partitions, y default what has been enabled in the petalinux build will be used.

 

All I need to know is how to read and write to QSPI flash with some APIs from a userspace C program,

0 Kudos
Voyager
Voyager
2,724 Views
Registered: ‎09-14-2016

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi @umamahesh,

 

Depends to what log... Please without more details we cannot help you. 

 

It's really simple, no FS -> search how to read/write block device

FS -> read/write (with file-system) like on a SD-card/eMMC/us stick ...

 

More info :

 

Programming QSPI Flash from Linux Console

Linux offers a complete set of utilities to manage the QSPI Flash.

 

Once the partitions are defined in the Device Tree, they can be listed in Linux using the command 'cat /proc/mtd':

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00800000 00010000 "Flash 0 Raw Data"
mtd1: 00800000 00010000 "Flash 1 jffs2 Filesystem" 

 

The following commands are available to manipulate QSPI Flash:

Command Description Usage

flash_eraseErase flash partitionflash_erase >flash_partition< 0 0
flashcpCopy file to flash partitionflashcp >file_name< >flash_partition<
mtdinfoDisplay flash infomtdinfo
mtd_debug infoDisplay flash infomtd_debug info <device>
mtd_debug readRead flashmtd_debug read <device> <offset> <len> <dest-filename>
mtd_debug writeWrite flashmtd_debug write <device> <offset> <len> <source-filename>
mtd_debug eraseErase flashmtd_debug erase <device> <offset> <len>

 

PS: Please search a little bit on internet ...

 

Cheers,

Trigger

0 Kudos
Adventurer
Adventurer
2,716 Views
Registered: ‎07-11-2018

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi Trigger,

Your information is acceptable but how to do in programming. For instance the request comes from user to erase flash and store a secret key in QSPI, how will I develop application using the information you have provided.

0 Kudos
Voyager
Voyager
2,711 Views
Registered: ‎09-14-2016

Re: Read/write to QSPI flash from userspace (ZC702)

Jump to solution

Hi @umamahesh,

 

It will be my last message in this thread.

 

In my opinion you have all you need to do what you what.

 

I gave you all commands... You have just to code... And it's not our job to do that.

 

Last tips: 

http://www.wiki.xilinx.com/U-Boot+QSPI+Driver

http://www.wiki.xilinx.com/Zynq+QSPI+Driver

http://www.wiki.xilinx.com/Qspi

 

[EDIT]: In order to close the thread:

 

#include <mtd/mtd-user.h>

..

mtd_info_t mtd_info;

....

int fd = open("/dev/mtd0", O_RDWR); // open the mtd device

...

lseek...
read...
write...

 

Cheers,

Trigger

View solution in original post