Skip to content

Commit

Permalink
Merge pull request #444 from NordicSemiconductor/fix/detect-mcuboot-n…
Browse files Browse the repository at this point in the history
…rf9160-thingy-91

Fix: set device family for MCU Boot devices
  • Loading branch information
kylebonnici authored Feb 14, 2024
2 parents d8a349d + 4fb014d commit 772923c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

- Update nrfutil device to v2.1.1.

### Fixed

- Valid Modem Firmware for Thingy:91 was previously detected as incorrect.
- Show the device family in the Memory layout title for MCU Boot devices

## 4.2.0 - 2024-01-04

## Added
Expand Down
5 changes: 5 additions & 0 deletions src/actions/mcubootTargetActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import {
import { Progress } from '@nordicsemiconductor/pc-nrfconnect-shared/nrfutil';
import { NrfutilDeviceLib } from '@nordicsemiconductor/pc-nrfconnect-shared/nrfutil/device';

import { setDeviceDefinition } from '../reducers/deviceDefinitionReducer';
import { targetWritableKnown } from '../reducers/targetReducer';
import { RootState } from '../reducers/types';
import { getDeviceInfoByUSB } from '../util/devices';

export const first = <T>(items: T[]): T | undefined => items[0];
export const last = <T>(items: T[]): T | undefined => items.slice(-1)[0];
Expand All @@ -26,6 +28,9 @@ export const openDevice =
// not all devices will have serialPorts property (non-Nordic devices for example)
if (!device.serialPorts || device.serialPorts.length === 0) return;

const deviceInfo = getDeviceInfoByUSB(device);
dispatch(setDeviceDefinition(deviceInfo));

dispatch(canWrite());
};

Expand Down
41 changes: 28 additions & 13 deletions src/components/ModemUpdateDialogView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { Progress } from '@nordicsemiconductor/pc-nrfconnect-shared/nrfutil';

import { performUpdate } from '../actions/modemTargetActions';
import { getDeviceDefinition } from '../reducers/deviceDefinitionReducer';
import { getZipFilePath } from '../reducers/fileReducer';
import {
getShowModemProgrammingDialog,
Expand All @@ -39,35 +40,37 @@ const ModemUpdateDialogView = () => {

const device = useSelector(selectedDevice);
const deviceInfo = useSelector(selectedDeviceInfo);
const deviceDefinition = useSelector(getDeviceDefinition);
const modemFwName = useSelector(getZipFilePath);
const isVisible = useSelector(getShowModemProgrammingDialog);
const isMcuboot =
(useSelector(getForceMcuBoot) || !!device?.traits.mcuBoot) &&
!device?.traits.jlink;

const is9160DK = deviceInfo?.jlink?.deviceVersion
?.toLocaleUpperCase()
.includes('NRF9160');
const is9161DK = deviceInfo?.jlink?.deviceVersion
?.toLocaleUpperCase()
.includes('NRF9161');
const is9160 =
deviceDefinition.type?.toLocaleUpperCase().includes('NRF9160') ||
deviceInfo?.jlink?.deviceVersion
?.toLocaleUpperCase()
.includes('NRF9160');
const is91x1 =
deviceDefinition.type?.toLocaleUpperCase().match(/NRF91\d1/) ||
deviceInfo?.jlink?.deviceVersion?.toLocaleUpperCase().match(/NRF91\d1/);

const deviceTypeKnown = is9160 || is91x1;
let expectedFwName = false;
let expectedFileName = '';
let url = '';

if (is9160DK) {
if (is9160) {
expectedFileName = 'mfw_nrf9160_X.X.X*.zip';
expectedFwName =
!modemFwName ||
/mfw_nrf9160_\d+\.\d+\.\d+\.*.zip/.test(modemFwName);
!modemFwName || /mfw_nrf9160_\d+\.\d+\.\d+.*.zip/.test(modemFwName);
url =
'https://www.nordicsemi.com/Products/Development-hardware/nrf9160-dk/download#infotabs';
} else if (is9161DK) {
} else if (is91x1) {
expectedFileName = 'mfw_nrf91x1_X.X.X*.zip';
expectedFwName =
!modemFwName ||
/mfw_nrf91x1_\d+\.\d+\.\d+\.*.zip/.test(modemFwName);
!modemFwName || /mfw_nrf91x1_\d+\.\d+\.\d+.*.zip/.test(modemFwName);
url = 'https://www.nordicsemi.com/Products/nRF9161/Download';
}

Expand Down Expand Up @@ -199,7 +202,8 @@ const ModemUpdateDialogView = () => {
{!writing &&
!writingSucceed &&
!writingFail &&
!expectedFwName && (
!expectedFwName &&
deviceTypeKnown && (
<Alert
label="Unexpected file name detected"
variant="warning"
Expand All @@ -221,6 +225,17 @@ const ModemUpdateDialogView = () => {
.
</Alert>
)}
{!writing &&
!writingSucceed &&
!writingFail &&
!deviceTypeKnown && (
<Alert label="Modem firmware" variant="warning">
<br />
Unable to detect the device family. Make sure
that the modem firmware file is intended for the
connected device family.
</Alert>
)}
</Form.Group>
{writing && (
<Form.Group>
Expand Down

0 comments on commit 772923c

Please sign in to comment.