Repository navigation
Conversation
An Avian powered with the board announces itself 43 to about 345 ms after the board's reset, links only once those handshakes are over and only if control frames are still coming, and never links if left unanswered. The ports opened at 325 ms, after the USB wait, and the driver first ran from the task at about 6 s, so a battery connected to board and ESC together left the motor dead until it was unplugged and plugged in again. Timer and serial init move ahead of the USB wait, and a board set to SRXL2 opens its ports there and runs the driver until every ESC has replied to a telemetry request (349 ms on the bench), gives up on one that has not spoken by 200 ms, and stops at 700 ms whatever happens. Init's fixed waits keep the ESCs answered instead of sleeping, so one powered a little after the board links too. Other motor protocols only see the two calls move. The keepalive answer waits 500 ms into a link: answered again during its handshakes, the Avian did not link when they ended. The rest of init leaves the ESC without frames for about 4 s. The Avian announces itself through them and the task links it again; one still starting begins its startup anew, so the arming check counts its readiness again from when the frames return. The check also asks for a recent telemetry reply rather than any frame, since an ESC that has lost its frames still sends handshakes. The docs and two comments said a board restarting under a powered ESC never gets it back: a linked Avian that loses its frames announces itself again, and the task links it.
The state of each ESC took 200 bytes, 800 for the four the driver allows, in the main RAM that fills first on F405 and AT32 boards. Following the RAM and flash guide, it moves to FASTRAM, which only the CPU touches here. AT32 does not zero that section, so srxl2MotorInitialize() clears it, as it already did, and escCount keeps every reader off it until then. The receive buffer held the protocol's 80-byte maximum. It now holds the longest control frame the driver can build, 34 bytes with every channel, so our own echo always fits, while the ESC's replies are 22 bytes at most; the control frame's stack buffer is sized the same way. With the fields of the ESC state and of its telemetry ordered by size, an ESC takes 144 bytes. The diagnostics written to the debug channels are gathered only when debug_mode is ALWAYS, instead of on every run of the task.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoReduce SRXL2 RAM use and link Smart ESCs during boot
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1. A shared port can lose setup access
|
|
RAM / Flash usage vs. base branch — commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #12086 251 targets built. Find your board's
|
# Conflicts: # docs/Spektrum Smart ESC.md # src/main/io/motor_srxl2.c
…tarts A 150 ms gap in the board's frames restarted the 10 s arming wait whatever the ESC's state, so a pause of the board's own, long after the ESC had started, blocked arming again for 10 s with the OSD's hardware warning. Only an Avian still starting when its frames stop starts over; one already started takes the throttle back at once. The state is judged when the frames stopped, so a gap that begins during the startup restarts the wait however long it is.
# Conflicts: # src/main/io/motor_srxl2.c
|
I think I might rather put more widely-used main loop code in FASTRAM. But leaving this open for now. |
FASTRAM is better kept for the main loop's data, which every board runs; the smaller state stays.
|
Fair point, FASTRAM is better spent on the main loop. I took it out in 80ac111: the ESC state stays in the main RAM. What is left is the smaller state (fields ordered by size, buffers sized for what the bus carries): 224 B less main RAM on F405, 256 B on AT32 and H7, FASTRAM untouched. Title and description updated. |
The SRXL2 driver keeps 200 bytes of state per ESC, 800 bytes for the four it allows, in the main RAM that fills first on F405 and AT32 boards. This applies the RAM and flash guide to it (
ram-and-flash-optimization, the draft from #11718): its buffers are sized for what the bus really carries and its fields are packed, so an ESC takes 144 bytes. The state stays in the main RAM: FASTRAM is better kept for the main loop.This builds on #12085 (Smart ESC at power-up): it reorders the struct that one changes.
The change
SRXL2_CONTROL_FRAME_MAX, the longest control frame the driver can build (every one of its channels, 34 bytes), so our own echo always fits. The frames it actually sends carry the throttle and the reverse channel, 16 to 18 bytes, and the ESC's replies are 22 bytes at most (telemetry) and 14 (handshake). A longer frame is dropped as corrupt, as one over 80 bytes was. The control frame's buffer on the stack is sized the same way.debug_modeisALWAYS, instead of on every run of the task at 200 Hz.Cost
Against #12085 (Smart ESC at power-up):
FASTRAM (CCM, RAM1, DTCM) is unchanged. The F7 targets build no SRXL2 driver, which is off there for flash, so they are not affected.
Tested
Related
smartBatteryback among the 4-byte fields.Not tested, testing wanted