AnsweredAssumed Answered

KDSK1.3 RTCS IAR TAD not working

Question asked by Adrian Rockall on Jan 14, 2016
Latest reply on Jan 20, 2016 by Adrian Rockall

Hi,

 

I have a project running on a custom board. It is built using KSDK 1.3 / MQX and the IAR Workbench V7.40.7.9865. The TAD plugin reports as version 4.7.3.0.

The MQX menu works for most things except NIO related items ("NIO seems not to be installed...") even though the console port, USB and SD seem to be using NIO drivers still.

However the most annoying is that none of the RTCS menu items work and all I see is "RTCS Data is not currently valid." in any of the views.

The HTTP, FTP servers are both working (most of the time) so the initialisation is OK for normal functionality but I guess I must be missing something for the TAD.

 

Can anyone suggest what I might have missed in the setup to allow the TAD to work?

 

I have looked at the HVAC sample and I can't see anything in there that is missing from my code. My initialisation code is as follows:

 

uint32_t Init_EthernetProtocols()
{
int32_t                              error;
uint32_t                             server;
extern const HTTPSRV_CGI_LINK_STRUCT cgi_lnk_tbl[];
extern const HTTPSRV_SSI_LINK_STRUCT ssi_lnk_tbl[];
HTTPSRV_PARAM_STRUCT                 params;
uint32_t        ipOptions = 0;

/* Init RTCS */
_RTCSPCB_init = 4;
_RTCSPCB_grow = 2;
_RTCSPCB_max = 20;
_RTCSTASK_stacksize = 4500;
_IP_forward = TRUE;

error = RTCS_create();
if (error != RTCS_OK)
{
  DEBUG_Print("RTCS failed to initialize, error = 0x%lX\n", (uint32_t)error);
  _task_block();
}

/* Bind IP address for ETHERNET interface */
uint32_t    phy_addr = 0;
_enet_address   address;
IPCFG_IP_ADDRESS_DATA ip_data;

//  ENET_get_mac_address(phy_addr, ip_addr[i], address);
uint16_t cmdBuf = 0x7A7F;      //Address of MAC in the chip is 0x7F7A but high byte followed by low byte so bytes swapped here for compatability
i2cCom1_MasterConfig0.baudRate_kbps = 100;  //Maximum speed with this design is 100 kHz
i2cCom1_MasterConfig0.address = 0x50;   //Chip address
while (I2C_DRV_MasterReceiveDataBlocking( FSL_I2CCOM1, &i2cCom1_MasterConfig0, (uint8_t*)&cmdBuf, 2, address, 6, 10 ) != kStatus_I2C_Success)
{
  OSA_TaskYield();
}
DEBUG_Print( "MAC address = %2X, %2X, %2X, %2X, %2X, %2X\n", address[ 0 ], address[ 1 ], address[ 2 ], address[ 3 ], address[ 4 ], address[ 5 ] );

/* Init ENET device */
error = ipcfg_init_device( phy_addr, address );
if (error != RTCS_OK)
{
  DEBUG_Print( "IPCFG: Device init failed. Error = 0x%lX\n", (uint32_t)error );
  _task_set_error( MQX_INVALID_DEVICE );
  _task_block();
}

cmdBuf = MAC_E2_IP; //Address of user configured IP, mask and gateway (12 bytes in total)
I2C_DRV_MasterReceiveDataBlocking( FSL_I2CCOM1, &i2cCom1_MasterConfig0, (uint8_t*)&cmdBuf, 2, (uint8_t*)&ip_data, 12, 20 );
if (ip_data.ip == 0xFFFFFFFF)
{
  ip_data.ip = IPADDR( ENET_IPADDR_A, ENET_IPADDR_B, ENET_IPADDR_C, ENET_IPADDR_D );
  ip_data.mask    = ENET_IPMASK;
  ip_data.gateway = 0;
}

cmdBuf = MAC_E2_OPTIONS; //Address of user configured IP options
I2C_DRV_MasterReceiveDataBlocking( FSL_I2CCOM1, &i2cCom1_MasterConfig0, (uint8_t*)&cmdBuf, 2, (uint8_t*)&ipOptions, 4, 20 );

/* Bind IPv4 address */
if ((ipOptions & IP_CONFIG_USE_DHCP) == IP_CONFIG_USE_DHCP)
{
  DEBUG_Print( "Getting IP address from DHCP server...\n" );
  error = ipcfg_bind_dhcp_wait( phy_addr, true, &ip_data );
}
else
{
  DEBUG_Print( "Using fixed IP: Address = %lu.%lu.%lu.%lu, Mask = %lu.%lu.%lu.%lu, Gateway = %lu.%lu.%lu.%lu\n", IPBYTES( ip_data.ip ), IPBYTES( ip_data.mask ), IPBYTES( ip_data.gateway ) );
  error = ipcfg_bind_staticip( phy_addr, &ip_data );
}
if (error != RTCS_OK)
{
  DEBUG_Print("\nIPCFG: Failed to bind IP address. Error = 0x%lX", (uint32_t)error);
  _task_block();
}

ipcfg_get_ip( phy_addr, &ip_data );

NIO_TFS_INIT_DATA_STRUCT tfs_init = {(NIO_TFS_DIR_ENTRY*)0xB8000000};
if (_nio_dev_install("tfs:", &nio_tfs_dev_fn, &tfs_init, &error) == NULL)
    {
        DEBUG_Print("\n Failed to initialize Trivial File System\n");
        _task_block();
    }

/* Start HTTP server on the interface */
char *secure_string;

_mem_zero(&params, sizeof(HTTPSRV_PARAM_STRUCT));
params.af = HTTP_INET_AF;  //IPv4, IPv6 or from config.h

#if RTCSCFG_ENABLE_IP6
/* Set interface number here. Zero is any. */
params.ipv6_scope_id = HTTP_SCOPE_ID;
#endif

params.root_dir = "tfs:";
params.index_page = "\\index.htm";
params.auth_table = auth_realms;
#if ENABLE_SSL && RTCSCFG_ENABLE_SSL
secure_string = "S";
#else
secure_string = "";
#endif
DEBUG_Print( "Starting HTTP%s server", secure_string );

if (HTTP_INET_AF & AF_INET)
{
  #if RTCSCFG_ENABLE_IP4
  params.ipv4_address.s_addr = INADDR_ANY;

  /* Print active IPv4 address */
  DEBUG_Print(" %lu.%lu.%lu.%lu", IPBYTES( ip_data.ip ));
  #endif
}
if (HTTP_INET_AF & AF_INET6)
{
  #if RTCSCFG_ENABLE_IP6
  IPCFG6_GET_ADDR_DATA data;
  char prn_addr6[RTCS_IP_ADDR_STR_SIZE];

  ipcfg6_get_addr(0, 0, &data);

  if(inet_ntop(AF_INET6, &(data.ip_addr), prn_addr6, sizeof(prn_addr6)))
  {
   /* Print active IPv6 address */
   DEBUG_Print("%s %s", (HTTP_INET_AF & AF_INET) ? " and" : "", prn_addr6);
  }
  #endif
}
DEBUG_Print(", port %d", HTTPSRV_PORT);
/*
** Maximum default number of available sockets in RTCS is six.
** Maximum of two are used for HTTP server as listening sockets (one for IPv4 and one for IPv6).
** So we take two of sockets and use them for sessions.
*/
params.max_ses = HTTPSRV_EXAMPLE_SESSIONS;
params.cgi_lnk_tbl = cgi_lnk_tbl;
params.ssi_lnk_tbl = ssi_lnk_tbl;
#if HTTPSRVCFG_WEBSOCKET_ENABLED
params.plugins = &plugins;
#endif
params.port = HTTPSRV_PORT;
#if ENABLE_SSL && RTCSCFG_ENABLE_SSL
params.ssl_params = &ssl_params;
#endif
init_plugins();
/* There are a lot of static data in CGIs so we have to set large enough stack for script handler */
params.script_stack = HTTPSRV_EXAMPLE_CGI_STACK;
server = HTTPSRV_init(&params);

printf("...");
if (server == 0)
{
  DEBUG_Print("[FAIL]\n");
}
else
{
  DEBUG_Print("[OK]\n");
}

//Start the Lan Name server
char lanName[ 20 ];
cmdBuf = MAC_E2_LAN_NAME; //Address of LAN NAME
I2C_DRV_MasterReceiveDataBlocking( FSL_I2CCOM1, &i2cCom1_MasterConfig0, (uint8_t*)&cmdBuf, 2, (uint8_t*)&lanName, 20, 30 );
if (lanName[ 0 ] == 255)
{
  strcpy( lanName, "xtpc" );
}

DEBUG_Print( "Starting Lan Name server as %s\n", lanName );

//Use the shell to start the server so the user can stop it from the console
char* args[ 4 ] = {"llmnr", "-h", lanName, "start"};
Shell_llmnrsrv(4, args );
// _rtcs_if_handle ihandle = ipcfg_get_ihandle(BSP_DEFAULT_ENET_DEVICE);
// _mem_zero(&llmnr_params, sizeof(llmnr_params));
// llmnr_params.interface = ihandle;
// llmnr_params.host_name_table = host_name_table;
// /* Start LLMNR server.*/
// LLMNRSRV_init(&llmnr_params);

DEBUG_Print( "Network setup complete\n" );

return RTCS_OK;
}

 

I initialise the FTP server once the SD card is mounted.

 

Best regards,

Adrian.

Outcomes