How to perform QSPI R/W from Linux?

Hey All,

Could anybody help me determine how to write to QSPI memory after Linux has booted from it? Basically, I am trying to store two RBF images in QSPI, one golden image and one “user” image. I would like to write/rewrite the user image while Linux is running. If I can successfully read and write a word to QSPI I can take it from there to accomplish what I need. I would suspect I can utilize the drivers already built into the Kernel but I am not sure how to proceed.

Following this documentation:
https://rocketboards.org/foswiki/view/Documentation/A10GSRD160QspiBoot
I was able to get the basics worked out and can successfully boot into Linux from QSPI loading the FW image from 0x72_0000. The space allocated for the image is much larger than what I will need and I would like to store the second image at 0x17C_F000.

Any help or pointers are very much appreciated!

Thank you,
Steve

To complete the thread and question I was able to determine how to read/write from QSPI. If the device tree is properly updated the partitions will show up in /dev as /dev/mtdblock0, 1, 2, etc.
Here is an example device tree entry for a few partitions:

            part0: partition@0 {
                label = "Boot data";    /* appended from boardinfo */
                reg = <0x00000000 0x00720000>;    /* appended from boardinfo */
            }; //end partition@0 (part0)
            part1: partition@3020000 {
                label = "Root Filesystem - JFFS2";    /* appended from boardinfo */
                reg = <0x03020000 0x04fe0000>;    /* appended from boardinfo */
            }; //end partition@3020000 (part1)
            
            part2: partition@0x720000 {
                label = "Golden FW Image";    /* appended from boardinfo */
                reg = <0x00720000 0x010B0000>;    /* appended from boardinfo */
            }; //end partition@720000 (part2)
            
            part3: partition@17D0000 {
                label = "User FW Image";    /* appended from boardinfo */
                reg = <0x017D0000 0x010B0000>;    /* appended from boardinfo */
            }; //end partition@17D0000 (part3)

From there you can read/write directly using dd.
For example, this will read the 4 bootloaders from QSPI.:
dd if=/dev/mtdblock0 of=block0.bin bs=1M count=1

Additionally via code you can use an ofstream or ifstream:
ifstream stream( “/dev/mtdblock0”, ios::in | ios::binary );

   if ( !stream.is_open() )
   {
     // error handling
   }

   // Read the struct from memory and close the file handle
   stream.read( block_ptr, block_size_bytes);
   stream.close();