[SOLVED] Issues creating flashloader for FRAM flash connected over SPI.

  • [SOLVED] Issues creating flashloader for FRAM flash connected over SPI.

    I have an NXP MCU connected to FRAM flash over a SPI peripheral connection. I am trying to create a flashloader for the MCU that can program, erase, and read data from the FRAM chip.

    Currently everything appears to be working in Debug mode in SES. I have some dummy data in the main.c file and can read, erase or program the FRAM. However, it doesn't work as well in JLink or JFlash using the Release version.

    In JFlash I can't do anything, it says that the FRAM flash bank is overlapping with the internal flash of the MCU. The internal flash of the MCU starts at 0x0 and is 0x00100000 bytes (1 MB). I currently have the FRAM flash bank base address set at 0xE0083000 and it is 0x20000 bytes (128 kB) long. I wasn't sure what the base address should be but in the MCU reference manual, it said that area wasn't used. So I don't see how those are overlapping at all. (this first issue isn't that big of a deal because ultimately I plan on using JLink Commander with script files to automate things and JFlash won't be used but its still odd)

    However, I can erase parts of the FRAM flash bank in JLink Commander (and I can verify that the erase operation worked by reading the flash back in SES debug mode). However, I can't read the flash data properly in JLink Commander because when I use the "mem" command and do something like this:

    Source Code

    1. mem 0xE0083000 0x100
    It just returns the memory at the address 0xE0083000 in the MCU. So how can I read back the memory at address 0x0 in the FRAM flash? Ultimately I would want to use the SaveBin command but that just reads back the same data as the mem command.
  • Hi,
    Thank you for your inquiry.

    Did you implement the read function in your flashloader?
    wiki.segger.com/SEGGER_Flash_Loader#SEGGER_FL_Read

    BR
    Fabian
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi SEGGER,

    I have theh same question as FrankM. Is there any furthur solution?
    I would like to use savebin from external flash memory with customized flash loader in JLink commander. But when use mem or savebin, the SEGGER_Open_Read seems not been loaded, is it normal? Or the SEGGER_Open_Read is not as expected usage for read callback ?
    Thanks
  • sharon,

    mem and savebin don't use the SEGGER_Open_Read custom flashloader function. I found another way of doing it that has worked for me.

    The issue I described above with the overlapping flashbanks error in J-Flash is now resolved in the latest J-Flash version. So instead of using J-Link commander to read memory and save it to a .bin, I ended up using J-Flash. You can run J-Flash from the command line and create a command like this: JFlash.exe /min /wait -openprjProjectName.jflash -readrange0x0,0x100 -saveasFile.bin,0x0,0x100 -hide -exit

    To create the ProjectName.jflash you can just open jflash and configure it with the correct device and then save the project. When you use the -readrange command in J-Flash it does use the custom flashloader SEGGER_Open_Read function.

    Info about the various command line options are documented in the JFlash manual chapter 5.
  • FrankM,

    Thanks for the sharing. I'll try with JFlash. The SEGGER_Open_Read function will be called.


    SEGGER-Fabian,

    I am confused that the loadbin and read by JLink will use SEGGER_Open_Program in flashloader but savebin and mem won't.
    wiki.segger.com/SEGGER_Flash_Loader and wiki.segger.com/J-Link_Device_Support_Kit does not mention about which supported by JLink or JFlash.
    Is there any other document or reference could I get more information? Thanks.
  • Hi sharon,
    The Mem and SaveBin commands are supposed to show the memory from the CPU's point of view.
    Therefore it would not be correct to use the SEGGER_FL_Read() function when using these commands,as they would not represent the memory space that the CPU "sees" anymore.

    BR
    Fabian
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Fabian,

    Trying with JFlash, the readrange called the SEGGER_FL_Read() but cannot save the data to specificed file.
    What below is my execute command:

    JFlash.exe -openprjMyDevice.jflash /min /wait -readrange,0x10078000,0x10080000 -saveasmydata.bin,0x10078000,0x10080000 -exit

    1. -saveas<FILENAME>[,<SADDR>,<EADDR>] seems that to save the config data not the read data, is it?
    2. -saveas<FILENAME>[,<SADDR>,<EADDR>] : The SADDR and EADDR was meant to be the ADDR of FILENAME or the memory addr?
    3. If wanna read data and save to file as savebin does from external flash with flashloader. Which tools or command can make it?
    I've tried out the command usage and the question 1,2,3 could be ignored.

    But the readrange seen not work to parsing EADDR.

    Thanks.

    BR
    Sharon

    The post was edited 2 times, last by sharon: I've tried out the command usage and the question 1,2,3 could be ignored. But the readrange seen not work to parsing EADDR. ().

  • sharon,
    In the command you posted, there shouldn't be a comma between -readrange and 0x1007800.

    So it should be like this:
    JFlash.exe -openprjMyDevice.jflash /min /wait -readrange0x10078000,0x10080000 -saveasmydata.bin,0x10078000,0x10080000 -exit

    Not sure if that will solve your issue but I did notice that bug in your command.