Segmentation fault error about ethernet connect mode with jetson platform

Hi;

    on the jetson platform:

  1\  compile:   cmake -DJETSON=1 -DWITH_NETWORK=1 ..;    make -j4

2\ ./imshow_jetson can run ok

Then terminal the
imshow_jetson.


3\ Run the server app on jetson platform
   ./aditof-server


On the host PC:
1\ compile: cmake -DWITH_EXAMPLES=on -DWITH_NETWORK=1 -DCMAKE_PREFIX_PATH="/opt/glog;/opt/protobuf;/opt/websockets" ..; make -j4
2\ ./aditof-demo
3\ set to ethernet connect mode, and click connet,
0812 19:39:40.590950 4171 camera_96tof1.cpp:74] Initializing camera
I0812 19:39:40.878207 4171 calibration_96tof1.cpp:163] EEPROM calibration data size 64940 bytes
I0812 19:39:42.960017 4171 camera_96tof1.cpp:91] Camera initialized
I0812 19:39:42.969327 4171 camera_96tof1.cpp:122] Chosen mode: near
I0812 19:39:42.969396 4171 camera_96tof1.cpp:163] Camera range for mode: near is: 250 mm and 800 mm
I0812 19:39:42.969607 4171 camera_96tof1.cpp:173] Found firmware for mode: near
I0812 19:39:42.969658 4171 camera_96tof1.cpp:176] Firmware size: 10440 bytes
I0812 19:39:46.356808 4171 calibration_96tof1.cpp:376] Camera calibration parameters for mode: near are gain: 1 offset: 0
I0812 19:39:46.356873 4171 calibration_96tof1.cpp:388] Camera intrinsic parameters:
fx: 379.578
fy: 375.153
cx: 341.56
cy: 240.833

4\ when click play, the log print "Connection Closed"

I check the server status, the server log print "segmentation fault".......


mike











  • 0
    •  Analog Employees 
    on Aug 13, 2020 8:03 AM 3 months ago

    Hi Mike,

    Currently on Jetson Nano the aditof-demo is not running and returning segmentation fault.

    This happens because we populate only Depth or IR frames (jetson nano does not support virtual channels and only one frame type can be captured).

    A fix will be created to this problem to be able to start the demo but due to previously mentioned HW limitations only one data type will be available.

    Regards,

    Bogdan

  • Hi ;

    Thanks for your reply.

    1\ When will this fix be ready? Maybe you can tell the code to modify , I will modify it directly

    2\ IR data or depth data can be selected on the user interface

    mike

  • 0
    •  Analog Employees 
    on Aug 14, 2020 10:10 AM 3 months ago in reply to mike2000

    Hi Mike,

    First I would like to ask you to clone the latest adi-tof master branch. Using that you should not have segfaults any more but also no image.

    In order to fix it you have to change this line of code.

    camera->setFrameType(frameTypes.front());

    should be replaced with:

    camera->setFrameType("depth_only");

    If you want to fix it also for local context you have to edit also line

    Regards,

    Bogdan

  • Hi ;

       1\ i clone the latest adi-tof master branch   ,  on target and host.

       2\ on target, i must add the code int the  file    aditof_sdk-master/apps/CMakeLists.txt  for the "aditof-server"

          if (JETSON)
                if (WITH_NETWORK)
                     add_subdirectory(server)
               endif()
          endif()

        3\ on pc host,   Add the fix to aditof_sdk-master/examples/aditof-demo/aditofdemocontroller.cpp

        camera->setFrameType("depth_only");

        4\ recompile all, and run ./aditof-server  on target,  and run ./aditof-demo

       5\ connet ok 

          I0817 20:12:31.149413 3553 camera_96tof1.cpp:173] Found firmware for mode: near
    I0817 20:12:31.149431 3553 camera_96tof1.cpp:176] Firmware size: 10440 bytes
    I0817 20:12:34.482084 3553 calibration_96tof1.cpp:376] Camera calibration parameters for mode: near are gain: 1 offset: 0
    I0817 20:12:34.482154 3553 calibration_96tof1.cpp:388] Camera intrinsic parameters:
    fx: 379.578
    fy: 375.153
    cx: 341.56
    cy: 240.833

       6\ when i click the play button

       The target  print : segmentation fault 

        so  i believe  that  the bug is  not resolved.

    mike

       

  • upload the stack  when the SIGSEGV  is happened

    GetFrame function

    Program received signal SIGSEGV, Segmentation fault.
    __memcpy_generic () at ../sysdeps/aarch64/multiarch/../memcpy.S:188
    188 ../sysdeps/aarch64/multiarch/../memcpy.S: No such file or directory.
    (gdb) bt
    #0 __memcpy_generic () at ../sysdeps/aarch64/multiarch/../memcpy.S:188
    #1 0x0000007fb7b39ce8 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) () from /usr/lib/aarch64-linux-gnu/libstdc++.so.6
    #2 0x0000007fb7b3ab80 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) () from /usr/lib/aarch64-linux-gnu/libstdc++.so.6
    #3 0x0000005555578998 in payload::ServerResponse::add_bytes_payload (this=
    0x55555a6198 <buff_send>, value=0x7fb7411000, size=921600)
    at /home/sg/TOF/aditof_sdk-master/build/apps/server/buffer.pb.h:1569
    #4 0x0000005555577364 in invoke_sdk_api (buff_recv=...)
    at /home/sg/TOF/aditof_sdk-master/apps/server/server.cpp:432
    #5 0x0000005555576520 in Network::callback_function (wsi=0x55555bda20,
    reason=LWS_CALLBACK_RECEIVE, user=0x55555c4610, in=0x55555c5dd6, len=13)
    at /home/sg/TOF/aditof_sdk-master/apps/server/server.cpp:133
    #6 0x0000007fb7f5ce58 in user_callback_handle_rxflow ()
    from /home/sg/TOF/aditof_sdk-master/build/sdk/libaditof.so.1.0
    #7 0x0000007fb7f68b1c in lws_parse_ws ()
    from /home/sg/TOF/aditof_sdk-master/build/sdk/libaditof.so.1.0

    mike

  • 0
    •  Analog Employees 
    on Aug 31, 2020 12:54 PM 2 months ago in reply to mike2000

    Hi Mike,

    First of all I would like to apologize for very late response.

    Please find below two diffs between aditof_sdk master branch.

    If you apply them you should be able to get Depth or IR data succesfully.

    Host Diff:

    diff --git a/examples/aditof-demo/aditofdemocontroller.cpp b/examples/aditof-demo/aditofdemocontroller.cpp
    index 389b18d249b6..5b2498fd51bf 100644
    --- a/examples/aditof-demo/aditofdemocontroller.cpp
    +++ b/examples/aditof-demo/aditofdemocontroller.cpp
    @@ -123,7 +123,7 @@ bool AdiTofDemoController::setEthernetConnection(const std::string &ip) {
                 LOG(WARNING) << "no frame type available!";
                 return false;
             }
    -        camera->setFrameType(frameTypes.front());
    +        camera->setFrameType("depth_only");
     
             std::vector<std::string> modes;
             camera->getAvailableModes(modes);
    diff --git a/sdk/src/ethernet_device.cpp b/sdk/src/ethernet_device.cpp
    index e94e0e05a3d9..85422c6f03c8 100644
    --- a/sdk/src/ethernet_device.cpp
    +++ b/sdk/src/ethernet_device.cpp
    @@ -364,6 +364,7 @@ aditof::Status EthernetDevice::getFrame(uint16_t *buffer) {
     
         Network *net = m_implData->net;
         std::unique_lock<std::mutex> mutex_lock(m_implData->net_mutex);
    +    unsigned int width, height, offset;
     
         if (!net->isServer_Connected()) {
             LOG(WARNING) << "Not connected to server";
    @@ -399,10 +400,22 @@ aditof::Status EthernetDevice::getFrame(uint16_t *buffer) {
         // throughput (raw data chunck is smaller, deinterleaving is usually slower
         // on target).
     
    +#if 0
         aditof::deinterleave(net->recv_buff.bytes_payload(0).c_str(), buffer,
                              net->recv_buff.bytes_payload(0).length(),
                              m_implData->frameDetails_cache.width,
                              m_implData->frameDetails_cache.height);
    +#else
    +    width = m_implData->frameDetails_cache.width;
    +    height = m_implData->frameDetails_cache.height;
    +    if (m_implData->frameDetails_cache.type == "ir_only")
    +	    offset = (width * height) / 2;
    +    else
    +	    offset = 0;
    +
    +    memcpy(buffer + offset, net->recv_buff.bytes_payload(0).c_str(),
    +           net->recv_buff.bytes_payload(0).length());
    +#endif
     
         return status;
     }

    Jetson Diff:

    diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt
    index 02e0a62..f876ac9 100644
    --- a/apps/CMakeLists.txt
    +++ b/apps/CMakeLists.txt
    @@ -13,3 +13,9 @@ if (RASPBERRYPI)
                     add_subdirectory(server)
             endif()
     endif()
    +
    +if (JETSON)
    +	if (WITH_NETWORK)
    +		add_subdirectory(server)
    +	endif()
    +endif()
    diff --git a/apps/server/server.cpp b/apps/server/server.cpp
    index 5893124..b4057b9 100644
    --- a/apps/server/server.cpp
    +++ b/apps/server/server.cpp
    @@ -411,7 +411,21 @@ void invoke_sdk_api(payload::ClientRequest buff_recv) {
                 break;
             }
     
    -        buff_send.add_bytes_payload(buffer, buf_data_len * sizeof(uint8_t));
    +        auto isBufferPacked = [](const struct v4l2_buffer &buf, unsigned int width,
    +                                 unsigned int height) {
    +            unsigned int bytesused = 0;
    +            if (buf.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
    +                bytesused = buf.m.planes[0].bytesused;
    +            } else {
    +                bytesused = buf.bytesused;
    +            }
    +            return bytesused == (width * height * 3 / 2);
    +        };
    +
    +        if(!isBufferPacked(buf, frame_width, frame_height))
    +            buff_send.add_bytes_payload(buffer, buf.bytesused);
    +        else
    +            buff_send.add_bytes_payload(buffer, buf_data_len * sizeof(uint8_t));
     
             status = device->enqueueInternalBuffer(buf);
             if (status != aditof::Status::OK) {

    Regards,

    Bogdan  

  • Hi ;

         Thank you very much, the segment error  resolved.  

         And our PC app can show the depth data !     it's great!

    But there are other errors  on jetson platform  when the server is running,  Below is the print log:

    local_device.cpp:755] Temp sensor open error

    Error temperature sensor open: Inappropriate ioctl for device

    local_device.cpp:790] Temp sensor open error

    Error temperature sensor open: Inappropriate ioctl for device

    mike

  • 0
    •  Analog Employees 
    on Sep 1, 2020 6:40 AM 2 months ago in reply to mike2000

    Great to hear that Mike,

    Yes, you're right. It looks like the Nvidia I2C driver does not support "I2C_FUNCS" ioctl. We have the same problem on Xavier.

    Please just remove the call from temp_sensor.c

    diff --git a/sdk/src/connections/mipi/temp_sensor.c b/sdk/src/connections/mipi/temp_sensor.c
    index c5e8b43fc45a..50eb743d5c37 100644
    --- a/sdk/src/connections/mipi/temp_sensor.c
    +++ b/sdk/src/connections/mipi/temp_sensor.c
    @@ -92,13 +92,6 @@ int temp_sensor_open(const char *dev_fqn, int addr, temp_sensor *t) {
             return -1;
         }
     
    -    // get funcs list
    -    if ((r = ioctl(fd, I2C_FUNCS, &funcs)) < 0) {
    -        fprintf(stderr, "Error in temperature sensor open: %s\n",
    -                strerror(errno));
    -        return -1;
    -    }
    -
         // set working device
         if ((r = ioctl(fd, I2C_SLAVE, addr)) < 0) {
             fprintf(stderr, "Error temperature sensor open: %s\n", strerror(errno));

  • Hi  btogorean;

    Is the temperature data used in the current system to calibrate depth data? If the temperature data is not available, will it affect the accuracy of the depth data?

    mike