Post Go back to editing

Store a variable in Flash

Hello

I am working on a project which requires some variables to be retained i.e. the value should not changed even after I switch off the system. I thought of storing such variable in a flash. But didn't know how to go ahead in the code to make that variable sit in flash. Also I want that project to be also loaded from flash. I am able to create the loader file and successfully able to boot from flash. But I need to retain some of the variable of the project. Is there any way to achieve this i.e simultaneously store the variable as well as the whole project in a flash and boot it from there. I am using SC584 Eval Kit for the project. Any guidance or sample code will be helpful.

Thanking You

Anukul Anand

Parents
  • Hi,

    Apologies for delay in response.

    We are attached a simple C bare metal code for SPI Flash read and write in Quad mode. Please refer this code.

    Regards,
    Anand Selvaraj.

  • Hi,

    I missed to attach the file.

    Please refer this code.

    0724.SPI_Quad_flash.zip

    Regards,
    Anand Selvaraj.

  • Hello 

    Can I try this example on SC584 board because this kit contains W25Q128FV 128 Mb Flash instead of W25Q32 given in example for BF707 EZ Kit. If any difference is there can you point out where to change such parameters. 

    Thanking You

  • Hi Anukul Anand,

    Sorry for the inconvenience, It is a typo. This code is written for ADSP-SC589. But you can try this example code in ADSP-SC584 board. Please follow the below steps.

    Right click the project,

    Go to properties >> C/C++ build >> Setting >> Processor setting >> change the processor name and silicon version >> Apply >> Apply and close

    Please follow the above steps in all cores. then you run the project in ADSP-SC584.

    If you are using any other flash means please change the code accordingly.

    Regards,
    Anand Selvaraj.

  • Thanks I will try this and I will let you know soon. 

  • Hello

    I tried the given example on SC584 board after changing the processor setting. The read and write buffers didn't match. In first PAGE read, the Read_BUFF misses the first character (i;e it reads from data 0x01 to 0xFF neglecting the starting data 0x00) and hence while matching with Write_BUFF data doesn't match. In the next PAGE read, the Read_BUFF doesn't read the data (it shows all 0xFF) and hence doesn't match the Write_BUFF. This same behavior appears in READ_IN_MEM_MAP_MODE also. 

    This example I am running on same eval board which shows SYS_FAULT LED glowing after running this faq code:

     (Missing Wiki Page) 

    This behavior I already reported in another thread and is still not solved. Please look into this matter and guide me in correct direction. Hoping for favorable response.

    Regards

    Anukul Anand

    Central Research Laboratory,

    Bharat Electronics Limited

  • Hi Anukul Anand,

    Sorry for the delay in response.

    Please try this attached code, that will perform flash write and read respectively. Please, don't flash this project as it reset all location in flash.

    flash_fullchip_complete.zip

    Regards,
    Anand Selvaraj.

  • Hello

    I tried the above attachment and it worked fine. This is able to write and read whole flash in debug mode. My requirement is this:

    1. One Main application will be flashed.

    2. There will be some configuration information such 10KB of data.

    3. The main application will write these info in specified location (which doesn't hinder the already occupied location by main app) on the flash and retain it.

    4. The main application can also read the config info already written before.

    How to know when a loader file is loaded to flash how much space it will take and how much space is available for further writing. Is there any way to get this info. 

    Any idea regarding this will be helpful.

    Anukul Anand

  • Hi,

    The Loader file does indeed contain additional information. This is covered in the 'File Formats' topic within the Loader and Utilities Manual. The Loader file will be significantly larger that the actual space required due to the headers for each record. There is no automated way to get the sizing information, you would need to extract the size from each record's header within the Loader file.

    Please refer the below CCES help path for Loader and Utilities Manual :
    CrossCore® Embedded Studio (version) > SHARC® Development Tools Documentation > Loader and Utilities Manual or please refer the below link.

    www.analog.com/.../cces-loaderutilities-manual.pdf

    We suggest you to write in the last block of the Flash memory, so that main application will not overwritten.

    Regards,
    Anand Selvaraj.

Reply
  • Hi,

    The Loader file does indeed contain additional information. This is covered in the 'File Formats' topic within the Loader and Utilities Manual. The Loader file will be significantly larger that the actual space required due to the headers for each record. There is no automated way to get the sizing information, you would need to extract the size from each record's header within the Loader file.

    Please refer the below CCES help path for Loader and Utilities Manual :
    CrossCore® Embedded Studio (version) > SHARC® Development Tools Documentation > Loader and Utilities Manual or please refer the below link.

    www.analog.com/.../cces-loaderutilities-manual.pdf

    We suggest you to write in the last block of the Flash memory, so that main application will not overwritten.

    Regards,
    Anand Selvaraj.

Children