Board Temps
Edit this on GitLab
Board Temps Sample Application (SSK 2.x)
Overview
The Board Temps sample application demonstrates how to read temperature sensors from an NAI board using the NAI Software Support Kit (SSK 2.x). It reads both motherboard-level temperatures (Zynq core and PCB) and module-level temperatures (interface Zynq core, interface PCB, and functional PCB) for every populated module slot. For boards with dual ARM processors (64ARM1, 64G5, 68ARM1), it also reads the slave Zynq core and slave PCB temperatures.
This sample is useful for thermal monitoring, environmental qualification testing, and verifying that temperature sensors are reporting valid data. It iterates over all connected boards and all populated module slots, displaying real-time, maximum, and minimum temperature readings in degrees Celsius.
There is no SSK 1.x counterpart for this sample.
Prerequisites
-
An NAI board powered on and connected to the development host.
-
SSK 2.x installed on your development host.
-
The sample applications built. Refer to the SSK 2.x Software Development Guide for platform-specific build instructions.
How to Run
Launch the board_temps executable from your build output directory. On startup the application looks for a configuration file (default_BoardTemperatures.txt). On the first run, this file will not exist — the application will present the interactive board menu where you configure a board connection. Once connected, the application displays temperature readings for all boards and modules, then prompts you to read again or quit.
Board Connection and Temperature Display
|
Note
|
This application does not perform module selection in the typical sense. Instead, it automatically iterates over all boards and all populated module slots. |
The main() function follows a streamlined SSK 2.x startup flow:
-
Call
naiapp_RunBoardMenu()to load a saved configuration file or present the interactive board menu. The configuration file (default_BoardTemperatures.txt) is not included with the SSK — it is created when the user saves their connection settings. -
Loop over all connected boards using
naiapp_GetBoardCnt(). -
For each board, read motherboard temperatures, then iterate over all module slots reading module temperatures.
-
Prompt the user to read again or quit.
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t BoardTemperatures(void)
#else
int32_t main(void)
#endif
{
int32_t cardIndex;
int32_t moduleCnt;
int32_t module;
bool_t stop = NAI_FALSE;
uint32_t moduleID;
int8_t txtModuleID[10];
int8_t inputBuffer[80];
int32_t inputResponseCnt;
int8_t boardName[NAI_MAX_BOARD_NAME_LEN];
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
{
while (stop != NAI_TRUE)
{
for (cardIndex = 0; cardIndex < naiapp_GetBoardCnt(); cardIndex++)
{
naiapp_GetBoardName(cardIndex, boardName);
naiif_printf("\r\n\r\nBoard #%d: Temperature Readings for %s:\r\n", cardIndex + 1, boardName);
naiif_printf("---------------------------------------------------------------------------\r\n");
getMotherboardTemperature(cardIndex);
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
for (module = 1; module <= moduleCnt; module++)
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if ((moduleID != 0))
{
naiapp_utils_ConvertModIdToAscii(moduleID, (char *)txtModuleID);
naiif_printf("\r\nModule #%d: Temperatures (in degrees Celsius) for %3s\r\n", module, txtModuleID);
naiapp_GetModuleTemperature(cardIndex, module);
}
}
}
naiif_printf("\r\nType Q to quit or Enter to read temperature:\r\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
}
naiif_printf("\r\nType the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
naiapp_access_CloseAllOpenCards();
return 0;
}
Note the SSK 2.x differences from SSK 1.x in this startup sequence:
-
The VxWorks preprocessor guard uses
NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS(SSK 1.x uses__VXWORKS__). -
The module identifier is retrieved with
naibrd_GetModuleName()(SSK 1.x usesnaibrd_GetModuleID()). -
Boolean constants are
NAI_TRUE/NAI_FALSE(SSK 1.x usesTRUE/FALSE). -
Console output uses
naiif_printf()from the platform abstraction layer (SSK 1.x usesprintf()directly).
|
Important
|
Common connection errors you may encounter at this stage:
|
Program Structure
Entry Point
On standard platforms (Petalinux, Windows) the entry point is main(). On VxWorks the entry point is BoardTemperatures() — the SSK 2.x build system selects the correct variant via a preprocessor guard:
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t BoardTemperatures(void)
#else
int32_t main(void)
#endif
Application Flow
This sample does not have a command table or interactive command loop. Instead, it follows a read-display-repeat pattern:
-
Connect to the board via
naiapp_RunBoardMenu(). -
Loop over all boards and modules, displaying temperatures.
-
Prompt the user to read again or quit.
-
On exit, close all open board connections with
naiapp_access_CloseAllOpenCards().
Reading Motherboard Temperatures
The getMotherboardTemperature() function reads the Zynq core and PCB temperatures from the motherboard. Each sensor provides real-time, maximum, and minimum readings:
static void getMotherboardTemperature(int32_t cardIndex)
{
float64_t temp = 0.0;
int8_t boardName[NAI_MAX_BOARD_NAME_LEN];
naiapp_GetBoardName(cardIndex, boardName);
naiif_printf("Motherboard Temperatures (in degrees Celsius)\r\n");
naiif_printf(" Real-Time Max Min\r\n");
naiif_printf("Zynq Core: ");
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_RT_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MAX_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MIN_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
naiif_printf("Zynq PCB: ");
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_RT_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MAX_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MIN_PCB, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
/* ... dual-ARM boards also read slave Zynq temperatures ... */
}
Key API calls:
-
naibrd_GetMotherboardTemperature(cardIndex, tempType, &temp)— Reads a specific motherboard temperature sensor. ThetempTypeparameter selects the sensor:-
NAIBRD_MOTHERBOARD_TEMP_RT_ZYNQ_CORE— Real-time Zynq core temperature. -
NAIBRD_MOTHERBOARD_TEMP_MAX_ZYNQ_CORE— Maximum recorded Zynq core temperature. -
NAIBRD_MOTHERBOARD_TEMP_MIN_ZYNQ_CORE— Minimum recorded Zynq core temperature. -
NAIBRD_MOTHERBOARD_TEMP_RT_PCB/MAX_PCB/MIN_PCB— PCB temperature readings.
-
For dual-ARM processor boards (64ARM1, 64G5, 68ARM1), the function also reads slave Zynq temperatures using NAIBRD_MOTHERBOARD_TEMP_RT_SLAVE_ZYNQ_CORE and NAIBRD_MOTHERBOARD_TEMP_RT_SLAVE_PCB variants.
Reading Module Temperatures
The naiapp_GetModuleTemperature() function reads three temperature sensors for each module: the interface Zynq core, the interface PCB, and the functional PCB.
static void naiapp_GetModuleTemperature(int32_t cardIndex, int32_t module)
{
float64_t temp = 0.0;
naiif_printf(" Real-Time Max Min\r\n");
naiif_printf("Zynq Core: ");
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_RT_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_MAX_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_MIN_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
/* ... similar for Zynq PCB and Functional PCB ... */
}
Key API calls:
-
naibrd_GetModuleTemperature(cardIndex, module, tempType, &temp)— Reads a specific module temperature sensor. ThetempTypeparameter selects the sensor:-
NAIBRD_MODULE_TEMP_INTF_RT_ZYNQ_CORE/MAX/MIN— Interface Zynq core temperature. -
NAIBRD_MODULE_TEMP_INTF_RT_PCB/MAX/MIN— Interface PCB temperature. -
NAIBRD_MODULE_TEMP_FUNC_RT_PCB/MAX/MIN— Functional PCB temperature.
-
Troubleshooting Reference
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
All temperatures read as 0.00 |
Board has not completed power-on initialization, or the temperature sensors are not yet active. |
Wait a few seconds after power-on and re-read. Verify firmware version supports temperature monitoring. |
No board found |
Board not powered, cable disconnected, or wrong interface selected. |
Verify power, cables, and that the correct interface type is chosen in the board menu. |
Connection timeout |
Incorrect IP address, firewall blocking communication, or network misconfiguration. |
Confirm the board IP address. Disable or configure firewall rules. |
Module temperatures not displayed |
Module slot is empty or module is not seated properly. |
Verify physical module installation. The application skips slots where |
Slave Zynq temperatures not displayed |
The board does not have a dual ARM processor. |
Slave temperatures are only displayed for 64ARM1, 64G5, and 68ARM1 boards. This is normal behavior for single-processor boards. |
Temperature values seem unreasonably high |
The module or board may be in a high-temperature environment, or a sensor fault exists. |
Compare real-time, max, and min values. If max is significantly higher than real-time, a transient thermal event occurred. If values exceed specification, check for ventilation issues. |
|
Communication failure or unsupported temperature register on the installed firmware. |
Verify board firmware is up to date. Some older firmware versions may not support all temperature registers. |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — board_temps.c (SSK 2.x)
/* nailib include files */
#include "nai_libs/nailib/include/naitypes.h"
#include "nai_libs/nailib/include/nailib.h"
#include "nai_libs/nailib/include/nailib_utils.h"
/* naibrd include files */
#include "nai_libs/naibrd/include/naibrd.h"
/* naiif include files */
#include "nai_libs/naiif/include/naiif_stdio.h"
/* Common Sample Program include files */
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_menu.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_query.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_access.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_display.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_utils.h"
static const int8_t* DEF_CONFIG_FILE = (const int8_t *)"default_BoardTemperatures.txt";
/* Private Function Prototypes */
static void getMotherboardTemperature(int32_t cardIndex);
static void naiapp_GetModuleTemperature(int32_t cardIndex, int32_t module);
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t BoardTemperatures(void)
#else
int32_t main(void)
#endif
{
int32_t cardIndex;
int32_t moduleCnt;
int32_t module;
bool_t stop = NAI_FALSE;
uint32_t moduleID;
int8_t txtModuleID[10];
int8_t inputBuffer[80];
int32_t inputResponseCnt;
int8_t boardName[NAI_MAX_BOARD_NAME_LEN];
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
{
while (stop != NAI_TRUE)
{
for (cardIndex = 0; cardIndex < naiapp_GetBoardCnt(); cardIndex++)
{
naiapp_GetBoardName(cardIndex, boardName);
naiif_printf("\r\n\r\nBoard #%d: Temperature Readings for %s:\r\n", cardIndex + 1, boardName);
naiif_printf("---------------------------------------------------------------------------\r\n");
getMotherboardTemperature(cardIndex);
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
for (module = 1; module <= moduleCnt; module++)
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if ((moduleID != 0))
{
naiapp_utils_ConvertModIdToAscii(moduleID, (char *)txtModuleID);
naiif_printf("\r\nModule #%d: Temperatures (in degrees Celsius) for %3s\r\n", module, txtModuleID);
naiapp_GetModuleTemperature(cardIndex, module);
}
}
}
naiif_printf("\r\nType Q to quit or Enter to read temperature:\r\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
}
naiif_printf("\r\nType the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
naiapp_access_CloseAllOpenCards();
return 0;
}
/********************/
/* Private Routines */
/********************/
static void getMotherboardTemperature(int32_t cardIndex)
{
float64_t temp = 0.0;
int8_t boardName[NAI_MAX_BOARD_NAME_LEN];
naiapp_GetBoardName(cardIndex, boardName);
naiif_printf("Motherboard Temperatures (in degrees Celsius)\r\n");
naiif_printf(" Real-Time Max Min\r\n");
naiif_printf("Zynq Core: ");
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_RT_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MAX_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MIN_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
naiif_printf("Zynq PCB: ");
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_RT_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MAX_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MIN_PCB, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
/* Check to see if the board has a Dual ARM Processor (64ARM1, 64G5, 68ARM1) */
if ((nailib_util_StringMatches((const char*)boardName, (const char *)NAI_DEV_NAME_64ARM1) == NAI_TRUE)
|| (nailib_util_StringMatches((const char*)boardName, (const char *)NAI_DEV_NAME_64G5) == NAI_TRUE)
|| (nailib_util_StringMatches((const char*)boardName, (const char *)NAI_DEV_NAME_68ARM1) == NAI_TRUE))
{
naiif_printf("Slave Zynq Core: ");
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_RT_SLAVE_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MAX_SLAVE_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MIN_SLAVE_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
naiif_printf("Slave Zynq PCB: ");
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_RT_SLAVE_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MAX_SLAVE_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetMotherboardTemperature(cardIndex, NAIBRD_MOTHERBOARD_TEMP_MIN_SLAVE_PCB, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
}
}
static void naiapp_GetModuleTemperature(int32_t cardIndex, int32_t module)
{
float64_t temp = 0.0;
naiif_printf(" Real-Time Max Min\r\n");
naiif_printf("Zynq Core: ");
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_RT_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_MAX_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_MIN_ZYNQ_CORE, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
naiif_printf("Zynq PCB: ");
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_RT_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_MAX_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_INTF_MIN_PCB, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
naiif_printf("Functional PCB: ");
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_FUNC_RT_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_FUNC_MAX_PCB, &temp));
naiif_printf(" %6.2f", temp);
check_status(naibrd_GetModuleTemperature(cardIndex, module, NAIBRD_MODULE_TEMP_FUNC_MIN_PCB, &temp));
naiif_printf(" %6.2f", temp);
naiif_printf("\r\n");
}