Mender DFU stuck in installation state after 'btattach command'

I am using mender DFU function to update a firmware on a BLE controller board that is based of the Nordic nRF5340. I am successfully able to install the firmware on to the board using the mcumgr tool.

Once the firmware file is installed on the chip and I have confirmed it, I need to again attach the BLE board to the HCI using the “btattach” command

The command that I am using to attach my device to HCI such that it gets detected as a BLE controller is : sudo btattach -B /dev/ttyACM0 -S 1000000

The issue with this command is that it is not a one-shot command. It runs as a process and as long as it is running the BLE controller will remain attached to the HCI. If you terminate the process the BLE controller is detached.

To implement the firmware update using mender I have modified the dfu script that is present at /usr/share/mender/modules/v3/dfu to call my custom script that actually implements the mcumgr command to update the firmware.

Now since the process does not return back, the status of the deployment on mender dashboard is stuck into “installing” state for long. Even though the firmware is updated, the mender script is not able to close because of the btattach command.

I have also tried to add the & at the end of the command(so it looks like : sudo btattach -B /dev/ttyACM0 -S 1000000 &) so that it runs as a background process but the issue is still the same.

Contents of the dfu script :

The contents of the custom script :

As you can see the last command for my custom script is the btattach command.
The status on the dashboard is stuck to installing :

How can I resolve this issue?

Hi @Utsav_Shah,

The Mender Update Modules are not meant to hold any scripts or commands that are long running or resident. They should only care about the actual installation process, and eventually rollback.
If your system has a kind of persistent state that you must keep, disable, or re-instantiate during an update installation, I would look into providing it as a systemd service, for example. The described btattach command sounds like it could be folded into such a setup.