-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for running IOMCU FW on CubeRedSecondary #29094
base: master
Are you sure you want to change the base?
Changes from all commits
2c43289
f1ddfcf
4d1722f
10f97de
38272df
6134d07
4222d19
e2a939c
c811808
3eb1b6f
1b06686
bad025d
40238bd
5e287a6
c18910b
78effbf
86414c1
d67d2ce
3ca947f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
# hw definition file for processing by chibios_hwdef.py | ||
# for H757 | ||
|
||
# MCU class and specific type | ||
MCU STM32H7xx STM32H757xx | ||
|
||
define CORE_CM7 | ||
define SMPS_PWR | ||
|
||
env OPTIMIZE -O3 | ||
|
||
# crystal frequency | ||
OSCILLATOR_HZ 24000000 | ||
|
||
# board ID for firmware load | ||
APJ_BOARD_ID 1070 | ||
|
||
FLASH_SIZE_KB 2048 | ||
|
||
# bootloader is installed at zero offset | ||
FLASH_RESERVE_START_KB 128 | ||
|
||
# the location where the bootloader will put the firmware | ||
# the H743 has 128k sectors | ||
FLASH_BOOTLOADER_LOAD_KB 128 | ||
|
||
define HAL_LED_ON 0 | ||
|
||
define IOMCU_FW TRUE | ||
define AP_FASTBOOT_ENABLED 1 | ||
IOMCU_FW 1 | ||
|
||
define HAL_USE_RTC FALSE | ||
define HAL_NO_UARTDRIVER TRUE | ||
define HAL_LOGGING_ENABLED 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these in here? These are the default for io firmware... (defaults_periph.h) |
||
define AP_CRASHDUMP_ENABLED 0 | ||
define HAL_ENABLE_SAVE_PERSISTENT_PARAMS 0 | ||
|
||
define HAL_USE_EMPTY_STORAGE 1 | ||
define HAL_STORAGE_SIZE 16384 | ||
|
||
# avoid timer threads to save memory | ||
define HAL_NO_TIMER_THREAD | ||
define HAL_NO_RCOUT_THREAD # also disables LED thread | ||
|
||
# ADC setup | ||
PF11 FMU_SERVORAIL_VCC_SENS ADC1 | ||
PA6 RSSI_IN ADC1 SCALE(2) | ||
|
||
define HAL_IOMCU_RSSI_ADC_CHANNEL 3 | ||
|
||
# CAN config | ||
PB14 GPIOCAN2_TERM OUTPUT LOW | ||
PC12 GPIOCAN1_SHUTDOWN OUTPUT HIGH | ||
PF1 GPIOCAN2_SHUTDOWN OUTPUT HIGH | ||
|
||
define HAL_CHIBIOS_ARCH_FMUV3 1 | ||
|
||
define BOARD_TYPE_DEFAULT 3 | ||
|
||
# RCIN | ||
PC8 TIM8_CH3 TIM8 RCININT PULLDOWN | ||
|
||
# SWD | ||
PA13 JTMS-SWDIO SWD | ||
PA14 JTCK-SWCLK SWD | ||
|
||
# GPIO | ||
PD10 AMBER_LED OUTPUT HIGH OPENDRAIN GPIO(0) | ||
PE15 VDD_BRICK_nVALID INPUT PULLUP | ||
PG0 VDD_BRICK2_nVALID INPUT PULLUP | ||
PG5 VDD_SERVO_FAULT INPUT PULLUP | ||
PG1 PWM_VOLT_SEL OUTPUT HIGH GPIO(3) | ||
|
||
# Control of Spektrum power pin | ||
PB2 SPEKTRUM_PWR_EN OUTPUT HIGH GPIO(73) | ||
define HAL_GPIO_SPEKTRUM_PWR 73 | ||
|
||
# Spektrum Power is Active High | ||
define HAL_SPEKTRUM_PWR_ENABLED 1 | ||
|
||
|
||
# Timer | ||
PA8 TIM1_CH1 TIM1 PWM(1) GPIO(50) | ||
PA9 TIM1_CH2 TIM1 PWM(2) GPIO(51) | ||
PA10 TIM1_CH3 TIM1 PWM(3) GPIO(52) | ||
PA11 TIM1_CH4 TIM1 PWM(4) GPIO(53) | ||
PA5 TIM2_CH1 TIM2 PWM(5) GPIO(54) | ||
PA1 TIM2_CH2 TIM2 PWM(6) GPIO(55) | ||
PB10 TIM2_CH3 TIM2 PWM(7) GPIO(56) | ||
PB11 TIM2_CH4 TIM2 PWM(8) GPIO(57) | ||
|
||
# Correctly set Direction of PWMs | ||
# if UNIDIR is set then BIDIR must be reset | ||
PA7 HP_UNIDIR_ENABLED OUTPUT HIGH GPIO(5) | ||
|
||
|
||
# UART connected to FMU, uses DMA | ||
PE7 UART7_RX UART7 SPEED_VERYLOW | ||
PE8 UART7_TX UART7 SPEED_VERYLOW | ||
|
||
# UART for SBUS out | ||
PC7 USART6_RX USART6 SPEED_HIGH LOW | ||
PC6 USART6_TX USART6 | ||
|
||
# UART for DSM input | ||
# TX side is for IO debug, and is unused | ||
PC10 USART3_TX USART3 SPEED_HIGH | ||
PC11 USART3_RX USART3 SPEED_HIGH | ||
|
||
# UART for debug | ||
PE1 UART8_TX UART8 | ||
PE0 UART8_RX UART8 | ||
|
||
# UART for RCIN | ||
PD1 UART4_TX UART4 | ||
|
||
# USART for future use | ||
PD5 USART2_TX USART2 SPEED_HIGH | ||
PD6 USART2_RX USART2 SPEED_HIGH | ||
PD4 USART2_RTS USART2 SPEED_HIGH | ||
PD3 USART2_CTS USART2 SPEED_HIGH | ||
|
||
# order of UARTs | ||
SERIAL_ORDER EMPTY EMPTY EMPTY EMPTY | ||
|
||
define HAL_USE_UART TRUE | ||
define STM32_UART_USE_UART7 TRUE | ||
define HAL_IO_FMU_COMMS UARTD7 | ||
define HAL_IO_FMU_COMMS_TX_DMA_STREAM STM32_UART_UART7_TX_DMA_STREAM | ||
define HAL_IO_FMU_COMMS_TX_DMA_CHANNEL STM32_UART_UART7_TX_DMA_CHAN | ||
define HAL_IO_FMU_COMMS_TX_IRQ_PRIORITY STM32_UART_UART7_IRQ_PRIORITY | ||
define HAL_IO_FMU_COMMS_RX_DMA_STREAM STM32_UART_UART7_RX_DMA_STREAM | ||
define HAL_IO_FMU_COMMS_RX_DMA_CHANNEL STM32_UART_UART7_RX_DMA_CHAN | ||
|
||
define HAL_USE_SERIAL TRUE | ||
define STM32_SERIAL_USE_UART7 FALSE | ||
define STM32_SERIAL_USE_UART4 TRUE | ||
define STM32_SERIAL_USE_USART3 TRUE | ||
define STM32_SERIAL_USE_USART6 TRUE | ||
|
||
define HAL_IOMCU_RCIN_SERIAL_DRIVER SD4 | ||
define HAL_IOMCU_DSM_SERIAL_DRIVER SD3 | ||
define HAL_IOMCU_SBUS_OUT_SERIAL_DRIVER SD6 | ||
define HAL_GPIO_PIN_SPEKTRUM_OUT PAL_LINE(GPIOC,11U) | ||
|
||
|
||
define AP_NETWORKING_BACKEND_PPP 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is odd? |
||
|
||
# only use pulse input for PPM, other protocols | ||
# are on serial | ||
define HAL_RCIN_PULSE_PPM_ONLY | ||
|
||
|
||
define HAL_DSHOT_ENABLED TRUE | ||
define HAL_IOMCU_SEPARATE_SBUS_OUT_RCIN 1 | ||
|
||
|
||
PC4 SAFETY_INPUT INPUT PULLDOWN | ||
PE3 SAFETY_LED OUTPUT HIGH OPENDRAIN | ||
|
||
define HAL_IOMCU_APP_SIZE_MAX (0x200000 - 0x20000 - 0x40000) | ||
define HAL_IOMCU_APP_LOAD_ADDRESS 0x08020000 | ||
|
||
define IOMCU_DEBUG SD8 | ||
define STM32_SERIAL_USE_UART8 TRUE | ||
define HAL_BL_IOMCU_FW_DETECT 1 | ||
|
||
define AP_HAL_UARTDRIVER_ENABLED 0 | ||
define HAL_SERIAL_SBUS_SWAPPED 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1052,6 +1052,12 @@ def write_mcu_config(self, f): | |
else: | ||
self.env_vars['IOMCU_FW'] = 0 | ||
|
||
# check if heater pin defined | ||
if 'HEATER' in self.bylabel.keys(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we already handle not having a heater with the HEATER_SET() macro, why also handle it at the build level? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed to disable multiple builds for highpol and lowpol heaters. With hwdef without Heaters we were still doing that. |
||
self.env_vars['IOMCU_FW_WITH_HEATER'] = 1 | ||
else: | ||
self.env_vars['IOMCU_FW_WITH_HEATER'] = 0 | ||
|
||
if self.get_config('PERIPH_FW', required=False): | ||
self.env_vars['PERIPH_FW'] = self.get_config('PERIPH_FW') | ||
else: | ||
|
@@ -1866,6 +1872,8 @@ def get_extra_bylabel(self, label, name, default=None): | |
def write_UART_config(self, f): | ||
'''write UART config defines''' | ||
serial_list = self.get_config('SERIAL_ORDER', required=False, aslist=True) | ||
if 'IOMCU_UART' in self.config and self.config['IOMCU_UART'][0] not in serial_list: | ||
serial_list.append(self.config['IOMCU_UART'][0]) | ||
if serial_list is None: | ||
return | ||
while len(serial_list) < 3: # enough ports for CrashCatcher UART discovery | ||
|
@@ -1903,11 +1911,15 @@ def write_UART_config(self, f): | |
self.error("Need io_firmware.bin in ROMFS for IOMCU") | ||
|
||
self.write_defaulting_define(f, 'HAL_WITH_IO_MCU', 1) | ||
f.write('#define HAL_UART_IOMCU_IDX %u\n' % len(serial_list)) | ||
f.write( | ||
'#define HAL_UART_IO_DRIVER ChibiOS::UARTDriver uart_io(HAL_UART_IOMCU_IDX)\n' | ||
) | ||
serial_list.append(self.config['IOMCU_UART'][0]) | ||
|
||
if self.config['IOMCU_UART'][0]: | ||
# get index of serial port in serial_list | ||
index = serial_list.index(self.config['IOMCU_UART'][0]) | ||
f.write('#define HAL_UART_IOMCU_IDX %u\n' % int(index)) | ||
f.write( | ||
'#define HAL_UART_IO_DRIVER constexpr ChibiOS::UARTDriver &uart_io = serial%sDriver;\n' % (index) | ||
) | ||
|
||
f.write('#define HAL_HAVE_SERVO_VOLTAGE 1\n') # make the assumption that IO gurantees servo monitoring | ||
# all IOMCU capable boards have SBUS out | ||
f.write('#define AP_FEATURE_SBUS_OUT 1\n') | ||
|
@@ -2054,8 +2066,6 @@ def get_RTS_alt_function(): | |
#endif | ||
''') | ||
num_ports = len(devlist) | ||
if 'IOMCU_UART' in self.config: | ||
num_ports -= 1 | ||
if num_ports > 10: | ||
self.error("Exceeded max num SERIALs of 10 (%u)" % num_ports) | ||
f.write('#define HAL_UART_NUM_SERIAL_PORTS %u\n' % num_ports) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and default it off and define to true in the hwdef.