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.
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:
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();