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.

UCD3138128: Switching between image/applications

Part Number: UCD3138128
Other Parts Discussed in Thread: USB-TO-GPIO2, UCD3138A

Tool/software:

I have been able to program block 0 with one application and Block2 with another.

I can use the PMBUS to switch between applications.

However, I need to be able to switch between applications under program mode in my firmware.

I have found the function that loads the memory control registers: attached

After calling the function, how do I get the program to start at the new block number? Seems there is one more step I need to do after these functions.

static void switch_active_program_to_pflash01(void)
{
    //------------------------------------------------------------------------------------
    // assumed entry state: program being executed is stored in pflash blocks 2 and 3
    // backup copy is in blocks 0 and 1

    // UPON ENTRY
    // block 0: address = 0x10000
    // MFBALR1:  0x0060 MFBAHR1: 0x10000

    // block 1: address = 0x18000
    // MFBALR17: 0x8060 MFBAHR17: 0x10000

    // block 2: address = 0x00000
    // MFBALR18: 0x0060 MFBAHR18: 0x00000

    // block 3: address = 0x08000
    // MFBALR19: 0x8060 MFBAHR19: 0x00000
    //------------------------------------------------------------------------------------
    // temporarily set size of blocks 2 and 3 to 0kB by setting MFBALRx.BLOCK_SIZE = 0 (x = 18,19)
    // setting MFBALRx.BLOCK_SIZE = 0 disables these blocks
    // this is necessary as you cannot map two blocks to the same address
    // doing so will result in a data abort exception
    DecRegs.MFBALR18.all = 0x0000;  // block 2, size = 0 KBytes
    DecRegs.MFBALR19.all = 0x8000;  // block 3, size = 0 KBytes

    DecRegs.MFBAHR1.all  = 0x0000;  // map block 0 to address 0x00000 (MFBAHL1  = 0x0060)
    DecRegs.MFBAHR17.all = 0x0000;  // map block 1 to address 0x08000 (MFBAHL17 = 0x8060)
    DecRegs.MFBAHR18.all = 0x0001;  // map block 2 to address 0x10000 (MFBAHL18 = 0x0000)
    DecRegs.MFBAHR19.all = 0x0001;  // map block 3 to address 0x18000 (MFBAHL19 = 0x8000)

    DecRegs.MFBALR18.all = 0x0060;  // block 2, size = 32Kbytes
    DecRegs.MFBALR19.all = 0x8060;  // block 3, size = 32Kbytes
}

static void switch_active_program_to_pflash23(void)
{
    //------------------------------------------------------------------------------------
    // assumed entry state: program being executed is stored in pflash blocks 0 and 1
    // backup copy is in blocks 2 and 3
    // UPON ENTRY
    // block 0: address = 0x00000
    // MFBALR1:  0x0060 MFBAHR1:  0x0000

    // block 1: address = 0x08000
    // MFBALR17: 0x8060 MFBAHR17: 0x0000

    // block 2: address = 0x10000
    // MFBALR18: 0x0060 MFBAHR18: 0x1000

    // block 3: address = 0x18000
    // MFBALR19: 0x0080 MFBAHR19: 0x1000
    //------------------------------------------------------------------------------------
    // temporarily set size of blocks 0 and 1 to 0kB by setting MFBALRx.BLOCK_SIZE = 0 (x = 1, 17)
    // setting MFBALRx.BLOCK_SIZE = 0 disables these blocks
    // this is necessary as you cannot map two blocks to the same address
    // doing so will result in a data abort exception
    DecRegs.MFBALR1.all  = 0x0000;  // block 0, size = 0 KBytes
    DecRegs.MFBALR17.all = 0x8000;  // block 1, size = 0 KBytes

    DecRegs.MFBAHR18.all = 0x0000;  // map block 2 to address 0x00000 (MFBAHL18 = 0x0060)
    DecRegs.MFBAHR19.all = 0x0000;  // map block 3 to address 0x08000 (MFBAHL19 = 0x8060)
    DecRegs.MFBAHR1.all  = 0x0001;  // map block 0 to address 0x10000 (MFBAHL1  = 0x0000)
    DecRegs.MFBAHR17.all = 0x0001;  // map block 1 to address 0x18000 (MFBAHL17 = 0x8000)

    DecRegs.MFBALR1.all  = 0x0060;  // block 0, size = 32Kbytes
    DecRegs.MFBALR17.all = 0x8060;  // block 1, size = 32Kbytes
}

  • Hello BatMan,

    Can you please elaborate on your issue? You said that you are able to switch between program block0 to program block2. However, you still "need to be able to switch between applications under program mode in my firmware." I do not understand what you are trying to switch between.

    Regards,

    Jonathan Wong

  • I can use the memory debugger in Fusion Digital Power Designer to switch applications. Using the available "Command ROM to execute its program ..."  

    But I want to do the same thing from my firmware. 

  • Hello BatMan,

    I will provide a response tomorrow.

    Regards,

    Jonathan Wong

  • Hello BatMan,

    Sending the 0xF0 command to address 11 within the UCD3138A will be difficult to do, since that would require modifying the Boot ROM firmware. The Boot ROM will need an external PMBus command to tell the Boot ROM to switch to Program Mode. Our examples use the Fusion GUI via the USB-TO-GPIO2 adapter but you can also create an external PMBus host to send the same command.

      

    The standalone Fusion API can be replicated on an external MCU, an automated Windows computer or a mini computer (ex. like a Raspberry Pi).

    Regards,

    Jonathan Wong

  • I don't have the luxury of using PMB bus commands while running my application. 

    What I am doing is this:

    While running my application in block 0 and1, I program a new application in blocks 2 and 3.

    Then, I want to execute (or jump to) the new application. 

    The new application should be able to do the same thing and jump back to the old application.

    (I'd like to do this without having to go through the bootloader to reprogram and invalidate boot loader checksums)

  • Hello BatMan,

    What would be the trigger to switch between block 0+1 to block 2+3? For example, are you going to use a gpio and an external signalto trigger this firmware switch?

    Regards,

    Jonathan Wong

  • It is commanded from another processor through a uart. The other processor sends the programming information via a uart. My firmware programs the unused blocks of memory with data sent across the uart. 

  • Hello BatMan,

    I sent you our On The Fly Update example firmware via private message. Try referring to this firmware. Below is an article from Ian Bower on the high-level steps. 

    7652.On-the-fly power supply firmware upgrades.docx

    Regards,

    Jonathan Wong

  • Thank you for the information. That is way more complicated than I was expecting. I don't have enough time allocated to implement it the way it is suggested so I will just reprogram the unused block of memory with the new application, write the proper check sum, clear the old application checksum, and reset and let the ROM boot handler take over.

  • Hello BatMan,

    Thanks for letting us know. The on-the-fly update is our recommended method for switching between different programs in the UCD3138x.

    Regards,

    Jonathan Wong