Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add write support for 91x #491

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

### Added

- Write support for 91x

## 4.5.0 - 2024-12-17

### Changed
Expand Down
4 changes: 3 additions & 1 deletion src/actions/mcubootTargetActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export const performUpdate = async (
dfuFilePath: string,
onProgress: (progress: Progress) => void,
abortController: AbortController,
netCoreUploadDelay?: number
netCoreUploadDelay?: number,
target?: string
) => {
logger.info(`Writing ${dfuFilePath} to device ${device.serialNumber}`);

Expand All @@ -75,6 +76,7 @@ export const performUpdate = async (
undefined,
{
netCoreUploadDelay,
target,
},
abortController
);
Expand Down
69 changes: 67 additions & 2 deletions src/components/McuUpdateDialogView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ import {
classNames,
clearConfirmBeforeClose,
clearWaitForDevice,
convertToDropDownItems,
DialogButton,
Dropdown,
DropdownItem,
GenericDialog,
getPersistentStore,
getSelectedDropdownItem,
logger,
NumberInlineInput,
Overlay,
selectedDevice,
selectedDeviceInfo,
setWaitForDevice,
Slider,
Toggle,
Expand All @@ -40,6 +46,8 @@ import { WithRequired } from '../util/types';

const TOOLTIP_TEXT =
'Delay duration to allow successful image swap from RAM NET to NET core after image upload. Recommended default timeout is 40s. Should be increased for the older Thingy:53 devices';
const TOOLTIP_TEXT_MULTIPLE_TARGETS =
'Your device has multiple targets. Please select the target you want to program.';

const NET_CORE_UPLOAD_DELAY = 120;

Expand All @@ -56,8 +64,19 @@ const McuUpdateDialogView = () => {
const isVisible = useSelector(getShowMcuBootProgrammingDialog);
const mcubootFwPath = useSelector(getMcubootFilePath);
const zipFilePath = useSelector(getZipFilePath);
const deviceInfo = useSelector(selectedDeviceInfo);

const programmingOptions =
deviceInfo?.mcuStateOptions?.filter(s => s.type === 'Programming') ??
[];

const targetDropdownItems = convertToDropDownItems(
programmingOptions.map(s => s.arguments?.target),
false
);

const fwPath = mcubootFwPath || zipFilePath;
const [chosenTarget, setChosenTarget] = useState<string>('');

const writingHasStarted = writing || writingFail || writingSucceed;

Expand Down Expand Up @@ -111,6 +130,12 @@ const McuUpdateDialogView = () => {
}
}, [device, showDelayTimeout]);

useEffect(() => {
if (targetDropdownItems.length > 0) {
setChosenTarget(targetDropdownItems[0].value);
}
}, [targetDropdownItems]);

const onCancel = () => {
dispatch(clearWaitForDevice());
dispatch(setShowMcuBootProgrammingDialog(false));
Expand Down Expand Up @@ -175,7 +200,8 @@ Are you sure you want to continue?`,
setProgress(updatedProgress);
},
abortController.current,
showDelayTimeout ? uploadDelay : undefined
showDelayTimeout ? uploadDelay : undefined,
mcubootFwPath ? chosenTarget : undefined
)
.then(() => {
setWritingSucceed(true);
Expand Down Expand Up @@ -231,7 +257,14 @@ Are you sure you want to continue?`,
<DialogButton
variant="primary"
onClick={onWriteStart}
disabled={writing || writingSucceed || writingFail}
disabled={
writing ||
writingSucceed ||
writingFail ||
(programmingOptions.length > 1 &&
!chosenTarget &&
!!mcubootFwPath)
}
>
Write
</DialogButton>
Expand All @@ -247,6 +280,38 @@ Are you sure you want to continue?`,
<span>{` ${mcubootFwPath || zipFilePath}`}</span>
</Form.Label>
</Form.Group>

{programmingOptions.length > 1 && !zipFilePath && (
<Form.Group>
<Form.Label
style={{ display: 'inline-flex', alignItems: 'center' }}
>
<strong>Target:</strong>
<Overlay
tooltipChildren={
<span>{TOOLTIP_TEXT_MULTIPLE_TARGETS}</span>
}
keepShowingOnHoverTooltip
tooltipId="test"
placement="right"
>
<span className="mdi mdi-information-outline info-icon ml-1" />
</Overlay>
</Form.Label>
<Dropdown
items={targetDropdownItems}
onSelect={(item: DropdownItem) => {
setChosenTarget(item.value);
}}
selectedItem={getSelectedDropdownItem(
targetDropdownItems,
chosenTarget
)}
disabled={writingHasStarted}
/>
</Form.Group>
)}

{writing && (
<Form.Group>
<Form.Label>
Expand Down
Loading