Skip to content

Conversation

@sensei-hacker
Copy link
Member

@sensei-hacker sensei-hacker commented Nov 16, 2025

User description

A couple minor changes to the NEXUS target based on my testing.

In #11082 (comment)
@functionpointer pointed out that UART3 would only work for a receiver due to the initialization order. One of the two variants already has an onboard receiver on UART5. Defining uart3 may therefore cause confusion more often than its helpful.


PR Type

Enhancement


Description

  • Remove UART3 configuration to prevent receiver confusion

  • Update serial port count from 7 to 6

  • Enable DMA support for DShot ESC protocol

  • Set motor count to 7 for proper PWM configuration


Diagram Walkthrough

flowchart LR
  A["UART3 Config"] -->|removed| B["6 Serial Ports"]
  C["DShot Protocol"] -->|enable DMA| D["USE_DSHOT_DMAR"]
  E["Motor Config"] -->|set count| F["TARGET_MOTOR_COUNT 7"]
Loading

File Walkthrough

Relevant files
Configuration changes
target.h
Remove UART3, enable DShot DMA, configure motors                 

src/main/target/NEXUSX/target.h

  • Removed UART3 definition and pin configuration (PB10/PB11)
  • Decreased SERIAL_PORT_COUNT from 7 to 6
  • Added USE_DSHOT_DMAR flag for DMA-accelerated DShot
  • Added TARGET_MOTOR_COUNT set to 7
+5/-6     

@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Nov 16, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No runtime logs: The changes are compile-time target configuration macros without any runtime action
handling or logging, so there is no evidence of audit logging for critical actions in the
added lines.

Referred Code
#define SERIAL_PORT_COUNT       6

#define DEFAULT_RX_TYPE         RX_TYPE_SERIAL
#define SERIALRX_PROVIDER       SERIALRX_CRSF
#define SERIALRX_UART           SERIAL_PORT_USART5

#define SENSORS_SET (SENSOR_ACC|SENSOR_BARO)

// *************** ADC *****************************
#define USE_ADC
#define ADC_INSTANCE                ADC1
#define ADC1_DMA_STREAM             DMA2_Stream0

#define ADC_CHANNEL_1_PIN           PC2
#define ADC_CHANNEL_2_PIN           PC1
#define ADC_CHANNEL_3_PIN           PC0

#define VBAT_ADC_CHANNEL            ADC_CHN_3 // port labelled "EXT-V"
//BEC ADC is ADC_CHN_2
//BUS ADC is ADC_CHN_1



 ... (clipped 26 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
No error handling: The added macros (e.g., SERIAL_PORT_COUNT, USE_DSHOT_DMAR, TARGET_MOTOR_COUNT) introduce
configuration changes without accompanying error handling or validation in this diff,
making robustness unassessable from the provided changes.

Referred Code
#define SERIAL_PORT_COUNT       6

#define DEFAULT_RX_TYPE         RX_TYPE_SERIAL
#define SERIALRX_PROVIDER       SERIALRX_CRSF
#define SERIALRX_UART           SERIAL_PORT_USART5

#define SENSORS_SET (SENSOR_ACC|SENSOR_BARO)

// *************** ADC *****************************
#define USE_ADC
#define ADC_INSTANCE                ADC1
#define ADC1_DMA_STREAM             DMA2_Stream0

#define ADC_CHANNEL_1_PIN           PC2
#define ADC_CHANNEL_2_PIN           PC1
#define ADC_CHANNEL_3_PIN           PC0

#define VBAT_ADC_CHANNEL            ADC_CHN_3 // port labelled "EXT-V"
//BEC ADC is ADC_CHN_2
//BUS ADC is ADC_CHN_1



 ... (clipped 26 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
No input validation: The changes are static build-time configuration and do not include any input handling or
validation logic, so compliance with secure input validation cannot be verified from the
new code.

Referred Code
#define SERIAL_PORT_COUNT       6

#define DEFAULT_RX_TYPE         RX_TYPE_SERIAL
#define SERIALRX_PROVIDER       SERIALRX_CRSF
#define SERIALRX_UART           SERIAL_PORT_USART5

#define SENSORS_SET (SENSOR_ACC|SENSOR_BARO)

// *************** ADC *****************************
#define USE_ADC
#define ADC_INSTANCE                ADC1
#define ADC1_DMA_STREAM             DMA2_Stream0

#define ADC_CHANNEL_1_PIN           PC2
#define ADC_CHANNEL_2_PIN           PC1
#define ADC_CHANNEL_3_PIN           PC0

#define VBAT_ADC_CHANNEL            ADC_CHN_3 // port labelled "EXT-V"
//BEC ADC is ADC_CHN_2
//BUS ADC is ADC_CHN_1



 ... (clipped 26 lines)

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Nov 16, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add missing DShot DMA resources

Add the required DSHOT_DMA_M_... macro definitions for each of the 7 motors to
correctly configure and enable the DShot DMA feature.
*

src/main/target/NEXUSX/target.h [151-152]

 #define USE_DSHOT_DMAR
 #define TARGET_MOTOR_COUNT      7
 
+// NOTE: The following DMA resource definitions are placeholders and MUST be
+// verified against the NEXUSX board's actual hardware pinout and timer/DMA mapping.
+// Motor 1
+#define DSHOT_DMA_M1_TIMER      TIM5
+#define DSHOT_DMA_M1_CHANNEL    TIM_Channel_1
+#define DSHOT_DMA_M1_STREAM     DMA1_Stream2
+// Motor 2
+#define DSHOT_DMA_M2_TIMER      TIM5
+#define DSHOT_DMA_M2_CHANNEL    TIM_Channel_2
+#define DSHOT_DMA_M2_STREAM     DMA1_Stream4
+// Motor 3
+#define DSHOT_DMA_M3_TIMER      TIM4
+#define DSHOT_DMA_M3_CHANNEL    TIM_Channel_1
+#define DSHOT_DMA_M3_STREAM     DMA1_Stream0
+// Motor 4
+#define DSHOT_DMA_M4_TIMER      TIM4
+#define DSHOT_DMA_M4_CHANNEL    TIM_Channel_2
+#define DSHOT_DMA_M4_STREAM     DMA1_Stream3
+// Motor 5
+#define DSHOT_DMA_M5_TIMER      TIM3
+#define DSHOT_DMA_M5_CHANNEL    TIM_Channel_1
+#define DSHOT_DMA_M5_STREAM     DMA1_Stream4
+// Motor 6
+#define DSHOT_DMA_M6_TIMER      TIM3
+#define DSHOT_DMA_M6_CHANNEL    TIM_Channel_2
+#define DSHOT_DMA_M6_STREAM     DMA1_Stream5
+// Motor 7
+#define DSHOT_DMA_M7_TIMER      TIM2
+#define DSHOT_DMA_M7_CHANNEL    TIM_Channel_3
+#define DSHOT_DMA_M7_STREAM     DMA1_Stream1
+
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that enabling USE_DSHOT_DMAR without defining the corresponding DMA resources for each motor will result in a non-functional feature, which is a critical omission in the PR.

High
Learned
best practice
Keep serial count consistent
Suggestion Impact:The commit adjusted SERIAL_PORT_COUNT from 6 to 7 in conjunction with UART3 being enabled, keeping the serial count consistent with active UARTs.

code diff:

+-#define USE_UART3
+-// port labelled "C"
+-#define UART3_TX_PIN            PB10
+-#define UART3_RX_PIN            PB11
+
 #define USE_UART4
 // port labelled "A"
 #define UART4_TX_PIN            PA0
@@ -103,7 +108,7 @@
 #define UART6_TX_PIN            PC6
 #define UART6_RX_PIN            PC7
 
-#define SERIAL_PORT_COUNT       6
+#define SERIAL_PORT_COUNT       7
 

Verify that reducing SERIAL_PORT_COUNT matches all enabled UARTs after removing
USE_UART3; update this count or UART enables to keep it consistent with the
actual number of active serial ports.

src/main/target/NEXUSX/target.h [106]

+// Ensure this matches the number of enabled UARTs (e.g., USART1, USART2, USART4, USART5, USART6, USB VCP?)
 #define SERIAL_PORT_COUNT       6

[Suggestion processed]

Suggestion importance[1-10]: 5

__

Why:
Relevant best practice - Align mode/enum priorities and related configuration counts across modules to maintain a single source of truth.

Low
  • Update

@functionpointer
Copy link
Contributor

Unfortunately this won't be acceptable for Vantac RF007 as it is missing the "B" Port, further reducing the number of available uarts.

Additionally, this target doesn't have a current sensor, potentially leading users to add an external one which will need a uart.

How much work would it be to fix the initialisation order instead?

@sensei-hacker
Copy link
Member Author

Unfortunately this won't be acceptable for Vantac RF007 as it is missing the "B" Port, further reducing the number of available uarts.

That might be a different target, with different considerations.

How much work would it be to fix the initialisation order instead?

I have no idea. Feel free to look into it. 😁

@functionpointer
Copy link
Contributor

I have managed to find the issue, and it turns out there is a solution already implemented. Just have to activate like so: #11127

@sensei-hacker sensei-hacker changed the title NEXUSX use dmar, remove uart3 NEXUSX use dmar Nov 23, 2025
@sensei-hacker
Copy link
Member Author

sensei-hacker commented Nov 23, 2025

Thanks @functionpointer
I reverted the removal of uart3.

That just leaves using DMAR and setting it to no more than 7 motors, as only 7 work for me.
(the other outputs CAN be servos)

@functionpointer
Copy link
Contributor

I have investigated the 7 motor limitation, and it can be removed by reassigning timers like so: #11129

With that PR no TARGET_MOTOR_COUNT is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants