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.

TMS320F28386S: Serial flash programmer and SCI_Boot() seem out of sync

Part Number: TMS320F28386S

In the function SCI_Boot at line 119 it is looking for the keyword from the packet and then throws away 16 bytes via ReadReservedFn()

uint32_t SCI_Boot(uint32_t bootMode)
{
    uint32_t entryAddress;
    uint16_t byteData;

    //
    // CPU1 Patch/Escape Point 13
    //
    entryAddress = CPU1BROM_TI_OTP_ESCAPE_POINT_13;
    if((entryAddress != 0xFFFFFFFFUL) &&
       (entryAddress != 0x00000000UL))
    {
        //
        // If OTP is programmed, then call OTP patch function
        //
        ((void (*)(void))entryAddress)();
    }

    //
    // Check if SCI is enabled on device or not
    //
    if((HWREG(DEVCFG_BASE + SYSCTL_O_DC8) & SYSCTL_DC8_SCI_A) == 0U)
    {
        return(FLASH_ENTRY_POINT);
    }

    //
    // Assign GetWordData to the SCI-A version of the
    // function. GetWordData is a pointer to a function.
    //
    GetWordData = SCIA_GetWordData;

    //
    // Initialize the SCI-A port for communications
    // with the host.
    //

    //
    // Enable the SCI-A clocks
    //
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_SCIA);
    SysCtl_setLowSpeedClock(SYSCTL_LSPCLK_PRESCALE_4);

    EALLOW;
    HWREGH(SCIA_BASE + SCI_O_FFTX) = SCI_FFTX_SCIRST;

    //
    // 1 stop bit, No parity, 8-bit character
    // No loopback
    //
    HWREGH(SCIA_BASE + SCI_O_CCR) = (SCI_CONFIG_WLEN_8 | SCI_CONFIG_STOP_ONE);
    SCI_setParityMode(SCIA_BASE,SCI_CONFIG_PAR_NONE);

    //
    // Enable TX, RX, Use internal SCICLK
    //
    HWREGH(SCIA_BASE + SCI_O_CTL1) = (SCI_CTL1_TXENA | SCI_CTL1_RXENA);

    //
    // Disable RxErr, Sleep, TX Wake,
    // Disable Rx Interrupt, Tx Interrupt
    //
    HWREGB(SCIA_BASE + SCI_O_CTL2) = 0x0U;

    //
    // Relinquish SCI-A from reset and enable TX/RX
    //
    SCI_enableModule(SCIA_BASE);

    EDIS;

    //
    // GPIO INIT
    //
    SCIBOOT_configure_gpio(bootMode);

    //
    // CPU1 Patch/Escape Point 13
    //
    entryAddress = CPU1BROM_TI_OTP_ESCAPE_POINT_13;
    if((entryAddress != 0xFFFFFFFFUL) &&
       (entryAddress != 0x00000000UL))
    {
        //
        // If OTP is programmed, then call OTP patch function
        //
        ((void (*)(void))entryAddress)();
    }

    //
    // Perform autobaud lock with the host.
    // Note that if autobaud never occurs
    // the program will hang in this routine as there
    // is no timeout mechanism included.
    //
    SCI_lockAutobaud(SCIA_BASE);

    //
    // Read data
    //
    byteData = SCI_readCharBlockingNonFIFO(SCIA_BASE);

    //
    // Configure TX pin after autobaud lock
    // (Performed here to allow SCI to double as wait boot)
    //
    GPIO_setPadConfig(SCI_gpioTx,GPIO_PIN_TYPE_PULLUP);
    GPIO_setPinConfig(SCI_gpioTxPinConfig);

    //
    // Write data to request key
    //
    SCI_writeCharNonBlocking(SCIA_BASE,byteData);

    //
    // If the KeyValue was invalid, abort the load
    // and return the flash entry point.
    //
    if(SCIA_GetWordData() != SCI_DATA_WORD_KEY)
    {
        return FLASH_ENTRY_POINT;
    }

    ReadReservedFn();

    entryAddress = GetLongData();

    CopyData();

    return entryAddress;
}

In serial_flash_programmer.cpp after the parsing and the comm state is set my program reaches this line:

    if (g_bf021 == true && g_bf2838x == true) //F021

and f021_DownloadKernel() is called, which opens the kernel file, runs autobaudLock() and calls loadProgram().

The function loadProgram() just starts downloading bytes. It seems that f021_SendPacket() should be called somewhere. Am I missing it?

Also SCI_Boot() calls CopyData() which just reads data, while loadProgram() wants each byte echoed back.

Thanks,

John

  • Hi John,

    The function f021_SendPacket() function resides in the f021_SendMessage.cpp file with the host programmer. 

    f021_SendPacket() occurs during the DFU_CPU1 sequence. 

    The original copyData() function copies multiple blocks of data but doesn't do error checking for what the addresses are in RAM. Are you saying the copyData() function mentioned above only reads the locations?

    Thanks,

    Charles

  • I am saying that loadProgram() wants to send bytes and have them echoed back. SCI_Init() does not echo back the characters, it only reads and copies.

  • John,

    On the host side, loadProgram() sends the kernel data to the target side. On the target side, SCI_Boot() calls copyData() to program the given Kernel data to RAM. 

    Do you have a scope available? On the host side, during loadProgram() when it is trying to echo back the character, it is writing that character to the COM Port, using Writefile() to send the character, and Readfile() to make sure the character arrived at the COM Port. You would need to check the SCITX and SCIRX lines to see if the kernel is being sent correctly. 

    Charles

  •  Yes, that is what I implied. loadProgram() expects characters to be echoed. The only thing that gets echoed is in SCI_Boot() where this call is made:

        if(SCIA_GetWordData() != SCI_DATA_WORD_KEY)
    CopyData() does not echo characters but loadProgram() expects them to be echoed.
  • I see. So the fact that CopyData() does not echo characters makes it harder to see if the kernel is being programmed in RAM appropriately. Are you able to check the address for DestAddr in the Memory window to see if it is being sent to the same location? If possible, can do a memory dump for the RAM.

  • loadProgram() will hang here as dwRead is zero until there is something in the buffer.

    		dwRead = 0;
    		while (dwRead == 0)
    		{
           ReadFile(file, &rcvData, 1, &dwRead, NULL);
        }

    Sorry for the screwing alignment but editing the code block does not work and I am tired of fighting this thing.

  • If it is hanging there at DownloadKernel()->loadProgram()->ReadFile() then I would check and see if the kernel file is being read correctly. It is trying to parse through the kernel file until it reaches final characters. Are you able to open the hex file and see what the bytes look like? Is the alignment ok? 

  • I don't think you read my posts completely. This was the problem:

    CopyData() does not echo characters but loadProgram() expects them to be echoed.
    loadProgram on the serial flash programmer side expected echos. Copy data did not have any write statements so it was not echoing back.
    But it doesn't matter anymore as I no longer work there.