Load QSPI during programming in e2 Studio - EK-RA6M5

Hi there,

I've purchased the EK-RA6M5 board and I'm trying to create a FAT partition on the external QSPI and I wanted to load the entire partition at once during the flashing/programming of the board. I have been searching a way of doing that and I have come across some topics here on the forum:  e2 studio download flash and qspi_flash and RE: How to store image in QSPI Flash? which is referenced in the first topic. However, when trying to use J-Flash from SEGGER, it just says that there is no valid license found, so it does not program the device. Using J-Flash Lite, when the .hex file has any data to be programmed in the QSPI, it just throws an error. If it doesn't, then the programming is done sucessfully. I've seen in the J-Flash that there is a Flash loader for the pins that the QSPI is connected to in EK-RA6M5 and I understood that I need to use this to program the QSPI, but I can't figure out how to do it. Is there anyway someone could explain this part to me ? I'm just trying to throw all of my files of the FAT partition in one flash to the QSPI and then let the webserver access them using FileX.

  • You can use jlink commander.

    Create a file with the following contents called upload_blinky

    // USAGE: jlink upload_blinky
    log upload_blinky.log
    Exec DEVICE_SelectLoader BankAddr=0x60000000 Loader=CLK@P305_nCS@P306_D0@P307_D1@P308_D2@P309_D3@P310
    Device R7FA6M5BH
    SelectInterface SWD
    Speed 4000
    //Reset
    //Halt
    Connect
    LoadFile blinky.bin 0x60000000
    Exit

    Make sure Jlink is in your path and run the script with the syntax:  jlink upload_blinky.

    of course, replace blinky.bin with your file.

    You can upload *.bin files and hex files.  Run jlink without any arguments and type ?

    ----------------------
    J-Link>? LoadFIle
    ----------------------
    Command long name: LoadFile
    Command short name: LoadFile
    Syntax: LoadFile <FileName>, [<Addr> (.bin only)].
    Function: Load data file into target memory. Supported ext.: *.bin, *.mot, *.hex, *.srec, *.elf, *.out, *.axf
    Requires connection to J-Link: yes
    Requires connection to target: yes

  • I forgot to mention.  If you create your own board these are the only supported pinnings.  If you use one not in this list, then you would need to contract with Segger to build a custom script for your board.

  • Hi Dale,

    Followed your instructions, but it returned an error:

    Downloading file [filesystem.bin]...

    ****** Error: SEGGER_OPEN_GetFlashInfo(): Algo reported a flash size of 0 bytes.
    Error while determining flash info (Bank @ 0x60000000)
    Unspecified error -1
    J-Link>Exit

    I'm using the EK-RA6M5 board, not a custom board, so the pinning is correct and it should have worked ...

  • // USAGE: jlink upload_blinky
    log upload_blinky.log
    Exec DEVICE_SelectLoader BankAddr=0x60000000 Loader=CLK@P305_nCS@P306_D0@P307_D1@P308_D2@P309_D3@P310
    Device R7FA6M5BH
    SelectInterface SWD
    Speed 4000
    //Reset
    //Halt
    Connect
    LoadFile blinky.bin 0x60000000
    Exit

    This script (i added the .txt so I could attach it, so remove the .txt) works without issue on my EK-RA6M5 version 1 board.  Have you tried loading it with the debugger?   In the debug configuration-->startup tab, click the Add... button in the Load images and symbols section and add your bin.  The load type should be raw Binary and the offset should be 6000000   like this:

    Check all the jumpers to make sure they are set correctly.  I would recommend running the QSPI example project from the example bundle.  Also, make sure you are using the latest version of Jlink. I am using 7.96.

  • Hi Dale,

    I know the QSPI is working since I was able to take the code from the example given by Renesas and do a chip erase + format the media as a FAT partition + create a file + load the file with html code and have the webserver find that file and serve the webpage correctly. So, I'm assuming the jumpers are set correctly.

    I haven't tried with the debugger because I couldn't figure out how to do it. Even if I add in the fsp.lld file a memory section in the qspi region to place my .bin file, it does not load anything to the QSPI. If I set a memory view to the section where the QSPI is, I only see 0's when my .bin is not just 0's. I can only see something different than 0 when I do a media_open after formating the media as a FAT partition.

    I've updated my jlink today, it's at DLL version V7.98h, compiled Sep 11 2024 14:31:28.

    Here is the complete output of the file:

    C:\dev\spain\workspace\tti_web_test>jlink upload_qspi
    SEGGER J-Link Commander V7.98h (Compiled Sep 11 2024 14:32:20)
    DLL version V7.98h, compiled Sep 11 2024 14:31:28
    
    
    J-Link Command File read successfully.
    Processing script file...
    J-Link>log upload_qspi.log
    J-Link connection not established yet but required for command.
    Connecting to J-Link via USB...O.K.
    Firmware: J-Link OB-S124 compiled Jul  3 2024 17:03:07
    Hardware version: V1.00
    J-Link uptime (since boot): 0d 00h 00m 39s
    S/N: 831883512
    USB speed mode: Full speed (12 MBit/s)
    VTref=3.300V
    J-Link>Exec DEVICE_SelectLoader BankAddr=0x60000000 Loader=CLK@P305_nCS@P306_D0@P307_D1@P308_D2@P309_D3@P310
    Flash bank @ 0x60000000: Stored loader selection. Loader = CLK@P305_nCS@P306_D0@P307_D1@P308_D2@P309_D3@P310
    J-Link>Device R7FA6M5BH
    J-Link>SelectInterface SWD
    Selecting SWD as current target interface.
    J-Link>Speed 4000
    Selecting 4000 kHz as target interface speed
    J-Link>Connect
    Device "R7FA6M5BH" selected.
    
    
    Connecting to target via SWD
    ConfigTargetSettings() start
    Configuring FlashDLNoRMWThreshold=0x200 in order to make sure that option bytes programming is done via read-modify-write
    ConfigTargetSettings() end - Took 530us
    InitTarget() start
    SWD selected. Executing JTAG -> SWD switching sequence.
    DAP initialized successfully.
    Determining TrustZone configuration...
      Secure Debug: Enabled (SSD)
    Determining currently configured transfer type by reading the AHB-AP CSW register.
      --> Correct transfer type configured. Done.
    InitTarget() end - Took 10.8ms
    Found SW-DP with ID 0x6BA02477
    DPIDR: 0x6BA02477
    CoreSight SoC-400 or earlier
    Scanning AP map to find all available APs
    AP[2]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x84770001, ADDR: 0x00000000)
    AP[1]: APB-AP (IDR: 0x54770002, ADDR: 0x01000000)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FE000
    CPUID register: 0x410FD214. Implementer code: 0x41 (ARM)
    Feature set: Mainline
    Cache: No cache
    Found Cortex-M33 r0p4, Little endian.
    FPUnit: 8 code (BP) slots and 0 literal slots
    Security extension: implemented
    Secure debug: enabled
    CoreSight components:
    ROMTbl[0] @ E00FE000
    [0][0]: E0044000 CID B105900D PID 005BB906 DEVARCH 00000000 DEVTYPE 14 CTI (?)
    [0][1]: E0047000 CID B105900D PID 003BB908 DEVARCH 00000000 DEVTYPE 12 CSTF
    [0][2]: E0048000 CID B105900D PID 001BB961 DEVARCH 00000000 DEVTYPE 21 ETB
    [0][3]: E0049000 CID B105F00D PID 001BB101 TSG
    [0][4]: E0040000 CID B105900D PID 000BBD21 DEVARCH 00000000 DEVTYPE 11 TPIU
    [0][5]: E00FF000 CID B105100D PID 000BB4C9 ROM Table
    ROMTbl[1] @ E00FF000
    [1][0]: E000E000 CID B105900D PID 000BBD21 DEVARCH 47702A04 DEVTYPE 00 Cortex-M33
    [1][1]: E0001000 CID B105900D PID 000BBD21 DEVARCH 47701A02 DEVTYPE 00 DWT
    [1][2]: E0002000 CID B105900D PID 000BBD21 DEVARCH 47701A03 DEVTYPE 00 FPB
    [1][3]: E0000000 CID B105900D PID 000BBD21 DEVARCH 47701A01 DEVTYPE 43 ITM
    [1][5]: E0041000 CID B105900D PID 002BBD21 DEVARCH 47724A13 DEVTYPE 13 ETM
    [1][6]: E0042000 CID B105900D PID 000BBD21 DEVARCH 47701A14 DEVTYPE 14 CSS600-CTI
    Memory zones:
      Zone: "Default" Description: Default access mode
    Cortex-M33 identified.
    J-Link>LoadFile filesystem.bin 0x60000000
    'loadfile': Performing implicit reset & halt of MCU.
    ResetTarget() start
    Reset: ARMv8M core with Security Extension enabled detected. Switch to secure domain.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    ResetTarget() end - Took 62.8ms
    Downloading file [filesystem.bin]...
    
    ****** Error: SEGGER_OPEN_GetFlashInfo(): Algo reported a flash size of 0 bytes.
    Error while determining flash info (Bank @ 0x60000000)
    Unspecified error -1
    J-Link>Exit
    
    Script processing completed.

  • Try erasing all the flash memory on the board first.  You can use jflashlite.  If something is running on the board it may be interfering.   I'll update my jlink to 7.98h and see if it still works for me.

    The memory region will show all 0's if the qspi has not been opened.

  • When you open jflashlite, it displays the various flash banks. Only the first two are selected. If I select all flash banks including the External QSPI flash one, it fails:

    Connecting to J-Link...
    Bank selection: BankAddr=0x0100A100 Enabled
    Bank selection: BankAddr=0x00000000 Enabled
    Bank selection: BankAddr=0x08000000 Enabled
    Bank selection: BankAddr=0x60000000 Enabled
    Loader selection: BankAddr=0x0100A100 Loader=Default
    Loader selection: BankAddr=0x00000000 Loader=Default
    Loader selection: BankAddr=0x08000000 Loader=Default
    Loader selection: BankAddr=0x60000000 Loader=CLK@P305_nCS@P306_D0@P307_D1@P308_D2@P309_D3@P310
    Connecting to target...
    Erasing...
    ERROR: Could not erase chip.
    Done.

    However, if I deselect the last flash bank, the one for the External QSPI, it now works properly:

    Connecting to J-Link...
    Bank selection: BankAddr=0x0100A100 Enabled
    Bank selection: BankAddr=0x00000000 Enabled
    Bank selection: BankAddr=0x08000000 Enabled
    Bank selection: BankAddr=0x60000000 Disabled
    Loader selection: BankAddr=0x0100A100 Loader=Default
    Loader selection: BankAddr=0x00000000 Loader=Default
    Loader selection: BankAddr=0x08000000 Loader=Default
    Loader selection: BankAddr=0x60000000 Loader=CLK@P305_nCS@P306_D0@P307_D1@P308_D2@P309_D3@P310
    Connecting to target...
    Erasing...
    Done.

    Now, even after doing all of this, running the commander again, it fails saying the exact same thing I've posted previously. I modified your example to adapt to my needs, so my file is:

    // USAGE: jlink upload_qspi
    log upload_qspi.log
    Exec DEVICE_SelectLoader BankAddr=0x60000000 Loader=CLK@P305_nCS@P306_D0@P307_D1@P308_D2@P309_D3@P310
    Device R7FA6M5BH
    SelectInterface SWD
    Speed 4000
    //Reset
    //Halt
    Connect
    LoadFile filesystem.bin 0x60000000
    Exit

    I've saved it as upload_qspi without any extension, so I think that is fine. Even if the .bin file had some issue, I don't think it would impact the read of the QSPI. I will reread the manual for this board and make sure that all jumpers are correct, but again, I've been able to deal with the QSPI using FileX and LevelX routines ... 

  • Ok so, apparentely, the QSPI was either stuck or in some weird state. After doing the program flash erase and power cycling the board, the jflashlite could actually communicate with the QSPI, erase it and program it with the commander. Now it throws a BSP_CFG_HANDLE_UNRECOVERABLE_ERROR when trying to open the media, but I'm assuming that is normal and that the data that I've uploaded to the QSPI is not exactly correct. I'll keep working on it. Thank you very much for your help.

  • You're not the only one that has struggled with this. Not sure exactly what might have been going on.  Like you said, perhaps the QSPI got itself into some strange state?