Skycontroller NG (nap 2.0.0-rc3) stick and button path
Correction. The firmware image analysed here (
nap-linux-2.0.0-rc3) is the NG model’s (model id 0x0913), not the Skycontroller 2’s. Wherever this page says “the controller” it means the NG controller, and a mention of the Skycontroller 2 is about the other model, which this image does not describe. See the Skycontroller mapping.
Static analysis only. Rootfs R = firmware/extracted/skycontroller-nap/rootfs. Ghidra instance “skyctrl-mppd” (port 8194) used on usr/bin/mppd, stopped afterwards. Function names below are Ghidra FUN_ names, addresses are mppd VMAs unless stated. Every claim is tagged EVIDENCE or INFERENCE.
1. Where raw stick and button values originate
Section titled “1. Where raw stick and button values originate”- EVIDENCE: sensorsd-mpp does NOT read sticks. Its strings are IMU/magnetometer only: libiio, “Unable to find imu iio device”, “magneto iio device found”, props ro.sensors.imu.name / ro.sensors.magneto.name / ro.sensors.trigger.name, persist.magneto.bias, persist.gyro.bias, Eigen matrix code, “magneto calibrated”, “can’t send ATTITUDE msg”, “imu rcv %d samples”. Kernel modules for those parts: R/lib/modules/3.4.11+/kernel/drivers/input/misc/{mpu6050*.ko, akm8975.ko}, drivers/parrot/i2c/muxes/p7-i2cmux.ko.
- EVIDENCE: sticks and buttons come from a “bottom board” (mpp and nap are two bottom-board families). udev rules R/lib/udev/rules.d/55-juba-gamepad.rules and 56-juba-bb.rules: input event nodes named “mpp2_gamepad” (JUBA type mpp2_gamepad), USB 03eb:2406 (mpp_gamepad) and 03eb:2407 (nap_gamepad) as /dev/input/event*, plus hidraw nodes for the same IDs typed mpp_bb / nap_bb. Also input “qpnp_pon” typed mpp2_power (power key). 52-bottomboard.rules runs /usr/bin/bottom_board_update when USB 03eb:2fd9 (Atmel DFU) appears.
- EVIDENCE: the bottom board MCU is an ATxmega32C4: R/usr/bin/bottom_board_update is a shell script running
dfu-programmer atxmega32c4 flash /lib/firmware/xmega.hex(36,930 bytes, present) using GPIO /sys/devices/platform/user_gpio/ATMEG_UPDATE/value. - EVIDENCE: two consumers of that hardware. (a) evdev: R/usr/lib/libmppd_hw_nap.so imports libevdev_new_from_fd, libevdev_next_event, libevdev_get_abs_minimum/maximum, libevdev_get_id_vendor/product, and libjuba (juba_client_new, juba_client_for_each_desc, juba_desc_get_udev_str) to discover devices by the udev JUBA tag. It exports gamepad_create/gamepad_set_axes_modes/gamepad_set_axes_expo/gamepad_get_number_of_axes/gamepad_button_name/gamepad_get_power_button. (b) hidraw: R/usr/lib/libnapbb.so (nap_bb_new/start/stop, nap_bb_set_*_leds, nap_bb_calibratie_zero [sic], nap_bb_axis_threshold_set, nap_bb_set_raw_mode) opens the bottom board device, logs “New HID raw frame : {DT : %4lli ms} : [0x..”, has a watchdog timer (“cannot start wd timer”), drives LEDs via /sys/class/gpio/gpio55..58/value. CLI front-end: R/usr/bin/nap_bb_cli.
- INFERENCE: normal flight stick data goes xmega -> USB -> kernel input event node -> libevdev in mppd (libmppd_hw_nap). The hidraw/libnapbb path appears to be for LEDs, battery state, zero calibration and axis dead-zone threshold, not the main stick stream. Not proven: HID report layout and the xmega firmware protocol are unknown.
- Calibration storage:
- EVIDENCE: mppd reads props
ro.factory.js.centersandro.factory.js.min_max(strings at 0x2e6b9 and 0x2e6cf). Their only xrefs are in mppd main (0x17d42, 0x17d4c), in a run of seven identical calls to 0x1d5c8 right after signal() setup and before pomp_loop_new. INFERENCE: that routine logs or snapshots the property at startup. No other binary in R contains those strings (grep -a over the whole rootfs), so who sets them is unknown. R/usr/bin/nap_factory_reader only sets ro.factory.{serial,wifi-ap.mac_address,country_lock,type,default.ssid} from /factory/parameters.xml, /customer_prod/parameters.xml, /customer_prod/type.txt, /customer_prod/countrylock.txt (launched from boxinit.rc line 18 viastatexec /factory/parameters.xml). R/factory and R/customer_prod are empty in the extraction (separate partitions not in the PLF). - INFERENCE: stick centers and min/max are per-unit factory values (read-only properties from the factory partition); there is no user-calibration file for sticks in the image. nap_bb_calibratie_zero in libnapbb is a runtime zeroing function whose persistence is unknown.
- EVIDENCE: the other persisted calibration is magnetometer/gyro bias: persist.magneto.bias, persist.gyro.bias in sensorsd-mpp.
- EVIDENCE: mppd reads props
- EVIDENCE (mapping defaults depend on product type): mppd loads from
/etc/mppd/{ro.factory.type}(string at 0x2d4eb); R/etc/mppd has two directories,bebop/andmilos/, each with mapping_{bebop,bebop_2,disco,anafi4k,chimera}.cfg. nap_factory_reader sets ro.factory.type from /customer_prod/type.txt. Which one the NG controller uses is UNKNOWN (INFERENCE: probably chosen by that type file).
2. How sensorsd-mpp hands data to mppd
Section titled “2. How sensorsd-mpp hands data to mppd”- EVIDENCE: Unix domain socket, abstract namespace, name “@sensorsd”. sensorsd-mpp does pomp_ctx_listen (string “pomp_ctx_listen : err=%d(%s)”); mppd FUN_00028c40 builds a sockaddr_un (family 1, 110 bytes), strcpy “@sensorsd” (0x31838) then zeroes byte 0, and calls pomp_ctx_connect. Framing is libpomp messages (pomp_msg_*, pomp_encoder formats in sensorsd-mpp such as “%d%hhu%hhu%hhu%f%f%f%f” for attitude, “%d%hhu%hhu%hhu” for calibration state, “SYNC” and “MAGNETO_CALIB” messages). mppd logs “disconnected from sensorsd” and “can’t decode MAGNETO_CALIB msg”.
- EVIDENCE: payload is attitude and magnetometer calibration quality, which mppd forwards to the app as Skyctrl_SkyControllerState_AttitudeChanged and Skyctrl_CalibrationState_MagnetoCalibration* (descriptors present).
- Not shared memory and not the ARSDK mux channel (mux is only used toward the phone). Stick data does not travel this socket.
3. mppd mapper to Ardrone3 Piloting PCMD
Section titled “3. mppd mapper to Ardrone3 Piloting PCMD”Pipeline (mixture of EVIDENCE and INFERENCE, marked per step):
- EVIDENCE: libmppd_hw_nap reads evdev events, normalizes with the abs min/max, and applies stick shaping: functions
apply_axis_expo,apply_axis_expo_int(uses pow/round),axis_squaring_circleandaxis_bound_inscribed_circle(sqrt/atan2/sincos). INFERENCE: square-to-circle mapping and expo curve happen here, exposed through gamepad_set_axes_expo/modes. - EVIDENCE: mppd FUN_0001e674 is the axis callback: stores the value as a signed char at obj+0x1c94+axis (16 axes). If the axis is grabbed (flag array at obj+0x1a80) it encodes Mapper_Grab_axis_event(axis,value) and sends it to the app; otherwise, if not blocked (obj+0x1c54), it calls FUN_0001e3aa.
- EVIDENCE: FUN_0001e3aa finds the action bound to that axis (mapping table, optionally gated by a button combination via FUN_0001e208), and if the per-product invert flag (array at obj+(axis+product*0x10+0x650)*4) is set, negates the value (
-(char)value). Then FUN_0001d648 dispatches: action < 16 (app_0..app_15) is encoded as Mapper_Application_axis_event/button_event to the app; action >= 16 goes through an ops table at obj+8 to the piloting/camera/system code (index +4 axis, +0 button). - EVIDENCE: default mapping file format and content (R/etc/mppd/{bebop,milos}/mapping_*.cfg, libconfig syntax, “version = 1”). Axis ids: 0 LEFT_LR, 1 LEFT_UD, 2 RIGHT_LR, 3 RIGHT_UD, 4..7 MINI_LEFT/MINI_RIGHT LR/UD. Axis actions: 16 roll, 17 pitch, 18 yaw, 19 gaz, 20 camera_pan, 21 camera_tilt, 0..15 app_n. bebop_2 default (bebop/ dir): yaw=LEFT_LR, gaz=LEFT_UD, roll=RIGHT_LR, pitch=RIGHT_UD, camera_tilt=MINI_RIGHT_UD(7), camera_pan=MINI_RIGHT_LR(6). Expo: axes 0..3 expo=1, axes 4..7 linear (0); scale 0=linear, 1..4 strength. Invert: all 0. Buttons (bebop/ dir): A=cycle_hud(28), B=center_camera(27), C=video_record(18), X=takeoff_land(17), Y=return_home(16), Z=emergency(26), L1=app_0, R1=take_picture(19). The milos/ dir differs: B=app_0, Z=center_camera, L1=cycle_hud, and has no A mapping; the ordering of the other items is the same. Button bit values: A 0x1, B 0x2, C 0x4, X 0x8, Y 0x10, Z 0x20, L1 0x40, R1 0x80, then virtual direction bits 0x100..0x800000 for stick-as-button.
- EVIDENCE: loader FUN_0001d7a0 reads the .cfg with libconfig (config_lookup “mapping.buttons”, “mapping.axes”, “mapping.expo”, “mapping.invert”), with validation messages (“button action %d already bound”, “axis action %d already bound”, “bad axis %d”, “bad inverted value %d”). Per-product tables are indexed 0..4, products = mapping_bebop, bebop_2, disco, anafi4k, chimera (string order at 0x2ee7a..0x2eeb6; USB-ish product ids 0x901..0x916 are mapped to those 5 slots in FUN_0001ea38/0001ebec/0001ee94). “Bad product %04x, using default product instead”.
- EVIDENCE: user changes persist: strings “/var/lib/mppd”, “.cfg”, “.cfg.tmp”, “unable to generate fname/tmpfname” (write-temp-then-rename). INFERENCE: Map_button_action, Map_axis_action, Set_expo, Set_inverted, Reset_mapping handlers (on_map_*_cmd_received) modify the table and write
/var/lib/mppd/<product>.cfg, which overrides the /etc default. Not traced instruction by instruction. - Grab, EVIDENCE: on_grab_cmd_received (xref FUN_00021088) calls FUN_0001f274 -> mapping_grab_controls(axes_mask, buttons_mask, &axis_grab[16] at +0x1a80, &button_grab[32] at +0x1ac0), then replies Mapper_Grab_state(…) (FUN_0001f274 builds it with arsdk_cmd_enc of three u32) and re-runs FUN_0001e6e4 to synthesize releases/neutral. While grabbed: button press sends Mapper_Grab_button_event(button,1) (FUN_0001e90c, third branch) instead of firing the mapped action, and axis motion sends Mapper_Grab_axis_event. The power button is excluded (gamepad_get_power_button branch triggers shutdown callback). INFERENCE: purpose is app-side remapping UI and letting the app take raw controls.
- Set_inverted, EVIDENCE: on_set_inverted_cmd_received (xref FUN_00021088 at 0x21b54/0x21ba8) writes the per-product, per-axis invert flag read in step 3; flag values 0 or 1 (loader rejects others). Also reported back via Mapper_Inverted_map_item.
- PCMD builder, EVIDENCE (FUN_000227d8, timer callback, piloting object):
- Two PCMD value sets: own stick values (flag at obj+0x19, then roll/pitch/yaw/gaz signed chars at +0x1a..+0x1d) and the app’s PCMD (obj+0x14..0x18, decoded by arsdk_cmd_dec in FUN_00022aac from an incoming Ardrone3_Piloting_PCMD). Selection: if obj+0x2c == 1 (piloting source = app) it uses the app set; otherwise own set.
- Encode call: arsdk_cmd_enc(buf, &Ardrone3_Piloting_PCMD, flag, roll, pitch, yaw, gaz, timestamp). Argument order is exactly flag, roll, pitch, yaw, gaz, then one u32. The u32 is
(gettimeofday ms) & 0xffffff | (seq << 24)where seq is a byte at obj+0x28 incremented each frame (decompiled aslocal_34.tv_sec*1000 + usec/1000 & 0xffffff | bVar1<<0x18). The wire byte layout inside the ARSDK frame is produced by libarsdk (not in this image’s analysis): UNKNOWN, I do not assert it. - Flag logic (own set): if roll and pitch (short at +0x1a) are non-zero, flag=1 immediately and a send is forced; if both are zero, a counter at +0x24 counts ticks and clears flag after 5 consecutive zero ticks (~250 ms at 50 ms), also forcing a send. Forced-send marker is obj+0x20.
- Debug log string at 0x2f945: “pcmd roll:%d, pitch:%d, yaw:%d, gaz:%d, flag:%d” (ulog level 7).
- Sent through a function pointer at obj+0xc with context obj+0x10 (the drone-side command interface).
- Rate, EVIDENCE: FUN_00022a14 (piloting start) clears seq and counter and calls pomp_timer_set_periodic(timer, 0x32, 0x32): both delay and period are 50 ms in the disassembly (
movs r2,#0x32; mov r1,r2; ... blx pomp_timer_set_periodic). So PCMD is sent every 50 ms = 20 Hz whenever the piloting object is started, independent of whether sticks changed (callback has no early return). The timer function is registered through a literal-pool pointer so Ghidra shows no xref to FUN_000227d8; the pairing of timer to callback comes from the constructor FUN_0002294c/FUN_0002294c (timer created with pomp_timer_new and obj as context). INFERENCE: this is the cmd the Bebop 2 receives; Bebop 2 firmware side handling not covered here. - Other commands, EVIDENCE: action ids drive Ardrone3 descriptors present in mppd: Piloting_TakeOff/Landing/UserTakeOff/NavigateHome, Animations_Flip, Camera_Orientation(V2)/Camera_Velocity, MediaRecord_PictureV2/VideoV2, PictureSettings_ExpositionSelection, plus emergency. Flip actions exist in the action list (22..25) but no default binds them. INFERENCE: camera_pan/tilt axes become Camera_Velocity or Camera_Orientation; not traced.
4. Piloting authority handoff (CoPiloting_SetPilotingSource)
Section titled “4. Piloting authority handoff (CoPiloting_SetPilotingSource)”- EVIDENCE: FUN_00022aac dispatches two message ids. One is Ardrone3 PCMD from the app, stored in obj+0x14..0x18. The other is Skyctrl_CoPiloting_SetPilotingSource: it arsdk_cmd_dec’s one integer, calls FUN_00022a40(obj, value == 1), then answers with Skyctrl_CoPilotingState_PilotingSource(value) to the app via the callback at obj+0xc.
- EVIDENCE: FUN_00022a40 stores the source at obj+0x2c (log “piloting source changed: %s -> %s”, string 0x2f999) and mirrors it as a byte into the object at obj+8 (+8). Zero-initialized default (calloc in FUN_0002294c/FUN_0002294c) = 0.
- INFERENCE: value 0 = SkyController (sticks drive the drone), value 1 = Controller (app’s PCMD is forwarded, per ARSDK xml enum; the mppd code only ever compares to 1). The PCMD builder forwards the app’s frames, re-stamped with mppd’s own timestamp/sequence, at the same 20 Hz timer, rather than relaying them as they arrive.
- EVIDENCE: on drone/link teardown FUN_00020fd0 (event handler) calls FUN_00022a40(obj, 0): piloting source falls back to the controller (value 0) and grab state is cleared (FUN_0001f274(…,0,0)).
- UNKNOWN: whether SetPilotingSource is accepted unconditionally; no authorization check was seen in FUN_00022aac.
5. Link failsafe on the controller side
Section titled “5. Link failsafe on the controller side”- EVIDENCE: no controller-side PCMD “hold last” or “zero on stale” watchdog was found in mppd. The 20 Hz timer keeps re-sending the current stick (or app) values. In app-source mode, if the app stops sending PCMD, mppd keeps re-sending the last received app values (obj+0x14..0x18 are only overwritten by new PCMDs). INFERENCE from the decompile: no timestamp/age check on that stored set. This is the single most important gap and it is worth confirming on the drone side.
- EVIDENCE: only reset of that state is on disconnect (FUN_00020fd0 falls back to source 0, i.e. own sticks).
- EVIDENCE: mppd connection-state machine: “DRONE_CONNECTING_TIMEOUT reached (%dms)”, “SDK_CONNECTING_TIMEOUT reached (%dms)”, “SDK_DEVICE_DISCONNECTED”, “WIFI_NETWORK_DISCONNECTED”, “WIFID_IPC_DISCONNECTED”, “wifi is connected: disconnect it”, “drone is going to be disconnected, force wifi disconnection”, “net peer disconnected because mux peer is a priority”, “%s device discarded because an usb device is already connected”. Per-peer mux EOF (“mux eof”, “peer disconnected”).
- EVIDENCE: libnapbb has a watchdog timer toward the bottom board (“cannot start wd timer”); on the nap, LEDs show drone/wifi/battery state. Relevant to MCU liveness, not flight link loss.
- Not found: any RSSI-based action, return-to-home trigger or “link lost” message originated on the controller. Return-to-home is only a button action (return_home -> Ardrone3_Piloting_NavigateHome). INFERENCE: loss-of-link failsafe is entirely drone-side (the Bebop 2 firmware).
Open questions
Section titled “Open questions”- HID report layout and the xmega protocol (libnapbb raw frames), and what exactly nap_bb_axis_threshold_set / calibratie_zero do. Needs decompiling libnapbb.so and libmppd_hw_nap.so in Ghidra.
- Who sets ro.factory.js.centers / js.min_max, and what consumes them (the properties may be written by the factory flow; mppd only references them in main).
- Exact scaling of stick values: evdev range -> signed char range (looks like -100..100 but not proven), and where the signed chars in obj+0x1a..0x1d are written (the ops-table callbacks for actions 16..19).
- Wire layout of PCMD (arg types/sizes come from libarsdk descriptor g_arsdk_cmd_desc_Ardrone3_Piloting_PCMD in libarsdk.so, not read here).
- Whether SetPilotingSource enum 0/1 matches SkyController/Controller exactly (read the descriptor in libarsdk or the ARSDK xml).
- Which mapping directory (bebop vs milos) the NG controller actually loads; contents of /customer_prod/type.txt unavailable.
- Confirm in the drone firmware that stale repeated PCMD is handled there (drone-side timeout), since the controller does not zero it.
- The 7 properties logged at mppd startup via 0x1d5c8: confirm the routine is a log-only dump.
Comments
Spotted a mistake, or tried this on your own Bebop? Leave a note. Comments are kept on this site's own server.