fix(boards): address MR-NavQ95 review feedback

- USB VALID/CONNECTED set to 0
- TPM: reject OneShot when the clock can't support it, fix W1C status
  and hw channel indexing, scale TPM3 to its correct tick
- Set pad pulls through the iomux
- Calibrate LOOPSPERMSEC on hardware (159856)
- Drop I2C_LATEINIT, the ADC critical section and the FAT DMA pool
- Add validateSPIConfig
- Round the LPIT reload up
- Make imx9 its own CI chip family, with its own group and seeder
- Reject BDShot150 and fall back to plain DShot (also a long-standing
  bug on i.MX RT)

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
Co-authored-by: Andre Heinemans <andre.heinemans@nxp.com>
This commit is contained in:
Peter van der PerkandAndre Heinemans authored and Ramon Roche committed 2026-11-06 07:32:53 -08:00
1 parent 92909e0f42
commit fec5cf5d14
11 files changed
+96 -34

No files matched your search

+2
View File
@@ -60,6 +60,7 @@ special_labels:
# NXP chip families are pooled under "nxp-{chip}" regardless of board directory
nxp_chip_families:
- imxrt
- imx9
- kinetis
- s32k
@@ -70,6 +71,7 @@ seeders:
stm32f4: "px4_fmu-v4_default"
stm32f1: "px4_io-v2_default"
imxrt: "nxp_mr-tropic_default"
imx9: "nxp_mr-navq95_default"
kinetis: "nxp_fmuk66-v3_default"
s32k: "nxp_mr-canhubk3_default"
rp2040: "raspberrypi_pico_default"
+2 -2
View File
@@ -339,10 +339,10 @@ if (args.group):
chip_label = chip
# Gather all (manufacturer -> targets) for this chip family
# NXP chip families (imxrt, kinetis, s32k) pool all manufacturers
# NXP chip families (imxrt, imx9, kinetis, s32k) pool all manufacturers
# under "nxp" since all boards use NXP silicon regardless of
# which directory they live in (e.g., px4/fmu-v6xrt is imxrt).
nxp_chips = tuple(ci_config.get('nxp_chip_families', ['imxrt', 'kinetis', 's32k']))
nxp_chips = tuple(ci_config.get('nxp_chip_families', ['imxrt', 'imx9', 'kinetis', 's32k']))
man_targets = {}
for (c, m), targets in chip_man_buckets.items():
if c == chip:
+2 -2
View File
@@ -125,7 +125,7 @@ def load_target_config(kconf, px4board_path):
def chip_family(board_path):
"""Chip family of a board, from its NuttX defconfig.
Returns one of: stm32h7, stm32f7, stm32f4, stm32f1, imxrt, kinetis,
Returns one of: stm32h7, stm32f7, stm32f4, stm32f1, imxrt, imx9, kinetis,
s32k, rp2040, native.
"""
nsh_defconfig = os.path.join(board_path, 'nuttx-config', 'nsh', 'defconfig')
@@ -149,7 +149,7 @@ def chip_family(board_path):
if arch_chip is None:
return 'native'
if arch_chip in ('stm32h7', 'stm32f7', 'imxrt', 'kinetis', 'rp2040'):
if arch_chip in ('stm32h7', 'stm32f7', 'imxrt', 'imx9', 'kinetis', 'rp2040'):
return arch_chip
elif arch_chip.startswith('s32k'):
return 's32k'
@@ -32,7 +32,7 @@ CONFIG_ARMV7M_ITCM=y
CONFIG_ARMV7M_MEMCPY=y
CONFIG_ARM_MPU_EARLY_RESET=y
CONFIG_BINFMT_DISABLE=y
CONFIG_BOARD_LOOPSPERMSEC=2664
CONFIG_BOARD_LOOPSPERMSEC=159856
CONFIG_BUILTIN=y
CONFIG_CAN=y
CONFIG_DEBUG_BUSFAULT=y
@@ -57,7 +57,6 @@ CONFIG_DEV_URANDOM=y
CONFIG_ETC_CROMFS=y
CONFIG_ETC_ROMFS=y
CONFIG_ETC_ROMFSSECTSIZE=128
CONFIG_FAT_DMAMEMORY=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FAT_LFN_ALIAS_HASH=y
@@ -123,7 +122,6 @@ CONFIG_MTD=y
CONFIG_MTD_PARTITION=y
CONFIG_NAME_MAX=40
CONFIG_NET=y
CONFIG_NETDEV_CAN_BITRATE_IOCTL=y
CONFIG_NETDEV_IFINDEX=y
CONFIG_NETDEV_LATEINIT=y
CONFIG_NET_CAN=y
+12 -14
View File
@@ -60,9 +60,12 @@
* Definitions
****************************************************************************************************/
/* SPI bus pins as GPIOs, parked as pulled-down inputs by board_spi_reset() */
/* SPI bus pins as GPIOs, parked as inputs by board_spi_reset().
* gpio_pinset_t carries no pad control (bits 9-10 are GPIO_INTCFG), so a pull
* has to be applied through the pad mux with imx9_iomux_configure().
*/
#define _PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT | IOMUXC_PAD_PD_ON))
#define _PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | GPIO_INPUT)
#define GPIO_LPSPI1_SCK /* SAI1_TXD0 */ (GPIO_PORT1 | GPIO_PIN13)
#define GPIO_LPSPI1_MISO /* SAI1_TXC */ (GPIO_PORT1 | GPIO_PIN12)
@@ -94,8 +97,6 @@
#define SYSTEM_ADC_BASE IMX9_ADC_BASE
#define BOARD_I2C_LATEINIT 1 /* See Note about SE550 Eanable */
/* PWM
*/
@@ -138,29 +139,26 @@
#define BOARD_NUMBER_BRICKS 1
#define BOARD_ADC_BRICK_VALID 1
/* Safety switch on pad GPIO_IO07 (GPIO2_IO07, net GPIO07_ARM_IO), GPS connector J8 pin 6, no on-board pull */
/* Safety switch on pad GPIO_IO07 (GPIO2_IO07, net GPIO07_ARM_IO), GPS connector J8 pin 6, no on-board pull.
* The pull-up is applied on the pad mux in imx95_bringup().
*/
#define GPIO_BTN_SAFETY /* GPIO_IO07 J8 pin 6 */ (GPIO_PORT2 | GPIO_PIN7 | GPIO_INPUT | IOMUXC_PAD_PU_ON)
#define GPIO_BTN_SAFETY /* GPIO_IO07 J8 pin 6 */ (GPIO_PORT2 | GPIO_PIN7 | GPIO_INPUT)
/* The safety LED (J8 pin 7) and the RGB LED sit on the IO-board PCAL6416A I2C expander
* at LPI2C4 address 0x20, which PX4 does not drive yet.
*/
/* By Providing BOARD_ADC_USB_CONNECTED (using the px4_arch abstraction)
* this board support the ADC system_power interface, and therefore
* provides the true logic GPIO BOARD_ADC_xxxx macros.
/* This board doesn't expose USB directly
*/
#define BOARD_ADC_USB_VALID (1)
#define BOARD_ADC_USB_CONNECTED (1)
#define BOARD_ADC_USB_VALID (0)
#define BOARD_ADC_USB_CONNECTED (0)
/* The servo rail is always powered */
#define BOARD_ADC_SERVO_VALID (1)
/* This board provides a DMA pool and APIs */
#define BOARD_DMA_ALLOC_POOL_SIZE 5120
#define PX4_GPIO_INIT_LIST { \
}
+4
View File
@@ -116,6 +116,10 @@ int imx95_bringup(void)
imx9_iomux_configure(IOMUX_CFG(IOMUXC_PAD_XSPI1_SS1_B_GPIO5_IO11, IOMUXC_PAD_PU_ON, 0));
/* Safety switch on pad GPIO_IO07, no on-board pull */
imx9_iomux_configure(IOMUX_CFG(IOMUXC_PAD_GPIO_IO07_GPIO2_IO07, IOMUXC_PAD_PU_ON, 0));
#ifdef CONFIG_PWM
/* Configure PWM outputs */
+2
View File
@@ -51,4 +51,6 @@ constexpr px4_spi_bus_t px4_spi_buses[] = {
initSPIDevice(DRV_ACC_DEVTYPE_BMI088, SPI::CS{GPIO::Port2, GPIO::Pin12}, SPI::DRDY{GPIO::Port2, GPIO::Pin17}),
}),
};
static constexpr bool unused = validateSPIConfig(px4_spi_buses);
#endif
@@ -67,9 +67,7 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
#if defined(CONFIG_IMX9_SAR_ADC)
uint32_t value = 0;
irqstate_t flags = px4_enter_critical_section();
int ret = imx9_sar_adc_read_channel(channel, &value);
px4_leave_critical_section(flags);
if (ret < 0) {
return UINT32_MAX;
+2 -2
View File
@@ -83,10 +83,10 @@
#define HRT_TIMER_FREQ 1000000
/* lpit value has to be multiplied by 133 because bus_wakeup runs 133MHz
* ponytail: assumes the LPIT runs from the 133.33 MHz bus_wakeup root; a different LPIT clock
* assumes the LPIT runs from the 133.33 MHz bus_wakeup root; a different LPIT clock
* root silently skews deadlines. Upgrade path: read the root with imx9_get_rootclock at init.
*/
#define LPIT_VALUE_FACTOR(a) ((a*400) / 3) /* == a * 133.333333... */
#define LPIT_VALUE_FACTOR(a) ((((a) * 400) + 2) / 3) /* == ceil(a * 133.333333...) */
/* HRT configuration */
#define HRT_LPTMR_INSTANCE 2
@@ -138,9 +138,9 @@ static int io_timer_handler(uint16_t timer_index)
uint32_t statusr = rSTATUS(timer_index);
/* Acknowledge all that are pending */
/* Acknowledge all that are pending (STATUS is write-1-to-clear) */
rSTATUS(timer_index) = 0;
rSTATUS(timer_index) = statusr;
/* Iterate over the timer_io_channels table */
@@ -149,7 +149,10 @@ static int io_timer_handler(uint16_t timer_index)
for (unsigned chan_index = first_channel_index; chan_index < last_channel_index; chan_index++) {
uint16_t chan = 1 << chan_index;
/* STATUS CHnF bits and CnV are indexed by the hardware channel, not the logical output */
const uint32_t hw_chan = timer_io_channels[chan_index].timer_channel;
uint16_t chan = 1 << hw_chan;
if (statusr & chan) {
@@ -160,7 +163,7 @@ static int io_timer_handler(uint16_t timer_index)
if (channel_handlers[chan_index].callback) {
channel_handlers[chan_index].callback(channel_handlers[chan_index].context, tmr,
chan_index, &timer_io_channels[chan_index],
now, count, _REG32(tmr->base, IMX9_TPM_CXV_OFFSET(chan_index)));
now, count, _REG32(tmr->base, IMX9_TPM_CXV_OFFSET(hw_chan)));
}
}
@@ -416,11 +419,38 @@ static int allocate_channel(unsigned channel, io_timer_channel_mode_t mode)
return rv;
}
/* Actual counter tick of a timer: the root clock divided by the active prescaler.
* Only power-of-two prescalers exist, so a root that is not a power-of-two multiple
* of BOARD_PWM_FREQ (TPM3 runs from the 133.33 MHz bus_wakeup root on i.MX95) does
* not tick at BOARD_PWM_FREQ. MOD and CnV are scaled by the real tick instead.
*/
static inline uint32_t timer_tick(unsigned timer)
{
return io_timers[timer].clock_rate >> (rSC(timer) & TPM_SC_PS_MASK);
}
/* Both conversions round to nearest, so a value read back with io_channel_get_ccr()
* matches what was written with io_timer_set_ccr().
*/
static inline uint32_t us_to_ticks(unsigned timer, uint32_t us)
{
return (uint32_t)((((uint64_t)us * timer_tick(timer)) + (BOARD_PWM_FREQ / 2)) / BOARD_PWM_FREQ);
}
static inline uint32_t ticks_to_us(unsigned timer, uint32_t ticks)
{
const uint32_t tick = timer_tick(timer);
return tick ? (uint32_t)((((uint64_t)ticks * BOARD_PWM_FREQ) + (tick / 2)) / tick) : 0;
}
static int timer_set_rate(unsigned timer, unsigned rate)
{
/* configure the timer to update at the desired rate */
while (rMOD(timer) != ((BOARD_PWM_FREQ / rate) - 1)) {
rMOD(timer) = (BOARD_PWM_FREQ / rate) - 1;
const uint32_t mod = (timer_tick(timer) / rate) - 1;
while (rMOD(timer) != mod) {
rMOD(timer) = mod;
}
return 0;
@@ -459,7 +489,8 @@ void io_timer_trigger(unsigned channel_mask)
for (unsigned channel = 0; channel < MAX_TIMER_IO_CHANNELS; channel++) {
if (channel_mask & (1 << channel)) {
uint32_t timer = channels_timer(channel);
REG(timer, IMX9_TPM_CXV_OFFSET(timer_io_channels[channel].timer_channel)) = channel_values[channel];
REG(timer, IMX9_TPM_CXV_OFFSET(timer_io_channels[channel].timer_channel)) = us_to_ticks(timer,
channel_values[channel]);
}
}
@@ -557,6 +588,17 @@ int io_timer_set_pwm_rate(unsigned timer, unsigned rate)
if (PWM_RATE_ONESHOT == rate) {
/* OneShot needs an exact BOARD_ONESHOT_FREQ tick and the TPM prescaler only divides by 2^0..2^7.
* A 1 MHz root gives a ratio of 0 (div2psc(0) is undefined) and 133.33 MHz gives 16 with a
* remainder, so neither can run OneShot.
*/
const uint32_t oneshot_div = io_timers[timer].clock_rate / BOARD_ONESHOT_FREQ;
if (oneshot_div == 0 || oneshot_div > 128 || (oneshot_div & (oneshot_div - 1)) != 0 ||
(io_timers[timer].clock_rate % BOARD_ONESHOT_FREQ) != 0) {
return -EINVAL;
}
/* Request to use OneShot
*/
int changed_channels = reallocate_channel_resources(channels, IOTimerChanMode_PWMOut, IOTimerChanMode_OneShot);
@@ -800,8 +842,9 @@ int io_timer_set_ccr(unsigned channel, uint16_t value)
if ((rv == 0) && (channel < MAX_TIMER_IO_CHANNELS)) {
irqstate_t flags = px4_enter_critical_section();
const unsigned timer = channels_timer(channel);
channel_values[channel] = value;
REG(channels_timer(channel), IMX9_TPM_CXV_OFFSET(timer_io_channels[channel].timer_channel)) = value;
REG(timer, IMX9_TPM_CXV_OFFSET(timer_io_channels[channel].timer_channel)) = us_to_ticks(timer, value);
px4_leave_critical_section(flags);
}
@@ -819,7 +862,8 @@ uint16_t io_channel_get_ccr(unsigned channel)
if ((mode == IOTimerChanMode_PWMOut) ||
(mode == IOTimerChanMode_OneShot) ||
(mode == IOTimerChanMode_Trigger)) {
value = REG(channels_timer(channel), IMX9_TPM_CXV_OFFSET(timer_io_channels[channel].timer_channel));
const unsigned timer = channels_timer(channel);
value = ticks_to_us(timer, REG(timer, IMX9_TPM_CXV_OFFSET(timer_io_channels[channel].timer_channel)));
}
}
@@ -628,6 +628,22 @@ int up_dshot_init(uint32_t channel_mask, uint32_t bdshot_channel_mask, unsigned
_dshot_armed = false;
_edt_enabled = edt_enable;
if (bdshot_channel_mask != 0 && (BOARD_FLEXIO_PREQ / (dshot_pwm_freq * 5 / 4) / 2) > 0xFF) {
/*
* The dual 8-bit divider cannot generate the required GCR sampling rate for
* bidirectional DShot150 from BOARD_FLEXIO_PREQ, so receiver training fails.
* Most ESCs do not support bidirectional DShot150 anyway, so fall back to
* regular DShot. TODO: Consider adjusting the FlexIO clock per DShot rate,
* although this complicates mixing rates and must preserve support for the
* commonly used bidirectional DShot600.
*/
PX4_ERR("bidirectional DShot not supported at %u bit/s, using plain DShot", dshot_pwm_freq);
/* Cannot capture, so it must never hold up DShot.cpp's all-channels-ready wait */
bdshot_ready_mask = bdshot_channel_mask;
channel_mask |= bdshot_channel_mask;
bdshot_channel_mask = 0;
}
/* Calculate dshot timings based on dshot_pwm_freq */
dshot_speed = dshot_pwm_freq;
dshot_tcmp = 0x2F00 | (((BOARD_FLEXIO_PREQ / (dshot_pwm_freq * 3) / 2) - 1) & 0xFF);