源码下载:
https://github.com/Zubax/zubax_gnss.git
源码默认支持STM32F107芯片
STM32 HAL库测试:zubax_gnss\bootloader\zubax_chibios\chibios\testhal\STM32
STM32 ChibiOS/RT系统测试:zubax_gnss\bootloader\zubax_chibios\chibios\demos\STM32
拷贝STM32F407默认配置文件
这三个文件是ChibiOS/RT系统主要的配置文件
源:zubax_gnss\bootloader\zubax_chibios\chibios\demos\STM32\RT-STM32F407-DISCOVERY
目的:zubax_gnss\bootloader\src\os_config
# vi mcuconf.h
#define STM32_SPI_USE_SPI3 TRUE //使用SPI3
#define STM32_USB_USE_OTG1 TRUE //使用USB1
#define STM32_SERIAL_USE_USART1 TRUE //使用UART1
# vi halconf.h
#define HAL_USE_SPI TRUE //使能SPI
#define HAL_USE_SERIAL_USB TRUE //使能SERIAL_USB
#define HAL_USE_USB TRUE //使能USB
# vi chconf.h
#define CH_DBG_ENABLE_STACK_CHECK TRUE //DEBUG使用
拷贝board.h
源:zubax_gnss\bootloader\zubax_chibios\chibios\os\hal\boards\ST_STM32F4_DISCOVERY
目的:zubax_gnss\bootloader\src\os_config
# vi board.h
#define GPIO_PORT_LED_CAN1 GPIOF //用户程序CAN状态灯定义
#define GPIO_PIN_LED_CAN1 9
#define GPIO_PORT_LED_CAN2 GPIOF
#define GPIO_PIN_LED_CAN2 10
#define DEBUG_BUILD 1 //DEBUG开关
修改Makefile
# vi Makefile
SERIAL_CLI_PORT_NUMBER = 3 //UART调试口选择。-DSTDOUT_SD=SD$(SERIAL_CLI_PORT_NUMBER)
include zubax_chibios/rules_stm32f446.mk
firmware中还需配置
pal_lld.h:(zubax_gnss\firmware\zubax_chibios\chibios\os\hal\ports\STM32\LLD\GPIOv2\pal_lld.h)
因为F407使用的是GPIOv2
#define pal_lld_setport(port, bits) (((ioportid_t)(port))->BSRR.H.set = (uint16_t)(bits)) //添加强制类型转换,不然编译报错
#define PAL_MODE_STM32_ALTERNATE_PUSHPULL 16 //GPIOv2中没有定义
#define PAL_MODE_STM32_ALTERNATE_OPENDRAIN 17
air_sensor.cpp:zubax_gnss\firmware\src\air_sensor.cpp
driver_(&SPID3, (GPIO_TypeDef*)GPIO_PORT_BAROMETER_CHIP_SELECT, GPIO_PIN_BAROMETER_CHIP_SELECT) //同上
配置board.cpp
board.cpp:\zubax_gnss\firmware\src\board
const PALConfig pal_default_config = {
#if STM32_HAS_GPIOA
{VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
#endif
#if STM32_HAS_GPIOB
{VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR,
VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
#endif
#if STM32_HAS_GPIOC
{VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR,
VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
#endif
#if STM32_HAS_GPIOD
{VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR,
VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
#endif
#if STM32_HAS_GPIOE
{VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR,
VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
#endif
#if STM32_HAS_GPIOF
{VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR,
VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
#endif
#if STM32_HAS_GPIOG
{VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR,
VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
#endif
#if STM32_HAS_GPIOH
{VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR,
VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
#endif
#if STM32_HAS_GPIOI
{VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
#endif
};
编译
# git submodule update --init --recursive //子模块更新
# cd firmware
# make binaries RELEASE=1
# ls build/ -l
-rwxrwxr-x 1 thomas thomas 5257152 Nov 4 18:59 compound.elf
-rw-rw-r-- 1 thomas thomas 213040 Nov 4 18:59 com.zubax.gnss-2.2-4.0.16f8c7b.application.bin
-rw-rw-r-- 1 thomas thomas 278569 Nov 4 18:59 com.zubax.gnss-2.2-4.0.16f8c7b.compound.bin //包含bootloader和application
-rw-rw-r-- 1 thomas thomas 2560450 Nov 4 18:59 com.zubax.gnss.map