Usage of the custom OpenBLT on the Nucleo-F446RE board

Compiling BootCommander tool

BootCommander is a tool available in the OpenBLT project. It is recommended to build it on the host system where it will be used to flash the microcontroller. The process is documented in the OpenBLT wiki.
In my case, I compiled it on a Raspberry Pi running Raspbian, as well as on a PC with Ubuntu and Fedora. Follow the steps below to compile the tool. In this example, the process will be done on an Ubuntu PC.

  1. Go to Host path of the openblt project sources. You can copy it in another location such my own case. You need the OpenBLT Host library (LibOpenBLT) and sources of BootCommander.
  2. Next step is build the library from build path to do it, execute following commands:
    ~/Host/Source/LibOpenBLT/build$ cmake ..
    ~/Host/Source/LibOpenBLT/build$ make
  3. After do it repeate the process with BootCommander.
  4. The BootCommander tool is ready to be used Host path.

Tool usage

You can execute the command without arguments to see the help of the tool. Its usage is simple:

  • Usage: ./BootCommander [options] [firmware file]
  • The available options depend on the specified communication session protocol and communication transport layer. The Nucleo-F446RE supports xcp_rs232, xcp_can, and xcp_mbrtu.
    -s=[name]        Name of the communication session protocol:
                       xcp (default) -> XCP version 1.0.
    -t=[name]        Name of the communication transport layer:
                       xcp_rs232 (default) -> XCP on RS232.
                       xcp_mbrtu           -> XCP on Modbus RTU.
                       xcp_can             -> XCP on CAN.
                       xcp_usb             -> XCP on USB.
                       xcp_net             -> XCP on TCP/IP.
    
  • Each of the transport layer had options as baudrate, ID or stop bit depending of the interface.
    • XCP on RS232 settings (xcp_rs232):
         -d=[name]      Name of the communication device. For example COM1 or /dev/ttyUSB0 (Mandatory).   
         -b=[value]     The communication speed, a.k.a baudrate in bits per second, as a 32-bit value (Default = 57600).   
                        Supported values: 9600, 19200, 38400, 57600, 115200.
      
    • XCP on Modbus RTU settings (xcp_mbrtu):
      -d=[name]        Name of the communication device. For example COM1 or /dev/ttyUSB0 (Mandatory).  
      -b=[value]       The communication speed, a.k.a baudrate in bits per second, as a 32-bit value (Default = 57600).  
                       Supported values: 9600, 19200, 38400, 57600, 115200.   
      -pa=[value]      The UART parity bit configuration as a 8-bit value. (Default = 2). 
                       Supported values: 0 (none), 1 (odd), 2 (even).  
      -sb=[value]      The number of UART stopbits as a 8-bit value. (Default = 1). Supported values: 1, 2.   
      -da=[value]      Destination address, i.e. the node ID of the receiver, as a 8-bit value (Default = 1). 
                       Supported values: between 1 and 247.
      
  • XCP on CAN settings (xcp_can):
    -d=[name]        Name of the CAN device (Mandatory). On Linux this is
                     the name of the SocketCAN network interface, such as
                     can0, slcan0. On Windows it specifies the CAN adapter.
                     Currently supported CAN adapters:
                       peak_pcanusb     -> Peak System PCAN-USB.
                       kvaser_leaflight -> Kvaser Leaf Light V2.
                       lawicel_canusb   -> Lawicel CANUSB.
                       vector_xldriver  -> Vector XL Driver.
                       ixxat_vcidriver  -> Ixxat VCI Driver.
    -c=[value]       Zero based index of the CAN channel if multiple CAN
                     channels are supported for the CAN adapter, as a 32-
                     bit value (Default = 0).
    -b=[value]       The communication speed, a.k.a baudrate in bits per
                     second, as a 32-bit value (Default = 500000).
                     Supported values: 1000000, 800000, 500000, 250000,
                     125000, 100000, 50000, 20000, 10000.
    -tid=[value]     CAN identifier for transmitting XCP command messages
                     from the host to the target, as a 32-bit hexadecimal
                     value (Default = 667h).
    -rid=[value]     CAN identifier for receiving XCP response messages
                     from the target to the host, as a 32-bit hexadecimal
                     value (Default = 7E1h).
    -xid=[value]     Configures the 'tid' and 'rid' CAN identifier values
                     as 29-bit CAN identifiers, if this 8-bit value is > 0
                     (Default = 0).
    

Examples of use

In linux systems (using a rapberrypi or another distro) You can useBootCommander to flash the software.

  • Flash with MBRTU using USART2 with BootCommander using linux:
    ` sudo ./BootCommander -s=xcp -t=xcp_mbrtu -d=/dev/ttyACM0 -b=57600 ~/STM32CubeIDE/workspace_1.13.2/GPIO_IOToggle/STM32CubeIDE/Debug/GPIO_IOToggle.srec `
  • Flash with RS232 using a USB - TTL converter in linux:
    sudo ./BootCommander -s=xcp -t=xcp_rs232 -d=/dev/ttyUSB0 -b=57600 ~/STM32CubeIDE/workspace_1.13.2/GPIO_IOToggle/STM32CubeIDE/Debug/GPIO_IOToggle.srec
  • Fash with CAN using CANable in a linux system:
    1. Configure the Baudrate as blt_conf.h in the system.
      sudo ip link set can0 type can bitrate 125000
      sudo ip link set up can0
    2. Flash with BootCommander.
      sudo ./BootCommander -s=xcp -t=xcp_can -d=can0 -b=125000 ~/STM32CubeIDE/workspace_1.13.2/GPIO_IOToggle/STM32CubeIDE/Debug/GPIO_IOToggle.srec
    3. You can se the output to check if it was successful:
    4. To see how to connect the system physically, check the README file in the custom OpenBLT repository.

Conclusion

OpenBLT is a lightweight and useful bootloader that is easy to understand and customize. In this case, it has produced successful results, and I plan to use it in future projects.