dragon-prog (Bebop 2 4.7.1): how the flight program talks to the motor board
Static analysis only. Tools: mcghidra (port 8192, read only, container dp-bldc-hal, stopped at the end), llvm-objdump, strings, python3.
Binary: rootfs/usr/bin/dragon-prog. ELF vaddr = file offset + 0x10000 for everything below.
Ghidra has no function objects at several of the HAL entry points (0x45b614/0x45b618, 0x45ba10, 0x444bac, 0x45a74c…), so those were read with llvm-objdump
(llvm-objdump -d --triple=armv7 --no-show-raw-insn). PIC string references were resolved by hand: a ldr rX,[pc,#n] literal L plus add rX,pc,rX at address A gives string = word(L) + A + 8.
EVIDENCE = address plus excerpt. INFERENCE = my reading. UNKNOWN = not determined.
0. Map of the code (all addresses in dragon-prog)
Section titled “0. Map of the code (all addresses in dragon-prog)”The motor code is the same libHAL source as the host tool (libMTB), identifiable by its packages/libHAL/Build/../Sources/Motors/*.c assert strings.
| Address | Role | How identified |
|---|---|---|
| 0x4cc54 | HAL board setup, selects motor driver | xrefs to “/dev/i2c-1” (0x48aee0) and “HAL_BLDC_mykonos3_init” (0x48af04) |
| 0x4453e4 | tiny wrapper: calls 0x45b000, on success installs read/write function pointers at HALctx+0x728 / +0x72c (thunks 0x4453e0 -> 0x45ba10 read, 0x4453dc -> 0x45b614 write) | disassembly |
| 0x45b000 | HAL_BLDC_mykonos3_init | its error strings (0x50827c, 0x5083c4, 0x508420, 0x508468) |
| 0x45b618 | HAL_BLDC_mykonos3_write | strings 0x5084dc, 0x508520, 0x508574, 0x5085c8 |
| 0x45ba10 | HAL_BLDC_mykonos3_read | strings 0x5086bc, 0x5086f4 |
| 0x45ac58, 0x45ade0, 0x45ae4c, 0x45ab04 | common3 state helpers: allow-start, temperature gate, wait ramp, wait brake | strings _does_BLDC_allow_to_start_motors, _is_BLDC_starting_up_motors, _is_BLDC_braking_motors |
| 0x444530 | HAL_BLDC_init (calls open with slave 8) | HAL_BLDC_init string refs |
| 0x444664 / 0x4446e0 | gpio_control frame builder (0x4D) | mov r3,#77 |
| 0x444710 | stop_motors (0x60) | mov r3,#96 |
| 0x444788 | clear_error (0x80) | mvn r3,#127 |
| 0x444818 | get_version (0xA0) | mvn r2,#95 |
| 0x444934 | set_ref_speed (0x02) | asserts motorN_speed <= 16000 |
| 0x444bac (entry), 0x444bb4 | get_observed_data_with_pwm (0x20 0x01) | CRC string 0x501728 |
| 0x444dd4 / 0x445028 | start_motors with / without direction (0x40) | mov r3,#64 |
| 0x444ef8 | play_test_note (0x82) | string 0x501830 |
| 0x45a45c / 0x45a74c / 0x45a8a8 | HAL_BLDC_open / write / write_read (the only paths onto the I2C fd) | HAL_BLDC_* func strings |
| 0x43d060 | HAL_send_motor_command | called at 0x4e12c |
| 0x43c948 | per-sample HAL acquisition (includes the motor read) | called from ACQON_hal_Thread_handler 0x4db24 |
| 0x43c688 | HAL_wait_drdy | called at 0x4db68 |
1. Q7 first: which motor-output class does milos instantiate?
Section titled “1. Q7 first: which motor-output class does milos instantiate?”EVIDENCE, FUN_0004cc54 (Ghidra decompile) branch structure:
if (!wai_is_mykonos3()) { if (!wai_is_milos() && !wai_is_loki()) { if (!wai_is_chimera()) -> error 0xfffffc18 ; ...chimera setup... } else -> milos/loki setup } // mykonos3 and milos/loki share the common tailLAB_0004cd80: ... if (wai_is_chimera() == 0) FUN_004453e4(ctx, "/dev/i2c-1", *(cfg+0x160), &lut) // BLDC over I2C else FUN_00445910(ctx, path) // PWM"/dev/i2c-1"is resolved from literal 0x4d50c + 0x4ce0c = 0x48aee0 and passed to 0x4453e4, whose failure path logs “HAL_BLDC_mykonos3_init” (0x4d200 -> 0x48af04).- 0x4453e4 calls 0x45b000, which is the function with the “HAL_BLDC_mykonos3_init()” error strings.
- The chimera-only branch calls FUN_00445910, which opens /sys/kernel/hsis/servoN_pwm style files (strings 0x4f2120.. “HAL_PWM_chimera”) and, on failure, logs the string “HAL_BLDC_chimera_init” (0x48aeec, referenced at 0x4d418 inside that chimera branch).
Answer: milos (and mykonos3, and loki) use the BLDC over I2C driver (HAL_BLDC_mykonos3_init, /dev/i2c-1, slave 8). The PWM driver is chimera only. Note the string name “HAL_BLDC_chimera_init” actually labels the PWM chimera path (misleading name, same source naming).
2. Q1: I2C open and every command byte the program sends
Section titled “2. Q1: I2C open and every command byte the program sends”2.1 Open (HAL_BLDC_open, 0x45a45c)
Section titled “2.1 Open (HAL_BLDC_open, 0x45a45c)”EVIDENCE disassembly:
45a4e0: bl open@plt ; open(path, 2) (O_RDWR), path = "/dev/i2c-1"45a4f0: movw r1,#0x706 ; 45a4f8: bl ioctl ; I2C_SLAVE_FORCE, arg = 8 (HAL_BLDC_init does: mov r1,#8 ; bl 0x45a45c at 0x44455c/0x444560)45a504..45a510: write(fd, buf, 0) ; 0-byte write probe ("BLDC card is not reachable" if it fails)45a524: movw r1,#0x702 ; mov r2,#2 ; ioctl ; I2C_TIMEOUT = 2 (units of 10 ms, so 20 ms kernel timeout)No I2C_RETRIES (0x701) in this module. Slave address 8 confirmed (7-bit).
Data transfer: write = plain write(fd,buf,n) (0x45a74c, expects n back, no retry). write_read = one I2C_RDWR ioctl, 2 messages (0x45a360 helper: movw r1,#0x707), error string “Received an empty message from BLDC” (all-0/all-FF reply filter, same as the host tool).
2.2 Complete command list
Section titled “2.2 Complete command list”The only callers of the write primitive 0x45a74c are bl at 0x444680, 0x44472c, 0x4447a4, 0x444a38, 0x444e38, 0x444f7c, 0x445050. The only callers of write_read 0x45a8a8 are 0x444850/0x4448fc (version) and 0x444bf8 (observed). No other code in dragon-prog calls them (checked with a grep of all bl 0x45a74c / 0x45a8a8). Generic I2C helpers elsewhere (0x707 ioctl at 0x44b4c0, 0x451a6c, 0x4560d0, 0x458588, 0x4588ac, 0x45928c, 0x459730, 0x45a0fc, 0x45a2e8) are used with the IMU (0x68), baro (0x77) and other config addresses; I did not see address 8 passed to them (UNKNOWN for completeness, the arguments are config-driven).
| Cmd | Frame sent | Where | When | Args and evidence |
|---|---|---|---|---|
| 0xA0 get_info | [A0], reads 16 bytes (4 bytes if ctx[0]==0) |
0x444818, called at 0x45b1e8 (init) and 0x45bc48 | at init; again once after a stop completes (refreshes flight counters) | mvn r2,#95 at 0x44481c; mov r3,#16 at 0x444840 |
| 0x80 clear_error | [80] |
0x444788, called at 0x45b77c and 0x45bd08 | (a) first step of every START command (write path, cmd type 1); (b) immediately when the board reports errno 6 (brownout) | mvn r3,#127 at 0x444790; read path cmp errno,#6 ; beq 45bd04 ; bl 0x444788 (0x45bb30..0x45bd08) |
| 0x40 start | [40] or [40][dir] |
0x445028 / 0x444dd4, called from read at 0x45be64 / 0x45bde4 | in read() after clear_error was sent, board status is idle or ramping, errno is 0, and temperature <= 79 | mov r3,#64. dir byte used iff HALctx+0x2738 != -1 (0x45bdcc ldr r2,[r6,#0x1c]; cmn r2,#1; beq 45be60); that field is init’s param_3 (motors_spin_dir <= 15 assert string 0x508264). Actual config value: UNKNOWN |
| 0x02 set_ref_speed | 11 bytes, see Q3 | 0x444934, called only from write at 0x45b82c | every write() with command type 3, i.e. every control cycle while the controller issues a speed command | see section 4 |
| 0x60 stop | [60] |
0x444710, called at 0x45b7d4 | when command type 2 (STOP) arrives (once per stop, flag byte HAL+0x58), and at program shutdown | mov r3,#96; shutdown at 0x4f468 (below) |
| 0x20 observed | [20][01] (2 bytes), reads 19 bytes (20 if ctx+0x83 != 0) |
0x444bac/0x444bb4, called from read at 0x45ba60 | every read() call, i.e. every HAL acquisition cycle, also while idle | strb 32,[r4,#0x40], strb 1,[r4,#0x41], mov r1,#2 (tx len), movne r7,#20 / moveq r7,#19 (0x444bc8..0x444bd0) |
| 0x4D gpio | [4D][bits] |
0x444664, called from write at 0x45b6fc | when write() gets command type 7 (LED) | bits = byte0 + 2byte1 + 4byte2 of the 3-byte payload (0x4446e0); who produces type 7: UNKNOWN |
| 0x82 play note | 6 bytes [82][note][dur hi][dur lo][vol hi][vol lo] |
0x444ef8, called from timer callback at 0x44100 (bl at 0x44130) | alternating 400 ms / 2500 ms pomp timer (0x44164 sets 400 and 0x9c4 = 2500), only on milos or mykonos3, only if the enabled flag is set and the board status is idle (ldrb [r5,#0x30]; cmp #1) |
args at call: note 0x1f (31), 0x1c3 (451), 0x96 (150). What sets the enable flag: UNKNOWN (INFERENCE: a lost-drone beeper) |
Not sent anywhere in dragon-prog: 0x8D, 0x06, 0xFA, 0x2B, 0xC0, 0xE0. Whole-binary mov rX,#141 hits exist (0x615c8, 0x2a7ba0, 0x32fbe8, …) but none lie in the HAL region 0x43xxxx..0x45cxxx and the HAL’s only write sites are the seven listed above.
Notable difference from the host tool and from ArduPilot: the flight program reads the observed data with a 2-byte request [20][01] and a 19-byte reply, not the 1-byte request and 15-byte reply. bldc-cyacd.md section 2 already records that the PSoC handles [20][x] with a 3-byte-per-motor layout and a 19-byte reply and says “the stock host never does this”. The stock flight program does.
3. Q2: does it send 0x8D?
Section titled “3. Q2: does it send 0x8D?”No. EVIDENCE: the seven write sites and three write_read sites above are exhaustive (section 2.2), and none builds 0x8D (immediate 0x8D would be mvn rX,#114 or mov rX,#141; neither occurs in 0x444530..0x445434 or in 0x45a000..0x45c000). So the PSoC I2C-loss watchdog runs on its power-up default (1024 loop ticks per bldc-cyacd.md).
Related, what the HAL does about I2C loss on its own side (EVIDENCE, 0x45ba10): a “link failed” flag byte (HAL+0x80) is set when the observed read, a start/stop, or the write path fails. In read(), after the observed read:
45bbb4..45bbe8 : if flag set: counter(0x5fcfc0) += 1 each cycle ; if counter > 199 (cmp r3,#199 ; bhi 45bcac) -> comm lost45baf0.. (flag clear) : counter = 0 (45bae4 str r3,[r2])45bcb8: mov r3,#4 ; mov r2,#15 ; strb r2,[r4,#0x33] ; strb r3,[r4,#0x2e] ; strb r3,[r5,#0x618..0x61b] ; errno := 4 (comm lost), motor mask := 0xF, per-motor result bytes := 4 ; logs "HAL_BLDC_common3_read(): HAL has lost i2c comm with motor"So the HAL declares errno 4 after the 201st consecutive flagged cycle (counter must exceed 199). INFERENCE: at the 198 Hz cycle that is about 1.0 s, similar to the PSoC’s own default watchdog. This is a host-side synthetic errno; it does not stop sending set_ref_speed (the write path has no check on it). Whether anything above the HAL reacts: UNKNOWN (section 6).
4. Q3: the pad byte (frame byte 9)
Section titled “4. Q3: the pad byte (frame byte 9)”EVIDENCE, HAL_BLDC_set_ref_speed 0x444934 (stack args after push of 9 regs + sub sp,#12: arg5 at [sp,#48], arg6 at [sp,#0x34], arg7 at [sp,#0x38]):
444968: ldrb r5,[sp,#0x34] ; arg6 -> r544496c: ldr r6,[sp,#0x38] ; arg7 = lut pointer444974..444990: cmp motorN,#16000 ; bhi assert ; all four speeds asserted <= 160004449f4..444a0c: strb 2,[buf] ; strb r5,[buf,#9] ; frame[0]=0x02, frame[9]=arg6444a10..444a34: XOR loop over buf[0..9] -> strb r2,[r3,#0xa] ; frame[10] = XOR8, length #11 at 444a28444a38: bl 0x45a74c (write)Frame bytes 1..8: four u16 speeds big-endian, re-ordered through the table at arg7 (ldrh r2,[r6,#2]!; uxtb; ...), the table is HALctx+0x2734, an 8-byte copy of a literal table passed to init.
The only caller is write() at 0x45b82c; EVIDENCE:
45b644: mov r6,#045b80c: ldr r12,[r9,#0x18] ; lut45b820: stmib sp,{r6,r12} ; sp+4 = r6 = 0 (arg6), sp+8 = lut (arg7)45b824: ldrh r12,[r10,#6]; str r12,[sp] ; motor4 (arg5)45b82c: bl 0x444934r6 is not written between 0x45b644 and 0x45b820 on this path. Answer: the byte is a parameter, but the single call site passes 0, so on the shipped flight program it is always 0. No code path writes a flag there. (This matches ArduPilot’s constant 0.)
5. Q4: rates
Section titled “5. Q4: rates”- write (speed, 0x02) and read (0x20) are separate calls in separate threads, but both are driven by the same acquisition samples.
- Read side: ACQON_hal_Thread_handler 0x4db24 loops
FUN_0043c688(HAL_wait_drdy) thenFUN_0043c948(per-sample acquisition). 0x43c948 calls the motor read through the function pointer at HALctx+0x271c+0xc (EVIDENCE:FUN_0043f6bc: ldr r3,[r0,#0xc]; bx r3, pointer installed by 0x4453e4 as the thunk to 0x45ba10) when the flag HAL+0x2718 is set (init sets it to 1:strb r3,[r4,#0x718]). - HAL_wait_drdy (0x43c688) has two modes: if
[ctx+0x2448]==0it sleeps to the next multiple of1000000 / [ctx+0x88]microseconds (clock_nanosleep), otherwise it polls the data-ready fd (-1 timeout, gpio style read). The period constant is therefore the HAL acquisition frequency inctx+0x88(config), and in drdy mode it is the IMU data-ready, so I take both to be the estimator rate. - Write side: ACQCON_colibry_Thread_Handler 0x4dd1c waits for the next sample (
FUN_004407f8(..., 100000), 100 ms timeout), runs the Colibry processes, then callsFUN_0043d060(HAL_send_motor_command, call at 0x4e12c) once per sample. That function calls the write pointer at HALctx+0x271c+0x10 (FUN_0043f6c4: ldr r3,[r0,#0x10]; bx r3) if flag HAL+0x2719 is set. - If no sample arrives within 100 ms the inner loop exits and logs, without calling HAL_send_motor_command. INFERENCE: during an IMU stall nothing is sent and the PSoC watchdog is the only safeguard.
- So: INFERENCE (not proven numerically): one 0x20 poll and one 0x02 set_ref_speed per sample, about 198.36 Hz (adcFsSet), around 5.04 ms; the exact period is data (ctx+0x88 or the drdy fd), not a constant in the code. UNKNOWN: whether ctx+0x88 equals 198 on this config. Start/stop/clear/get_info are event driven, not periodic.
- The beeper timer (0x82) is on a pomp timer, 400 ms and 2500 ms.
6. Q5: what it does with the reply, and with each error
Section titled “6. Q5: what it does with the reply, and with each error”6.1 Fields read (0x444bac..0x444dac, with the 19-byte layout; four motors, three bytes per motor)
Section titled “6.1 Fields read (0x444bac..0x444dac, with the 19-byte layout; four motors, three bytes per motor)”EVIDENCE:
- rx[0..11]: per motor k three bytes. byte0 bit7 is a flag (stored at ctx+0x20+k, cleared if the value is 0),
(byte0 & 0x7f)<<8 | byte1is the speed (stored at ctx+0x18+2k), byte2 is a third byte (stored at ctx+0x24+k, the PWM byte). Motor index goes through the lut. - rx[12..13] battery u16 -> ctx+0x2c (
strh r2,[r5,#44]). - rx[14]: low nibble = status (ctx+0x30), high nibble (ctx+0x32); ctx+0x31 keeps the previous status if it changed.
- rx[15]: errno -> ctx+0x2e.
- rx[16]: motor-fault byte, expanded through the lut into the motor mask at ctx+0x33.
- rx[17]: signed temperature -> ctx+0x54 (
ldrsb ...; strh r2,[r5,#84]). - rx[18]: extra byte stored at ctx+0x56 only if ctx+0x83 != 0; XOR8 of the first N-1 bytes is compared with the last byte (0x444c50..0x444c8c), error string “CRC error: Obtained %u Computed %u” (0x501728). With ctx+0x83 == 0 (memset to 0 in init, 0x4445a0..) total length is 19 and the XOR byte is rx[18]. So it reads status, errno, motor fault, temperature and battery, all of them.
6.2 Reactions
Section titled “6.2 Reactions”EVIDENCE for what the HAL does (0x45ba10):
- errno 6 (brownout, “Battery shut-down unexpectedly”): the HAL sends clear_error 0x80 at once (
ldrb r3,[r4,#0x2e]; cmp r3,#6; beq 45bd04 ; bl 0x444788). - Any errno change is published as a message:
bl 0x43fc40with id 10 and a 2-byte payload {motor mask (ctx+0x33), errno (ctx+0x2e)} (0x45bb10..0x45bb2c); id 12 carries the version block (ctx+0x34, 4 bytes) and id 11 carries 12 bytes of flight counters (ctx+0x3c) after a stop or on change. - The message callback (function containing 0x70444, label BEHAVIOUR_Lib_Colibry_Message_Callback) handles id 10 at 0x70718: calls
FUN_0005eca8(0x70730), which isbldc_err_to_sdk: maps the errno (< 14) through a table to another enum (< 14) and sends ARDrone3SettingsStateMotorErrorStateChanged to the app (alert), logs “Unknown BLDC error : %d” for >= 14. It then jumps on errno 1..13 to a name (E_BLDC_ERR_EEPROM,..._MOTOR_STALLED,..._PROPELLER_SECURITY,..._COMM_LOST,..._H_BRIDGE,E_BLDC_BROWNOUT, errno 7 skipped,..._TEMPERATURE,..._BATTERY_VOLTAGE,..._LIPO_CELLS,..._MOSFETS; 12 and 13 have no name here, see 0x7074c table), formats “Motors Error : %s (%d motor(s) impacted)” (0x496930) together with a navigation state snapshot and writes it to the blackbox (call to 0x758e0). - Start gating (0x45ac58 allow-start, 0x45ade0 temperature, 0x45ae4c wait ramp): start is refused if status is not idle or ramping, if status is 6 (“suicided”), if errno is 10 or 11, or if errno is any other non-zero value (“Errno not cleareed. This cas should never happen !!!!”, 0x507f8c). Start is also refused when the signed temperature is greater than 79 (
cmp r2,#79 ; ble ok, string “BLDC internal temperature is out of range. Starting motor refused.”, 0x508064). Start must see the ramp within 800 polls (cmp r3,#800at 0x45ae5c) or it reports a timeout, brake end is likewise awaited up to 800 polls (0x45ab14). - The read result also exposes per-sample flags (
str r0,[r5,#0x62c],[r5,#0x630]= is-spinning-ish test 0x45aab0,[r5,#0x634]= errno==0 and status!=6 test 0x45aae0, start and stop progress codes at[r5,#0x624]and[r5,#0x628]) which go into the data node hal.HAL_BLDC_result (string 0x4b4834).
By error number (what the HAL layer itself does; nothing here stops motors or lands):
- 4 (comm lost, board or synthetic): alert and blackbox message; no stop. The HAL also generates errno 4 itself after >199 failed cycles (section 3).
- 8 (temperature out of bounds, board raised): alert and blackbox message; the temperature byte (signed, C) refuses a start above 79. No stop in the HAL.
- 9 (battery voltage out of bounds): alert and blackbox message; blocks the next start (non-zero errno). No stop.
- 6: auto-cleared with 0x80 as above.
- 10, 11: also block a start with the “critical error” message.
- Is there a table or switch on the error value? Yes, two: the jump table in the message callback (log names only) and the table in bldc_err_to_sdk (value mapping for the app). Neither changes motor commands.
UNKNOWN (not traced): whether the Colibry/Mykonos3 layer (SensorBLDCProcessing, BLDCMotorController, the motorStartTryCount / takeoffFailed nodes, control states such as emergency landing) consumes hal.HAL_BLDC_result and reacts to errors by landing or cutting. I found no stop command at any HAL error site, but a higher-level reaction through the command type (stop = type 2 at 0x45b7d4) cannot be excluded from what I read.
7. Q6: init and shutdown sequence
Section titled “7. Q6: init and shutdown sequence”Init (0x45b000, called from 0x4cc54 via 0x4453e4)
Section titled “Init (0x45b000, called from 0x4cc54 via 0x4453e4)”- malloc/calloc state (0x84-byte HAL_BLDC context, 3-byte and 2x4-byte arrays), store config params (spin dir param_3, lut copy).
- HAL_BLDC_init (0x444530): memset 0x84, open(/dev/i2c-1) + I2C_SLAVE_FORCE 8 + zero-byte probe + I2C_TIMEOUT 2 (section 2.1); sets ctx[0]=1 (open ok),
ctx[0x2f]=14,ctx[0x81]=3, clears flags. - get_info 0xA0 (0x45b1e8). Version log “Get BLDC infos. * Version is: ‘%u.%u.%c.%u’” prints bytes ctx+0x34..0x37 (0x5082b8).
- Version check (EVIDENCE, Ghidra decompile of 0x45b000, and 0x45b208..0x45b21c): require
ctx[0x37] == 4(“error BLDC firmware does not managed the same number of motors”, 0x5083c4), andctx[0x36] == 'R' || ctx[0x36] == 'D'(“error BLDC firmware is not tagged ‘Released’”, 0x508420). Major and minor bytes (0x34, 0x35) are only printed, never compared. Version 6.7.R.4 passes. - On success sets the flags HAL+0x2718 and HAL+0x2719 (read and write enabled), clears start and stop flags, logs flight infos (last error, number of flights, previous and total flight time). On failure the init returns an error (-3 etc.) and no motor driver is enabled. No 0x8D, no reset, and no start/stop is sent during init.
Start sequence (EVIDENCE)
Section titled “Start sequence (EVIDENCE)”command type 1 (write path, 0x45b744..0x45b77c): startup_msg_sent (HAL+0x57) is set and clear_error 0x80 is sent. Next read() cycles (0x45bc58..0x45bde4): allow-start check, temperature check, then 0x40 (with or without direction byte), then poll the 0x20 status until ramping or spinning (<= 800 polls).
Stop sequence
Section titled “Stop sequence”command type 2 (0x45b7b0..0x45b7e8): 0x60 once (stop_msg_sent HAL+0x58). read() then waits for the board to leave stopping, and when braking ended calls get_info again (0x45bc48).
Shutdown (EVIDENCE, function 0x4f468, the one that logs “Stop BLDC”)
Section titled “Shutdown (EVIDENCE, function 0x4f468, the one that logs “Stop BLDC”)”4f4a4: iVar1 = param_1[0x8a]; *(iVar1+0x2608) = 2 (STOP) ; *(iVar1+0x2708) = -1 FUN_0043d060(); // HAL_send_motor_command, so one 0x60 goes out FUN_004403c0 ... FUN_004579ec ... sup_thread_delete x2 ; *param_1 = 0So exit via this path sends one stop (0x60) and then ends the threads. There is no 0x8D and no reset. If the process dies without running this function (crash, kill -9) nothing is sent; the board’s I2C-loss watchdog is then the only protection (INFERENCE).
RESET_PSOC
Section titled “RESET_PSOC”The strings “/sys/devices/platform/user_gpio/RESET_PSOC/value” (0x507788) and “/sys/class/gpio/gpio199/value” (0x5077bc) are present, but I found no reference to either:
- Ghidra xrefs to 0x507788: none.
- My PIC scan (every
ldr rX,[pc,#]literal followed within 60 instructions byadd rY,pc,rX, over the whole text) finds no target equal to either string; the same scan does find the FAN path (0xc2430, 0xc2474) as a control. Also none by absolute word, GOT-offset word,movw/movt, oradr. - The VBUS_DETECT string (0x4fecac) is likewise unreferenced, so this appears to be dead linked-in code from the same libHAL sources.
Answer: dragon-prog does not toggle the PSoC reset line in any way I can find (EVIDENCE of absence by pointer scan, INFERENCE that no other addressing form is used). Reset of the board at boot is done by other programs (flash_bldc / BLDC_Host_Bootloader, started by etc/boxinit.standalone.milosboard.rc line 43
start flash_bldc).
8. Summary of answers
Section titled “8. Summary of answers”- Open /dev/i2c-1, slave 8 (I2C_SLAVE_FORCE), kernel timeout 20 ms, no retries. Commands sent: 0xA0, 0x80, 0x40, 0x02, 0x60, 0x20 (as
[20][01]with 19-byte reply), 0x4D, 0x82 (6-byte frame). Never: 0x8D, 0x06, 0xFA, 0x2B, 0xC0, 0xE0. - 0x8D: never sent. Board stays on its default.
- Pad byte: always 0 (single call site passes 0).
- One 0x20 poll per acquisition cycle (read thread) and one 0x02 per sample (control thread), separate calls; both follow the HAL acquisition rate (inferred 198 Hz); no separate motor thread.
- Reads status, errno, motor mask, temperature, battery. The HAL reacts to errno 6 (auto clear), blocks start on errno != 0 and temperature > 79, and forwards every errno change as an app alert plus blackbox log. It generates errno 4 itself after >199 failed cycles. No stop or landing is issued at the HAL level for 4, 8, 9; higher-level reaction UNKNOWN.
- No GPIO reset; clear_error then start; version check = 4 motors and tag R or D only (not the version number); stop at shutdown.
- milos instantiates the BLDC I2C driver (HAL_BLDC_mykonos3_init). PWM is chimera only.
9. Open questions
Section titled “9. Open questions”- Whether the Colibry layer (BLDCMotorController, SensorBLDCProcessing, takeoff and emergency control states) reacts to
hal.HAL_BLDC_result(errno, flags at sample+0x62c..0x634) by commanding STOP or landing. Needs a trace of the consumers of those fields. - What produces command type 7 (LEDs, 0x4D) and what enables the 0x82 beeper timer (flag at 0x44164’s allocation).
- Actual value of the config word at cfg+0x160 (motors_spin_dir) that decides between
[40]and[40][dir]; the propertypersist.force_motors_dirand strings at 0x477fa4..0x478020 are in the same area. - Value of the acquisition frequency in ctx+0x88 and which mode (timed sleep or drdy poll) is used on the Bebop 2; I only showed both modes exist.
- What the PSoC does with the second byte and the extra PWM bytes of
[20][01]on the 6.7.R.4 image is only covered bybldc-cyacd.md(19-byte reply claimed); not re-checked here. - Whether any process other than dragon-prog resets the board (flash_bldc is started at boot; not analysed here).
Comments
Spotted a mistake, or tried this on your own Bebop? Leave a note. Comments are kept on this site's own server.