[Solved] Stm32loader issues for Mbed firmware with RasPi 3B

Hello,

I am using documentation ROSbot - quick start | Husarion for Mbed firmware installation.

I just got new CORE2-ROS board, attached RasPI 3B and installed ros-2019-02-17.img on it. Everything looks perfect on RasPI side and L2 LED is fast flashing on CORE2 board.
Then I followed section I. Mbed firmware (recommended) - stm32loader installation, using rosbot-2.0-fw-v0.9.0.bin in the /home/husarion directory. However, when I try to load Mbed firmware, I am having issues running stm32loader (for ROSbot 2.0 configuration):

husarion@husarion:~$ sudo stm32loader -c tinker -u -W
Traceback (most recent call last):
File “/usr/local/bin/stm32loader”, line 9, in
load_entry_point(‘stm32loader==0.5.0’, ‘console_scripts’, ‘stm32loader’)()
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 37, in main
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 379, in main
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 135, in connect
File “build/bdist.linux-armv7l/egg/stm32loader/uart_gpios.py”, line 58, in init
RuntimeError: This module can only be run on a ASUS Pi!

husarion@husarion:~$ sudo stm32loader -c tinker -e -w -v rosbot-2.0-***.bin
Traceback (most recent call last):
File “/usr/local/bin/stm32loader”, line 9, in
load_entry_point(‘stm32loader==0.5.0’, ‘console_scripts’, ‘stm32loader’)()
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 37, in main
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 379, in main
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 135, in connect
File “build/bdist.linux-armv7l/egg/stm32loader/uart_gpios.py”, line 58, in init
RuntimeError: This module can only be run on a ASUS Pi!

Is this runtime error because I am using RasPi and not ASUS Tinker board or something else? I even was trying to run sudo stm32loader -c rpi****** (replacing parameter “tinker” with “rpi” ) but got the same runtime error

I was reading and following suggestions in the post [Solved] Rosbot 2.0 : hConfig error and microcontroller can't be flashed - #4 by byq77 , but i got the same error even executing sudo ./test-gpios

husarion@husarion:~$ sudo ./test-gpios
Traceback (most recent call last):
File “./test-gpios”, line 2, in
import RPi.GPIO as GPIO
RuntimeError: This module can only be run on a ASUS Pi!

I would appreciate any thoughts on this!

Thank you very much,
Leo

Hi Leo,

Please look at this tutorial:

You will see that RPi 3B need different libraries for GPIO then Asus Tinker Board and UpBoard. As soon as you will install it everything should work perfectly fine.

Best regards,
Hubert

Hi Leo,
Check this note out: Raspberry Pi, Tinker Board, UpBoard - GPIOs. In section Rasperry Pi you should find info on how to install and configure RPi.GPIO module. Then when you use stm32loader command, replace -c tinker option with -c rpi.

Hi Hubert and byq77,
You guys are awesome! Thank you very much!

I installed RPi.GPIO libraries, added user husarion to gpio group, checked /dev/gpiomem permissions, tested gpio. Looks good now on GPIO side.
However… when I executed “sudo stm32loader -c rpi -u -W”, I’ve got different error:
“termios.error: (22, ‘Invalid argument’)”, please see below.

sudo stm32loader -c rpi -u -W
Traceback (most recent call last):
File “/usr/local/bin/stm32loader”, line 9, in
load_entry_point(‘stm32loader==0.5.0’, ‘console_scripts’, ‘stm32loader’)()
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 37, in main
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 379, in main
File “build/bdist.linux-armv7l/egg/stm32loader/main.py”, line 172, in connect
File “build/bdist.linux-armv7l/egg/stm32loader/uart_gpios.py”, line 91, in connect
File “/usr/lib/python2.7/dist-packages/serial/serialutil.py”, line 180, in init
self.open()
File “/usr/lib/python2.7/dist-packages/serial/serialposix.py”, line 298, in open
self._reconfigure_port(force_update=True)
File “/usr/lib/python2.7/dist-packages/serial/serialposix.py”, line 441, in _reconfigure_port
[iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
termios.error: (22, ‘Invalid argument’)

I am wondering, do I need to reconfigure serial communications (port, baud speed, etc)? Or execute stm32loader with port and baud speed options? If yes, which port name and baud rate should I use, or stm32loader command line with right options? I checked couple of Husarion links, but I got different options on that :slight_smile:

Many thanks,
Leo

Hello Hubert and Szymon,

In addition to my previous post, I was searching for available ports and found that /dev/serial1 is active

husarion@husarion:~$ ls -la /dev/ser*
lrwxrwxrwx 1 root root 5 Feb 11 2016 /dev/serial0 → ttyS0
lrwxrwxrwx 1 root root 7 Feb 11 2016 /dev/serial1 → ttyAMA0

So I was executing below commands and got “Can’t init into bootloader. Ensure that BOOT0 is enabled and reset the device.”:
husarion@husarion:~$ sudo stm32loader -c rpi -u -W -p /dev/serial1
Can’t init into bootloader. Ensure that BOOT0 is enabled and reset the device.

husarion@husarion:~$ sudo stm32loader -c rpi -e -w -p /dev/serial1 -v rosbot-2.0-fw-v0.9.0.bin
Can’t init into bootloader. Ensure that BOOT0 is enabled and reset the device.

Not sure how to fix that.

I still not sure what is baudrate currently configured for RasPI. I was trying default and 230400, did not work.

husarion@husarion:~$ sudo stm32loader -c rpi -e -w -p /dev/serial1 -b 230400 -v rosbot-2.0-fw-v0.9.0.bin
Can’t init into bootloader. Ensure that BOOT0 is enabled and reset the device.

I am looking for your help, I found similar issue in the Husarion community blog, but it was saying that this was resolved privately by Husarion team :slight_smile:

Just for clarifications on hardware setup. All communications with CORE2 done via attached RasPI GPIO not USB. Sensors and motors NOT connected to CORE2 yet. Just CORE2, RasPI 3B and 9v DC power supply connected to CORE2.

Thank you very much,
Leo

Hi,
Simlinks are incorrect (serial0 should point to ttyAMA0), so I suspect the problem with a Bluetooth module configuration. Check my note: Uploading firmware to CORE2 using SBC. Under “Inspect serial capability” you should find more detailed description of this problem as well as the solution.

We will inspect the system image for the problem. Until then, please use the fix above.

Let me know if you were able to resolve the issue.

Cheers

Thank you Szymon for valuable advice! It fixed the firmware update issue!

in /boot/config.txt I added the line

# it disables the bluetooth module
dtoverlay=pi3-disable-bt

and then I was able to update firmware to rosbot-2.0-fw-v0.9.0.bin

Its funny, however when few days ago I put command and comment in one line as document suggests
dtoverlay=pi3-disable-bt # it disables the bluetooth module
it did not work, the right way - put comment and command in separate lines (never paid attention to this :), I usually automatically put comments and command in separate lines):

# it disables the bluetooth module
dtoverlay=pi3-disable-bt

Thanks again!
Leo

Hello Szymon,

Sorry, another question related to CORE2 Mbed firmware serial communications. I think there is another conflict with /dev/ttyS1 serial communications related to RasPI and CORE2 when executing the rosbot_ekf package - roslaunch rosbot_ekf all.launch. I’ve got:

[ERROR] [1577507224.956769]: Error opening serial: [Errno 2] could not open port /dev/ttyS1: [Errno 2] No such file or directory: '/dev/ttyS1’

Should I tweak another configuration file such as rosbot_ekf/launch/all.launch or should I use command line parameters to specify /dev/serial0 and possible baudrate?

I executed below commands once a while ago before STM32 firmware upgrade and repeated today as well

sudo systemctl disable husarnet-configurator
sudo systemctl stop husarnet-configurator
sudo systemctl disable husarion-shield
sudo reboot

Below is the ouptut of roslaunch rosbot_ekf all.launch:

husarion@husarion:~/ros_workspace$ roslaunch rosbot_ekf all.launch

… logging to /home/husarion/.ros/log/5ffbc75e-2928-11ea-ae16-b827eb49be0d/roslaunch-husarion-2040.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://husarion:35137/

SUMMARY

CLEAR PARAMETERS

  • /rosbot_ekf/

PARAMETERS

  • /rosbot_ekf/acceleration_gains: [0.8, 0.0, 0.0, 0…
  • /rosbot_ekf/acceleration_limits: [1.3, 0.0, 0.0, 0…
  • /rosbot_ekf/base_link_frame: base_link
  • /rosbot_ekf/control_config: [True, False, Fal…
  • /rosbot_ekf/control_timeout: 0.2
  • /rosbot_ekf/debug: False
  • /rosbot_ekf/debug_out_file: /path/to/debug/fi…
  • /rosbot_ekf/deceleration_gains: [1.0, 0.0, 0.0, 0…
  • /rosbot_ekf/deceleration_limits: [1.3, 0.0, 0.0, 0…
  • /rosbot_ekf/frequency: 20
  • /rosbot_ekf/imu0: /imu
  • /rosbot_ekf/imu0_config: [False, False, Fa…
  • /rosbot_ekf/imu0_differential: True
  • /rosbot_ekf/imu0_linear_acceleration_rejection_threshold: 0.8
  • /rosbot_ekf/imu0_nodelay: False
  • /rosbot_ekf/imu0_pose_rejection_threshold: 0.8
  • /rosbot_ekf/imu0_queue_size: 4
  • /rosbot_ekf/imu0_relative: True
  • /rosbot_ekf/imu0_remove_gravitational_acceleration: True
  • /rosbot_ekf/imu0_twist_rejection_threshold: 0.8
  • /rosbot_ekf/initial_estimate_covariance: [‘1e-9’, 0, 0, 0,…
  • /rosbot_ekf/map_frame: map
  • /rosbot_ekf/odom0: /odom/wheel
  • /rosbot_ekf/odom0_config: [True, True, True…
  • /rosbot_ekf/odom0_differential: False
  • /rosbot_ekf/odom0_nodelay: False
  • /rosbot_ekf/odom0_queue_size: 6
  • /rosbot_ekf/odom0_relative: True
  • /rosbot_ekf/odom_frame: odom
  • /rosbot_ekf/print_diagnostics: True
  • /rosbot_ekf/process_noise_covariance: [0.05, 0, 0, 0, 0…
  • /rosbot_ekf/publish_acceleration: False
  • /rosbot_ekf/publish_tf: True
  • /rosbot_ekf/sensor_timeout: 0.2
  • /rosbot_ekf/stamped_control: False
  • /rosbot_ekf/transform_time_offset: 0.0
  • /rosbot_ekf/transform_timeout: 0.0
  • /rosbot_ekf/two_d_mode: False
  • /rosbot_ekf/use_control: True
  • /rosbot_ekf/world_frame: odom
  • /rosdistro: kinetic
  • /rosversion: 1.12.14
  • /serial_node/baud: 500000
  • /serial_node/port: /dev/ttyS1

NODES
/
imu_publisher (tf/static_transform_publisher)
msgs_conversion (rosbot_ekf/msgs_conversion)
rosbot_ekf (robot_localization/ekf_localization_node)
serial_node (rosserial_python/serial_node.py)

ROS_MASTER_URI=http://master:11311

process[serial_node-1]: started with pid [2059]
process[msgs_conversion-2]: started with pid [2060]
process[rosbot_ekf-3]: started with pid [2061]
process[imu_publisher-4]: started with pid [2067]
[INFO] [1577507224.926150]: ROS Serial Python Node
[INFO] [1577507224.949383]: Connecting to /dev/ttyS1 at 500000 baud
[ERROR] [1577507224.956769]: Error opening serial: [Errno 2] could not open port /dev/ttyS1: [Errno 2] No such file or directory: '/dev/ttyS1’
[serial_node-1] process has finished cleanly
log file: /home/husarion/.ros/log/5ffbc75e-2928-11ea-ae16-b827eb49be0d/serial_node-1*.log

As always thank you very much,
Leo

Hi,
To make it work, you will have to edit the rosbot_ekf/launch/rosserial_bridge.launch file and change the default value of serial_port argument to /dev/serial0. You probably noticed the serial_baudrate default value is set to 500000. This setting is overridden for pro version when you start all.launch with option rosbot_pro:=true.

If it comes to the firmware, we provide two binary files, one for ROSbot 2.0 and another for pro version. The only difference between them is the baudrate setting:

  • binary for ROSbot 2.0 - 500000
  • binary for ROSbot 2.0 pro - 460800

If you want to use different baudrate, you will need to build firmware from the source. I prepared the binary for 230400 baudrate so you don’t have to. You can check it here : https://files.husarion.com/rosbot-firmware/rosbot_fw_230400.bin. If you upload this firmware, remember to change the serial_baudrate value to 230400 in rosserial_bridge.launch.

In short make sure, that both launch file and the firmware have the same baudrate setting. I’m sure the 230400 setting should work fine for RPi3B. I’m not so confident about the remaining two.

I’m sorry it took so long to response. I was out of office from Christmas Day for more then two weeks. I hope you are able to solve this problem now. Let me know how it went.

Kind Regards

Happy New Year everyone!
First of all thank you very much for new firmware rosbot_fw_230400.bin It works and resolved issue with RPI communication on /dev/serial0 with baud rate 230400! Now it’s time for me to install hardware, MPU9250 and VLS53L0X sensors, RPLidar A1, 2 motors (for my project) and the whole thing should work! I will keep my fingers crossed :grinning:
I was playing with ~/ros_workspace/src/rosbot_ekf/launch/rosserial_bridge.launch prior to new firmware with your proposed RPI settings, but it only worked now when I replaced firmware with rosbot_fw_230400.bin since it has compiled RPI communication settings.

Your guys are awesome, you did great job and save my time on recompiling firmware this time!

Thanks again,
Leo