Skip to content

Commit

Permalink
driver: apdu: add MBIM backend (#166)
Browse files Browse the repository at this point in the history
Add an APDU backend for MBIM devices.

The MBIM device path can be passed via the MBIM_DEVICE environment
variable. We'll default to /dev/cdc-wdm0.

By default we will not operate through the mbim-proxy. Set
MBIM_USE_PROXY to 1 to enable this.

Like QMI devices, use UIM_PORT to select the active SIM slot.

Tested on Semtech EM9191 and EM7590, and Quectel RM520N-GL.

resolve #94

Signed-off-by: Frans Klaver <[email protected]>
Co-authored-by: Frans Klaver <[email protected]>
  • Loading branch information
fransklaver and Frans Klaver authored Nov 16, 2024
1 parent 63f29b4 commit 5987dfa
Show file tree
Hide file tree
Showing 7 changed files with 543 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/ENVVARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
- `stdio`: use standard input/output
- `qmi`: use QMI
- `qmi_qrtr`: use QMI over QRTR
- `mbim`: use MBIM
- GBinder-based backends for `libhybris` (Halium) distributions:
- `gbinder_hidl`: use HIDL IRadio (SoC launched before Android 13)
* `LPAC_HTTP`: specify which HTTP backend will be used.
- `curl`: use libcurl
- `stdio`: use standard input/ouput
* `AT_DEVICE`: specify which serial port device will be used by AT APDU backend.
* `QMI_DEVICE`: specify which QMI device will be used by QMI APDU backend.
* `UIM_SLOT`: specify which UIM slot will be used by QMI APDU backends. (default: 1)
* `UIM_SLOT`: specify which UIM slot will be used by QMI and MBIM APDU backends. (default: 1, slot number starts from 1)
* `DRIVER_IFID`: specify which PC/SC interface will be used by PC/SC APDU backend.
* `MBIM_DEVICE`: specify which MBIM device will be used by MBIM APDU backend. (default: "/dev/cdc-wdm0")
* `MBIM_USE_PROXY`: tell the MBIM APDU backend to use the mbim-proxy. (default: 0, anything other than 0 means true)

## Debug

Expand Down
14 changes: 14 additions & 0 deletions driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ endif()
option(LPAC_WITH_APDU_GBINDER "Build APDU Gbinder backend for libhybris devices (requires gbinder headers)" OFF)
option(LPAC_WITH_APDU_QMI "Build QMI backend for Qualcomm devices (requires libqmi)" OFF)
option(LPAC_WITH_APDU_QMI_QRTR "Build QMI-over-QRTR backend for Qualcomm devices (requires libqrtr and libqmi headers)" OFF)
option(LPAC_WITH_APDU_MBIM "Build MBIM backend for MBIM devices (requires libmbim)" OFF)

option(LPAC_WITH_HTTP_CURL "Build HTTP Curl interface" ON)

Expand Down Expand Up @@ -94,6 +95,19 @@ if(LPAC_WITH_APDU_QMI_QRTR)
endif()
endif()

if(LPAC_WITH_APDU_MBIM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_MBIM")
target_sources(euicc-drivers PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/apdu/mbim.c
${CMAKE_CURRENT_SOURCE_DIR}/apdu/mbim_helpers.c)
find_package(PkgConfig REQUIRED)
pkg_check_modules(MBIM_GLIB REQUIRED IMPORTED_TARGET mbim-glib)
target_link_libraries(euicc-drivers PkgConfig::MBIM_GLIB PkgConfig::MBIM_GLIB)
if(LPAC_DYNAMIC_DRIVERS)
list(APPEND LIBEUICC_DRIVERS_REQUIRES "mbim-glib")
endif()
endif()

if(LPAC_WITH_HTTP_CURL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_HTTP_CURL")
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/http/curl.c)
Expand Down
Loading

0 comments on commit 5987dfa

Please sign in to comment.