micro-ROS / micro-ROS_sensors_demo

Provides a demo of micro-ROS based on ST Disco L475 IOT01 board.
Apache License 2.0
12 stars 3 forks source link

STIOT Board: Failed to enable USB #11

Closed ravi-nanjaiah closed 2 years ago

ravi-nanjaiah commented 2 years ago

Issue template

Steps to reproduce the issue

Install ROS2 foxy Install micro-ros-setup version foxy Insall Zephyr v2.6.0 Follow the steps of building and flashing the firmware in microRos-Sensor-Demo https://github.com/micro-ROS/micro-ROS_sensors_demo STIOT Board JP4 is set to 5V_ST_LINK. Board connected to PC and firmware flashing step executed STIOT board connected back with same settings of JP4

Expected behavior

STIOT board starts publishing the sensor topics

Actual behavior

STIOT board connected back with same settings of JP4 STIOT board does not publish sensor topics

STIOT board connected back with JP4 set to 5V_USB_FS and ST-LINK port connected STIOT board does not publish sensor topics

Additional information

Serial dump from STIOT Board observed on minicom:

Booting Zephyr OS build zephyr-v2.6.0
Failed to enable USB

pablogs9 commented 2 years ago

Hello @ravi-nanjaiah can you paste here the micro-ROS agent output using -v6 flag?

ravi-nanjaiah commented 2 years ago

@pablogs9 JP4 set to 5V_USB_FS Device id visible on connecting ST LINK usb port is /dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_066FFF575654888367181131-if02

Firmware is already flashed on the STIOT board. Agent started with following set of commands:

ros2 run micro_ros_setup create_agent_ws.sh

ros2 run micro_ros_setup build_agent.sh

source install/local_setup.bash

ls /dev/serial/by-id/*

ros2 run micro_ros_agent micro_ros_agent serial --dev $DEV

source /opt/ros/$ROS_DISTRO/setup.bash`

micro-ROS agent out is:

device: usb-STMicroelectronics_STM32_STLink_066FFF575654888367181131-if02, error 2, waiting for connection...

pablogs9 commented 2 years ago

What does $DEV define? It seems that it is just usb-STMicroelectronics_STM32_STLink_066FFF575654888367181131-if02 but it should be /dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_066FFF575654888367181131-if02

ravi-nanjaiah commented 2 years ago

Thanks @pablogs9 With /dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_066FFF575654888367181131-if02

output is

[1645613066.063224] info | TermiosAgentLinux.cpp | init | running... | fd: 3 [1645613066.063425] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 6

pablogs9 commented 2 years ago

You are using the ST-Link USB port but micro-ROS was configured to use USB-Serial.

Connect the other Micro-USB, change the power supply selector and modify the agent serial device accordingly.

ravi-nanjaiah commented 2 years ago

The other USB port on the STIOT board is the OTG USB port. I have tried this one with JP4 set to all options one by one. This port is not listed as serial. So 'ls /dev/serial/by-id/' and the output is 'ls: cannot access '/dev/serial/by-id/': No such file or directory'

Similarly I have tried connecting STIOT board to PC with ST-LINK USB port and JP4 set to all options one by one. This port gets listed with 'ls /dev/serial/by-id/*' command but with the device name I have shared in the earlier comment.

@pablogs9 is there additional jumper settings to be done to enable only serial-usb on the ST LINK port apart from JP4? The board I'm using is B-L475-IOT01A1.

pablogs9 commented 2 years ago

@ravi-nanjaiah tomorrow we will check the procedure with the board (I do not have it here right now) and we will provide some solutions. CC @Acuadros95

Acuadros95 commented 2 years ago

Just checked and its working fine in our end.

Just to clarify: You need to use the USB OTG usb port with jumper J4 on 5V_USB_FS, there is no need to connect the ST-LINK usb port. The serial identifier looks like this: /dev/serial/by-id/usb-ZEPHYR_Zephyr_micro-ROS_203035554E345008-if00

This may be related to Zephyr version, micro_ros_setup downloads and uses Zephyr v2.5.0, you dont need to install Zephyr manually. Do you actually need to use the v2.6.0 version?

ravi-nanjaiah commented 2 years ago

Thanks!

@Acuadros95 Docker is not working for me so I had to install the required components manually. I'll check if Zephyr can be downgraded to 2.5.0 and feedback. But what I understand from STM community page is the virtual com port (serial-usb) is on the ST-LINK USB port. To enable virtual com port, the board has to be powered through other options of JP4 (NOT 5V_ST_LINK). I'll feedback by EOD. Thanks again!

Acuadros95 commented 2 years ago

How are you using the micro_ros_setup module?

You don't need docker, micro_ros_setup wiill handle zephyr download in this step: ros2 run micro_ros_setup create_firmware_ws.sh zephyr discovery_l475_iot1

Try to uninstall your local zephyr installation and let the build system handle the dependencies.

ravi-nanjaiah commented 2 years ago

@Acuadros95, can you share the jumper setting for this board for flashing and also when board starts publishing? what is JP4 connected to and other jumpers JP5, 6, 7 and 8 are connected?

Acuadros95 commented 2 years ago

Flashing:

Running micro-ROS:

Other jumpers (Not changed between the two steps):

To a detail on the JP4 configurations, check secion 7.4 Power supply of the board docs: link

ravi-nanjaiah commented 2 years ago

I have these jumper settings and USB connections done correctly for flashing and also for running micro-ROS. Somehow I don't see the serial device with the ID mentioned in your comment. For the discovery board I have the com port is only visible on USB STLINK and the STLINK id is /dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_066FFF575654888367181131-if02. The board number I have is B-L475E-IOT01A1

Acuadros95 commented 2 years ago

How are you using the micro_ros_setup module? Also, did you uninstall Zephyr v2.6.0? micro_ros_setup handles zephyr install on its own, so your local installation could be messing with the board conf

ravi-nanjaiah commented 2 years ago

@Acuadros95 I'm not sure about your question on how are you using the micro_ros_setup ? I'm following the steps that are defined in the demo and tutorial page. I have deleted the Zephyr installations and run fresh steps of micro_ros_setup but after flashing I still see the Zephyr version output on minicom is still v2.6.0. I have flashed a blinking LED experiment first with STMIDE just to confirm the new build is flashed on the board. Also I referred the document from the link you shared. In chapter 7.8 there is a mention of mounting additional components to enable comm on USB_FS port. This could be also a reason (guessing) why the serial port on USB_FS is not visible. Is there an option in the configuration stage to switch from USB_FS to USB_STLINK on the board?

Acuadros95 commented 2 years ago

I am asking because the demo tutorial uses docker and you said you are not using docker. Also, I would like to have your exact steps so I can try to replicate and have a better understanding of the problem.

I'm not sure about your question on how are you using the micro_ros_setup? I'm following the steps that are defined in the demo and tutorial page.

ravi-nanjaiah commented 2 years ago

Docker failed to run in my PC. Hence I referred the instructions from the tutorial page and also referred the board specific instructions e.g. board name from the docker file.

I have implemented the following steps post installation of ros2. ROS2 working is checked with the demo nodes talker and publisher.

mkdir stmiot
cd stmiot

git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup

# Update dependencies using rosdep
sudo apt update && rosdep update
rosdep install --from-path src --ignore-src -y

# Install pip
sudo apt-get install python3-pip

# Build micro-ROS tools and source them
colcon build
source install/local_setup.bash

ros2 run micro_ros_setup create_firmware_ws.sh zephyr discovery_l475_iot1

ros2 run micro_ros_setup configure_firmware.sh sensors_publisher --transport serial-usb

ros2 run micro_ros_setup build_firmware.sh

ros2 run micro_ros_setup flash_firmware.sh

ros2 run micro_ros_setup create_agent_ws.sh

ros2 run micro_ros_setup build_agent.sh

source install/local_setup.bash

ls /dev/serial/by-id/*

ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/serial/by-id/usb-STMicroelectronics_STM32_STLink_066FFF575654888367181131-if02

The serial device ID visible for me is the STLINK device.

pablogs9 commented 2 years ago

Have you tried to use

ros2 run micro_ros_setup configure_firmware.sh sensors_publisher --transport serial

to change the transport to the STLink serial bridge?

Acuadros95 commented 2 years ago

I have checked and the docker uses a older version of micro_ros_setup, that is why I am getting zephyr v2.5.0 while you have v2.6.0, the tool-chains versions also change.

Will try to replicate this on Monday with your commands and latest micro_ros_setup version.

ravi-nanjaiah commented 2 years ago

@pablogs9 @Acuadros95 I compared the last changes done in the foxy branch of [micro_ros_setup](https://github.com/micro-ROS/micro_ros_setup/compare/foxy)

As you indicated could see the version update of Zephyr in link Referring these changes, I locally modified the create.sh to downgrade the zephyr and sdk version to predecessors. Build was fine with this change. On flashing this firmware with zephyr 2.5.0, now the comm port is available on USB_OTG port with the device ID as mentioned in the docker file.

On running the micro_ros_agent, output is

[1646052307.199936] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1646052307.200173] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4
[1646052308.251642] info     | Root.cpp           | create_client            | create                 | client_key: 0x490F5E74, session_id: 0x81
[1646052308.251793] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x490F5E74, address: 0
[1646052308.294836] info     | ProxyClient.cpp    | create_participant       | participant created    | client_key: 0x490F5E74, participant_id: 0x000(1)
[1646052308.297629] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x490F5E74, topic_id: 0x000(2), participant_id: 0x000(1)
[1646052308.303185] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x490F5E74, publisher_id: 0x000(3), participant_id: 0x000(1)
[1646052308.305913] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x490F5E74, datawriter_id: 0x000(5), publisher_id: 0x000(3)
[1646052308.311324] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x490F5E74, topic_id: 0x001(2), participant_id: 0x000(1)
[1646052308.317111] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x490F5E74, publisher_id: 0x001(3), participant_id: 0x000(1)
[1646052308.319050] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x490F5E74, datawriter_id: 0x001(5), publisher_id: 0x001(3)
[1646052308.325346] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x490F5E74, topic_id: 0x002(2), participant_id: 0x000(1)
[1646052308.330908] info     | ProxyClient.cpp    | create_subscriber        | subscriber created     | client_key: 0x490F5E74, subscriber_id: 0x000(4), participant_id: 0x000(1)
[1646052308.333133] info     | ProxyClient.cpp    | create_datareader        | datareader created     | client_key: 0x490F5E74, datareader_id: 0x000(6), subscriber_id: 0x000(4)
[1646052308.339434] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x490F5E74, topic_id: 0x003(2), participant_id: 0x000(1)
[1646052308.341050] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x490F5E74, publisher_id: 0x002(3), participant_id: 0x000(1)
[1646052308.343536] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x490F5E74, datawriter_id: 0x002(5), publisher_id: 0x002(3)
[1646052308.349624] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x490F5E74, topic_id: 0x004(2), participant_id: 0x000(1)
[1646052308.355124] info     | ProxyClient.cpp    | create_subscriber        | subscriber created     | client_key: 0x490F5E74, subscriber_id: 0x001(4), participant_id: 0x000(1)
[1646052308.357788] info     | ProxyClient.cpp    | create_datareader        | datareader created     | client_key: 0x490F5E74, datareader_id: 0x001(6), subscriber_id: 0x001(4)

In another terminal did ros2 topic echo /sensors/imu I could see the output of x,y and z axis. I guess the issue is solved now. Let me know if I have missed something here.

Another observation is starting the micro_ros_agent / accessing serial device required privileged access. So had to use sudo

pablogs9 commented 2 years ago

Ok, I'm closing, please reopen if you have any other problems.