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.

LAUNCHXL-F280025C: Warning: Failed unlocking device (zone 1) after reset.

Part Number: LAUNCHXL-F280025C
Other Parts Discussed in Thread: UNIFLASH

Hi,

I have FLASH issues after modified codes based on flashapi_ex1_programming example, now even reinstall the original flashapi_ex1_programming, I still encountered error messages : 

Warning: Failed unlocking device (zone 1) after reset.  

I did touch or set any password, can you please tell me how to unlock it ? and how to prevent it from lock again ? 

I tried UNIFLASH to erase with same error returned.

thanks,

Patrick

  • Patrick,

    Maybe you programmed DCSM OTP by mistake.

    Can you check the password locations in the memory window and see if it is visible?  If they are visible, you can copy it to Uniflash GUI to unlock the device.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    Can you check the password locations in the memory window and see if it is visible?  If they are visible, you can copy it to Uniflash GUI to unlock the device.

    where's the memory windows  ? 

    Thanks

    Patrick

  • Patrick,

    CCS debug view menu -> View -> Memory browser.

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    The problem is I couldn't get DEBUG windows because compile failed.

    see my last attachment, my Memory Browser windows is empty !

    Thanks,

    Patrick  

  • Patrick,

    That error is not a compilation failure error.  That error is related to unlocking the device.

    Once the debugger connection is established to the device, open the CCS memory window for the password locations and check for the values in those locations.  If you are able to read those locations, you can use those values to unlock the device.  

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    Thanks for your follow up, however as I said before without compiled, my MEMORY BROWSER (memory window that you mentioned) windows is empty, before my FLASH was locked I can check memory contains there, READ and WRITE variables in exact location.

    C28xx_CPU1: GEL Output: ... DCSM Initialization Start ...
    C28xx_CPU1: GEL Output: ... DCSM Initialization Done ...
    C28xx_CPU1: Warning: Failed unlocking device (zone 1) after reset.
    C28xx_CPU1: Warning: Failed unlocking device (zone 2) after reset.
    C28xx_CPU1: Flash Programmer: Error erasing Sector 0. FMSTAT (STATCMD on some devices) value = 1040. Operation Cancelled (0).
    C28xx_CPU1: File Loader: Memory write failed: Unknown error
    C28xx_CPU1: GEL: File: /Users/dannychan/workspace_v11/universal_motorcontrol_lab_f28002x/Flash_lib_DRV8323RH/universal_motorcontrol_lab_f28002x.out: Load failed.

    But UNIFLASH can show Memory contain, does it help ? 

    Thanks,

    Patrick

  • Hi Patrick,

    I will review and get back to you this week.

    Thanks and regards,
    Vamsi

  • Patrick,

    In the memory window snapshot that you provided, the address is shown as 0x00000000.

    As you know, you need to enter the desired address to view the content at that address - please enter the address of the password locations and see what values you see there.

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    yes this is UNIFLASH interface, as I said I can browser MEMORY from UNIFLASH not CCS debug view menu -> View -> Memory browser (you mentioned)

    OK, if you agree UNIFLASH can solve my problem, please let me know what's next ? 

    Thanks,

    Patrick 

  • Patrick,

    It does not matter which tool you use, if you are able to see the password values in the memory window, you can copy them to the GUI's password fields and click on unlock.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    f you are able to see the password values in the memory window, you can copy them to the GUI's password fields and click on unlock.

    I don't know where about ? can you tell me how ? 

    Thanks,

    Patrick

  • Patrick,

    Did you read the DCSM chapter in the TRM?  If not, I would suggest you to read it.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    Did you read the DCSM chapter in the TRM?  If not, I would suggest you to read it.

    yes please, what's TRM ? 

    Thanks,

    Patrick

  • Patrick,

    Technical Reference Manual available here: https://www.ti.com/product/TMS320F280025C

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    f you are able to see the password values in the memory window, you can copy them to the GUI's password fields and click on unlock.

    Can you tell me where's the memory address of Password values stored ? 

    Thanks,

    Patrick

  • Hi Vamsi,

    I tried to load the value from MEMORY location e.g. PSWDLOCK, Zone_Select_Blockx 

    Look liked I couldn't load any value with UNIFLASH too, right ? 

    Thanks,

    Patrick

  • Patrick,

    You might have programmed PSWDLOCK field as well at 0x78010.  If that is programmed, you won't be able to read the passwords.  

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    I pressed the Program OTPSECLOCK button, I still have Failed unlocking device (zone 1) ... error, can you let me know why  ?

    Thanks,

    Patrick

  • Patrick,

    I am assigning this thread to our security expert to help you further.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    Thank you for your excellent supports  Slight smile

    Thanks,

    Patrick

  • Hi,

    Look like the password is programmed so you need to use the password to unlock the device.

    Regards,

    Vivek Singh

  • Hi Vivek,

    Look like the password is programmed so you need to use the password to unlock the device.

    how can you tell password is programmed ? 

    I didn't use any password on my board, after modified some codes of the example "flashapi_ex1_programming" I got the following error.

    C28xx_CPU1: Warning: Failed unlocking device (zone 1) after reset.
    C28xx_CPU1: Warning: Failed unlocking device (zone 2) after reset.

    so you need to use the password to unlock the device.

    I don't know the password since I didn't enter to it Disappointed

    Thanks,

    Patrick

  • Hi Vivek / Vamsi,

    Any update ? 

    Thanks,

    Patrick

  • Patrick,

    You might have programmed the password and the PSWDLOCK by mistake.

    Unless you know the password, you won't be able to unlock this device.

    Maybe you can check the map file (and/or the hex file generated from the executable out file) and see if anything is mapped to the DCSM OTP password locations by mistake in your application.

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    Maybe you can check the map file (and/or the hex file generated from the executable out file) and see if anything is mapped to the DCSM OTP password locations by mistake in your application.

    I have attached my MAP file can you help to check if it's overlap with password location  ?

    Also I don't have ELF / HEX file generated because of errors  

    ******************************************************************************
                 TMS320C2000 Linker Unix v21.6.0                   
    ******************************************************************************
    >> Linked Mon Sep  5 15:04:05 2022
    
    OUTPUT FILE NAME:   <flashapi_ex1_programming.out>
    ENTRY POINT SYMBOL: "code_start"  address: 00080000
    
    
    MEMORY CONFIGURATION
    
             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      BOOT_RSVD             00000002   00000126  00000000  00000126  RWIX
      RAMM0                 00000128   000002d8  00000000  000002d8  RWIX
      RAMM1                 00000400   000003f8  00000380  00000078  RWIX
      RAMLS4567             0000a000   00002000  00000139  00001ec7  RWIX
      RAMGS0                0000c000   000007f8  00000000  000007f8  RWIX
      BEGIN                 00080000   00000002  00000002  00000000  RWIX
      FLASH_BANK0_SEC0      00080002   00000ffe  00000000  00000ffe  RWIX
      FLASH_BANK0_SEC1      00081000   00001000  00000279  00000d87  RWIX
      FLASH_BANK0_SEC2      00082000   00001000  000007c3  0000083d  RWIX
      FLASH_BANK0_SEC3      00083000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC4      00084000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC5      00085000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC6      00086000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC7      00087000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC8      00088000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC9      00089000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC10     0008a000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC11     0008b000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC12     0008c000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC13     0008d000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC14     0008e000   00001000  00000000  00001000  RWIX
      FLASH_BANK0_SEC15     0008f000   00000ff0  00000000  00000ff0  RWIX
      BOOTROM               003f0000   00008000  00000000  00008000  RWIX
      BOOTROM_EXT           003f8000   00007fc0  00000000  00007fc0  RWIX
      RESET                 003fffc0   00000002  00000000  00000002  RWIX
    
    
    SECTION ALLOCATION MAP
    
     output                                  attributes/
    section   page    origin      length       input sections
    --------  ----  ----------  ----------   ----------------
    codestart 
    *          0    00080000    00000002     
                      00080000    00000002     f28002x_codestartbranch.obj (codestart)
    
    .cinit     0    00081268    00000014     
                      00081268    00000009     (.cinit..data.load) [load image, compression = lzss]
                      00081271    00000001     --HOLE-- [fill = 0]
                      00081272    00000004     (__TI_handler_table)
                      00081276    00000002     --HOLE-- [fill = 0]
                      00081278    00000004     (__TI_cinit_table)
    
    .reset     0    003fffc0    00000000     DSECT
    
    .stack     0    00000400    00000380     UNINITIALIZED
                      00000400    00000380     --HOLE--
    
    .init_array 
    *          0    00081000    00000000     UNINITIALIZED
    
    .data      0    0000a130    0000000a     UNINITIALIZED
                      0000a130    00000006     rts2800_fpu32_eabi.lib : exit.c.obj (.data)
                      0000a136    00000002                            : _lock.c.obj (.data:_lock)
                      0000a138    00000002                            : _lock.c.obj (.data:_unlock)
    
    .const     0    00081130    00000136     
                      00081130    0000009b     driverlib.lib : flash.obj (.const:.string)
                      000811cb    00000001     --HOLE-- [fill = 0]
                      000811cc    0000009a                   : sysctl.obj (.const:.string)
    
    .TI.ramfunc 
    *          0    00081000    0000012f     RUN ADDR = 0000a000
                      00081000    0000003f     driverlib.lib : flash.obj (.TI.ramfunc:Flash_initModule)
                      0008103f    0000002d                   : flash.obj (.TI.ramfunc:Flash_setBankPowerMode)
                      0008106c    00000024                   : flash.obj (.TI.ramfunc:Flash_setWaitstates)
                      00081090    0000001e                   : flash.obj (.TI.ramfunc:Flash_setPumpPowerMode)
                      000810ae    0000001a                   : flash.obj (.TI.ramfunc:Flash_disableCache)
                      000810c8    0000001a                   : flash.obj (.TI.ramfunc:Flash_disablePrefetch)
                      000810e2    00000019                   : flash.obj (.TI.ramfunc:Flash_enableCache)
                      000810fb    00000019                   : flash.obj (.TI.ramfunc:Flash_enablePrefetch)
                      00081114    00000017                   : flash.obj (.TI.ramfunc:Flash_enableECC)
                      0008112b    00000004                   : sysctl.obj (.TI.ramfunc)
    
    .text      0    00082000    000007c3     
                      00082000    00000133     driverlib.lib : sysctl.obj (.text:SysCtl_setClock)
                      00082133    000000fe                   : sysctl.obj (.text:SysCtl_isPLLValid)
                      00082231    0000009a     device.obj (.text:Device_enableAllPeripherals)
                      000822cb    00000088     rts2800_fpu32_eabi.lib : fs_div28.asm.obj (.text)
                      00082353    0000007a     driverlib.lib : sysctl.obj (.text:DCC_setCounterSeeds)
                      000823cd    00000043                   : sysctl.obj (.text:SysCtl_selectOscSource)
                      00082410    0000003d                   : interrupt.obj (.text:Interrupt_initModule)
                      0008244d    00000031     rts2800_fpu32_eabi.lib : copy_decompress_lzss.c.obj (.text:decompress:lzss)
                      0008247e    0000002b     driverlib.lib : sysctl.obj (.text:SysCtl_selectXTAL)
                      000824a9    0000002b     rts2800_fpu32_eabi.lib : autoinit.c.obj (.text:__TI_auto_init_nobinit_nopinit)
                      000824d4    00000029                            : exit.c.obj (.text)
                      000824fd    00000026     driverlib.lib : sysctl.obj (.text:SysCtl_pollX1Counter)
                      00082523    00000025                   : sysctl.obj (.text:DCC_enableSingleShotMode)
                      00082548    00000024     device.obj (.text:Device_init)
                      0008256c    0000001f     driverlib.lib : sysctl.obj (.text:DCC_setCounter0ClkSource)
                      0008258b    0000001f                   : sysctl.obj (.text:DCC_setCounter1ClkSource)
                      000825aa    0000001e                   : interrupt.obj (.text:Interrupt_initVectorTable)
                      000825c8    0000001d     rts2800_fpu32_eabi.lib : memcpy.c.obj (.text)
                      000825e5    0000001a     driverlib.lib : sysctl.obj (.text:SysCtl_selectXTALSingleEnded)
                      000825ff    00000019     flashapi_ex1_programming.obj (.text:main)
                      00082618    00000017     driverlib.lib : sysctl.obj (.text:DCC_disableDoneSignal)
                      0008262f    00000017     device.obj (.text:SysCtl_enablePeripheral)
                      00082646    00000017     driverlib.lib : sysctl.obj (.text:SysCtl_enablePeripheral)
                      0008265d    00000017     rts2800_fpu32_eabi.lib : boot28.asm.obj (.text)
                      00082674    00000016     driverlib.lib : sysctl.obj (.text:DCC_clearDoneFlag)
                      0008268a    00000016                   : sysctl.obj (.text:DCC_clearErrorFlag)
                      000826a0    00000016                   : sysctl.obj (.text:DCC_disableErrorSignal)
                      000826b6    00000015                   : sysctl.obj (.text:DCC_isBaseValid)
                      000826cb    00000015     device.obj (.text:GPIO_unlockPortConfig)
                      000826e0    00000014     driverlib.lib : sysctl.obj (.text:DCC_disableModule)
                      000826f4    00000014                   : sysctl.obj (.text:DCC_enableModule)
                      00082708    00000010     device.obj (.text:Device_initGPIO)
                      00082718    00000010     driverlib.lib : flash.obj (.text:Flash_isCtrlBaseValid)
                      00082728    00000010                   : flash.obj (.text:Flash_isECCBaseValid)
                      00082738    0000000e                   : interrupt.obj (.text:Interrupt_defaultHandler)
                      00082746    0000000d                   : interrupt.obj (.text:Interrupt_disableMaster)
                      00082753    0000000d     device.obj (.text:SysCtl_setLowSpeedClock)
                      00082760    0000000c     driverlib.lib : sysctl.obj (.text:SysCtl_setPLLSysClk)
                      0008276c    0000000c     rts2800_fpu32_eabi.lib : args_main.c.obj (.text)
                      00082778    0000000b     driverlib.lib : sysctl.obj (.text:SysCtl_isMCDClockFailureDetected)
                      00082783    00000009     rts2800_fpu32_eabi.lib : _lock.c.obj (.text)
                      0008278c    00000008     device.obj (.text:SysCtl_disableWatchdog)
                      00082794    00000008     rts2800_fpu32_eabi.lib : copy_decompress_none.c.obj (.text:decompress:none)
                      0008279c    00000008     f28002x_codestartbranch.obj (.text)
                      000827a4    00000007     device.obj (.text:ASysCtl_lockVREG)
                      000827ab    00000007     driverlib.lib : sysctl.obj (.text:SysCtl_resetMCD)
                      000827b2    00000007     device.obj (.text:__error__)
                      000827b9    00000003     flashapi_ex1_programming.obj (.text:Example_Done)
                      000827bc    00000002     driverlib.lib : interrupt.obj (.text:Interrupt_illegalOperationHandler)
                      000827be    00000002                   : interrupt.obj (.text:Interrupt_nmiHandler)
                      000827c0    00000002     rts2800_fpu32_eabi.lib : pre_init.c.obj (.text)
                      000827c2    00000001                            : startup.c.obj (.text)
    
    MODULE SUMMARY
    
           Module                         code   ro data   rw data
           ------                         ----   -------   -------
        ./
           flashapi_ex1_programming.obj   28     0         0      
        +--+------------------------------+------+---------+---------+
           Total:                         28     0         0      
                                                                  
        ./device/
           device.obj                     285    0         0      
           f28002x_codestartbranch.obj    10     0         0      
        +--+------------------------------+------+---------+---------+
           Total:                         295    0         0      
                                                                  
        /Applications/ti/ccs1120/ccs/tools/compiler/ti-cgt-c2000_21.6.0.LTS/lib/rts2800_fpu32_eabi.lib
           fs_div28.asm.obj               136    0         0      
           copy_decompress_lzss.c.obj     49     0         0      
           exit.c.obj                     41     0         6      
           autoinit.c.obj                 43     0         0      
           memcpy.c.obj                   29     0         0      
           boot28.asm.obj                 23     0         0      
           _lock.c.obj                    9      0         4      
           args_main.c.obj                12     0         0      
           copy_decompress_none.c.obj     8      0         0      
           pre_init.c.obj                 2      0         0      
           startup.c.obj                  1      0         0      
        +--+------------------------------+------+---------+---------+
           Total:                         353    0         10     
                                                                  
        /Users/dannychan/ti/C2000Ware_4_01_00_00/driverlib/f28002x/driverlib/ccs/Debug/driverlib.lib
           sysctl.obj                     1167   154       0      
           flash.obj                      630    155       0      
           interrupt.obj                  122    0         0      
        +--+------------------------------+------+---------+---------+
           Total:                         1919   309       0      
                                                                  
           Stack:                         0      0         896    
           Linker Generated:              0      17        0      
        +--+------------------------------+------+---------+---------+
           Grand Total:                   2595   326       906    
    
    
    LINKER GENERATED COPY TABLES
    
    __TI_cinit_table @ 00081278 records: 1, size/record: 4, table size: 4
    	.data: load addr=00081268, load size=00000009 bytes, run addr=0000a130, run size=0000000a bytes, compression=lzss
    
    
    LINKER GENERATED HANDLER TABLE
    
    __TI_handler_table @ 00081272 records: 2, size/record: 2, table size: 4
    	index: 0, handler: __TI_decompress_lzss
    	index: 1, handler: __TI_decompress_none
    
    
    GLOBAL DATA SYMBOLS: SORTED BY DATA PAGE
    
    address     data page           name
    --------    ----------------    ----
    00000400      10 (00000400)     __stack
    
    0000a130     284 (0000a100)     __TI_enable_exit_profile_output
    0000a132     284 (0000a100)     __TI_cleanup_ptr
    0000a134     284 (0000a100)     __TI_dtors_ptr
    0000a136     284 (0000a100)     _lock
    0000a138     284 (0000a100)     _unlock
    
    
    GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name 
    
    page  address   name                           
    ----  -------   ----                           
    0     000824d4  C$$EXIT                        
    0     00082231  Device_enableAllPeripherals    
    0     00082548  Device_init                    
    0     00082708  Device_initGPIO                
    0     000827b9  Example_Done                   
    0     0000a000  Flash_initModule               
    0     00082410  Interrupt_initModule           
    0     000825aa  Interrupt_initVectorTable      
    abs   0008112f  RamfuncsLoadEnd                
    abs   0000012f  RamfuncsLoadSize               
    abs   00081000  RamfuncsLoadStart              
    abs   0000a12f  RamfuncsRunEnd                 
    abs   0000012f  RamfuncsRunSize                
    abs   0000a000  RamfuncsRunStart               
    0     0000a12b  SysCtl_delay                   
    0     00082133  SysCtl_isPLLValid              
    0     000823cd  SysCtl_selectOscSource         
    0     0008247e  SysCtl_selectXTAL              
    0     000825e5  SysCtl_selectXTALSingleEnded   
    0     00082000  SysCtl_setClock                
    0     00081278  __TI_CINIT_Base                
    0     0008127c  __TI_CINIT_Limit               
    0     0008127c  __TI_CINIT_Warm                
    0     00081272  __TI_Handler_Table_Base        
    0     00081276  __TI_Handler_Table_Limit       
    0     00000780  __TI_STACK_END                 
    abs   00000380  __TI_STACK_SIZE                
    0     000824a9  __TI_auto_init_nobinit_nopinit 
    0     0000a132  __TI_cleanup_ptr               
    0     0008244d  __TI_decompress_lzss           
    0     00082794  __TI_decompress_none           
    0     0000a134  __TI_dtors_ptr                 
    0     0000a130  __TI_enable_exit_profile_output
    abs   ffffffff  __TI_pprof_out_hndl            
    abs   ffffffff  __TI_prof_data_size            
    abs   ffffffff  __TI_prof_data_start           
    0     000822cb  __c28xabi_divf                 
    n/a   UNDEFED   __c_args__                     
    0     000827b2  __error__                      
    0     00000400  __stack                        
    0     0008276c  _args_main                     
    0     0008265d  _c_int00                       
    0     0000a136  _lock                          
    0     0008278b  _nop                           
    0     00082787  _register_lock                 
    0     00082783  _register_unlock               
    0     000827c2  _system_post_cinit             
    0     000827c0  _system_pre_init               
    0     0000a138  _unlock                        
    0     000824d4  abort                          
    0     00080000  code_start                     
    0     000824d6  exit                           
    0     000825ff  main                           
    0     000825c8  memcpy                         
    
    
    GLOBAL SYMBOLS: SORTED BY Symbol Address 
    
    page  address   name                           
    ----  -------   ----                           
    0     00000400  __stack                        
    0     00000780  __TI_STACK_END                 
    0     0000a000  Flash_initModule               
    0     0000a12b  SysCtl_delay                   
    0     0000a130  __TI_enable_exit_profile_output
    0     0000a132  __TI_cleanup_ptr               
    0     0000a134  __TI_dtors_ptr                 
    0     0000a136  _lock                          
    0     0000a138  _unlock                        
    0     00080000  code_start                     
    0     00081272  __TI_Handler_Table_Base        
    0     00081276  __TI_Handler_Table_Limit       
    0     00081278  __TI_CINIT_Base                
    0     0008127c  __TI_CINIT_Limit               
    0     0008127c  __TI_CINIT_Warm                
    0     00082000  SysCtl_setClock                
    0     00082133  SysCtl_isPLLValid              
    0     00082231  Device_enableAllPeripherals    
    0     000822cb  __c28xabi_divf                 
    0     000823cd  SysCtl_selectOscSource         
    0     00082410  Interrupt_initModule           
    0     0008244d  __TI_decompress_lzss           
    0     0008247e  SysCtl_selectXTAL              
    0     000824a9  __TI_auto_init_nobinit_nopinit 
    0     000824d4  C$$EXIT                        
    0     000824d4  abort                          
    0     000824d6  exit                           
    0     00082548  Device_init                    
    0     000825aa  Interrupt_initVectorTable      
    0     000825c8  memcpy                         
    0     000825e5  SysCtl_selectXTALSingleEnded   
    0     000825ff  main                           
    0     0008265d  _c_int00                       
    0     00082708  Device_initGPIO                
    0     0008276c  _args_main                     
    0     00082783  _register_unlock               
    0     00082787  _register_lock                 
    0     0008278b  _nop                           
    0     00082794  __TI_decompress_none           
    0     000827b2  __error__                      
    0     000827b9  Example_Done                   
    0     000827c0  _system_pre_init               
    0     000827c2  _system_post_cinit             
    abs   0000012f  RamfuncsLoadSize               
    abs   0000012f  RamfuncsRunSize                
    abs   00000380  __TI_STACK_SIZE                
    abs   0000a000  RamfuncsRunStart               
    abs   0000a12f  RamfuncsRunEnd                 
    abs   00081000  RamfuncsLoadStart              
    abs   0008112f  RamfuncsLoadEnd                
    abs   ffffffff  __TI_pprof_out_hndl            
    abs   ffffffff  __TI_prof_data_size            
    abs   ffffffff  __TI_prof_data_start           
    n/a   UNDEFED   __c_args__                     
    
    [54 symbols]
    

    You might have programmed the password and the PSWDLOCK by mistake.

    I just modify the TI example flashapi_ex1_programming and added data read write to 0x86100U, and this is within section 6, nowhere else.

    #define DataArea_start 0x86000U
    #define OptionArea_start 0x86100U

    #define W_DATA_IN_FLASH_BUFFER 0x100
    #define W_OPTION_IN_FLASH_BUFFER 0x100

    uint16_t DataBuffer[W_DATA_IN_FLASH_BUFFER];
    uint16_t OptionBuffer[W_OPTION_IN_FLASH_BUFFER];

    for(i=0, u32Data_Index = DataArea_start; (u32Data_Index < (DataArea_start + W_DATA_IN_FLASH_BUFFER)); i+= 8, u32Data_Index+= 8)
    {
       oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Data_Index, DataBuffer+i, 8, 0, 0,                       Fapi_AutoEccGeneration);

       while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);

       if(oReturnCheck != Fapi_Status_Success)
       {
          Example_Error(oReturnCheck);
       }
    }

    .
    .
    .


    for(j=0, u32Option_Index = OptionArea_start; (u32Option_Index < (OptionArea_start + W_OPTION_IN_FLASH_BUFFER)); j+=8, u32Option_Index+= 8)
    {
       oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Option_Index, OptionBuffer+j, 8, 0, 0,                   Fapi_AutoEccGeneration);

       while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);

       if(oReturnCheck != Fapi_Status_Success)
       {
          Example_Error(oReturnCheck);
       }
    }

    Vamsi, please help, at lease to point out what's going on both my code or setting caused this so that it won't happened again !!!!!!

    Thanks,

    Patrick 

  • Patrick,

    I don't see any thing mapped to the DCSM OTP in your map file.

    Maybe you might have entered some values for the password and PSWDLOCK locations in the GUI by mistake?  Please check.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    Maybe you might have entered some values for the password and PSWDLOCK locations in the GUI by mistake?  Please check.

    I don't think so, I am still in the learning path of TI MCU, learning how to READ WRITE variables to / from FLASH, therefore modify based on example "flashapi_ex1_programming", at first everything was fine, until I added #define OptionArea_start 0x86100U to see if I can share both DataArea_start (0x86000U) and OptionArea_start (0x86100U) within sector 6 ... then did debug got below error messages : 

    C28xx_CPU1: Warning: Failed unlocking device (zone 1) after reset.
    C28xx_CPU1: Warning: Failed unlocking device (zone 2) after reset.

    Then download and install UNIFLASH to see what's inside FLASH area ... 

    Thanks,

    Patrick

  • Hi Patrick,

    There is no any other way to lock this device except by programming the password.  

    If you don't know the password, there is no way to unlock this.

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    If I order new board, how to prevent it from accidentally locked (I think you still believe my board was locked by mistake), such as programme my own password first ?

    If you have time can you take a look of my codes because I am afraid if I run this code I will lock my board again.

    Thanks,

    Patrick

    //#############################################################################
    //
    // FILE:   flashapi_ex1_programming.c
    //
    // TITLE:  Flash programming example
    //
    //! \addtogroup driver_example_list
    //! <h1> Flash Programming with AutoECC, DataAndECC, DataOnly and EccOnly </h1>
    //!
    //! This example demonstrates how to program Flash using API's following options
    //! 1. AutoEcc generation
    //! 2. DataOnly and EccOnly
    //! 3. DataAndECC
    //!
    //! \b External \b Connections \n
    //!  - None.
    //!
    //! \b Watch \b Variables \n
    //!  - None.
    //!
    //
    //#############################################################################
    // $Copyright:
    // Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //#############################################################################
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    
    //
    // Include Flash API include file
    //
    #include "F021_F28002x_C28x.h"
    
    //
    // Include Flash API example header file
    //
    #include "flash_programming_f28002x.h"
    
    //
    // Defines
    //
    
    //
    // Length (in 16-bit words) of data buffer used for program
    //
    #define  WORDS_IN_FLASH_BUFFER    0x100
    
    //
    // Globals
    //
    
    
    
    
    
    //
    // Data Buffers used for program operation using the flash API program function
    //
    #pragma     DATA_SECTION(DataBuffer,"DataBufferSection");
    //uint16_t    Buffer[WORDS_IN_FLASH_BUFFER];
    
    
    #define DataArea_start              0x86000U
    #define OptionArea_start            0x86100U
    
    #define W_DATA_IN_FLASH_BUFFER      0x100
    #define W_OPTION_IN_FLASH_BUFFER    0x100
    
    
    uint16_t    DataBuffer[W_DATA_IN_FLASH_BUFFER];
    uint16_t    OptionBuffer[W_OPTION_IN_FLASH_BUFFER];
    
    uint32_t    *Buffer32 = (uint32 *)DataBuffer;
    
    uint16_t    DataVar_01, DataVar_02, DataVar_03, DataVar_04, DataVar_05, DataVar_06, DataVar_07, DataVar_255, DataVar_256;
    uint16_t    DataVar_08, result_08;
    uint32_t    DataVar_09, result_09;
    float32_t   DataVar_10, result_10;
    
    
    uint16_t    OptionVar_01;
    
    
    
    
    
    //
    // Prototype of the functions used in this example
    //
    void Example_Error(Fapi_StatusType status);
    void Example_Done(void);
    void Example_CallFlashAPI(void);
    void FMSTAT_Fail(void);
    void ECC_Fail(void);
    void Example_EraseSector(void);
    void Example_ProgramUsingAutoECC(void);
    void Example_ProgramUsingDataOnlyECCOnly(void);
    void Example_ProgramUsingDataAndECC(void);
    
    //
    // Main
    //
    void main(void)
    {
        //
        // Initialize device clock and peripherals
        // Copy the Flash initialization code from Flash to RAM
        // Copy the Flash API from Flash to RAM
        // Configure Flash wait-states, fall back power mode, performance features
        // and ECC
        //
        Device_init();
    
        //
        // Initialize GPIO
        //
        Device_initGPIO();
    
        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();
    
        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;
    
        //
        // At 100MHz, execution wait-states for external oscillator is 4. Modify the
        // wait-states when the system clock frequency is changed.
        //
        Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, 4);
    
        //
        // Flash API functions should not be executed from the same bank on which
        // erase/program operations are in progress.
        // Also, note that there should not be any access to the Flash bank on
        // which erase/program operations are in progress.  Hence below function
        // is mapped to RAM for execution.
        //
        //Example_CallFlashAPI();
    
    
        //
        // Example is done here
        //
        Example_Done();
    }
    
    
    //*****************************************************************************
    //  Example_CallFlashAPI
    //
    //  This function will interface to the flash API.
    //  Flash API functions used in this function are executed from RAM in this
    //  example.
    //*****************************************************************************
    #ifdef __cplusplus
    #pragma CODE_SECTION(".TI.ramfunc");
    #else
    #pragma CODE_SECTION(Example_CallFlashAPI, ".TI.ramfunc");
    #endif
    void Example_CallFlashAPI(void)
    {
        uint16 i = 0;
        Fapi_StatusType  oReturnCheck;
    
        //
        // Initialize the Flash API by providing the Flash register base address
        // and operating frequency(in MHz).
        // This function is required to initialize the Flash API based on System
        // frequency before any other Flash API operation can be performed.
        // This function must also be called whenever System frequency or RWAIT is
        // changed.
        //
        oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, DEVICE_SYSCLK_FREQ/1000000U);
    
        if(oReturnCheck != Fapi_Status_Success)
        {
            //
            // Check Flash API documentation for possible errors
            //
            Example_Error(oReturnCheck);
        }
    
        //
        // Initialize the Flash banks and FMC for erase and program operations.
        // Fapi_setActiveFlashBank() function sets the Flash banks and FMC for
        // further Flash operations to be performed on the banks.
        //
        oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
    
        if(oReturnCheck != Fapi_Status_Success)
        {
            //
            // Check Flash API documentation for possible errors
            //
            Example_Error(oReturnCheck);
        }
    
        //
        // Erase the sector before programming
        //
        Example_EraseSector();
    
        //
        // Fill a buffer with data to program into the flash.
        //
        //for(i=0; i < WORDS_IN_FLASH_BUFFER; i++)
        //{
        //    Buffer[i] = i;
        //}
    
    
    
    
    
    
        //
        // Program the sector using AutoECC option
        //
       Example_ProgramUsingAutoECC();
    
    
       //var_01 = *(uint16*)(Bzero_Sector6_start + 8);
    
       //ResultBuffer = (uint32)0x86000U;
    
       //memcpy(&result_08, (0x86000U+7), 1);
       //memcpy(&result_09, (0x86000U+8), 2);
    
       result_09 = *(uint32*)(DataArea_start + 8);
       result_10 = *(float32_t*)(DataArea_start + 10);
    
    
       //float dataflash1 = -1000.0f;
      // float gain;
       //uint32_t Address= 0x08008000;
       //.......
       //FLASH_ProgramWord(Address,dataflash1);
       //.......
       //gain=*(float*)Address;
    
    
        //
        // Erase the sector before programming
        //
        //Example_EraseSector();
    
        //
        // Program the sector using DataOnly and ECCOnly options
        //
        //Example_ProgramUsingDataOnlyECCOnly();
    
        //
        // Erase the sector before programming
        //
        //Example_EraseSector();
    
        //
        // Program the sector using DataAndECC option
        //
        //Example_ProgramUsingDataAndECC();
    
        //
        // Erase the sector for cleaner exit from the example.
        //
        //Example_EraseSector();
    
    }
    
    
    
    //*****************************************************************************
    //  Example_ProgramUsingDataOnlyECCOnly
    //
    //  Example function to Program data in Flash using "DataOnly" option and ECC
    //  using "EccOnly" option.
    //  Flash API functions used in this function are executed from RAM in this
    //  example.
    //*****************************************************************************
    #ifdef __cplusplus
    #pragma CODE_SECTION(".TI.ramfunc");
    #else
    #pragma CODE_SECTION(Example_ProgramUsingDataOnlyECCOnly, ".TI.ramfunc");
    #endif
    void Example_ProgramUsingDataOnlyECCOnly(void)
    {
        uint32 u32Data_Index = 0;
        uint16 i = 0, ECC_B = 0, ECC_LB = 0, ECC_HB = 0;
        uint64 *LData, *HData, dataLow, dataHigh;
        Fapi_StatusType  oReturnCheck;
        Fapi_FlashStatusType  oFlashStatus;
        Fapi_FlashStatusWordType  oFlashStatusWord;
    
        //
        // Program data using "DataOnly" option and ECC using "EccOnly" option.
        //
        // When DataOnly option is used, Flash API will program only the data
        // portion in Flash at the address specified.
        //
        // When EccOnly option is used, Flash API will program only the ECC portion
        // in Flash ECC memory space (Flash main array address should be provided
        // for this function and not the corresponding ECC address).
        // Fapi_calculateEcc is used to calculate the corresponding ECC of the data.
        //
        // Note that data buffer (Buffer) is aligned on 64-bit boundary for verify
        // reasons.
        //
        // In this example, 0x100 bytes are programmed in Flash Sector6
        // along with the specified ECC.
        //
    
        for(i=0, u32Data_Index = Bzero_Sector6_start; (u32Data_Index < (Bzero_Sector6_start + WORDS_IN_FLASH_BUFFER)); i+= 8, u32Data_Index+= 8)
        {
            //
            // Point LData to the lower 64 bit data
            // and   HData to the higher 64 bit data
            //
            LData = (uint64 *)(Buffer32 + i/2);
            HData = (uint64 *)(Buffer32 + i/2 + 2);
    
            //
            // Calculate ECC for lower 64 bit and higher 64 bit data
            //
            // extern uint8 Fapi_calculateEcc(uint32 u32Address, uint64 u64Data);
    
            ECC_LB = Fapi_calculateEcc(u32Data_Index,*LData);
            ECC_HB = Fapi_calculateEcc(u32Data_Index+4,*HData);
            ECC_B = ((ECC_HB<<8) | ECC_LB);
    
            oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Data_Index,DataBuffer+i, 8, 0, 0, Fapi_DataOnly);
    
            //
            // Wait until the Flash program operation is over
            //
            while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
            if(oReturnCheck != Fapi_Status_Success)
            {
                //
                // Check Flash API documentation for possible errors
                //
                Example_Error(oReturnCheck);
            }
    
            //
            // Read FMSTAT register contents to know the status of FSM after
            // program command to see if there are any program operation related
            // errors
            //
            oFlashStatus = Fapi_getFsmStatus();
            if(oFlashStatus != 0)
            {
                //Check FMSTAT and debug accordingly
                FMSTAT_Fail();
            }
    
            oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Data_Index, 0, 0, &ECC_B, 2, Fapi_EccOnly);
    
            //
            // Wait until the Flash program operation is over
            //
            while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
            if(oReturnCheck != Fapi_Status_Success)
            {
                //
                // Check Flash API documentation for possible errors
                //
                Example_Error(oReturnCheck);
            }
    
            //
            // Read FMSTAT register contents to know the status of FSM after
            // program command to see if there are any program operation related
            // errors
            //
            oFlashStatus = Fapi_getFsmStatus();
            if(oFlashStatus != 0)
            {
                //
                // Check FMSTAT and debug accordingly
                //
                FMSTAT_Fail();
            }
    
            Flash_enableECC(FLASH0ECC_BASE);
    
            //
            // Read back the programmed data to check if there are any ECC failures
            //
            dataLow = *(uint64 *)(u32Data_Index);
    
            Flash_ErrorStatus errorStatusLow = Flash_getLowErrorStatus(FLASH0ECC_BASE);
            if((errorStatusLow != FLASH_NO_ERR) || (dataLow != *LData))
            {
                ECC_Fail();
            }
    
            dataHigh = *(uint64 *)(u32Data_Index + 4);
    
            Flash_ErrorStatus errorStatusHigh = Flash_getHighErrorStatus(FLASH0ECC_BASE);
            if((errorStatusHigh != FLASH_NO_ERR) || (dataHigh != *HData))
            {
                ECC_Fail();
            }
    
            //
            // Verify the programmed values.  Check for any ECC errors.
            //
            oReturnCheck = Fapi_doVerify((uint32 *)u32Data_Index, 4, Buffer32 + (i/2), &oFlashStatusWord);
    
            if(oReturnCheck != Fapi_Status_Success)
            {
                //
                // Check Flash API documentation for possible errors
                //
                Example_Error(oReturnCheck);
            }
        }
    }
    
    //*****************************************************************************
    //  Example_ProgramUsingDataAndECC
    //
    //  Example function to Program data in Flash using "DataAndEcc" option.
    //  Flash API functions used in this function are executed from RAM in this
    //  example.
    //*****************************************************************************
    #ifdef __cplusplus
    #pragma CODE_SECTION(".TI.ramfunc");
    #else
    #pragma CODE_SECTION(Example_ProgramUsingDataAndECC, ".TI.ramfunc");
    #endif
    void Example_ProgramUsingDataAndECC(void)
    {
        uint32 u32Data_Index = 0;
        uint16 i = 0, ECC_B = 0, ECC_LB = 0, ECC_HB = 0;
        uint64 *LData, *HData, dataLow, dataHigh;
        Fapi_StatusType  oReturnCheck;
        Fapi_FlashStatusType  oFlashStatus;
        Fapi_FlashStatusWordType  oFlashStatusWord;
    
        //
        // Program data and ECC in Flash using "DataAndEcc" option.
        // When DataAndECC option is used, Flash API will program both the supplied
        // data and ECC in Flash at the address specified.
        // Fapi_calculateEcc is used to calculate the corresponding ECC of the data.
        //
        // Note that data buffer (Buffer) is aligned on 64-bit boundary for verify
        // reasons.
        //
        // In this example, 0x100 bytes are programmed in Flash Sector6
        // along with the specified ECC.
        //
    
        for(i=0, u32Data_Index = Bzero_Sector6_start;
           (u32Data_Index < (Bzero_Sector6_start + WORDS_IN_FLASH_BUFFER));
           i+= 8, u32Data_Index+= 8)
        {
            //
            // Point LData to the lower 64 bit data
            // and   HData to the higher 64 bit data
            //
            LData = (uint64 *)(Buffer32 + i/2);
            HData = (uint64 *)(Buffer32 + i/2 + 2);
    
            //
            // Calculate ECC for lower 64 bit and higher 64 bit data
            //
            ECC_LB = Fapi_calculateEcc(u32Data_Index,*LData);
            ECC_HB = Fapi_calculateEcc(u32Data_Index+4,*HData);
            ECC_B = ((ECC_HB<<8) | ECC_LB);
    
            oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Data_Index,DataBuffer+i, 8, &ECC_B, 2, Fapi_DataAndEcc);
    
            //
            // Wait until the Flash program operation is over
            //
            while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
            if(oReturnCheck != Fapi_Status_Success)
            {
                //
                // Check Flash API documentation for possible errors
                //
                Example_Error(oReturnCheck);
            }
    
            //
            // Read FMSTAT register contents to know the status of FSM after
            // program command to see if there are any program operation related
            // errors
            //
            oFlashStatus = Fapi_getFsmStatus();
            if(oFlashStatus != 0)
            {
                //
                // Check FMSTAT and debug accordingly
                //
                FMSTAT_Fail();
            }
    
            Flash_enableECC(FLASH0ECC_BASE);
    
            //
            // Read back the programmed data to check if there are any ECC failures
            //
            dataLow = *(uint64 *)(u32Data_Index);
    
            Flash_ErrorStatus errorStatusLow = Flash_getLowErrorStatus(FLASH0ECC_BASE);
            if((errorStatusLow != FLASH_NO_ERR) || (dataLow != *LData))
            {
                ECC_Fail();
            }
    
            dataHigh = *(uint64 *)(u32Data_Index + 4);
    
            Flash_ErrorStatus errorStatusHigh = Flash_getHighErrorStatus(FLASH0ECC_BASE);
            if((errorStatusHigh != FLASH_NO_ERR) || (dataHigh != *HData))
            {
                ECC_Fail();
            }
    
            //
            // Verify the programmed values.  Check for any ECC errors.
            //
            oReturnCheck = Fapi_doVerify((uint32 *)u32Data_Index, 4, Buffer32 + (i/2), &oFlashStatusWord);
    
            if(oReturnCheck != Fapi_Status_Success)
            {
                //
                // Check Flash API documentation for possible errors
                //
                Example_Error(oReturnCheck);
            }
        }
    
    }
    
    //*****************************************************************************
    //  Example_EraseSector
    //
    //  Example function to Erase data of a sector in Flash.
    //  Flash API functions used in this function are executed from RAM in this
    //  example.
    //*****************************************************************************
    #ifdef __cplusplus
    #pragma CODE_SECTION(".TI.ramfunc");
    #else
    #pragma CODE_SECTION(Example_EraseSector, ".TI.ramfunc");
    #endif
    void Example_EraseSector(void)
    {
        Fapi_StatusType  oReturnCheck;
        Fapi_FlashStatusType  oFlashStatus;
        Fapi_FlashStatusWordType  oFlashStatusWord;
    
        //
        // Erase the sector that is programmed in the above example
        // Erase Sector6
        //
        oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)Bzero_Sector6_start);
        //
        // Wait until FSM is done with erase sector operation
        //
        while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    
        if(oReturnCheck != Fapi_Status_Success)
        {
            //
            // Check Flash API documentation for possible errors
            //
            Example_Error(oReturnCheck);
        }
    
        //
        // Read FMSTAT register contents to know the status of FSM after
        // erase command to see if there are any erase operation related errors
        //
        oFlashStatus = Fapi_getFsmStatus();
        if(oFlashStatus != 0)
        {
            //
            // Check Flash API documentation for FMSTAT and debug accordingly
            // Fapi_getFsmStatus() function gives the FMSTAT register contents.
            // Check to see if any of the EV bit, ESUSP bit, CSTAT bit or
            // VOLTSTAT bit is set (Refer to API documentation for more details).
            //
            FMSTAT_Fail();
        }
    
        //
        // Verify that Sector6 is erased
    
        /*
          Sector length in number of 16bits
          #define Sector8KB_u16length       0x1000U 4k x 16
          Sector length in number of 32bits
          #define Sector8KB_u32length       0x800U 2k x 32
    
          extern Fapi_StatusType Fapi_doBlankCheck(
                                            uint32 *pu32StartAddress,
                                            uint32 u32Length,
                                            Fapi_FlashStatusWordType *poFlashStatusWord
                                            );
         */
    
    
        oReturnCheck = Fapi_doBlankCheck((uint32 *)Bzero_Sector6_start, Sector8KB_u32length, &oFlashStatusWord);
    
        if(oReturnCheck != Fapi_Status_Success)
        {
            //
            // Check Flash API documentation for error info
            //
            Example_Error(oReturnCheck);
        }
    }
    
    //******************************************************************************
    // For this example, just stop here if an API error is found
    //******************************************************************************
    void Example_Error(Fapi_StatusType status)
    {
        //
        //  Error code will be in the status parameter
        //
        __asm("    ESTOP0");
    }
    
    //******************************************************************************
    //  For this example, once we are done just stop here
    //******************************************************************************
    void Example_Done(void)
    {
        __asm("    ESTOP0");
    }
    
    //******************************************************************************
    // For this example, just stop here if FMSTAT fail occurs
    //******************************************************************************
    void FMSTAT_Fail(void)
    {
        __asm("    ESTOP0");
    }
    
    //******************************************************************************
    // For this example, just stop here if ECC fail occurs
    //******************************************************************************
    void ECC_Fail(void)
    {
        __asm("    ESTOP0");
    }
    
    
    //*****************************************************************************
    //  Example_ProgramUsingAutoECC
    //
    //  Example function to Program data in Flash using "AutoEccGeneration" option.
    //  Flash API functions used in this function are executed from RAM in this
    //  example.
    //*****************************************************************************
    #ifdef __cplusplus
    #pragma CODE_SECTION(".TI.ramfunc");
    #else
    #pragma CODE_SECTION(Example_ProgramUsingAutoECC, ".TI.ramfunc");
    #endif
    void Example_ProgramUsingAutoECC(void)
    {
        uint32 u32Data_Index = 0;
        uint32 u32Option_Index = 0;
        uint16 i = 0;
        uint16 j = 0;
        Fapi_StatusType  oReturnCheck;
        Fapi_FlashStatusType  oFlashStatus;
        Fapi_FlashStatusWordType  oFlashStatusWord;
    
        //
        // A data buffer of max 8 16-bit words can be supplied to the program
        // function.
        // Each word is programmed until the whole buffer is programmed or a
        // problem is found. However to program a buffer that has more than 8
        // words, program function can be called in a loop to program 8 words for
        // each loop iteration until the whole buffer is programmed.
        //
        // Remember that the main array flash programming must be aligned to
        // 64-bit address boundaries and each 64 bit word may only be programmed
        // once per write/erase cycle.  Meaning the length of the data buffer
        // (3rd parameter for Fapi_issueProgrammingCommand() function) passed
        // to the program function can only be either 4 or 8.
        //
        // Program data in Flash using "AutoEccGeneration" option.
        // When AutoEccGeneration option is used, Flash API calculates ECC for the
        // given 64-bit data and programs it along with the 64-bit main array data.
        // Note that any unprovided data with in a 64-bit data slice
        // will be assumed as 1s for calculating ECC and will be programmed.
        //
        // Note that data buffer (Buffer) is aligned on 64-bit boundary for verify
        // reasons.
        //
        // Monitor ECC address for Sector6 while programming with AutoEcc mode.
        //
        // In this example, 0x100 bytes are programmed in Flash Sector6
        // along with auto-generated ECC.
        //
    
    
        DataVar_01 = 1234;
        DataVar_02 = 1111;
        DataVar_03 = 2222;
        DataVar_04 = 3333;
        DataVar_05 = 1357;
        DataVar_06 = 8964;
        DataVar_07 = 2468;
        DataVar_08 = 8888;
        DataVar_09 = 1344445678;
        DataVar_10 = 0.008926632f;
        DataVar_255 = 2222;
        DataVar_256 = 9101;
    
        OptionVar_01 = 2222;
    
        memcpy(&DataBuffer[0],   &DataVar_01, 1);
        memcpy(&DataBuffer[1],   &DataVar_02, 1);
        memcpy(&DataBuffer[2],   &DataVar_03, 1);
        memcpy(&DataBuffer[3],   &DataVar_04, 1);
        memcpy(&DataBuffer[4],   &DataVar_05, 1);
        memcpy(&DataBuffer[5],   &DataVar_06, 1);
        memcpy(&DataBuffer[6],   &DataVar_07, 1);
        memcpy(&DataBuffer[7],   &DataVar_08, 1);
        memcpy(&DataBuffer[8],   &DataVar_09, 2);
        memcpy(&DataBuffer[10],  &DataVar_10, 2);
        memcpy(&DataBuffer[254], &DataVar_255, 1);
        memcpy(&DataBuffer[255], &DataVar_256, 1);
    
    
        memcpy(&OptionBuffer[0], &OptionVar_01, 1);
    
    
        /*
         * section 0
         * 0x0008 0000 - 0008 0FFF
         *
         * section 1
         * 0x0008 1000 - 0008 1FFF
         *
         * 32 bit address, 16 bit wide
         *
         * 8 x 16 at once = 128 bit
         * */
    
    
    
        // for(i=0, u32Index = Bzero_Sector6_start; (u32Index < (Bzero_Sector6_start + WORDS_IN_FLASH_BUFFER)); i+= 8, u32Index+= 8)
    
    
    
    
        for(i=0, u32Data_Index = DataArea_start; (u32Data_Index < (DataArea_start + W_DATA_IN_FLASH_BUFFER)); i+= 8, u32Data_Index+= 8)
        {
            /*
            extern Fapi_StatusType Fapi_issueProgrammingCommand(
                                                        uint32 *pu32StartAddress,
                                                        uint16 *pu16DataBuffer,
                                                        uint16  u16DataBufferSizeInWords,
                                                        uint16 *pu16EccBuffer,
                                                        uint16  u16EccBufferSizeInBytes,
                                                        Fapi_FlashProgrammingCommandsType oMode
                                                        );
            */
            /* 128 bit at once */
            oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Data_Index, DataBuffer+i, 8, 0, 0, Fapi_AutoEccGeneration);
    
            //
            // Wait until the Flash program operation is over
            //
            while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
            if(oReturnCheck != Fapi_Status_Success)
            {
                //
                // Check Flash API documentation for possible errors
                //
                Example_Error(oReturnCheck);
            }
    
            //
            // Read FMSTAT register contents to know the status of FSM after
            // program command to see if there are any program operation related
            // errors
            //
            oFlashStatus = Fapi_getFsmStatus();
            if(oFlashStatus != 0)
            {
                //
                //Check FMSTAT and debug accordingly
                //
                FMSTAT_Fail();
            }
    
            Buffer32 = (uint32 *)DataBuffer;
    
            //
            // Verify the programmed values.  Check for any ECC errors.
            //
    
           
            oReturnCheck = Fapi_doVerify((uint32 *)u32Data_Index, 4, Buffer32+(i/2), &oFlashStatusWord);
    
            if(oReturnCheck != Fapi_Status_Success)
            {
                //
                // Check Flash API documentation for possible errors
                //
                Example_Error(oReturnCheck);
            }
        }
    
    
    
    
    
        for(j=0, u32Option_Index = OptionArea_start; (u32Option_Index < (OptionArea_start + W_OPTION_IN_FLASH_BUFFER)); j+=8, u32Option_Index+= 8)
          {
              oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Option_Index, OptionBuffer+j, 8, 0, 0, Fapi_AutoEccGeneration);
    
              while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
              if(oReturnCheck != Fapi_Status_Success)
              {
                  Example_Error(oReturnCheck);
              }
          }
    
    
    }
    
    
    //
    // End of File
    //
    

  • Hi Patrick,

    I looked at the code snippets that you sent me in previous days.  Reviewing the entire code takes time - I can take a look on September 23rd.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    I am going to order new board tomorrow, can you suggest any way to prevent my new board from being locked again such as programme my own password first before hand ?

    Also thanks for your prompt help for reviewing my codes.

    Thanks,

    Patrick

  • Hi Patrick,

    Another thing that you may want to try (although I don't think this is not the case with your previous device corruption):  Try powering the board from external supply instead of the laptop USB pot.

    Thanks and regards,
    Vamsi