This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

osal_read() and osal_write problem

Other Parts Discussed in Thread: CC2650

Hi,
 I am using CC2650 controller and tying to write flash memory. i want to store some parameter in flash. when i ask for help in this forum i was adviced to use these functions. after trying to use thsi functions i have the following doubts
1) when writing only   like FlashTest = osal_snv_write( 0x80, 28, z); where z is an array of size 28, i colud not write an array having a size >28. when lenth in this function is set to 29 or more i cant debugg or run the code.
2) when using write followed by read  like
  FlashTest = osal_snv_write( 0x80, 12, z);
   osal_snv_read(0x80, 12, y);
Maximum size is limited to 12, if i try to increse the length more than 12 , system not working
3) when writing, data is being written to different addresses, even if i am giving the same id each time. Why ?? what is the meaning of this id value??
4) how can i erase an already written location?

  • hi,
     I want to know maximum no.of bytes that can be written to falsh with an id using osal_snv_write function
    Thank You

  • Hello,

    Likely it's not the size but how/where you are calling the osal_snv_xxx API. Since this is an ICall API, you need to call from an ICall registered task and it must be in a TASK context. Do not call from a callback, SWI, HWI, etc. In any event, you can use the debugger to step through the osal_snv code if you see an issue.

    To erase, just write FF or 00 over your value. Note that wear leveling is used, so a new value is written to a different location on each write until a compaction occurs.

    osalSnvLen_t is either 8 bits or 16-bits, see osal_snv.h. Note that the max flash size is 4kB, and the GAP Bond Manager uses this location as well.

    Also, may I ask that you create a single thread on this topic or update one of your existing threads for future inquires on this topic.

    Best wishes
  • Hi,
    Thank You for your time and reply.

    Likely it's not the size but how/where you are calling the osal_snv_xxx API. Since this is an ICall API, you need to call from an ICall registered task and it must be in a TASK context. Do not call from a callback, SWI, HWI, etc.


    I am calling from the task

    To erase, just write FF or 00 over your value. Note that wear leveling is used, so a new value is written to a different location on each write until a compaction occurs.

    So if i erase and write like this:

    FlashTest1= osal_snv_write( 0x80, 29, y); // where char y[29] = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
    FlashTest1= osal_snv_write( 0x80, 29, x); // where char x[29] = "12345678901234567890123456789"

    it first it write fffff to a location , then it write my values to next location, right???

    osalSnvLen_t is either 8 bits or 16-bits, see osal_snv.h. Note that the max flash size is 4kB, and the GAP Bond Manager uses this location as well.

    I know this, but my problem is :

    1.if i write(without calling read after this) a char array of length greater than 29 it wont works.if i try to write a leght greater than 29 , program hangs, i cant run/debugg/load the code.

    2. if i call read after write , then max size i can write is reduced to 12. if i try to write a leght greater than 12 , program hangs, i cant run/debugg/load the code.

    Also, may I ask that you create a single thread on this topic or update one of your existing threads for future inquires on this topic.


    i want to keep this thread on this topic

  • hi
    when i change the task stack size from 512 to 1024 its working now!!. thank you
  • hi,
    I have another doubt. these functions are for writing and reading SNV section only , right?. i want to store  log data on NV flash  , which functions we have to use? i found a flash.c file and nvcop.c file. functions in which one i have to use?.

    EDIT: on searchon i found osal_nv_write function too... now i am totally confused

  • Actually, SNV driver read/write data on NV flash.
  • So the functions in nvcop.c and flash.c are same as as this?. i want to store a message in flash. it require more than 4kb. what will i do?

    EDIT: on searching i found osal_nv_write function too... now i am totally confused

  • Where do you get this nvcop.c?
  • FYI, it's nvocop.c.

    SNV is an example implementation for read/write to flash. The "SNV flash pages" are standard 4kB flash sectors.

    Best wishes
  • sorry it  was nvocop.c. typing error (C:\ti\simplelink\ble_cc26xx_2_01_00_44423\Components\services\nv\cc26xx)

  • hi i want to write data read from internal temparature sensnor and RTC to flash memory periodically. for that what i did is : i added osal_read() and write functions within EDPDevice_performPeriodicTask();. is that the right way to do this???? or any other way?. (i observed that i can write flash once)

    if (events & EDP_PERIODIC_EVT)
    {
    events &= ~EDP_PERIODIC_EVT;

    Util_startClock(&periodicClock);

    // Perform periodic application task
    EDPDevice_performPeriodicTask();

    }
  • Although I don't have experiences using functions in nvocop.c, they look similar to osal_snv_XXX. If you require more than 4Kb, I would suggest you to use an external EEPROM or FLASH as storage.