@@ -176,8 +176,6 @@ def __init__(self,
176176
177177 self .firmwares_data = {}
178178
179- if sd_req is not None :
180- init_packet_vars [PacketField .REQUIRED_SOFTDEVICES_ARRAY ] = sd_req
181179
182180 if app_fw :
183181 firmware_type = HexType .EXTERNAL_APPLICATION if is_external else HexType .APPLICATION
@@ -187,6 +185,26 @@ def __init__(self,
187185 boot_validation_type = app_boot_validation_type ,
188186 init_packet_data = init_packet_vars )
189187
188+ # WARNING
189+ # Do not move the setting of the `REQUIRED_SOFTDEVICES_ARRAY`
190+ # field to be `sd_req` to before the `self__.add_firmware_info` call
191+ # for HexType.EXTERNAL_APPLICATION.
192+ #
193+ # When doing a dfu update, the sd_req, specifies that whatever is being
194+ # updated requires some version of the softdevice. In the case when
195+ # somebody does a an update with both an application and a softdevice,
196+ # both sd_req and sd_id are used at the same time. Moving assignment up
197+ # will cause the versions accepted for the softdevice to also be
198+ # accepted for the application, which can lead to invalid updates. If
199+ # the value 0x00 is provided, it can also lead to the softdevice being
200+ # deleted.
201+ #
202+ # Moving was tried https://github.com/NordicSemiconductor/pc-nrfutil/pull/349, but a
203+ # stable solution is currently favored over one solving this particular
204+ # issue. Any changes will have to be sufficiently tested to enusre a
205+ # similar bug has not been introduced.
206+ if sd_req is not None :
207+ init_packet_vars [PacketField .REQUIRED_SOFTDEVICES_ARRAY ] = sd_req
190208
191209 if bootloader_fw :
192210 self .__add_firmware_info (firmware_type = HexType .BOOTLOADER ,
0 commit comments