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.

Tiva c 123bpz Problems with FlashProgramm

Hi,

just wanted to ask if anybody has the same issues ... or even better .. maybe a solution for me ;)

Currently i am using the above mentioned IC. I started to use the flash access routines FlashProgramm to write

to the internal flash. If i use them, i can exactly write 128 Bytes, after that, the FlashProgram Routine hangs ..

I thought that i did something wrong, switched to the EEPROM for storage and almost forgot this issue.

Now i try to use the sflash programm to update the CHIP and i am running into the same issue .... i am allowed to write 128 bytes, after that i do not receive an ACK and therefore everything hangs.

To be sure that the flash is empty i tried to erase the Flash with the LM Flasher tool from Ti, but this does not

succeed. The flash is not erased .

So ..... anybody an Idea what went wrong here ? I have the same issues on all Boards available here . ( around 8 ) .

Kind Regards,

      Robert

  • My initial thought was to try the "Debug Port Unlock" option in LMFlash (on the Other Utilities tab, select "Fury, DustDevil and Blizzard Classes" for this part) to be 100% sure that the flash and all flash protection registers are erased. If you find that you can successfully program the parts after doing this, that suggests that the parts have somehow reached you with flash protection enabled. This would surprise me, though, since protection is on a 2KB block on this part so I would expect to see problems at 2KB boundaries, not after 128 bytes, and I would also expect the function to return with an error rather than hanging in this case.

    Do you have one of our EK or DK boards for TM4C123? If so, can you successfully program this? If so, that suggests the problem isn't something to do with PC-side drivers. If not, I would recommend uninstalling the drivers for the board and reinstalling in case something became corrupted or is clashing with some other device in your system.

    128 bytes is exactly the size of 1 full flash write buffer so I wonder if you are just not able to program anything at all. Does FlashProgram() return to you after you write 128 bytes or does it hang on the first attempt to write a 128 byte block of data? Where in the function is it hanging?

    If nothing here helps, please post a snippet of the code you are using the try to configure the system clock and write the flash, and examples of the addresses and counts you are passing to FlashProgram() and I'll try to see if I can reproduce the problem here.

  • HI Dave, i think you are correct .... the data is never written ... here the code i am executing

        static uint8_t pulData[64];
        unsigned int i = 0;
        int iError = 0;
        int iSize;

       // Set the clocking to run at 50MHz from the PLL.
        SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);



        for ( i = 0; i < 64; i++ )
            pulData[i] = i;

        iError = FlashErase(0x0001F000);
        iError = FlashErase(0x0001F400);
        iError = FlashErase(0x0001F800);
        iError = FlashErase(0x0001Fc00);


        iSize = sizeof(pulData);

        for ( i = 0; i < 64; i++ )
        {
            iError = FlashProgram(( uint32_t *)pulData, 0x0001F000 + i * 64, iSize );
            if ( iError < 0 )
                break;
        }

    and i am hangin in the loop of Flash programm with the following values

    ui32Count = 64

    FLASH_FMC2 = 0

    FLASH_FWBVAL = -1

        //
        // Loop over the words to be programmed.
        //
        while(ui32Count)
        {
            //
            // Set the address of this block of words.
            //
            HWREG(FLASH_FMA) = ui32Address & ~(0x7f);

            //
            // Loop over the words in this 32-word block.
            //
            while(((ui32Address & 0x7c) || (HWREG(FLASH_FWBVAL) == 0)) &&
                  (ui32Count != 0))
            {
                //
                // Write this word into the write buffer.
                //
                HWREG(FLASH_FWBN + (ui32Address & 0x7c)) = *pui32Data++;
                ui32Address += 4;
                ui32Count -= 4;
            }

            //
            // Program the contents of the write buffer into flash.
            //
            HWREG(FLASH_FMC2) = FLASH_FMC2_WRKEY | FLASH_FMC2_WRBUF;

            //
            // Wait until the write buffer has been programmed.
            //
            while(HWREG(FLASH_FMC2) & FLASH_FMC2_WRBUF)
            {
            }
        }

    My first thought was that i missed some initialization ...

    Maybe you can help me .... i try to find the sample board from TI to test the code on the sample board

    Kind regards,

         Robert

  • Robert,

      Thanks for this code. I'll use it as the basis for a testcase and see how it behaves for me. It's interesting that the failure occurs on the first write which will fill data from somewhere other than the start of the write buffer (64 bytes is half the write buffer size).

      More later...

  • Hi Dave, thanks for that .. it is a good starting point .. but more important to me would be that the sflash

    is working correctly .. but it behaves like i do ... writing in small portions .. so maybe the fix is in the end the same ;)

    Let me know if you find out something ;)

    Kind regards,

         Robert

  • Robert,

      I ran your code here and it works perfectly for me. I'm attaching a ZIP file containing the C and binary I used. Please could you run this and see what result you get? The code assumes UART0 is available on PA0/1. If that's not the case, let me know and I'll remove the UART stuff and just use the debugger to determine whether the test passed or failed, then send you the modified version.

    customer_flash_test.zip
  • Hi Dave, thanks for your help ... first the application failed .... so i tried again to unlock the device and

    after that, everything went fine ....

    We do not have a reset button designed on our board, so my way to "hit" the reset button was not

    very successful... i tested 5 Boards and on some boards, i had to unlock it more than 4 times to be able to flash.

    So, the questions, why where the devices locked ?

    I just have long time test run, after that, i'll try out the sflash tool .. but i think it will work now  ;)

    Kind regards,

            Robert

  • Hi Dave, i found the answer ... the device was programmed to the other flash key .... it was old key moved from

    Stelaris to Tiva ... and to change the pin for the update mode, we wrote the BOOTCFG register ....

    and forget to add the KEY bit .... for the default value ...

    so, while debugging everything was fine, after the first poweroffon cycle, the device couldn't be flashed anymore ...

    Thanks for your patience and help !

    Kind regards,

        Robert