micro-ROS / micro_ros_zephyr_module

micro-ROS Zephyr module and sample code
Apache License 2.0
46 stars 22 forks source link

nRF52 support over Zephyr #60

Closed Manucar closed 2 years ago

Manucar commented 2 years ago

Hi, I was wondering if there are already on-going porting for the Nordic family (specifically nRF52840), and if not, are there some references I can look into to add hardware support for it?

Thank you for your time!

pablogs9 commented 2 years ago

You should be able to use this component as it is with your boards if it is supported by Zephyr.

Did you have any problem?

Manucar commented 2 years ago

Hi @pablogs9,

I first tried the following tutorial, but obviously my board is not in the supported ones, and so I cloned this repo, and executed the west build as follow:


(nrf) manucar@D311:~/Desktop/micro-ROS$ west build --board ubx_bmd360eval_nrf52811 micro_ros_zephyr_module
-- west build: generating a build system
Including boilerplate (Zephyr base (cached)): /home/manucar/Documents/NRF_SDK/ncs/zephyr/cmake/app/boilerplate.cmake
-- Application: /home/manucar/Desktop/micro-ROS/micro_ros_zephyr_module
-- Zephyr version: 2.7.99 (/home/manucar/Documents/NRF_SDK/ncs/zephyr), build: v2.7.99-ncs1-1
-- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
CMake Warning at /home/manucar/Documents/NRF_SDK/ncs/zephyr/cmake/app/boilerplate.cmake:241 (message):
  BOARD_ROOT element without a 'boards' subdirectory:

  /home/manucar/Desktop/micro-ROS

  Hints:

    - if your board directory is '/foo/bar/boards/<ARCH>/my_board' then add '/foo/bar' to BOARD_ROOT, not the entire board directory
    - if in doubt, use absolute paths
Call Stack (most recent call first):
  /home/manucar/Documents/NRF_SDK/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  /home/manucar/Documents/NRF_SDK/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
  CMakeLists.txt:7 (find_package)

-- Board: ubx_bmd360eval_nrf52811
-- Cache files will be written to: /home/manucar/.cache/zephyr
-- Found dtc: /usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (/home/manucar/gcc-arm-none-eabi-10.3-2021.10)
-- Found BOARD.dts: /home/manucar/Documents/NRF_SDK/ncs/zephyr/boards/arm/ubx_bmd360eval_nrf52811/ubx_bmd360eval_nrf52811.dts
-- Generated zephyr.dts: /home/manucar/Desktop/micro-ROS/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/manucar/Desktop/micro-ROS/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /home/manucar/Desktop/micro-ROS/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /home/manucar/Desktop/micro-ROS/build/zephyr/dts.cmake
Parsing /home/manucar/Documents/NRF_SDK/ncs/zephyr/Kconfig
Loaded configuration '/home/manucar/Documents/NRF_SDK/ncs/zephyr/boards/arm/ubx_bmd360eval_nrf52811/ubx_bmd360eval_nrf52811_defconfig'
Merged configuration '/home/manucar/Desktop/micro-ROS/micro_ros_zephyr_module/prj.conf'
Merged configuration '/home/manucar/Desktop/micro-ROS/build/zephyr/misc/generated/extra_kconfig_options.conf'

warning: NATIVE_POSIX_TIMER (defined at drivers/timer/Kconfig.native_posix:6) was assigned the value
'y' but got the value 'n'. Check these unsatisfied dependencies: BOARD_NATIVE_POSIX (=n). See
http://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_NATIVE_POSIX_TIMER.html and/or look up
NATIVE_POSIX_TIMER in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.

/home/manucar/Desktop/micro-ROS/micro_ros_zephyr_module/prj.conf:17: warning: attempt to assign the value 'y' to the undefined symbol USB

error: Aborting due to Kconfig warnings

CMake Error at /home/manucar/Documents/NRF_SDK/ncs/zephyr/cmake/kconfig.cmake:272 (message):
  command failed with return code: 1
Call Stack (most recent call first):
  /home/manucar/Documents/NRF_SDK/ncs/zephyr/cmake/app/boilerplate.cmake:544 (include)
  /home/manucar/Documents/NRF_SDK/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  /home/manucar/Documents/NRF_SDK/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
  CMakeLists.txt:7 (find_package)

-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/manucar/Desktop/micro-ROS/build -S/home/manucar/Desktop/micro-ROS/micro_ros_zephyr_module -GNinja

and it gives me the above errors. It's my first time with micro-ROS, any advice is really appreciated!

pablogs9 commented 2 years ago

I have tested the whole process with your board, here you have my session: https://asciinema.org/a/Vpcvaj7wgAqTRv8Y3Gbs8hoHp

The final error is that the board has not enough memory (this SoC has 24 kB? this will be challenging)... In any case, you can check this tutorial for tunning the micro-ROS memory usage.

Manucar commented 2 years ago

Ok definitely this SoC is not powerful enough, I will upgrade to the next version "ubx_bmd380eval_nrf52840". Following your video and compiling for this new board, it gives me no error! So when the board will arrive I think the flashing will be okay, I will let you know.

Thank you very much for your precious help!

pablogs9 commented 2 years ago

Nice, I'm closing. Feel free to open another issue if you have further problems.

Manucar commented 2 years ago

Hi @pablogs9, the board is arrived and I flashed the built image, but it remains stuck in this function (as far as I can see with gdb):

(gdb) c
Continuing.
^C
Program received signal SIGTRAP, Trace/breakpoint trap.
0x000018de in main () at ../src/main.c:54
54      RCCHECK(rclc_support_init_with_options(&support, 0, NULL, &init_options, &allocator));

and on the agent side:

(base) manucar@D311:~$ docker run -it --rm -v /dev:/dev --privileged --net=host microros/micro-ros-agent:humble serial --dev /dev/ttyACM1 -v6
[1654605220.329402] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1654605220.329568] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 6

I compiled the example on this repo with the same steps of your video (for the actual board: ubx_bmd380eval_nrf52840). Do you think anything I can try?

Thanks!

pablogs9 commented 2 years ago

Make sure that your board is reaching the PC via /dev/ttyACM1. Make sure that your serial ports are working ok before using it for micro-ROS client transport.

Manucar commented 2 years ago

Hi @pablogs9, okay after some debugging I find out that for some reason in this function for opening the transport layer:


bool zephyr_transport_open(struct uxrCustomTransport * transport){
    zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args;

    char uart_descriptor[8];
    sprintf(uart_descriptor,"UART_%d", params->fd);
    params->uart_dev = device_get_binding(uart_descriptor);
    if (!params->uart_dev) {
        printk("Serial device not found\n");
        return false;
    }
...

the params->fd field was set to 1, so it was opening the UART_1, changing it to 0 -> UART_0 make it works.