BMC-side state machine details

ONLY ONE BLOB IS ALLOWED OPEN AT A TIME

To avoid excessive complications, there is a restriction that only one blob within the firmware handler can be open at a time.

The system starts in the notYetStarted state.

At each state, each method has a specific effect, depending on a variety of details, and sometimes the behavior is consistent regardless of overall state.

Opening the active image or hash always fails:

  • open(/flash/active/image) returns false -- file cannot be opened.
  • open(/flash/active/hash) returns false -- file cannot be opened.

The two files are only present once their corresponding blob has been opened.

The state of fileOpen() per state

You can only open one file at a time, and some of the states exist only when a file is open.

StatefileOpen()
notYetStartedfalse
uploadInProgresstrue
verificationPendingfalse
verificationStartedtrue
verificationCompletedtrue
updatePendingfalse
updateStartedtrue
updatedCompletedtrue

The states in the Firmware Handler State Machine

notYetStarted

The starting state.

  • open(/flash/image)
  • open(/flash/tarball)
  • open(/flash/hash)
  • open(/flash/verify)
  • open(/flash/update)

uploadInProgress

The BMC is expecting to receive bytes.

  • open(/flash/*) returns false because fileOpen() == true

  • close(/flash/*) triggers state -> verificationPending

  • commit(/flash/*) returns false

verificationPending

The BMC is ready for verification or more bytes.

  • open(/flash/image) triggers state -> uploadInProgress

  • open(/flash/tarball) triggers state -> uploadInProgress

  • open(/flash/hash) triggers state -> uploadInProgress

  • open(/flash/verify)

  • open(/flash/update)

  • commit(/flash/verify) state -> verificationStarted

verificationStarted

The verification process has started, no more writes allowed.

  • open(/flash/*) returns false because state == verificationStarted

  • close(/flash/verify) state -> verificationCompleted

verificationCompleted

The verification process has completed.

  • open(/flash/image)
  • open(/flash/tarball)
  • open(/flash/hash)
  • open(/flash/verify)
  • open(/flash/update)

updatePending

The update process is pending.

updateStarted

The update process has started.

  • open(/flash/*)r eturns false because fileOpen() == true

updatedCompleted

The update has completed (optional state to reach)

Expected State Transition Sequence

If verification fails, the state still transitions to verificationCompleted and similarly, if the update fails the state still transitions to updateCompleted. It is up to the host-tool to check the result of the process by running the stat() command on their open session (either their session with the verifyBlobId or the updateBlobId.

ActionBeforeAfter
1. getBlobList()NYSNYS
2. stat(/flash/image)NYSNYS
3. open(/flash/image)NYSUIP
4. write(...)UIPUIP
5. close(/flash/image)UIPVP
6. open(/flash/hash)VPUIP
7. write(...)UIPUIP
8. close(/flash/hash)UIPVP
9. open(/flash/verify)VPVP
10. commit(...)VPVS
11. sessionStat(...)VSVS (if !completed)
11. sessionStat(...)VSVC (if completed)
12. close(/flash/verify)VCUP
13. open(/flash/update)UPUP
14. commit(...)UPUS
15. sessionStat(...)USUS (if !completed)
15. sessionStat(...)USUC (if completed)
16. close(/flash/update)UCNYS