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.

Ethernet Bootloader for TMS570LC4357

Other Parts Discussed in Thread: TMS570LC4357, HALCOGEN

Hi TI,

I am using TMS570LC4357. I want to have a Ethernet Bootloader for this controller.

I've found one ethernet bootloader based on TFTP Protocol from the below Link.

But TI has given this bootloader for only TMS570LS2x/3x not for TMS570LC43xx.

So,

1. Is there any ethernet bootloader available from TI for TMS570LC4357? If yes, Please give me the link.

Or else,

2. Anyways, I've downloaded that ethernet bootloader and I want to adopt that for TMS570LC4357. So please anybody guide me what are the changes or steps I've to do so that this Ethernet Bootloader will also work for TMS570LC4357.

Please anybody help me in this.

Thanks in advance.

Regards,

Karthikeyan Kasivishwanathan.

  • Karthikeyan,

    Karthikeyan Kasi Vishwanathan said:
    1. Is there any ethernet bootloader available from TI for TMS570LC4357?

    Not aware of one.   Think you found the best starting point.

    Karthikeyan Kasi Vishwanathan said:
    2. Anyways, I've downloaded that ethernet bootloader and I want to adopt that for TMS570LC4357. So please anybody guide me what are the changes or steps I've to do so that this Ethernet Bootloader will also work for TMS570LC4357.


    Off the top of my head, the gotchas are likely:

       - different device startup code is needed.  use HalCoGen if possible.

       - cache management

            - be careful of write back cache (MPU setting) for the memory that is used as: 

                   a) packet buffering for EMAC

                   b) relocation of flash API code from flash to SRAM prior to execution

             In both cases you will need to ensure the the data is flushed from cache back to L2SRAM before it is used again.

             (there is no automatic coherency between instruction & data caches, so writing with a 'memcpy' during relocation

              needs to be flushed before the I$ can fetch this code to execute it..)

               The easiest way to handle this is to change the cache setting for any region of SRAM

               used for these purposes to WRITE-THROUGH ... 

          - there is some quirk in the interconnect on the TMS570LC4357 such that there is byte swizzling required when writing to the EMAC's internal descriptor memory.   You can look at the Hercules LWIP example from HalCoGen to see what this code needs to be.

       - flash programming is also different for the 4357 so you need the right F021 library. 

        - if your hardware is different you may be using the new dedicated pins for the EMAC on the LC4357.  this may mean a difference in pinmux settings.

    -Anthony

  • Hi Anthony F.Seely,

    I am having a doubt in Ethernet bootloader project which is given by TI in this link.

    So if you go thorugh the HL_sys_link.cmd file, you can find that FlashAPI libray is begin loaded in Flash memory and is begin executed from internal RAM memory?

    Why the approach is like this here instead of running the same FlashAPI code from the Flash memory itself?

    Is there any specific reason like Flash memory can only be erased or written or read when CPU execution is from RAM memory?

    Or can I do Flash related operations from flash memory itself?

    Please clarify this doubt.

    Thanks in advance.

    Regards,

    Karthikeyan KasiVishwanathan.

  • Is there any specific reason like Flash memory can only be erased or written or read when CPU execution is from RAM memory?

    Karthikeyan,

    This is correct.  The device cannot program a bank and execute from it at the same time.
    It is explained in SPNU501G:

      

  • Hi Anthony Seely,

    I tried to adapt the mentioned Bootloader Example from TI  for TMS570LC4357 and did modification in the listed files to adopt it for tms570lc4357.

    1. flashdefines.h - modified the sectors and bank information as per tm570lc4357 trm.

    2. SYSCLK macro to be 100MHz, since my HCLK (I've kept as ) is 100MHz.

    3. Included the library file F021_API_CortexR4_BE_L2FMC.lib. (also I tried with F021_API_CortexR4_BE_L2FMC_v3D16.lib)

    4. Constants.h file -> modified the Base address of OTP sections, EEPROM section, ECC Section for TMS570LC4357 (as per datasheet)

    5. Defined _L2FMC macro before F021.h file including statement.

    6. MPU access is modified as NORMAL_OINC_SHARED and PRV_RW_USER_RW_EXEC for both Flash memory and SRAM memory regions.

    7. Modified HL_sys_link.cmd file as per my memory configuration.

    So after all, I did steps as per the spna148, spnu501, I can't create a bootloader for TMS570LC4357.

    Please guide me where I'm doing something wrong.

    Here is my Project file for your reference.

    5238.Bootloader.zip

    I've attached the screen shot of my Debug window here (The error I got).

    So please guide to get my project working.

    Thanks in advance.

    Regards,

    Karthiekyan Kasivishwanathan

  • Karthiekeyan,

    The flash in your screen shot is erased. On the TMS570LC4537 this is what Erased flash looks like because ECC correction is always turned on.
    Most of the flash when erased will look like it has uncorrectable double bit errors but at various addresses it looks like a single bit error and the correction changes what you read from 0xFFFFFFFF to 'corrected' value. This varies by address because the address lines are included in the ECC syndrome computation.
  • Hi Karthik,

     You have a successful erase. Below is the content of the LC4357 from the same address range after I erase the flash which is the same as yours. As explained by Anthony, a fully erased flash means the data and the ECC are both F's. An all F's data and ECC at different address locations can be detected by the CPU as either no errors, single bit error in which case one of the bits is corrected or double bit errors.  

  • Hi Both,

    If this Screen shot is correct (i.e: Flash is erased correctly means), then Flash_erase_check function is returning Error value and hence the current UDP communication is getting closed. So how to avoid that.

    Note: I am using Cola-soft Packet builder software to send the UDP frame from PC to TMS570LC4357 board. (Yes I'm connecting my TMS570LC4357 board with PC ethernet Interface directly. And I'm sending  UDP Packet given below from PC using Colasoft Packet builder. Extract this rar file to get the Colasoft Packet Builder file, which you can use to send udp frame from PC to TMS570LC4357).

    2620.BootloaderUDPPacket.rar

    So that CPU Control will come to TFTPReceive function. From there my Bootloader logic is trying to erase flash and verify it after erase.

    This verification is getting failed because of these erroneous bits. If this screenshot is correct one, then how can I overcome this problem and proceed bootloader further.

    This is where I'm struck. Please help me.

    Thanks.

    Regards,

    Karthikeyan.K

  • Hi Karthik,

     Which flashAPI version are you using? If you are not using v2.01.01 then it is possible the blank check will fail. 

    v2.01.01
    o Fapi_enableEepromBankSectors() and Fapi_enableMainBankSectors() functions to check the OTP and enable the requested sector only if it exists on the device
    o Blank Check support for L2FMC devices, this function has to be executed from RAM for main banks.
    o All libraries compiled without debug symbols included in the distributed files. These filenames are suffixed by “_NDS” (No Debug Symbols).

  • Hi Charles,

    I'm using the following F021API library.

      Hercules™ ARM® Safety MCUs - F021 Flash API      
      v2.01.01 Build(000830)                           
      Build Date:  2014-10-21  

    I'm trying to enabe Bank0, Bank1 and Bank7 (EEPROM). And they are present in this device.

    Entire FlashAPI library itself is getting executed from RAM Space. (In RAMCODE Section as mentioned in HL_sys_link.cmd file).

    I tried  using F021_API_CortexR4_BE_L2FMC.lib, F021_API_CortexR4_BE_L2FMC_v3D16.lib, F021_API_CortexR4_BE_L2FMC_v3D16_NDS.lib. But None of these libraries worked after the flash_erase_check() function.

    So Is there any options I've to take care to overcome this Single bit Error correction which causes some of Flash bits to be logic Zero.?

    Thanks,

    Regards,

    Karthikeyan Kasivishwanathan.

  • Hi Karthik,
    Are you using the Fapi_doBlankCheck() flash API function?
  • HI Charles Tsai,

    No. I'm (actually TI Bootloader Example Project) not calling Fapi_doBlankCheck()  anywhere. That example project is trytin to read Flash memory regions and verify whether all bits are One or Zero. If any bits are zero then it throws error.

    Please have a look at the project I've uploaded in my previous prost in the same thread.  I had developed that project from the link below.

    Actually this example project is created for TMS370LS31x and I've modified it for TMS570LC4357. So I'm working in a application layer only. (Ok some configurations I did as mentioned in previous posts in the same thread.).

    In bl_flash.c file, Fapi_BlockErase() function only tries to verify whether flash memory is erased correctly or not.

    This is where the check is getting failed, and udppcb interface is closed.

    You can find this once you go through the code.

    Also you can colasoft packet builder software to send TFTP frame to Firmware to invoke the TFTPRecv() function.

    So please guide me what I have to do further to make this thernet bootloader working?

    Thanks in advance,

    Regards,

    Karthiekyan Kasivishwanthan.

  • Hi Karthik,

      The Flash_Erase_Check() will not work for LC4357 device because of the reason that was explained in the earlier threads. You will need to use the Fapi_DoBlankCheck() that comes with the flashAPI library to verify the erased flash. In the meantime, you can comment out the Flash_Erase_Check() to see if your program can proceed further. If you can proceed with your application then you should come back to fix this issue by using the Fapi_DoBlankCheck(). Please refer to the flash API user guide for this function.

    uint32_t Flash_Erase_Check(uint32_t Start_Address, uint32_t Bytes)
    {
    uint32_t error=0;
    register uint32_t *dst1 = (uint32_t *) Start_Address;
    register uint32_t bytes = Bytes;

    while(bytes > 0)
    {
    if(*dst1++ != 0xFFFFFFFF){
    error = 2;
    }
    bytes -= 0x4;
    }
    #ifdef DEBUG_MSG_L2
    UART_putString(UART, "\r Erase Flash Errors: ");
    UART_send32BitData(sciREG1, error);
    UART_putString(UART, "\r ");
    #endif
    return(error);
    }

      

  • Hi Charles,

    I tried using Fapi_DoBlankCheck() function, but that also doesn't care about corrected SECDED values in the flash memory. So that A021 API Function also returns error flag (i.e: Flash is not erased correctly). So I tried commenting the Blank check function. after that cpu control comes to while(1) line in tftp.c file Line No: 724.

    So I transmit Data Frame (TFTP protocol based frame using Colasoft Packet builder. I've given the file here. 5808.TFTP_PUT_DATA_PACKETS.zip, And my project file is here. 5873.Bootloader.zip ).

    So then My Write Frame from Colasoft Packet builder is received by the controller and the CPU execution comes to the TFTPDataRecv() function in tftp.c file , Line No: 283. But after that if I allow cpu execution  Line by line, no problem occurs. When CPU Execution comes to Line No:350 in tftp.c file, CPU Execution goes to Data Abort.

    So entirely Bootloader API is not working.

    Please help me in getting this Bootloader project successfully. We can't go further without this F021API working correctly. I've attached my Project file too in this post. Please refer it to detect the problem.

    Thanks in advance,

    Karthikeyan Kasivishwanathan

  • Hi Karthikeyan,
    If you are still having problem with the Fapi_DoBlankCheck() then I will need to forward your question to the flash API development team.

    For the data abort you are seeing, can you tell what are recorded in the Data Fault Status Register and Data Fault Address Registers inside the CPU? They will tell what caused the abort.
  • Hi Charles,

    I have attached the screen shot of status registers when I get abort condition.

    Hope this will make your understanding good regarding my problem.

    Regards,

    Kathikeyan Kasivishwanathan.

  • Kathikeyan,
    Looking at the link register (LR) it is 0x00020004. You are executing from a flash location for which has been erased. Is 0x00020004 where your application will be programmed to or this is where your bootloader also resides.