u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
301 stars 89 forks source link

Help needed with integrating ubxlib into ESP-IDF with VS Code #271

Open nasihnazer opened 3 weeks ago

nasihnazer commented 3 weeks ago

I'm working on a project where I need to integrate the ubxlib library with the ESP-IDF framework using VS Code. I'm encountering some challenges and would appreciate any guidance or advice.

Project Details:

Issues Faced

Steps Taken:

m-abubakar commented 2 weeks ago

Hi @nasihnazer,

I’m sorry to hear you’re experiencing these issues. While ubxlib has been updated to a slightly newer version (ESP-IDF 5.2.2), it may still be compatible with the older version of ESP-IDF that you're using.

Could you please share the specific errors you’re encountering? If possible, any output from the build process or details about your configuration would be helpful.

nasihnazer commented 2 weeks ago

Hi @m-abubakar, I want to use ubxlib for gnss but I'm not able to integrate it with esp-idf, when I'm integrating it using the steps mentioned in documentation, but when I'm building it in esp-idf shows that ubxlib is not take as component and can't be used. is there any step by step to integrate ubxlib in esp-idf to use gnss

m-abubakar commented 2 weeks ago

Sorry to see that you have followed the steps as you mentioned here and could not build successfully. Here I am just simplifying the steps for you.

set(EXTRA_COMPONENT_DIRS "path-to-ubxlib/port/platform/esp-idf/mcu/esp32/components")
                         "${CMAKE_CURRENT_LIST_DIR}/main")

set(COMPONENTS "driver" "esptool_py" "unity" "ubxlib" "main" "heap" ${GEODESIC_COMPONENT})

Now just need #include "ubxlib.h" in your main and you can use any ubxlib API in your application.

Let me know if you face any issues, Thank you.

nasihnazer commented 2 weeks ago

Thank you @m-abubakar i will try it and let you know if i face any issues, i have doubt should i clone this ubxlib to components of my project and give its path in CMakeLists.txt

nasihnazer commented 2 weeks ago

Hi @m-abubakar , i tried your steps, but I'm still not able to build the hello_world project log:-

Processing RUNNER build starts COMPONENTS for RUNNER build will be driver;esptool_py;unity;ubxlib;main;heap -- Found Git: C:/Users/Inthings/.espressif/tools/idf-git/2.39.2/cmd/git.exe (found version "2.39.2.windows.1") -- Component directory C:/Users/Inthings/gpstest3/components/ubxlib does not contain a CMakeLists.txt file. No component will be added -- The C compiler identification is GNU 8.4.0 -- The CXX compiler identification is GNU 8.4.0 -- The ASM compiler identification is GNU -- Found assembler: C:/Users/Inthings/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Users/Inthings/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Users/Inthings/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Project is not inside a git repository, or git repository has no commits; will not use 'git describe' to determine PROJECT_VER. -- Building ESP-IDF components for target esp32 -- Project sdkconfig file C:/Users/Inthings/gpstest3/sdkconfig -- Found Python3: C:/Users/Inthings/.espressif/python_env/idf4.4_py3.8_env/Scripts/python.exe (found version "3.8.7") found components: Interpreter -- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS -- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success -- App "gpstest3" version: 1 -- Adding linker script C:/Users/Inthings/gpstest3/build/esp-idf/esp_system/ld/memory.ld -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/esp_system/ld/esp32/sections.ld.in -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-time.ld -- Adding linker script C:/Users/Inthings/esp/v4.4.1/esp-idf/components/soc/esp32/ld/esp32.peripherals.ld Processing UBXLIB component starts COMPONENT_REQUIRES for component UBXLIB is driver;esp_timer;esp_system;esp_netif CMake Error at C:/Users/Inthings/esp/v4.4.1/esp-idf/tools/cmake/component.cmake:301 (message): Include directory 'C:/Users/Inthings/gpstest3/components/ubxlib/common/geofence/geographiclib/include' is not a directory. Call Stack (most recent call first): C:/Users/Inthings/esp/v4.4.1/esp-idf/tools/cmake/component.cmake:473 (__component_add_include_dirs) C:/Users/Inthings/esp/v4.4.1/esp-idf/tools/cmake/component.cmake:592 (idf_component_register) components/ubxlib/port/platform/esp-idf/mcu/esp32/components/ubxlib/CMakeLists.txt:99 (register_component)

-- Configuring incomplete, errors occurred! See also "C:/Users/Inthings/gpstest3/build/CMakeFiles/CMakeOutput.log".

m-abubakar commented 2 weeks ago

Hi @nasihnazer,

It looks like a few dependencies might be missing. I am curious to know if you have downloaded the sub modules too using git submodule update --init --recursive as described here. This could help resolve the issue.

P.S.: I understand that some parts of the documentation can be a bit challenging to follow. We're actively working on improving it to make everything clearer and more accessible.

nasihnazer commented 2 weeks ago

Hi @m-abubakar, I'm able to build it without any issues, now im trying to use the pos_main from gnss and this is the out I'm getting, should i change anything to use the example code

log:- I (0) cpu_start: App cpu up. I (248) cpu_start: Pro cpu start user code I (248) cpu_start: cpu freq: 160000000 I (248) cpu_start: Application information: I (252) cpu_start: Project name: gpstest3 I (257) cpu_start: App version: 1 I (262) cpu_start: Compile time: Aug 27 2024 16:57:37 I (268) cpu_start: ELF file SHA256: ea03885eda1ed229... I (274) cpu_start: ESP-IDF: v4.4.1 I (279) heap_init: Initializing. RAM available for dynamic allocation: I (286) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (292) heap_init: At 3FFB31A8 len 0002CE58 (179 KiB): DRAM I (298) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM I (304) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (311) heap_init: At 4008D9B8 len 00012648 (73 KiB): IRAM I (318) spi_flash: detected chip: generic I (322) spi_flash: flash io: dio I (327) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. U_GNSS: initialising with ENABLE_POWER pin not connected, transport type I2C. U_GNSS: sent command b5 62 0a 06 00 00 10 3a. U_GNSS: decoded UBX response 0x0a 0x06: 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [body 120 byte(s)]. U_GNSS: sent command b5 62 06 04 04 00 00 00 09 00 17 76. U_GNSS: sent command b5 62 0a 06 00 00 10 3a. U_GNSS: decoded UBX response 0x0a 0x06: 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [body 120 byte(s)]. Opened device with return code 0. Starting position stream. U_GNSS: sent command b5 62 06 8b 08 00 00 00 00 00 ff ff 21 00 b8 cc. U_GNSS: decoded UBX response 0x06 0x8b: 01 00 00 00 03 00 21 20 01 01 00 21 30 e8 03 02 00 21 30 01 00 [body 21 byte(s)]. U_GNSS: sent command b5 62 06 01 02 00 01 07 11 3a. U_GNSS: decoded UBX response 0x06 0x01: 01 07 00 00 00 00 00 00 [body 8 byte(s)]. U_GNSS: sent command b5 62 06 01 08 00 01 07 01 00 00 00 00 00 18 e2. U_GNSS: decoded UBX response 0x05 0x00: 06 01 [body 2 byte(s)]. Unable to start position stream! Done.