Repository navigation
fix(app): wait out a board's first start of a model it copies to SRAM - #64
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 shareDEPLOY_ACK_TIMEOUT_MS; they are nowDEPLOY_START_ACK_TIMEOUT_MSandDEPLOY_STOP_ACK_TIMEOUT_MSinsrc/app/store/useBleCommandStore.ts.Nothing else in the app changes.
Why
Brainchip-Inc/BrainBoard1500#9 runs Vision Human Detection (the three-pass
HwPrmodel) 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
NiclaVisionConnectsketch loads the model inside itsDEPLOYSTARThandler and sends the acknowledgement only afterwards, so the acknowledgement arrives afterthe 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
HwPr's 376,856 B. Scaled linearly to the whole 1,048,320 B SRAM, thelargest 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.
and a slower phone or busier link. For
HwPrthat leaves 6.7 s, about three times the copy itself.against it.
error. During that time the card shows
● Startingwith the Run button readingStarting…and everystart 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_deploywithrunningfalse) only clears the demos' running flags and loadsnothing, 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,
endDeviceSessiondrops the pending acknowledgementbut 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:startingthroughout.DEPLOYSTART ACK timeoutat 10 s, clearing the starting state.Against the old 3 s start wait, the first two fail.
npm run lint(0 errors),npx tsc --noEmitand
npm test -- --runInBand(202 tests) pass.Test build
scripts/build-standalone-debug-apk.shat356cfac:app-debug.apkwithassets/index.android.bundleinside (checked with
unzip -l; the bundle carries the 10 s start and 3 s stop waits), sha256918c57a75c7bf10739470df912d2b9f556cdd1dac2fd16f9643f1534fbc4885b.Captain's test steps
Together with Brainchip-Inc/BrainBoard1500#9 on the board.
What is loaded
app-debug.apkfrom commit356cfacwith its JavaScript bundled in(sha256
918c57a75c7bf10739470df912d2b9f556cdd1dac2fd16f9643f1534fbc4885b). It runs without Metro.NiclaVisionConnectsketch fromfeat(src): run flash slot programs from AKD1500 SRAM when they fit BrainBoard1500#9, with the
HwPrVision Human Detection model in flash.Steps
BrainBoard1500, and connect.application is running. No "Failed to deploy application" error appears.
Anything that does not match, tell firstmate what you saw.