Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include TM2 firmware directly #3647

Merged
merged 31 commits into from
Apr 16, 2019

Conversation

radfordi
Copy link
Contributor

@radfordi radfordi commented Apr 1, 2019

This has a few nice features:

  • Downloads the firmware with SHA1 hash to avoid having to ever re-download
  • Downloads the firmware into a versioned file to avoid having to re-download
    when changing branches/versions
  • Avoids parsing the firmware
  • Avoids the process of creating huge headers with cmake (portable, but slow)
  • Avoids regenerating files on every cmake run
  • Greatly Speed up running cmake in the normal case
  • Simplifies the cmake code drastically
  • The fw/ directory should drop into any libtm replacement
  • Only writes into the build directory (not the source directory)

but it has a few drawbacks as well:

  • Less portable technique
  • We may need a few changes for Windows when switching between static and dynamic libraries
  • Doesn't support local firmware development as well as the old code
  • Currently missing a compile-time sanity check for the central app version

Most of the drawbacks can easily be fixed, except for the portability which should be outweighed by the other benefits. This is based on and should be included into #3507, but it might need a bit more testing and I don't want to hold #3507 up. CC @claudiofantacci.

@bfulkers-i bfulkers-i requested a review from dorodnic April 1, 2019 20:28
@bfulkers-i bfulkers-i added the T260 series Intel® T265 library label Apr 1, 2019
@radfordi radfordi force-pushed the libtm-fw-incbin branch 10 times, most recently from 8eb84bb to d610028 Compare April 2, 2019 05:35
@@ -11,12 +11,12 @@ set(INFRA_INCLUDE_DIR "${LIBTM_ROOT}/libtm/src/infra")
set(LIBTM_SRC_DIR "${LIBTM_ROOT}/libtm/src")
set(LIBTM_RESOURCES_DIR "${LIBTM_ROOT}/resources")

include(versions.cmake)
set(HOST_VERSION "0.19.3.1711")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this version maintained?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea if this version number is used outside this project, but it is used to extract LIBTM_VERSION_MAJOR, etc., so I kept it for now. I'd be happy to remove it.


set(USE_EXTERNAL_USB ON)
set(LIBUSB_LOCAL_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/third-party/libusb)
if (APPLE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't it be moved to apple_config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really part of the exported interface of libusb, so I think it should stay in a libusb specific place. Normally this would come from a target_* function if we were actually compiling libusb, an installed cmake file, or a pkg-config file, but since we are using an "external project" without installation, we need to do it ourselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I removed (cc40ab3) apple_config.cmake as it wasn't being used. :)

@dorodnic
Copy link
Contributor

dorodnic commented Apr 2, 2019

This worked well for me on Windows, except:
You have called ADD_LIBRARY for library fw without any source files. This typically indicates a problem with your CMakeLists.txt file warning. Any idea?
Another finding is that with the PR, when setting FORCE_WINUSB_UVC the build fails for some reason. This is driving the Win7 SDK, so this can be a problem.
In fw_target.h:16, (as well as fw_central and fw_central_app) changing ::GetModuleHandle to ::GetModuleHandleA solves the problem, and at least to me it makes sense since it is being called with non-unicode string.

@claudiofantacci
Copy link
Contributor

Hey thanks for calling me here! I was not able to have a look into it today and I have some other things tomorrow, but I will have a look asap, possibly within next Friday 👍🏻

@dorodnic dorodnic added the cmake label Apr 2, 2019
@radfordi radfordi force-pushed the libtm-fw-incbin branch 2 times, most recently from e172425 to 78e85d7 Compare April 2, 2019 15:49
@radfordi
Copy link
Contributor Author

radfordi commented Apr 2, 2019

Thanks for debugging that @dorodnic! I (force) pushed a fix to use A and to move one of the files to the add_library call itself (instead of doing so through target_source) to avoid the warning (which oddly I wasn't getting myself).

We have a CI build that uses Win7 and FORCE_WINUSB_UVC which passed. Was it failing for you locally?

@dorodnic
Copy link
Contributor

dorodnic commented Apr 2, 2019

Another thing I noticed is:

Configuring done
CMake Error: install(EXPORT "realsense2Targets" ...) includes target "realsense2" which requires target "usb" that is not in the export set.
CMake Error: install(EXPORT "realsense2Targets" ...) includes target "realsense2" which requires target "tm" that is not in the export set.
Generating done

When setting BUILD_SHARED_LIBS=false. Then, it builds successfully.

We have a CI build that uses Win7 and FORCE_WINUSB_UVC which passed. Was it failing for you locally?

Yes, basically I like to sanity check everything locally. Not sure why it failed only for me, but the fix seem to make sense.

@radfordi radfordi force-pushed the libtm-fw-incbin branch 6 times, most recently from b7d1118 to e94a2ed Compare April 2, 2019 23:59
@radfordi
Copy link
Contributor Author

radfordi commented Apr 3, 2019

@dorodnic, I updated both #3507 and #3647 with fixes to the issues you mentioned, except for the FORCE_WINUSB_UVC=True issue which I can't reproduce.

@claudiofantacci
Copy link
Contributor

Hi @radfordi, I tried to configure and compile this PR with ninja build, under Windows 10, with the standard options and unfortunately it does not work. I get the following error:

ninja: error: 'third-party/libtm/fw/fw.dir/fw.res', needed by 'realsense2.dll', missing and no known rule to make it

It instead works using Visual Studio 15 2017 toolchain (via CMake generator).

I'll try to have a look at the CMake code of this PR, and specifically for the libtm target, trying to help.

@radfordi radfordi force-pushed the libtm-fw-incbin branch 2 times, most recently from ad3850d to 13f3400 Compare April 5, 2019 21:52
@radfordi
Copy link
Contributor Author

radfordi commented Apr 5, 2019

Rebased on v2.20.0.

radfordi and others added 7 commits April 15, 2019 20:08
This has a few nice features:

      - Downloads the firmware with SHA1 hash to avoid having to ever re-download
      - Downloads the firmware into a versioned file to avoid having to re-download
         when changing branches/versions
      - Avoids parsing the firmware
      - Avoids the process of creating huge headers with cmake (portable, but **slow**)
      - Avoids regenerating files on every cmake run
      - Greatly Speed up running cmake in the normal case
      - Simplifies the cmake code drastically
      - The fw/ directory should drop into any `libtm` replacement
      - Only writes into the build directory (not the source directory)

but it has a few drawbacks as well:

      - Less portable technique
      - Doesn't support local firmware development as well as the old code
      - Currently missing a compile-time sanity check for the central app version

Most of the drawbacks can easily be fixed, except for the portability
which should be outweighed by the other benefits.
@matkatz
Copy link
Contributor

matkatz commented Apr 16, 2019

Android gradle solution built successfully.

@ev-mp ev-mp changed the base branch from master to development April 16, 2019 13:53
Copy link
Collaborator

@ev-mp ev-mp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radfordi , great contribution!
Really appreciated.

I redirected this PR to the development branch in order to avoid extra-merges
This makes the other 2507 PR redundant.

@ev-mp ev-mp merged commit ca5ce87 into IntelRealSense:development Apr 16, 2019
@radfordi radfordi deleted the libtm-fw-incbin branch April 16, 2019 16:34
@radfordi radfordi mentioned this pull request Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake T260 series Intel® T265 library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants