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.

DCA1000EVM: Bus error (core dumped) using CLI Application to capture raw data on Linux

Part Number: DCA1000EVM
Other Parts Discussed in Thread: IWR6843ISK-ODS

Hi,

I try to capture the raw data from the DCA1000EVM by using the DCA1000EVM CLI application.

The precompiled version in mmwave_studio_02_01_01_00\mmWaveStudio\PostProc on Windows works fine for the Hardware I use. (IWR6843ISK-ODS)

I now want to use the Reference Code to capture the raw data by a Linux System. I use the Nvidia Xavier NX board with Ubuntu 18.04 installed.

If I compile and try to use the application I recieve the following output:

user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode$ make
Folder Release not exists
mkdir -p Release
g++ -g -std=c++11 -w -shared -o Release/libRF_API.so -fPIC -pthread RF_API/*.cpp Common/Validate_Utils/validate_params.cpp Common/Osal_Utils/osal_linux.cpp
g++ -g -static-libgcc -static-libstdc++ -std=c++11 -Wall -o Release/DCA1000EVM_CLI_Control CLI_Control/cli_control_main.cpp Common/Json_Utils/dist/jsoncpp.cpp Common/Validate_Utils/validate_params.cpp Common/Osal_Utils/osal_linux.cpp -I Common/DCA1000_API/. -I Common/Json_Utils/dist/json/. -I Common/. -I Common/Validate_Utils/. -I Common/Osal_Utils/. -L Release/. -lRF_API
CLI_Control/cli_control_main.cpp: In function ‘SINT32 ValidateJsonFileData(SINT8*, UINT16)’:
CLI_Control/cli_control_main.cpp:190:8: warning: ‘%s’ directive writing up to 254 bytes into a region of size 227 [-Wformat-overflow=]
SINT32 ValidateJsonFileData(SINT8 *configFile, UINT16 u16CmdCode)
^~~~~~~~~~~~~~~~~~~~
CLI_Control/cli_control_main.cpp:669:20: note: ‘sprintf’ output between 45 and 299 bytes into a destination of size 255

~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gsStartRecConfigMode.s8FileBasePath,CLI_JSON_REC_INVALID_FILE_BASE_PATH_ERR);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -g -static-libgcc -static-libstdc++ -std=c++11 -Wall -o Release/DCA1000EVM_CLI_Record CLI_Record/cli_record_main.cpp Common/Json_Utils/dist/jsoncpp.cpp Common/Validate_Utils/validate_params.cpp Common/Osal_Utils/osal_linux.cpp -pthread -I Common/DCA1000_API/. -I Common/Json_Utils/dist/json/. -I Common/. -I Common/Validate_Utils/. -I Common/Osal_Utils/. -L Release/. -lRF_API
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode$ cd Release/
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode/Release$ sudo chmod +x DCA1000EVM_CLI_Control
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode/Release$ sudo chmod +x DCA1000EVM_CLI_Record
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode/Release$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$pwd
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode/Release$ ./DCA1000EVM_CLI_Control fpga ../test_config.json

FPGA Configuration command : Success
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode/Release$ ./DCA1000EVM_CLI_Control record ../test_config.json

Configure Record command : Success
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode/Release$ ./DCA1000EVM_CLI_Control start_record ../test_config.json
# Option “-x” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.

Start Record command : Success
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode/Release$ ./DCA1000EVM_CLI_Control stop_record ../test_config.json

Stop Record command : Timeout Error! Couldnt read the record process status. [error -4068]
user@BJNX-1:~/Desktop/ReferenceCode/DCA1000/SourceCode/Release$ ./DCA1000EVM_CLI_Record start_record ../test_config.json

Start Record command : Success
Bus error (core dumped)


When I try to start a record with the Control application (and trigger the board from mmWave Studio) it creates an empty .bin and log file. A second terminal window opens for a fraction of a second.
The Control application does not report any errors.
If I try start_record with the Record application, it prints "Bus error (core dumped)"
I think the Control application does not show the error because it is displayed for fraction of a second in the Record terminal.

I followed the troubleshooting guide for this case and raised the packetDelay_us time. This didn´t change anything.

I tried to fix the warning by increasing the s8DebugMsg variable size in line 194 in cli_control_main.cpp. It fixed the warning but did not affect anything else.

This is the output if I try to debug with gdb:


(gdb) run start_record ../test_config.json
Starting program: /home/user/Desktop/ReferenceCode/DCA1000/SourceCode/Release/DCA1000EVM_CLI_Record start_record ../test_config.json
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fb7b541c0 (LWP 12807)]
[New Thread 0x7fb73531c0 (LWP 12808)]
[New Thread 0x7fac3161c0 (LWP 12809)]
[New Thread 0x7fabb151c0 (LWP 12810)]
Thread 4 "DCA1000EVM_CLI_" received signal SIGBUS, Bus error.
[Switching to Thread 0x7fac3161c0 (LWP 12809)]
__pthread_cond_wait_common (abstime=0x0, mutex=0x7fb7f903ec <objUdpDataRecv+1444>, cond=0x7fb7f903bc <objUdpDataRecv+1396>) at pthread_cond_wait.c:397
397 pthread_cond_wait.c: No such file or directory.


Could someone help me figure out where the problem is?


Thanks in advance

Hans-Peter

  • HI, there:

    There is some user guide and developer guide located at:

    C:\ti\mmwave_studio_02_01_01_00\mmWaveStudio\ReferenceCode\DCA1000\Docs

    Best,

    Zigang

  • Hi,

    thanks for the quick response. I'm aware of these guides but couldn't figure out a solution from there.

    In the mean time I was able to track the error further:

    The function call StartRecordData() is the step where the problem occurs. (Refer to DCA1000EVM CLI Software Developer Guide, page 14 figure 4 and cli_record_main.cpp)

    In this function several threads are created. The last one (Thread_WriteDatatoFile() of object objUpdDataRecv in rf_api.cpp) seems to trigger the problem.

    The first step in this thread is to call the WaitForSignal() function of the object osalObj. But I'm unable to track it any further from there. If I try to step into this function the error occurs immediately. 

    I still can't figure out how to fix this issue.

    Best regards

    Hans-Peter

  • Hello

    Can you please  try this on x86 based system.

    Wonder if Nvidia based platform is causing issue with binaries in the package.

    Thank you,

    Vaibhav

  • Hello,

    yes, I tried it on an x86 based system and it worked fine. There are no binaries included in the package.

    In the meantime, I was able to solve the problem myself. I will briefly explain what I did to get it running. Maybe it makes sense to include a similar fix in a future update.

    The SIGBUS Error is caused by an unaligned memory access in connection with pthread functions. I don't know exacly why the memory must be aligned for these function, because the arm64v8 in general supports unaligned memory access. Perhaps it is caused by deeper machine commands of this library.

    In several header files there is a statement: (for example rf_api.h)

    /** To avoid structure padding                                               */
    #pragma pack (1)

    Caused by this statement, there is no memory alignment to 64bit of the architecture. This indirectly triggers the problem but reduces the memory used and maybe some other higher purpose.

    No matter, if you want to keep these statements, it needs to be fixed at the two locations, where the error occurs:

    In osal.h the struct OSAL_SIGNAL_HANDLE_TYPE contains a pthread_cond_t(48B), pthread_mutex_t(48B) and a bool(1B) variable. In sum this struct takes 97Bytes. This need to be aligned to 104 Bytes, for example with this modification: alignas(8)

    /** Structure definition for event handle (Linux)       */
    typedef struct alignas(8)
    {
        /** Condition variable handle  */
        OSAL_CONDN_HANDLE_TYPE condnVar;
    
        /** Mutex variable handle      */
        OSAL_MUTEX_HANDLE_TYPE mutexVar;
    
        /** Signalled state flag       */
    
        bool bSignalled;
    }OSAL_SIGNAL_HANDLE_TYPE;

    In recorddatarecv.h is the class with a lot of variables. Two of them are the event structures of the previously changed struct. I assume the event structs are already aligned to 104B. So these structs start at an offset of 1299B and 1403B. The offset need to be aligned. The easiest way is to simply move the event structs to the beginning of the memory. By that they start at an offset of 0B and 104B:

    (Left - original   Right - modification)

    class cUdpDataReceiver
    
    {
    
    	/** Data type index										*/
    
        UINT8 u8DataTypeId;
    
    
    
        /** Record data file pointer                            */
    
        FILE *pRecordDataFile;
    
    
    
        /** Record data file path                               */
    
        SINT8 strRecordFilePath[MAX_NAME_LEN * 2];
    
    
    
        /** Record data file name                               */
    
        SINT8 strFileName1 [MAX_NAME_LEN * 3];
    
    
    
        /** Socket state                */
    
        bool bSocketState;
    
    
    
        /** Thread state                */
    
        bool bThreadState;
    
    
    
        /** First packet state          */
    
        bool bFirstPktSeqSet;
    
    
    
        /** File Data count             */
    
        UINT32 u32DataCount;
    
    
    
        /** File count                  */
    
        UINT32 u32DataFileCount;
    
    
    
    	/** File writing - Loop index	*/
    
        UINT32 u32ByteIndex;
    
    
    
        #ifndef POST_PROCESSING
    
    
    
        /** File write completion wait event                    */
    
        OSAL_SIGNAL_HANDLE_TYPE sgnFileWriteCompletionWaitEvent;
    
    
    
        /** File write init wait event                          */
    
        OSAL_SIGNAL_HANDLE_TYPE sgnFileWriteInitWaitEvent;
    
    
    
        /** Buffer 1 empty flag                                 */
    
        bool bBuf1Empty;
        
    ...
    class cUdpDataReceiver
    
    {   
    
        #ifndef POST_PROCESSING
    
    
    
        /** File write completion wait event                    */
    
        OSAL_SIGNAL_HANDLE_TYPE sgnFileWriteCompletionWaitEvent;
    
    
    
        /** File write init wait event                          */
    
        OSAL_SIGNAL_HANDLE_TYPE sgnFileWriteInitWaitEvent;
    
    
    
        #endif
    
    
    
    	/** Data type index										*/
    
        UINT8 u8DataTypeId;
    
    
    
        /** Record data file pointer                            */
    
        FILE *pRecordDataFile;
    
    
    
        /** Record data file path                               */
    
        SINT8 strRecordFilePath[MAX_NAME_LEN * 2];
    
    
    
        /** Record data file name                               */
    
        SINT8 strFileName1 [MAX_NAME_LEN * 3];
    
    
    
        /** Socket state                */
    
        bool bSocketState;
    
    
    
        /** Thread state                */
    
        bool bThreadState;
    
    
    
        /** First packet state          */
    
        bool bFirstPktSeqSet;
    
    
    
        /** File Data count             */
    
        UINT32 u32DataCount;
    
    
    
        /** File count                  */
    
        UINT32 u32DataFileCount;
    
    
    
    	/** File writing - Loop index	*/
    
        UINT32 u32ByteIndex;
    
    
    
        #ifndef POST_PROCESSING
    
    
    
        /** Buffer 1 empty flag                                 */
    
        bool bBuf1Empty;
        
    ...

    With these modifications it works for me.

    I hope with this post I save other people a lot of work to get the CLI tool running on arm64 based systems.

    Best regards

    Hans-Peter