Skip to content

Commit

Permalink
Boards: warn about boot0 jumper before flashing in dfu mode
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Nov 21, 2023
1 parent 3a72aa7 commit 838b2e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/components/setup-steps/mcu/dfu-flash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { trpc } from '../../../helpers/trpc';
import { Board } from '../../../server/router/mcu';
import { Button } from '../../button';
import { ErrorMessage } from '../../error-message';
import { InfoMessage } from '../../info-message';

interface DFUFlashProps {
board: Board;
Expand Down Expand Up @@ -37,18 +38,24 @@ export const DFUFlash: React.FC<DFUFlashProps> = (props) => {
const instructions = props.board.dfu?.instructions.map((step, index) => <li key={index}>{step}</li>);

const detectionText = dfuDetected ? 'DFU device detected' : 'DFU not detected';
const jumperReminder =
dfuDetected && props.board.dfu?.hasBoot0Jumper ? (
<InfoMessage title="Reminder">Make sure to remove the BOOT0 jumper from the board before flashing.</InfoMessage>
) : null;

return (
<div className="space-y-4">
<h3 className="text-xl font-medium text-zinc-900 dark:text-zinc-100">Flashing {props.board.name} via DFU</h3>
{dfuError}
{}
<p className="mt-4 text-zinc-500 dark:text-zinc-400">Status: {detectionText}</p>
{jumperReminder}
<Button color="brand" disabled={!dfuDetected || isFlashing} onClick={startFlash}>
{flashButtonTitle}
</Button>
<h4 className="text-sm font-medium text-zinc-900 dark:text-zinc-100">DFU Boot Instructions</h4>
<div className="mt-4 prose text-base text-zinc-500 dark:text-zinc-400">
<ol className="list-decimal pl-4 mb-4">{instructions}</ol>
<div className="prose mt-4 text-base text-zinc-500 dark:text-zinc-400">
<ol className="mb-4 list-decimal pl-4">{instructions}</ol>
<img src={'/configure/api/dfu-image?' + boardPathUri} alt="DFU boot buttons and or jumper visualization" />
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/setup-steps/mcu/flash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const MCUFlashing = (props: MCUStepScreenProps) => {
</Fragment>
);
} else if (boardVersion || (isBoardDetected && !forceReflash)) {
const jumperReminder =
const dfuReminder =
flashStrategy === 'dfu' && firstBoard?.dfu?.reminder ? (
<InfoMessage title="Reminder">{firstBoard?.dfu?.reminder}</InfoMessage>
) : null;
Expand All @@ -105,7 +105,7 @@ export const MCUFlashing = (props: MCUStepScreenProps) => {
<h3 className="text-xl font-medium text-zinc-900 dark:text-zinc-100">
<CheckCircleIcon className="text-brand-700 h-7 w-7 inline relative -top-0.5" /> {firstBoard?.name} detected
</h3>
{jumperReminder}
{dfuReminder}
{versionMismatch}
<p>
Proceed to the next step or{' '}
Expand Down

0 comments on commit 838b2e5

Please sign in to comment.