Skip to content

fix(app): wait out a board's first start of a model it copies to SRAM - #64

Merged
nikunj95 merged 1 commit into
mainfrom
fix/bcc-start-timeout
Oct 31, 2026
Merged

nikunj95 merged 1 commit into
mainfrom
fix/bcc-start-timeout

Conversation

@nikunj95

Copy link
Copy Markdown
Collaborator

What this changes

The app now waits up to 10 s for a board to confirm a start (DEPLOYSTART), instead of 3 s. The stop
(DEPLOYSTOP) keeps its 3 s wait. The two used to share DEPLOY_ACK_TIMEOUT_MS; they are now
DEPLOY_START_ACK_TIMEOUT_MS and DEPLOY_STOP_ACK_TIMEOUT_MS in src/app/store/useBleCommandStore.ts.
Nothing else in the app changes.

Why

Brainchip-Inc/BrainBoard1500#9 runs Vision Human Detection (the three-pass HwPr
model) from the AKD1500's SRAM, 12.8 ms per inference instead of 45.0 ms from flash. The first load of
that model after the board powers up copies its 377 KB of program data from flash over the 2 MHz bridge,
which takes 3.24 s, measured on the board. The NiclaVisionConnect sketch loads the model inside its
DEPLOYSTART handler and sends the acknowledgement only afterwards, so the acknowledgement arrives after
the app's 3 s wait has already run out and the first Run reports a start error although the board did
start. Later loads find the data still in SRAM and take 0.32 s.

The same copy also happens after a Model Update rewrites the slot, after learning changes the program
data, and after another model's buffers overwrite the copy, so this is not only a power-up case.

Why 10 s

  • The cold copy is 3.24 s for HwPr's 376,856 B. Scaled linearly to the whole 1,048,320 B SRAM, the
    largest program any model could ever copy there, it is about 9 s, and a real program is smaller
    because the engine's own buffers need room beside it. So 10 s covers the copy for any model that runs
    from SRAM, not just today's human detection.
  • On top of the copy: the Bluetooth notification back to the phone, the rest of the board's start work,
    and a slower phone or busier link. For HwPr that leaves 6.7 s, about three times the copy itself.
  • The wait timer starts only once the command's write has completed, so the write itself is not counted
    against it.
  • The cost is that a start the board genuinely never confirms now takes 10 s, not 3 s, to report its
    error. During that time the card shows ● Starting with the Run button reading Starting… and every
    start and stop button disabled, which reads correctly for a few seconds. After 10 s the start rejects
    with DEPLOYSTART ACK timeout, the starting state clears, and the screen shows its usual error alert.

Why the stop keeps 3 s

The sketch's stop path (on_deploy with running false) only clears the demos' running flags and loads
nothing, so it acknowledges as quickly as before. Making a failed stop wait longer would only delay its
error.

Worth knowing, unchanged here

If the board disconnects while a start is waiting, endDeviceSession drops the pending acknowledgement
but does not reject the start, so the start's error alert still appears only when the wait runs out. That
was up to 3 s after the disconnect and is now up to 10 s. This pull request keeps to the wait itself; a
disconnect ending the wait at once would be its own change.

Tests

__tests__/appTransition.test.ts, with fake timers:

  • A start acknowledged at 3.5 s, after the cold copy's 3.24 s, succeeds, and the store reports
    starting throughout.
  • A start the board never acknowledges is still pending at 9.999 s and rejects with
    DEPLOYSTART ACK timeout at 10 s, clearing the starting state.
  • A stop the board never acknowledges still rejects at 3 s.

Against the old 3 s start wait, the first two fail. npm run lint (0 errors), npx tsc --noEmit
and npm test -- --runInBand (202 tests) pass.

Test build

scripts/build-standalone-debug-apk.sh at 356cfac: app-debug.apk with assets/index.android.bundle
inside (checked with unzip -l; the bundle carries the 10 s start and 3 s stop waits), sha256
918c57a75c7bf10739470df912d2b9f556cdd1dac2fd16f9643f1534fbc4885b.

Captain's test steps

Together with Brainchip-Inc/BrainBoard1500#9 on the board.

What is loaded

Steps

  1. Install this app build on the phone.
  2. Unplug the Nicla Vision's USB cable and plug it back in, so the board powers up with its SRAM empty.
  3. Open BrainChip Connect, pick BrainBoard1500, and connect.
  4. Run Vision Human Detection.
    • Pass: the card shows Starting for a few seconds (the board is copying the model into SRAM), then the
      application is running. No "Failed to deploy application" error appears.
  5. Stop it, then Run Vision Human Detection again.
    • Pass: it starts quickly this time, well under a second, and no error appears.

Anything that does not match, tell firstmate what you saw.

A BrainBoard1500 that runs a model from its AKD1500 SRAM copies the
model there from flash over the 2 MHz bridge on its first load, and only
then acknowledges the start. For Vision Human Detection that copy takes
3.24 s, longer than the 3 s the app waited, so the first Run after power
up reported a start error although the board had started.

The start now waits 10 s. The stop keeps its 3 s wait, because a stop
on the board only clears the running flags and loads nothing.
@nikunj95
nikunj95 merged commit eac1304 into main Oct 31, 2026
3 checks passed
@nikunj95
nikunj95 deleted the fix/bcc-start-timeout branch October 31, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant