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.

MSP432E401Y: XDS110 UART_write function hanged using flash access operation in TIRTOS

Part Number: MSP432E401Y
Other Parts Discussed in Thread: MSP-EXP432E401Y

Hi,

To test flash operation, I imported "nvsinternal" as TIRTOS CCS project and replace "nvsinternal.c" with "flash_access.c".

/*
 *  ======== flash_access.c ========
 */

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>

/* DriverLib Header files */
#include <ti/devices/msp432e4/driverlib/driverlib.h>

/* Driver Header files */
#include <ti/display/Display.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/NVS.h>

#include <xdc/runtime/System.h>

/* Driver configuration */
#include "ti_drivers_config.h"

typedef struct _rtConfig {
    uint32_t programmed;          // Deve ter um valor 0x0000ABCD quando programada e nao podemos zerar
    uint8_t  serverIp4Addr[4];    // Endereco IP do servidor
    uint16_t serverPort;          // Porta do servidor
    uint16_t localServerPort;     // Porta local de config
    uint32_t equipmentId[8];      // ID do Equipamento
    uint8_t  serialNumber[16];    // SerialNumber (string)
    uint32_t partNumber[4];       // PartNumber
    uint32_t reserved[45];        // Reservado Scientts = (256 - Numero de uint32_t acima)
} rtConfig;

#define FOOTER "=================================================="
#define FLASH_STRT_ADDR     0xFC000

/*
 *  ======== mainThread ========
 */
void *mainThread(void *arg0)
{
    uint32_t pui32Data[2], aaa, i, siz;
    char     buf[64];
    rtConfig sv_remoteConf, remoteConf;
    uint8_t  *ptr;

    UART_Params uartParams;
    UART_Handle uart;

    // Initialize the UART driver and UART parameters
    UART_init();

    UART_Params_init(&uartParams);
    uartParams.writeDataMode  = UART_DATA_BINARY;       // UART_DATA_BINARY;
    uartParams.readDataMode   = UART_DATA_BINARY;       // UART_DATA_TEXT;
    uartParams.readReturnMode = UART_RETURN_NEWLINE;    // UART_RETURN_FULL;
//  uartParams.readEcho       = UART_ECHO_ON;           /*!< Echo received data back */
    uartParams.baudRate = 115200;

    /* Create a UART for the console */
    uart = UART_open(CONFIG_UART_0, &uartParams);
    if (uart == NULL) {
        while (1);
    }
//    UART_write(uart, "Hello, Flash Access Test PGM\n", 29);

    // Erase a block of the flash.
    FlashErase(FLASH_STRT_ADDR);

    // Program some data into the newly erased block of the flash.
    aaa = sizeof sv_remoteConf;
    memset(&sv_remoteConf, 0x00, sizeof sv_remoteConf);
    sv_remoteConf.programmed = 0x35353535;
    sv_remoteConf.serverIp4Addr[0] = 192;
    sv_remoteConf.serverIp4Addr[1] = 168;
    sv_remoteConf.serverIp4Addr[2] = 59;
    sv_remoteConf.serverIp4Addr[3] = 132;
    sv_remoteConf.serverPort = 5555;
    sv_remoteConf.localServerPort = 5556;
    sv_remoteConf.equipmentId[0] = 70;
    sv_remoteConf.equipmentId[1] = 71;
    sv_remoteConf.equipmentId[2] = 72;
    sv_remoteConf.equipmentId[3] = 73;
    sv_remoteConf.equipmentId[4] = 74;
    sv_remoteConf.equipmentId[5] = 75;
    sv_remoteConf.equipmentId[6] = 76;
    sv_remoteConf.equipmentId[7] = 77;
    memset(sv_remoteConf.serialNumber, 0x00, sizeof sv_remoteConf.serialNumber);
    strcpy((char *)&sv_remoteConf.serialNumber[0], "SN:1234567890");
    sv_remoteConf.partNumber[0] = 80;
    sv_remoteConf.partNumber[1] = 81;
    sv_remoteConf.partNumber[2] = 82;
    sv_remoteConf.partNumber[3] = 83;

    FlashProgram((uint32_t *)&sv_remoteConf, FLASH_STRT_ADDR, sizeof sv_remoteConf);

    SysCtlDelay(100);

    // read data from flash designated by FLASH_STRT_ADDR
    siz = sizeof sv_remoteConf ;
    i = 0;
    ptr = (uint8_t  *)&remoteConf;
    while (i < siz) {
        aaa = HWREG(FLASH_STRT_ADDR + i);
        memcpy((void *)ptr, (void *)&aaa, 4);
        i = i + 4;
        ptr = ptr + 4;
    }

    // output to XDS110 UART
    i = remoteConf.programmed;
    sprintf((char *)&buf[0], (char *)" programmed = 0x%x\n", i);
    aaa = strlen((const char *)&buf[0]);
//    UART_write(uart, buf, aaa);

    i = remoteConf.serverIp4Addr[0];    // Endereco IP do servidor
    i = remoteConf.serverIp4Addr[1];    // Endereco IP do servidor
    i = remoteConf.serverIp4Addr[2];     // Endereco IP do servidor
    i = remoteConf.serverIp4Addr[3];    // Endereco IP do servidor
    sprintf((char *)&buf[0], (char *)" Server IP = %d.%d.%d.%d\n",
            remoteConf.serverIp4Addr[0], remoteConf.serverIp4Addr[1],
            remoteConf.serverIp4Addr[2], remoteConf.serverIp4Addr[3]);
    aaa = strlen((const char *)&buf[0]);
//    UART_write(uart, buf, aaa);

    i = remoteConf.serverPort;         // Porta do servidor
    i = remoteConf.localServerPort;    // Porta local de configuration
    sprintf((char *)&buf[0], (char *)" Server ports = %d and %d\n",
            remoteConf.serverPort, remoteConf.localServerPort);
    aaa = strlen((const char *)&buf[0]);
//    UART_write(uart, buf, aaa);

    i = remoteConf.equipmentId[0];      // ID do Equipamento
    i = remoteConf.equipmentId[1];      // ID do Equipamento
    i = remoteConf.equipmentId[2];      // ID do Equipamento
    i = remoteConf.equipmentId[3];      // ID do Equipamento
    i = remoteConf.equipmentId[4];      // ID do Equipamento
    i = remoteConf.equipmentId[5];      // ID do Equipamento
    i = remoteConf.equipmentId[6];      // ID do Equipamento
    i = remoteConf.equipmentId[7];      // ID do Equipamento
    sprintf((char *)&buf[0], (char *)" Equip IDs = %d %d %d %d %d %d %d %d\n",
            remoteConf.equipmentId[0], remoteConf.equipmentId[1],
            remoteConf.equipmentId[2], remoteConf.equipmentId[3],
            remoteConf.equipmentId[4], remoteConf.equipmentId[5],
            remoteConf.equipmentId[6], remoteConf.equipmentId[7]);
    aaa = strlen((const char *)&buf[0]);
//    UART_write(uart, buf, aaa);

    sprintf((char *)&buf[0], (char *)" SerialNumber = %s\n", (char *)&(remoteConf.serialNumber[0]));
    aaa = strlen((const char *)&buf[0]);
//    UART_write(uart, buf, aaa);

    i = remoteConf.partNumber[0];      // PartNumber
    i = remoteConf.partNumber[1];      // PartNumber
    i = remoteConf.partNumber[2];      // PartNumber
    i = remoteConf.partNumber[3];      // PartNumber
    sprintf((char *)&buf[0], (char *)" Part NOs = %d %d %d %d\n",
            remoteConf.partNumber[0], remoteConf.partNumber[1],
            remoteConf.partNumber[2], remoteConf.partNumber[3]);
    aaa = strlen((const char *)&buf[0]);
//    UART_write(uart, buf, aaa);

    SysCtlDelay(500);

    UART_close(uart);
    return (NULL);
}

 This C program is very simple:

   1. Open UART0 configured to XDS 110 UART 

   2. FlashErase(0xFC000)

   3. Fill the data in C structure called sv_remoteConf

   4. Save this contents of  sv_remoteConf structure using FlashProgram() function

   5. Access the data saved in the flash memory and load into data structure

   6. Output loaded data to COM port using UART_write

If I comment out all the UART_write statements, this program worked fine in CCS debugging mode.

But, if I make all the UART_write statements alive, CCS debugging is hanged at first UART_write statement. 

I cannot continue debugging further. So I stop its debugging.

Under the TI-RTOS, is there any conflict between Flash operation and UART operation ?

Please let me have any clue to fix this problem.

My testing environments are:

   - OS: Windows 10 64-bit

   - CCS:  Version: 11.2.0.00007 

   - simplelink_msp432e4_sdk:  ver 4_20_00_12

   - MSP-EXP432E401Y LaunchPad

Any help/advice appreciated in advance.   

HaeSeung

   

  • Hi HaeSeung

    Please consider set break point insider the function "UART_write" and check if the function is normal running on this function through step in and step over

    Thanks!

  • Hi Xiaodong,

    To use ROV, I changed the Referenced Project to "tirtos_builds_MSP_EXP432E401Y_debug_ccs" from "tirtos_builds_MSP_EXP432E401Y_release_ccs".

    Then I found that UART_open() caused java.lang.Exception before UART_write() operation hanged, saying:

         Error: java.lang.Exception: Target memory read failed at address: 0x8, length: 76 This read is at an INVALID address

         according to the application's section map. The application is likely either uninitialized or corrupt.

    I attached all the available screenshot(raw, basic, CallStacks and Module) as follows:

    If I comment out all the flash driverlib API, then UART_open() and UART_write() run very well without problems.

    This error only happened when UART driver API and flash driverlib API together under TI-RTOS.

    Is there any known conflict between UART driver API and flash driverlib API ?

    Any help/clue are welcomed in advance.

    HaeSeung