infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 8 of 8

Thread: FLASH002 UCB programming, lock/unlock

  1. #1
    JoeShidle is on a distinguished road
    Join Date
    May 2013
    Posts
    15
    Points
    46.875

    FLASH002 UCB programming, lock/unlock

    I'm trying to use the FLASH002 app and associated API calls to read/write lock all flash on an XMC4500, and then be able to unlock it at a later time for field upgrades and so forth.

    I've used the USBVC001 previously for serial commands for a variety of other functions, and recently implemented a series of FLASH002 related commands so that I can read lock, write lock, unlock, etc. the device via the serial port when needed.

    Per the FLASH002 DAVE3 help the process for implementing flash protection is:

    1) Program Page0 of the UCB with protection options.
    2) Reset the device.
    3) Verify password by attempting disabling the protection, attempting
    operation on the locked sectors and checking status registers.
    4) Program confirmation code into Page2 of UCB.

    I've followed these steps and seem to be able to lock the flash on the target using the Flash002_ConfigureProtection() and Flash002_ConfirmProtection(), but am unable to subsequently unlock the same way. Even using the Flash002_DisableSectorWriteProtection() or Flash002_DisableGlobalReadProtection() to temporarily turn off protection does not seem to allow me to write or read (respectively) the flash via JFlashARM or DAVE3 programmer.

    Are there some FLASH002 protection / UCB examples available? Failing that, can someone help walk me through what specifically needs to be done to enable and disable UCB flash protection on a target XMC4500 using the FLASH002 app?

    Thanks in advance,
    Joe Shidle

  2. #2
    Advanced Advanced sophia is on a distinguished road
    Join Date
    Nov 2011
    Posts
    678
    Points
    2190
    Hi Joe Shidle,

    Our colleague will look into it and update you later, thanks.

    Best regards,
    Sophia

  3. #3
    JoeShidle is on a distinguished road
    Join Date
    May 2013
    Posts
    15
    Points
    46.875
    Thanks for the response, Sophia. Included below are the simple flash protection utilities that I access individually via USBVC001 AT-style commands.

    Based on my understanding as outlined above:
    1) Issue command to call HandleFlashReadLock() to initiate the locking
    2) Reset the target device
    3) Issue command to call HandleFlashProtection() to verify and restore the flash protection
    4) Issue command to call HandleFlashConfirm() to handle the confirmation code to UCB2

    Code:
    #define FLASH_UCB0              0
    #define FLASH_UCB1              1
    #define FLASH_UCB2              2
    #define FLASH_PWD1              0x00010002
    #define FLASH_PWD2              0x00030004
    #define FLASH002_PROT_OPEN      0x0000
    
    status_t HandleFlashProtection() {
        status_t status = (uint32_t)FLASH002_ERROR;
        FLASH002ProtectionFlags_Type protectFlags = FLASH002_PROT_RD_GLOBAL;
    
        status = Flash002_VerifyProtection(FLASH_UCB0, FLASH_PWD1, FLASH_PWD2, protectFlags);
    
        if (status == DAVEApp_SUCCESS) {
            SetFlashProtection();
        }
    
        status = Flash002_ResumeProtection();
    
        return status;
    }
    
    status_t HandleFlashReadLock() {
        status_t status = FLASH002_ERROR;
        FLASH002ProtectionFlags_Type protectFlags = FLASH002_PROT_RD_GLOBAL;
    
        status = Flash002_ConfigureProtection(FLASH_UCB0, FLASH_PWD1, FLASH_PWD2, protectFlags);
    
        if (status != DAVEApp_SUCCESS) {
            lastErrorStatus = ERR_FLASH_READLOCK;
        }
    
        return status;
    }
    
    status_t HandleFlashUnlock() {
        status_t status = FLASH002_ERROR;
        FLASH002ProtectionFlags_Type protectFlags = FLASH002_PROT_OPEN;
    
        status = Flash002_ConfigureProtection(FLASH_UCB0, FLASH_PWD1, FLASH_PWD2, protectFlags);
    
        if (status != DAVEApp_SUCCESS) {
            lastErrorStatus = ERR_FLASH_UNLOCK;
        }
    
        return status;
    }
    
    status_t HandleFlashConfirm() {
        status_t status = FLASH002_ERROR;
    
        status = Flash002_ConfirmProtection(FLASH_UCB2);
    
        if (status != DAVEApp_SUCCESS) {
            lastErrorStatus = ERR_FLASH_CONFIRM;
        }
    
        return status;
    }
    
    status_t HandleFlashDisableRead() {
        status_t status = FLASH002_ERROR;
    
        status = Flash002_DisableGlobalReadProtection(FLASH_PWD1, FLASH_PWD2);
    
        if (status != DAVEApp_SUCCESS) {
            lastErrorStatus = ERR_FLASH_DISABLE_READ;
        }
    
        return status;
    }
    
    status_t HandleFlashDisableWrite() {
        status_t status = FLASH002_ERROR;
    
        status = Flash002_DisableSectorWriteProtection(FLASH_UCB0, FLASH_PWD1, FLASH_PWD2);
    
        if (status != DAVEApp_SUCCESS) {
            lastErrorStatus = ERR_FLASH_DISABLE_WRITE;
        }
    
        return status;
    }
    Let me know if anything seems amiss. We are on an XMC4500 series AB chip.

    Thanks in advance,
    Joe Shidle

  4. #4

    Infineon Employee
    Infineon Employee
    Expert
    Travis will become famous soon enough
    Join Date
    Feb 2013
    Location
    Singapore
    Posts
    749
    hi,

    While investigating your case, you might want to look into this link. There is an attachement on flash protection knowhow.


    https://www.infineonforums.com/thread...ght=protection

    Best Regards
    Travis
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  5. #5
    JoeShidle is on a distinguished road
    Join Date
    May 2013
    Posts
    15
    Points
    46.875
    Travis;

    Thanks for the response. Prior to your post, I had changed my HandleFlashUnlock() as quoted earlier to use the Flash002_EraseUCB() API call from the FLASH002 app but with the same results. Per the recommendation from the API documentation, I do issue a Flash002_DisableSectorWriteProtection() prior to issuing the Flash002_EraseUCB().

    But the results are the same, I am able to lock flash protection but unable to turn the flash protection off via Erase. I have verified that the Flash002_EraseUCB() in my FLASH002 API performs the six sequential commands per your PPT but the operation comes back FLASH002_ERROR. I have implemented a command to dump the FSR and after the EraseUCB() fails, the FSR reads 0x02050800.

    I've included my updated HandleFlashUnlock() below. Thanks in advance for your help.

    Code:
    status_t HandleFlashUnlock() {
        status_t status = FLASH002_ERROR;  // assume failure
        FLASH002ProtectionFlags_Type protectFlags = FLASH002_PROT_OPEN;
    
        status = Flash002_DisableSectorWriteProtection(FLASH_UCB0, FLASH_PWD1, FLASH_PWD2);
        if (status != DAVEApp_SUCCESS) {
            lastErrorStatus = ERR_FLASH_DISABLE_WRITE;
            return status;
        }
    
        status = Flash002_EraseUCB(FLASH_UCB0);
        if (status != DAVEApp_SUCCESS) {
            lastErrorStatus = ERR_FLASH_UNLOCK;
        }
    
        return status;
    }

  6. #6

    Infineon Employee
    Infineon Employee
    Expert
    Travis will become famous soon enough
    Join Date
    Feb 2013
    Location
    Singapore
    Posts
    749
    Hi,

    I am looking at this issue offline with Mike and Robert.

    Best Regards
    Travis
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  7. #7
    New Member New Member MAH is on a distinguished road
    Join Date
    Nov 2017
    Posts
    1
    Points
    20

    internal flash lock and unlock in xmc4500

    Hello everyone
    I am try to lock internal flash memory in xmc4500 by this program :

    status_t status;
    uint32_t PW0 = 0x00010002; //first 32 bit of password
    uint32_t PW1 = 0x00030004; //second 32 bit of password
    uint32_t UserLevel = 0;
    FLASH002ProtectionFlags_Type ProtectionFlags;

    ProtectionFlags = FLASH002_PROT_RD_GLOBAL;
    status = Flash002_ConfigureProtection(UserLevel, PW0, PW1, ProtectionFlags);
    status = Flash002_ConfirmProtection(UserLevel);
    And then try to unlock global read protection by this program :
    status_t status;
    uint32_t PW0 = 0x00010002; //first 32 bit of password
    uint32_t PW1 = 0x00030004; //second 32 bit of password
    status = Flash002_DisableGlobalReadProtection(PW0, PW1);
    But after lock chip I can not unlock it. I do not know what happen.
    I am use DAVE 3
    Can anyone help me about that?
    Thanks a lot
    Mah

  8. #8

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    419
    Hi,

    Please have a look to the FLASH_PROTECTION XMC4500 example in the XMCLib distribution http://dave.infineon.com/Libraries/X...ry_v2.1.18.zip

    Regards,
    Jesus
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.