[Solved] Rosbot 2.0 : hConfig error and microcontroller can't be flashed

Hi,

I’m facing a strange issue on my Rosbot 2.0 (Asus Tinker board with latest ubuntu image, ros-2019-02-17) :

Leds state :
LR1 → constant ON
LR2 → constant ON
POWER LED → ON
For the other leds (LED1 to 3), they first blink in a strange way but then turn off.

Ubuntu boots normally, I can access to the desktop it with HDMI and RDP and ROS works as well.

Issues :

  • hConfig : I can connect to the rosbot with the HusarionConfigXXX WiFi but it’s not possible to setup the parameters (new Wifi config or connection to the cloud). It told me there is an error and the LR1 and 2 leds don’t blink, they are constant on. Therefore, I can’t add the Rosbot to the cloud.
    I followed the two other connection options (browser and directly on the Rosbot with Ubuntu) too but with no success.

    • with the browser way, it can connect to the rosbot WiFi but then it fails to add the rosbot on the cloud or husarnet.
    • On Ubuntu, when I execute the command sudo systemctl restart husarnet-configurator, the led LR2 turns off and directly turns on after. And no device has been added the cloud.
  • the command /opt/husarion/tools/rpi-linux/ros-core2-client /dev/ttyCORE2 fails (same problem as : https://community-mirror.husarion.com/t/trouble-bridging-core2-to-ros/452/3).

  • The microcontroller fell into hard fault state with the special leds pattern but it is impossible for me to flash a new program because I don’t have access to it with the cloud. So I tried with VSC but it doesn’t work, I get this error:
    core2_flash_error

Before the problem, I updated the firmware with the default one for ROSbot 2.0 on the cloud. I wanted to change the proximity sensors from VL53L0X to GP2Y0A41SK0F.

Thank you in advance for your support.

Best regards,
Antonio

Hello Antonio,

You should try with updating bootloader.

Regards,
Łukasz

Hi Łukasz

just a short question:
where can I see the version of the bootloader/firmware of Core2?

Michael

Hi Antonio,
Sorry to hear that you encountered a problem with your ROSbot. I will try to help you to debug it, but it will require a few steps. The upside is you’ll learn new tools that might be useful in the future so let’s start:

1. Disable husarnet-configurator and husarion-shield services and reboot your device. These processes are responsible for connection to the Husarion Cloud and they also control GPIO pins that are used for uploading the firmware. We will need the direct access to them. Log into your ROSbot and run:

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

LR1 and LR2 leds should stop blinking after reboot.

2. Install gpio_lib_python library if you have Asus Tinker Board (ROSbot 2.0) or python-periphery if you have Upboard (ROSbot 2.0 Pro). On your SBC run:

Asus Tinker board:

$ cd ~/ && git clone https://github.com/TinkerBoard/gpio_lib_python.git
$ cd ~/gpio_lib_python && sudo python setup.py install --record files.txt

Upboard:

$ cd ~/ && git clone https://github.com/vsergeev/python-periphery.git
$ cd ~/python-periphery && sudo python setup.py install --record files.txt

Restart terminal after installation.

3. To test if gpio_lib_python or python-periphery works and you in fact have access to GPIO pins, save the below python script as test-gpios:

Asus Tinker board:

#!/usr/bin/python
import RPi.GPIO as GPIO
import time

LR1_GPIO_PIN = 11

def blink_lr1():
    '''Blink LR1 led for 10s with interval of 1s'''
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(LR1_GPIO_PIN, GPIO.OUT)
    GPIO.setwarnings(False)
    time_start = time.time()
    while time.time() - time_start < 10.0:
        GPIO.output(LR1_GPIO_PIN, GPIO.HIGH)
        time.sleep(1)
        GPIO.output(LR1_GPIO_PIN, GPIO.LOW)
        time.sleep(1)
    GPIO.cleanup()


if __name__ == '__main__':
    blink_lr1()

Upboard:

#!/usr/bin/python
from periphery import GPIO
import time

LR1_GPIO_PIN = 17

def blink_lr1():
    '''Blink LR1 led for 10s with interval of 1s'''
    lr1_led = GPIO(LR1_GPIO, "out")
    time_start = time.time()
    while time.time() - time_start < 10.0:
        lr1_led.write(True)
        time.sleep(1)
        lr1_led.write(False)
        time.sleep(1)
    lr1_led.close()


if __name__ == '__main__':
    blink_lr1()

Save the script as test-gpios and run:

$ chmod a+x test-gpios
$ sudo ./test-gpios

You need to use sudo because the userspace GPIO driver is not implemented yet for Tinker and Upboard. The script should blink the LR1 led for approximately 10s with interval of 1s. If everything works you can proceed to next steps.

4. From your description it seems to be the software problem with CORE2 board, but we’ll need to confirm that it’s not some hardware malfunction instead. It looks like the RDP level somehow switched from 0 to 1 and CORE2 flash content is blocked from reading and modification. We will use stm32loader tool to unlock the rdp and flash some test firmware to check if board is fine. In your home folder run:

$ cd ~/ && git clone https://github.com/byq77/stm32loader.git
$ cd ~/stm32loader && sudo python setup.py install --record files.txt

First we will unlock the readout and the write protection for all sectors. It will also trigger mass erase of flash memory including the bootloader, but don’t worry, you can flash it latter. Run:

Asus Tinker board:

$ sudo stm32loader -c tinker -u -W

Upboard:

$ sudo stm32loader -c upboard -u -W

Wait until script finishes with messages “read unprotect done” and “write unprotect done”. It might take 20-30s.

5. To test if board is fine we’ll upload a test firmware. The firmware.bin file should be here, just copy it to your ROSbot and run:

Asus Tinker board:

$ sudo stm32loader -c tinker -e -w -v firmware.bin

Upboard:

$ sudo stm32loader -c upboard -e -w -v firmware.bin

You should see the progress bar. Wait until uploading and verification processes finish successfully. The L1, L2 and L3 leds should blink now.

If everything goes well, your CORE2 is resurrected!

6. Now you can flash the bootloader accordingly to the procedure described here or use stm32loader to do it like described below.

Copy HEX file to your SBC and run:

$arm-none-eabi-objcopy -I ihex -O binary bootloader_1_0_0_core2.hex bootloader_1_0_0_core2.bin

Asus Tinker board:

$ sudo stm32loader -c tinker -e -w -v bootloader_1_0_0_core2.bin

Upboard:

$ sudo stm32loader -c upboard -e -w -v bootloader_1_0_0_core2.bin

7. Enable husarnet-configurator and reboot the machine.

$ sudo systemctl enable husarnet-configurator
$ sudo reboot

Now you should be able to connect your ROSbot to the Cloud.

Edit: I updated this fix to accommodate the ROSbot 2.0 Pro case.

I followed the procedure step by step and now the ROSbot works again,

Thank you so much for your help