Tutorial: Firmware Installation via MoSh
The ahoi modem comprises a microcontroller running the ahoi firmware. In this tutorial, we will explore an alternative way to install or update the modem firmware. This alternative works without additional hardware.
ahoi Firmware
This time, we need a firmware image in HEX-format ahoi.hex to install on the modem.
Unless you want to build your own, you will find images on our Downloads page.
Tool Installation
Assuming that PyLib is installed and working, the only additional tool that we need to take care of is stm32flash.
In Ubuntu Linux, you can simply install via
sudo apt install stm32flash
If this does not work for you for some reason, download it from the link provided in the list of External Links and install it on your computer. We used version 0.5, but any version should do.
Firmware Installation
Connect the ahoi modem, for which you plan to install or update the firmware, to the host computer and run the Modem Shell (MoSh).
To install a firmware, you must first put the modem into the so-called bootloader mode. This can be achieved by pressing and holding the tiny button between the microcontroller and serial IO pin header on the mainboard during power-on. If there is no previous ahoi firmware image installed on the modem, this is the only way to enter the bootloader mode. If there is a previous ahoi firmware image installed on the modem, there is a more convenient alternative, particularly if the modem is installed in a housing.
Bootloader Mode
- Once the modem is in bootloader mode, it will no longer be able to interact via the MoSh nor another modem. To leave this mode, you must reboot the modem (e.g., by unplugging it from the power supply for a short time).
- You can tell if the modem is in normal or bootloader mode by checking the behavior of LD5 (see Hardware Usage): The LED is only blinking in normal mode and it is not blinking in bootloader mode.
Bootloader Mode via MoSh
In the MoSh, run
version
bootloader
exit
Disconnect MoSh before updating the firmware
Failure to close MoSh before updating the firmware may cause error during firmware update!
Example:
$ cd path/to/pylib/apps/mosh/
$ python3 mosh.py
...
...
mosh @/dev/ttyUSB0 >> version
TX@ 1578910588.920 00 FF 80 00 00 00
RX@ 1578910588.930 00 00 80 00 00 13 6D 61 73 74 65 72 2D 31 35 39
-> 31 2D 33 39 34 39 36 31 30 (master -1591 -3949610)
mosh @/dev/ttyUSB0 >> bootloader
TX@ 1578910659.044 00 FF 86 00 00 00
mosh @/dev/ttyUSB0 >> exit
$
In the previous example, the current firmware version is master-1591-3949610, which means:
| Git Parameter | Value |
|---|---|
| Branch | master |
| Commit count | 1591 |
| Commit ID | 3949610 |
Afterwards, navigate to the folder, which contains the compiled firmware image ahoi.hex
and flash the ahoi modem with stm32flash, e.g.:
$ cd /path/to/firmware/src/build/stm/
$ stm32flash -w ahoi.hex -v -R /dev/<YOUR_SERIAL_PORT>
Example (the ahoi modem is connected via /dev/ttyUSB0):
$ cd ~/ahoi/firmware/src/build/stm/
$ stm32flash -w ahoi .hex -v -R /dev/ ttyUSB0
stm32flash 0.5
http://stm32flash.sourceforge.net/
Using Parser : Intel HEX
Interface serial_posix : 57600 8E1
Version : 0x31
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0421 ( STM32F446xx )
- RAM : 128 KiB (12288 b reserved by bootloader )
- Flash : 512 KiB ( size first sector : 1 x16384 )
- Option RAM : 16b
- System RAM : 30 KiB
Write to memory
Erasing memory
Wrote and verified address 0x0803ff08 (100.00%) Done .
Resetting device ... done .
Afterwards use the MoSh again to check the firmware version (command: version):
$ cd $ AHOI / pylib / apps / mosh /
$ python3 mosh .py
...
...
mosh @/ dev/ ttyUSB0 >> version
TX@ 1578910989.267 00 FF 80 00 00 00
RX@ 1578910989.278 00 00 80 00 00 13 6D 61 73 74 65 72 2D 31 35 39
-> 32 2D 32 62 66 38 39 64 35 (master -1592 -2 bf89d5 )
In the previous examples, the firmware was updated from version master-1591-3949610 to
master-1592-2bf89d5.