WB Modbus Devices Firmware Update/en: различия между версиями

Материал из Wiren Board
(Новая страница: «WB-MCU-Flasher»)
 
м (FuzzyBot переименовал страницу WB-MCU-Flasher/en в WB Modbus Devices Firmware Update/en без оставления перенаправления: Часть переводимой страницы WB-MCU-Flasher.)
 
(не показана 41 промежуточная версия 1 участника)
Строка 3: Строка 3:
{{DISPLAYTITLE:Загрузка прошивок на устройства Wiren Board}}
{{DISPLAYTITLE:Загрузка прошивок на устройства Wiren Board}}


== Загрузчик прошивок ==
== Firmware bootloader ==


В новых версиях наших устройств реализован механизм загрузчика прошивок (bootloader). Он позволяет обновлять микропрограммы устройств/модулей Wiren Board по RS-485/Modbus RTU.  
The new versions of our devices have a firmware bootloader. It allows you to update the firmware of our devices/Wiren Board modules via RS-485/Modbus RTU. The bootloader mode, in which it is possible to update the firmware, has been added to the devices.  
На устройства добавлен режим загрузчика, в котором возможно обновлять прошивку.  


В режиме загрузчика основной функционал устройства отключается. '''Коммуникационные параметры в режиме загрузчика фиксированы и не зависят от значений в памяти устройства: 9600 8N2.'''
In the bootloader mode, the main functionality of the device is disabled. '''Communication parameters in the bootloader mode are fixed and do not depend on the values in the device memory: 9600 8N2.'''




== Переход в режим загрузчика ==
== Entering bootloader mode ==


[[Special:MyLanguage/Файл:Bootloader.gif||right||Индикация режима загрузчика]]
[[File:Bootloader.gif||right||Bootloader mode indication]]
Устройство переходит в режим загрузчика, если:  
The device enters bootloader mode if:  
* на устройстве имеется корректная прошивка первые 2 секунды после включения питания устройство работает в режиме загрузчика;
* the device has the correct firmware the first 2 seconds after power on, the device operates in bootloader mode;
* на устройстве нет корректной прошивки (например, был сбой при обновлении прошивки) — в этом случае режим загрузчика активен постоянно;
* the device does not have the correct firmware (for example, there was a failure when updating the firmware) — in this case, the bootloader mode is constantly active;
* при работе основной программы в holding-регистр 129 (0x81) была записана 1 — в этом случае устройство перезагружается и остается в режиме загрузчика 120 секунд.
* when the main program in the holding-register 129 (0x81) was recorded 1 — in this case, the device is rebooted and remains in bootloader mode for 120 seconds.


Индикация режима загрузчика: индикатор Status устройства редко мигает. При заливке новой прошивки индикатор перестает менять состояние.
Bootloader mode indication: the device Status indicator rarely flashes. When you download a new firmware, indicator stops changing state.




== Прошивки ==
== Firmware ==


Запись прошивки в память устройства выполняется загрузчиком, который получает ее по Modbus RTU. Прошивки хранятся в файлах с расширением '''.wbfw'''.
Writing firmware in the memory device is performed by a loader that gets its Modbus RTU. Firmware is stored in files with extension '''.wbfw'''. Currently available firmwares are available on request.
В настоящее время имеющиеся прошивки высылаются по запросу.




== Сигнатуры устройств ==
== Device signatures ==


   
   


При прошивке на заводе в память устройства записывается сигнатура наименование аппаратного типа устройства. При перезаписи прошивки текущая сигнатура сравнивается с сигнатурой прошивки. Запись новой прошивки возможна только при совпадении сигнатур.
When flashing at the factory, the signature the name of the hardware type of the device — is recorded into the memory of the device. When overwriting the firmware, the current signature is compared with the firmware signature. Writing new firmware is possible only if the signatures match.




Строка 39: Строка 37:
   
   


Загрузчик устройства получает прошивку по Modbus RTU. В режиме загрузчика коммуникационные параметры фиксированы и не зависят от значений, записанных ранее в память устройства: 9600 8N2. По протоколу Modbus устройство можно перевести в режим загрузчика, если во время работы основной программы записать 1 в holding-регистр 129 (0x81). В этом случае устройство перезагружается и остается в режиме загрузчика 120 секунд.
The device loader receives firmware via Modbus RTU. In the bootloader mode, the communication parameters are fixed and do not depend on the previous values in the device memory: 9600 8N2. According to the Modbus protocol, the device can be set to bootloader mode, if 1 is written to the holding register 129 (0x81) during the operation of the main program. In this scenario, the device restarts and remains in bootloader mode for 120 seconds.


Modbus-адрес устройства для прошивки в режиме загрузчика следует выбирать следующим образом:
The Modbus address of the bootloader firmware device should be selected as follows:


# Основной адрес для прошивки — адрес, заданный в памяти устройства: то есть это стандартный адрес, на который устройство отвечает из основной программы.
# The main address for the firmware is the address specified in the device memory: that is, it is the standard address to which the device responds from the main program.
# Прошивать устройства можно по широковещательному адресу 0. Это менее предпочтительный способ.
# To flash a device using a broadcast address of 0. This is a less preferred method.




== Утилита для прошивки wb-mcu-fw-flasher ==
== Utility for WB-mcu-fw-flasher firmware ==


Для передачи прошивки на устройства используется утилита wb-mcu-fw-flasher, запускаемая с контроллера Wiren Board (или компьютера с Linux или Windows).  
To transfer firmware to the devices, use the wb-mcu-fw-flasher utility launched from the Wiren Board controller (or a computer with Linux or Windows).  


Для установки утилиты '''на контроллер Wiren Board''' выполните команды:
To install the utility '''on the Wiren Board controller''', run the following commands:
<pre>
<pre>
apt-get update
apt-get update
Строка 57: Строка 55:
</pre>
</pre>


Версию утилиты для '''MS Windows''' можно скачать по этой ссылке: [[Special:MyLanguage/Media: Wb-mcu-fw-flasher_1.0.2.zip | Wb-mcu-fw-flasher_1.0.2.zip]]
Software for '''MS Windows''' can be downloaded here: [[Media: Wb-mcu-fw-flasher_1.0.2.zip | Wb-mcu-fw-flasher_1.0.2.zip]].


Для установки на '''компьютер с Debian''' скачайте пакет отсюда: [[Special:MyLanguage/Media: Wb-mcu-fw-flasher_1.0.2_amd64-all.deb | Wb-mcu-fw-flasher_1.0.2_amd64-all.deb]]
To install on a '''Debian computer''', download the package from here: [[Media: Wb-mcu-fw-flasher_1.0.2_amd64-all.deb | Wb-mcu-fw-flasher_1.0.2_amd64-all.deb]]
и выполните команды в директории, гуда загрузился пакет пакет.
and execute commands in the directory where the package was downloaded.
<pre>
<pre>
apt-get update
apt-get update
Строка 69: Строка 67:




Опции запуска утилиты wb-mcu-fw-flasher:
wb-mcu-fw-flasher utility starting options:
{| class="wikitable"
{| class="wikitable"
! Параметр !! Описание !! Значение по умолчанию
! Option !! Description !! Value by default
|-
|-
| -d || Устройство последовательного порта ||  
| -d || serial port device ||  
|-
|-
| -f || Файл прошивки ||  
| -f || firmware file ||  
|-
|-
| -a || Адрес Modbus || 1
| -a || Modbus address || 1
|-
|-
| -j || Отправить на устройство команду перехода в режим загрузчика ||  
| -j || Send a command to the device to enter bootloader mode ||  
|-
|-
| -r || Адрес holding-регистра для перехода в режим загрузчика || 129
| -r || Address of the holding register to enter bootloader mode || 129
|-
|-
| -D || Включить режим отладки ||  
| -D || Enable debug mode ||  
|}
|}


Строка 91: Строка 89:
</pre>
</pre>


Пример для Windows:
The example for Windows:
<pre>
<pre>
wb-mcu-fw-flasher.exe -j -d COM10 -a 25 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw
wb-mcu-fw-flasher.exe -j -d COM10 -a 25 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw
</pre>
</pre>


Здесь COM10 — имя виртуального последовательного порта, которое присвоено адаптеру USB RS-485.
COM10 is the name of the virtual serial port that is assigned to the USB RS-485 adapter.




== Прошивка устройств ==
== Device flashing ==


'''При прошивке с контроллера остановите wb-mqtt-serial:'''
'''When flashing from the controller, stop wb-mqtt-serial:'''
<pre>
<pre>
service wb-mqtt-serial stop
service wb-mqtt-serial stop
</pre>
</pre>


Подключите устройство к RS-485.
Connect the device to RS-485.


Если вы не знаете точного аппаратного типа устройства, то его сигнатуру можно прочесть командой:
If you do not know the exact hardware type of the device, you can read its signature with the command:
<pre>
<pre>
export mbusaddr=1;  echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a$mbusaddr -t0x03 -r290 -c 12 | grep Data | sed -e 's/0x00/\x/g' -e 's/Data://' -e 's/s//g'`|  xxd -r -p && echo ''
export mbusaddr=1;  echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a$mbusaddr -t0x03 -r290 -c 12 | grep Data | sed -e 's/0x00/\x/g' -e 's/Data://' -e 's/s//g'`|  xxd -r -p && echo ''
</pre>     
</pre>     
Задайте адрес прошиваемого устройства в переменной mbusaddr.
Specify the address of the flash device in a  mbusaddr variable.


В выводе команды вы получите сигнатуру устройства, например, '''wbmr6c'''.
In the output of the command, you will get the device signature, for example, '''wbmr6c'''.


Выберите подходящую прошивку, например, WB-MR-MR6C_MCU3_3_1.9.4.wbfw.
Select the appropriate firmware, for example, WB-MR-MR6C_MCU3_3_1.9.4.wbfw.


Прошейте устройство командой:
Flash the device with the command:
<pre>
<pre>
wb-mcu-fw-flasher -j -d /dev/ttyRS485-1 -a 25 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw
wb-mcu-fw-flasher -j -d /dev/ttyRS485-1 -a 25 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw
</pre>
</pre>
Успешный процесс прошивки выглядит следующим образом:
The successful firmware process is as follows:
<pre>
<pre>
   wb-mcu-fw-flasher -j -d /dev/ttyRS485-1 -a 1 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw           
   wb-mcu-fw-flasher -j -d /dev/ttyRS485-1 -a 1 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw           
Строка 135: Строка 133:
</pre>
</pre>


'''После успешной прошивки устройство само выйдет из режима загрузчика и перезапустится в основной программе.'''
'''After successful flashing, the device will exit the bootloader mode itself and restart in the main program.'''


Пример ошибки при несовпадении сигнатуры:
The example of a signature mismatch error:
<pre>
<pre>
Sending info block...
Sending info block...
Строка 145: Строка 143:




=== Прошивка устройств по широковещательному Modbus-адресу 0 ===
=== Firmware devices on the Modbus broadcast address 0 ===


Bootloader позволяет загружать прошивку на устройства но Modbus-адресу 0. Для этого устройство должно быть единственным устройством на шине и находится в режиме загрузчика.
Bootloader allows you to download firmware to devices via Modbus address 0. To do this, the device must be the only device on the bus and must be in bootloader mode.




=== Прошивка нескольких устройств на шине ===
=== Flashing several devices on the bus ===


Возможна прошивка нескольких устройств, подключенных к шине. Устройства должны быть переведены в режим загрузчика и прошиваться по отдельности с указанием нешироковещательного Modbus-адреса. Прошивка устройств с одинаковым адресом возможна, если в режиме загрузчика находится только одно из них. Устройства прошиваются по очереди.
It is possible to flash several devices connected to the bus. The devices must be set to bootloader mode and flashed separately with a non-broadcast Modbus address. Flashing devices with the same address is possible if only one of them is in the bootloader mode. The devices shall be flashed at a time.


'''Внимание!''' Прошивка устройств, находящимся в режиме загрузчика и имеющим одинаковый modbus-адрес, или же прошивка нескольких устройств, находящихся в режиме загрузчика по адресу 0 не будет выполнена; имеющаяся прошивка на устройствах будет испорчена.
'''Attention!''' The flashing of the devices in bootloader mode and of the same modbus address, or the flashing of multiple devices being in the bootloader mode at address 0 will not be performed; the existing firmware of the device will be ruined.

Текущая версия на 23:38, 28 мая 2020

Другие языки:

Внимание: Отображаемое название «Загрузка прошивок на устройства Wiren Board» переопределяет ранее заданное отображаемое название «WB-MCU-Flasher».

Firmware bootloader

The new versions of our devices have a firmware bootloader. It allows you to update the firmware of our devices/Wiren Board modules via RS-485/Modbus RTU. The bootloader mode, in which it is possible to update the firmware, has been added to the devices.

In the bootloader mode, the main functionality of the device is disabled. Communication parameters in the bootloader mode are fixed and do not depend on the values in the device memory: 9600 8N2.


Entering bootloader mode

Bootloader mode indication

The device enters bootloader mode if:

  • the device has the correct firmware — the first 2 seconds after power on, the device operates in bootloader mode;
  • the device does not have the correct firmware (for example, there was a failure when updating the firmware) — in this case, the bootloader mode is constantly active;
  • when the main program in the holding-register 129 (0x81) was recorded 1 — in this case, the device is rebooted and remains in bootloader mode for 120 seconds.

Bootloader mode indication: the device Status indicator rarely flashes. When you download a new firmware, indicator stops changing state.


Firmware

Writing firmware in the memory device is performed by a loader that gets its Modbus RTU. Firmware is stored in files with extension .wbfw. Currently available firmwares are available on request.


Device signatures

When flashing at the factory, the signature — the name of the hardware type of the device — is recorded into the memory of the device. When overwriting the firmware, the current signature is compared with the firmware signature. Writing new firmware is possible only if the signatures match.


Modbus

The device loader receives firmware via Modbus RTU. In the bootloader mode, the communication parameters are fixed and do not depend on the previous values in the device memory: 9600 8N2. According to the Modbus protocol, the device can be set to bootloader mode, if 1 is written to the holding register 129 (0x81) during the operation of the main program. In this scenario, the device restarts and remains in bootloader mode for 120 seconds.

The Modbus address of the bootloader firmware device should be selected as follows:

  1. The main address for the firmware is the address specified in the device memory: that is, it is the standard address to which the device responds from the main program.
  2. To flash a device using a broadcast address of 0. This is a less preferred method.


Utility for WB-mcu-fw-flasher firmware

To transfer firmware to the devices, use the wb-mcu-fw-flasher utility launched from the Wiren Board controller (or a computer with Linux or Windows).

To install the utility on the Wiren Board controller, run the following commands:

apt-get update
apt-get install wb-mcu-fw-flasher

Software for MS Windows can be downloaded here: Wb-mcu-fw-flasher_1.0.2.zip.

To install on a Debian computer, download the package from here: Wb-mcu-fw-flasher_1.0.2_amd64-all.deb and execute commands in the directory where the package was downloaded.

apt-get update
apt-get install libmodbus5
dpkg -i Wb-mcu-fw-flasher_1.0.2_amd64-all.deb


wb-mcu-fw-flasher utility starting options:

Option Description Value by default
-d serial port device
-f firmware file
-a Modbus address 1
-j Send a command to the device to enter bootloader mode
-r Address of the holding register to enter bootloader mode 129
-D Enable debug mode

Пример:

wb-mcu-fw-flasher -j -d /dev/ttyRS485-1 -a 25 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw

The example for Windows:

wb-mcu-fw-flasher.exe -j -d COM10 -a 25 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw

COM10 is the name of the virtual serial port that is assigned to the USB RS-485 adapter.


Device flashing

When flashing from the controller, stop wb-mqtt-serial:

service wb-mqtt-serial stop

Connect the device to RS-485.

If you do not know the exact hardware type of the device, you can read its signature with the command:

export mbusaddr=1;  echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a$mbusaddr -t0x03 -r290 -c 12 | grep Data | sed -e 's/0x00/\x/g' -e 's/Data://' -e 's/s//g'`|  xxd -r -p && echo ''

Specify the address of the flash device in a mbusaddr variable.

In the output of the command, you will get the device signature, for example, wbmr6c.

Select the appropriate firmware, for example, WB-MR-MR6C_MCU3_3_1.9.4.wbfw.

Flash the device with the command:

wb-mcu-fw-flasher -j -d /dev/ttyRS485-1 -a 25 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw

The successful firmware process is as follows:

   wb-mcu-fw-flasher -j -d /dev/ttyRS485-1 -a 1 -f WB-MR-MR6C_MCU3_3_1.9.4.wbfw          
   /dev/ttyRS485-1 opened successfully.
   Send jump to bootloader command and wait 2 seconds...
   Error: Connection timed out.
   May be device already in bootloader, try to send firmware...
   WB-MR-MR6C_MCU3_3_1.9.4.wbfw opened successfully, size 12136 bytes
   Sending info block... OK
   Sending data block 89 of 89... OK.
   All done!

After successful flashing, the device will exit the bootloader mode itself and restart in the main program.

The example of a signature mismatch error:

Sending info block...
Error while sending info block: Slave device or server failure 
Data format is invalid or firmware signature doesn't match the device


Firmware devices on the Modbus broadcast address 0

Bootloader allows you to download firmware to devices via Modbus address 0. To do this, the device must be the only device on the bus and must be in bootloader mode.


Flashing several devices on the bus

It is possible to flash several devices connected to the bus. The devices must be set to bootloader mode and flashed separately with a non-broadcast Modbus address. Flashing devices with the same address is possible if only one of them is in the bootloader mode. The devices shall be flashed at a time.

Attention! The flashing of the devices in bootloader mode and of the same modbus address, or the flashing of multiple devices being in the bootloader mode at address 0 will not be performed; the existing firmware of the device will be ruined.