Part Number: TM4C129ENCPDT
Tool/software: Code Composer Studio
I am using TIVA RTOS with NDK. Here is my code -
The main task at the bottom, calls the board.h functions to start up the chip peripherals. Then an init task is started, top function, to do the remainder task creation.
The NDK is started and when the iniTaskFxn task completes the network is supposed to be up and running.
/******************************************************************************
* initTaskFxn
* init task
*
* called from Scheduler to initialize application. This function:
* 1) sets up the eeprom
* 2) validates the contents of the eeprom
* 3) reads and instantiates the parameters
* 4) calls all task init functions
*
* @param arg0 - task parameter
* @param arg1 - task parameter
* @return none
*
*****************************************************************************/
void initTaskFxn(UArg arg0, UArg arg1)
{
// intialize the EEPROM hardware
initEEPROM();
#if 0
//*****JKP - Remove - test only
EEPROM_Format();
//**** JKP - End Remove
#endif
// copy the default parameters into the working parameters
memcpy(&WorkingConfigParams, &DefaultConfigParams, sizeof(Config_Params_t));
// set the temporary parameters to the default parameters
// When parsing the JSON, only those parameters contained in the JSON
// are updated. Missing JSON parameters are defaulted to the default values.
memcpy(&TempConfigParams, &DefaultConfigParams, sizeof(Config_Params_t));
// get the board id
BoardId = IPMI_GetBoardID();
// Check the eeprom and extract the current configuration parameters
// If the eeprom is not setup, it will format the eeprom.
EEPROM_Open();
// at this point, the WorkingConfigParams are valid.
System_printf("eeprom open\n");
System_flush();
// signal the EEPROM parameters is completed
Semaphore_post(EEPROM_Semaphore);
eepromIsOpen = true;
// wait for the network
Semaphore_pend(Network_Semaphore, 0);
while(!networkIsOpen)
{
Task_sleep(1000);
}
// call the board gpio function with the board Id
Board_initGPIO(BoardId);
// Start the IPMI UDP socket task
initPIC_IPMI();
// Init the UDP configuration update task
initConfigUpdate();
// Board specific task initializations
if(BoardId == BOARD_TYPE_CPU)
{
// ARcpu board
// Setup the switch based on the parameters
initSwitchConfig();
// Start the Console UART task
initConsole();
// check that the EMAC link is up - else do a cpu reset
Task_sleep(2000);
if (EMACSnow_isLinkUp(0) != true)
{
SysCtlReset();
}
Console_printfStr("CPU board is ready ... \n\r");
}
else if(BoardId == BOARD_TYPE_EIO)
{
// AReio board
// Start the GPIO UDP and TCP tasks
initGPIO();
// Start the RS232 UDP and TCP tasks
initNetRS232();
// Start the RS422 UDP and TCP tasks
initNetRS422();
}
else
{
// Bad Board ID
// TODO - error handler here
}
// spawn the registered UDP/TCP socket tasks
InitSocketConfig();
// this task ends and is never called again.
}
/******************************************************************************
* main
* Entry point for the application
*
* @param void
* @return application exit value
*
*****************************************************************************/
int main(void)
{
// local task setup structure
Task_Params taskParams;
// local SPI parameters
SPI_Params Spi0Params;
// crc_pointer = (uint32_t *) &_text_crc;
// setup up initialization flags
eepromIsOpen = false;
networkIsOpen = false;
/* Call board init functions */
Board_initGeneral();
// initialize the Ethernet peripheral
Board_initEMAC();
// Initialize the GPIO
Board_initGPIO(BOARD_TYPE_UNKNOWN);
// initialize the board spi's
Board_initSPI();
// initialize the UARTs
Board_initUART();
// Open the EEPROM SPI port
SPI_Params_init(&Spi0Params);
// Initialize the SPI peripheral that is connected to the EEPROM and the switch chips
Spi0Handle = SPI_open(Board_SPI0, &Spi0Params);
if (Spi0Handle == NULL)
{
System_abort("EPROM SPI_open failed\n");
}
// create a hardware mutex to the EEPROM/Switch SPI
GateMutex_construct(&(SPI0gate), NULL);
// create a semaphore to the EPROM/Switch spi bus
Semaphore_Params EEPROM_SemParams;
Semaphore_Params_init(&EEPROM_SemParams);
EEPROM_SemParams.mode = Semaphore_Mode_BINARY;
EEPROM_Semaphore = Semaphore_create(0, &EEPROM_SemParams, NULL);
Semaphore_Params Network_SemParams;
Semaphore_Params_init(&Network_SemParams);
Network_SemParams.mode = Semaphore_Mode_BINARY;
Network_Semaphore = Semaphore_create(0, &Network_SemParams, NULL);
// Create the Initialization Task
Task_Params_init(&taskParams);
taskParams.priority = 8;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)initTaskFxn, &taskParams, NULL);
// initialize the Boot loader
initBootLoaderUpdate();
// compute the application CRC
uint32_t mycrc = getCrc();
// SysMin will only print to the console when you call flush or exit
// FORDEBUG
// JumpToBootLoader();
// print any pending messages to the debug console.
System_flush();
// start the RTOS system
// Start BIOS - kick off the tasks
BIOS_start();
return (0);
}
I am having an issue during startup of my code.
1) using the debugger, the code always starts and behaves properly.
2) When I take the debugger probe off and cycle power, my application does not behave normally. The NDK does not startup properly. The code appears to startup however the network does not function. The initTaskFnx creates some UDP and TCP tasks. When a power-cycle these tasks appear not to run.
3) If I put cause an external reset the code starts up properly and the network UDP/TCP tasks operate normally.
4) I have tried to detect a POR using the SysCtrlCauseGet() and perform a software reset via SysCtlRest(), but this does not work. Only an external reset strobe on the reset pin.
5) I have also loaded the code using the UNIFLASHER, but the result is the same.
Questions:
1) what is the difference between code starting up from a debugging session vs from power up?
2) When I load code using the debugger, and then remove the debugger, and then power cycle the board - should this work properly? it does not.
3) What is the difference between RELEASE CODE and DEBUG code?
4) Is there a difference between loading the code using the debugger and the Uniflasher?