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.

TMS570LC4357: Data abort when run code in Ram

Part Number: TMS570LC4357

Hi,

in my project I have a large section of code copied from flash to ram with the binit table, I set the MPU to allow the execution of code from RAM but a data abort exception occur after a few instruction executed form RAM .

Just to check the problem i tried to make a simpler project  generated from Halcodgen  that generate the data exception, in this case the code loaded from flash to RAM is the FEE-eeprom driver.

To test the code I'm using the launchpad XL2 with the TMS570LC4357 with the "TI v18.1.2.LTS" compiler

The main function only try to launch the TI_Fee_Init API, but will generate the data abort on the  TI_Fee_u32BlockEraseCount = 0xFFFFFFFFU instruction.

This is the test project:

4555.TMS_570LC4357_test.zip

Can you tell me which is my mistake or geve me a solution to my problem?

Just for information, i see this behaviour only when i copy a large section of code from flash to RAM otherwise all works fine

Thanks, best regards,

Giovanni

  • Hello,

    You can erase and program the EEPROM from flash without causing any problem. You don't have to execute the EEPROM related code from RAM.

    You need to write code to copy data from flash to RAM, but I don't see the code in your project.
  • Hi,

    thanks for your reply, my objective is to run from RAM a section of code with a  size greater than 0x4000 byte but, in my test, the code generate the data abort exception after few RAM instruction.

    I cannot post my real project and  for this reason i tried replicate my problem executing in RAM the FEE_TEXT_SECTION (that has a size similar to the code that i wanto to run in RAM), the behaviour is the same, after a few instruction execute in ram of the TI_Fee_Init function the code fall in data abort execption.

    The code will be copied from flash to ram in the __TI_auto_init(), in the linker file is indicate to use the binit table ( FEE_TEXT_SECTION    :> FLASH0 | FLASH1  palign(32), run > RAM table(BINIT)).

    If i change the linker line from "FEE_TEXT_SECTION    :> FLASH0 | FLASH1  palign(32), run > RAM table(BINIT)" to "FEE_TEXT_SECTION    :> FLASH0 | FLASH1  palign(32)" the TI_Fee_Init function is executed correclty.

    Looking the disassembly of the TI_Fee_Init function in this 2 cases ( code in RAM and  the code in flash), seems that the generated assemby instructions differs, tomorrow i'll try to catch 2 screenshot to explain better my idea.

    Thanks,

    Giovanni

  • here the 2 screenshot,

    the first is the code executed in flash and in the second the code is executed in ram, the only change between the 2 projects is the linker file ( there are no optimization in the project's settings).

    the disassembly of the "TI_Fee_u32BlockEraseCount = 0xFFFFFFFFU;" and the next instruction are different.

  • Hi,

    this problem is already present and I cannot find a solution, running big section of code from ram will cause the data abort.
    The time for my project is running out and if there are no solution we need to change this device.
    I just need to know if the behaviour of the submitted code is correct or not and which is the right method to run code from the RAM of the TMS570 ( and what is the poblem in my code, i know that is not necessary to run the TI_Fee_Init from RAM but why it didnt work?) .
    Thanks, best regards

    Giovanni

  • Hi Giovanni,

    The code is not copied to RAM.
    1. place TI_Fee_Init() in a section of flash
    for example:
    In CMD file, MEMORY:
    FEE_API (RX) : origin=0x00000020 length=0x000014E0

    In CMD file, SECTIONS:
    feeAPI :
    {
    TI_Fee_Init.obj (.text)
    } load = FEE_API, run = SRAM, LOAD_START(api_load), LOAD_END(api_end), RUN_START(api_run), SIZE(api_size)

    2. copy this whole section to SRAM
    copy whole TI_Fee_Init() from api_start to api_end to SRAM (from api_run).
  • ok,

    thanks, i have followed the guide in  and i understand that the copy form flash to ram is done in the the __TI_auto_init function using the binit table set in the linker. ( it work if the  code section copied form flash to RAM  is small)

    So this method is not usable? it is better make a custom flash to ram function?

  • Hello Giovanni,

    I make a copy in my code:

    ;-------------------------------------------------------------------------------
    ;
    ; Copy the Flash API from flash to SRAM.
    ;

    .def _copyAPI2RAM_
    .asmfunc

    _copyAPI2RAM_

    .ref api_load
    flash_load .word api_load
    .ref api_run
    flash_run .word api_run
    .ref api_size
    flash_size .word api_size

    ldr r0, flash_load
    ldr r1, flash_run
    ldr r2, flash_size
    add r2, r1, r2
    copy_loop1:
    ldr r3, [r0], #4
    str r3, [r1], #4
    cmp r1, r2
    blt copy_loop1
    bx lr

    .endasmfunc
  • Hi,

    sorry for late, i have just tried your solution.

    I have modified the linker, added the asm code in the HL_sys_core.asm and called it in the HL_sys_startup.c  after the __TI_auto_init() function.

    In the linker i just do a little modification:

    FEE_TEXT_SECTION    :> FEE_API, run = RAM, LOAD_START(api_load), LOAD_END(api_end), RUN_START(api_run), SIZE(api_size)

    insted of

    feeAPI :
    {
    TI_Fee_Init.obj (.text)
    } load = FEE_API, run = SRAM, LOAD_START(api_load), LOAD_END(api_end), RUN_START(api_run), SIZE(api_size)

    due the fee code is loaded in that section by pragma.

    The code fall anyway in the data abort exception during the execution of the TI_Fee_Init function.

    Just for confirmation if i run the code from flash the TI_Fee_Init function execution is ok.

    Thanks for your support,

    Giovanni

  • Hi Giovanni,

    I tried to load your code, but failed. I checked the map file, some fee drivers are mapped to SRAM.