Getting Started with V2

From Open Mower Wiki
Jump to navigation Jump to search

This page gathers information on how to get started with the Open Mower v2 software. Although things are getting stable, expect some changes and issues at the moment. If you have any questions, reach out on Discord, we try to help.

Reflashing the Bootloader onto the STM32

If you got one of the very first x-core boards, you will need to re-flash the bootloader (there have been breaking changes in the protocol).


Requirements:

- CM4 on the core board

- DHCP server on the ethernet where the STM32 is connected (I recommend installing isc-dhcp-server. Its easy and works well for met)

- OpenOCD installed on the CM4 (see here for how to do it: https://core.x-tech.online/docs/tutorials/flashing-stm32-from-cm4/)

- Docker or Podman installed on the CM4. I am using podman here, you can replace `podman` for `docker` and it should work the same.

Step1: Get the latest firmware

SSH into your CM4 and execute the following commands:

mkdir ~/bootloader && cd ~/bootloader

wget https://github.com/xtech/fw-xcore-boot/releases/download/v1.1.3/xcore-boot-v1.1.3.zip

unzip xcore-boot-v1.1.3.zip


You should now have a folder `artifacts` in your working directory. It contains the bootloader binaries.


Step2: Flash the bootloader to your STM32

Run the following command to write the bootloader to your STM32.

openocd -f interface/xcore.cfg -f target/stm32h7x.cfg -c "program artifacts/bootloader/xcore-boot.elf verify reset exit"

When the command succeeded, the updated bootloader is stored in the STM32.

Step 3: Check, if it worked

Whenever the bootloader is running, the Heartbeat LED (heart icon on the PCB) should be flashing *BLUE*. Check, if this is the case.

If this is not the case, the STM32 is in user-program mode and not in the bootloader. In order to force the STM32 into the bootloader, you need to power cycle the STM32 (RESET button is not enough).

After power cycling, you should see the blue LED flashing. If not, ask on Discord - something has gone wrong.

Step 4: Use the bootloader host program to connect to the bootloader.

In this step we test that the host application can talk to the bootloader.

Run the following command to disable the developer mode on the bootloader:

podman run --rm -it --network=host ghcr.io/xtech/fw-xcore-boot --interface=eth0 set_dev_mode --disable


Information about the used flags:

  • --rm: removes the temporary container after uploading the firmware
  • -it: Allows terminal output to be instantly visible
  • --network=host: Allows the container to access the hosts' network directly
  • --interface=eth0: Forces the bootloader software to use eth0, change to whatever your ethernet interface name is
  • set_dev_mode --disable: Disables the bootloader's developer mode. Developer mode will just jump into the user space program without any verification. You won't need it when using the bootloader.


A successful run should look like this:

openmower@openmower:~/bootloader $ podman run --rm -it --network=host ghcr.io/xtech/fw-xcore-boot --interface=eth0 set_dev_mode --disable

Using interface eth0 with IP 172.16.78.1

Received advertisement from 172.16.78.150: BOARD_ADVERTISEMENT:xcore-boot;application-mode

Board in application mode, sending RESET to board

Timeout (1/25)

Received advertisement from 172.16.78.150: BOARD_ADVERTISEMENT:xcore-boot

Found board at 172.16.78.150

Connected to 172.16.78.150:8007

Variables received from board:

BOOTLOADER VERSION: xcore-boot v1.1

BOARD: xcore

HARDWARE VERSION: 1.1.7

CARRIER BOARD: hw-openmower-yardforce

CARRIER BOARD VERSION: 1.0.1

Sent SET_DEV_MODE to board

> Got command: SET_DEV_MODE

Received HASH OK

Sent new value to board

> Dev Mode: Disabled.

>Successfully updated EEPROM

Error reading line: Connection closed by remote host

Connection closed

Step 5: Upload a user firmware

We can now use the bootloader to upload a firmware to the STM32.

In this example we flash the OpenMower v2 firmware for a YardForce robot.

# Download the firmware you want to upload (.bin file)
# Get it here: https://github.com/xtech/fw-openmower-v2/actions
# Select the latest successful run, login and download the artifact

# Extract the zip:
unzip openmower.zip

# Upload the firmware
podman run --rm -it -v $(pwd):/workdir --network=host ghcr.io/xtech/fw-xcore-boot --interface=eth0 upload /workdir/openmower-yardforce.bin

A successful run should look like this:

openmower@openmower:~/firmware $ podman run --rm -it -v $(pwd):/workdir --network=host ghcr.io/xtech/fw-xcore-boot --interface=eth0 upload /workdir/openmower-yardforce.bin
Using interface eth0 with IP 172.16.78.1
Received advertisement from 172.16.78.150: BOARD_ADVERTISEMENT:xcore-boot;application-mode
Board in application mode, sending RESET to board
Timeout (1/25)
Received advertisement from 172.16.78.150: BOARD_ADVERTISEMENT:xcore-boot
Found board at 172.16.78.150
File SHA256: 92d8213153e4a757edaff8070c3c51b7de48da1383bb2c9ef1042c3469b89130
File Length: 191208
Connected to 172.16.78.150:8007
Variables received from board:
BOOTLOADER VERSION: xcore-boot v1.1
BOARD: xcore
HARDWARE VERSION: 1.1.7
CARRIER BOARD: hw-openmower-yardforce
CARRIER BOARD VERSION: 1.0.1
Sending UPLOAD command
> Got command: UPLOAD
Received SEND HASH
Sent SHA256 to board
Received HASH OK
Sent file length to board
>Image size: 191208
>Erasing 2 Flash Pages.
>Erasing Chip...
>Erasing Done
Uploading file...
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 191k/191k [00:01<00:00, 182kB/s]
File content sent
Connection closed