You need the correct flash driver file to do this.
A flash driver file is a special ELF file which is loaded to the RAM of the microcontroller and executed there.
The J-Link debugger writes the data to the RAM and the flash driver file then writes this data to the QSPI flash.
In the file JLinkDevices.xml
you'll find a list of already existing flash driver files. Example:
<Device>
<ChipInfo Vendor="O2Micro" Name="OZ93510F160LN" ... />
<FlashBankInfo Name="QSPI Flash" BaseAddr="0x60000000" MaxSize="0x00020000" Loader="Devices/O2Micro/O2Micro_OZ93510F160LN_QSPI.elf" ... />
</Device>
This means:
Name="OZ93510F160LN"
:
The flash driver is valid for this microcontroller.
MaxSize="0x00020000"
:
The size of the QSPI flash
Loader="Devices/O2Micro/O2Micro_OZ93510F160LN_QSPI.elf"
:
The flash driver file
BaseAddr="0x60000000"
:
The QSPI flash corresponds to addresses 0x60000000
to 0x6001FFFF
in the ELF file
This means that you have to compile your ELF file in a way that the data to be written to the QSPI flash is located at address 0x60000000
in the ELF file when using this flash driver.
Unfortunately, some QSPI flash memories require different commands than others. In this case, it might be necessary to write your own flash driver when your QSPI flash uses different commands than supported by the already existing flash driver.