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.

How to read flash memory contents of internal flash memory of TM4C129DNCPDT board

Other Parts Discussed in Thread: TM4C129DNCPDT

Hi All,

I am currently working on TM4C129DNCPDT board and i want to know if we can read flash memory contents of that board? Can we read it word by word or in bunch or both? I tried to search this information in its datasheet but not  getting clear information.

Also if possible please suggest ways to read the flash memory contents.

 

  • Hello Shrikant,

    There are multiple ways of reading the Flash content and I am not aware where you are putting out the content. I will put out the simplest one's first

    1. In the debugger window you can select the Memory View to be from 0x0 and read it out on the debugger gui

    2. You can write a small program in Flash to read out Flash from 0x0 to MAX LIMIT of 1MB onto UART display.

    Regards

    Amit

  • Hi,

     Thanks for your reply. Can it be done in a very simple way like:

    read_byte =  *(unsigned char *)0x1234 where 0x1234 is the flash memory address we want to read.

    what if we want to read a chunk of bytes?

    I don't want to do it in a debugger mode.

    Is there any tivaware function available for this. I searched in driverlib/flash.c but it contains function for writing to flash memory, read protection and all. But doesn't provide any such function for reading some chunk of bytes from flash memory.

  • Hello Shrikant,

    read_byte =  *(unsigned char *)0x1234 where 0x1234 is the flash memory address we want to write.

    Did you mean "read" as the operation above is a read and not a write?

    Reading flash in that manner is perfectly fine. If you want to read a chunk of bytes the a for loop would be sufficient.

    Regards

    Amit

  • Hello Amit,

     Yes it is "read", it was a typo mistake.

    Actually reading a byte in the above way is OK, but using a for loop for reading a chunk of memory in flash doesn't seem a convincing way to me as it will take some extra machine cycles everytime in coming back to fash program increment for loop counter and then again execute the read staement.

    In microcontroller we have pop instruction which autoincrement the register address and give some bytes. This kind of method looks more convincing specially when we dont want to waste a siginificant time in executing this small program to read flash memory.

    If i am missing something you can correct me.

    Thanks.

    Regards,

    Shrikant

  • Hello Shrikant,

    The POP instruction is meant when there is something PUSH-ed into a stack and more for a branch. I would keep the code simple to read in a for loop. It's fast and reliable...

    Final implementation is your call.

    Regards

    Amit

  • OK.

    Actually i was looking for some tivaware function if it exists for such kind of read.

    Anyways, Thanks Amit.

    Regards,

    Shrikant

  • Hello Shrikant

    There is no API to read Flash as the Flash is directly readable in case of TIVA. Only for Program and Erase there are API's.

    Regards

    Amit

  • Hello Amit,

    While going through the datasheet i came to know that the flash write is 4 byte alligned and also the tivaware funtion for flash Write is writing four bytes at a time. Is the same for read also.

    Means. If i use the same example as above, i.e :

    read_byte =  *(unsigned char *)0x1234 where 0x1234 is the flash memory address

    Will the above statement return me a 32 bit value of location 0x1234,0x1235,0x1236 and 0x1237

    I have a big doubt here?

    Please reply

    Regards,

    Shrikant

  • Hello Shrikant,

    Yes, the Flash is a word wide access (4 bytes). Reading can be done byte wise.

    Regards

    Amit

  • Hello amit,

    Actually i want to copy some bytes(more than 50) bytes of data from one flash memory to other. so can it do it using memcpy.

    like memcpy(dest_flash_addr, source_flash_addr, count)

    or do i need to do it in two steps:

    1. Get data from flash

    2. Write FMA, FMD and control registers to write data into flash.

    I will be happy if it can be done in onestep using memcpy directly.

     

    Regards,

    Shrikant

     

  • Hello Shrikant,

    You would need to do it in two step process. The memcpy to a Flash always requires the FMA-FMD-FMC approach.

    To accelerate the copy process you can use the FWBn if byte wide copy is not a limitation.

    Regards

    Amit

  • I realize this is an old post but in case someone comes across it like I did, this is what I did.

    WRITE:

    // save string called saveString at location 0xFC000

    // note:  you also need set the end address of your program to 0x0007F7FF in Flash Settings to avoid writing over the saved data 

    chksum = 0;
    for ( loop = 0; loop < strlen(saveString); loop++ ) {
    chksum =chksum+saveString[loop];
    }

    // save checksum
    pui32Buffer[0] = (uint32_t)chksum;
    pui32Buffer[1] = (uint32_t)','; // add comma

    for ( loop = 2; loop < strlen(saveString)+4; loop++ ) { // include null term
        pui32Buffer[loop] = saveString[loop-2];
    }

    FlashErase(0xFC000); // erases 16K block
    FlashProgram(pui32Buffer, 0xFC000, sizeof(pui32Buffer)); // saved as 32 bit words

    READ:

    uint32_t *ui32Ptr;

    ui32Ptr = malloc(1024);
    memcpy(ui32Ptr, (const void *)0xFC000, 256*sizeof(uint32_t)); // has checksum in [0] and comma in [1] read bytes x 4 (32 bit memory)

    for ( loop = 0; loop < 256; loop++) {
        pucBuffer[loop] = (char)ui32Ptr[loop+1];
    }

    free(ui32Ptr);

  • Oops

    Just noticed I copied two different memory ranges.
    To protect 0xFC000 you need to end program at 0x000FBFFF

    I had another program that saved data at 0x7F800

    I was looking at two programs that I used this method in.