1

我正在开发一个完美编译的 ChibiOS 版本 3.0.2 的大项目(我们称之为 chibios3)(它非常过时)所以现在我正在尝试迁移到 ChibiOS 版本 20.3.x(以免称之为 chibios20)。我从 STM32F407 Discovery 演示中获取了 chibios20 chconf.h、halconf.h、mcuconf.h 和 Makefile,并用它们替换了旧配置。旧的 Makefile 如下所示:

# Build global options
# NOTE: Can be overridden externally.
#

# Compiler options here.
ifeq ($(USE_OPT),)
  USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99
  USE_OPT += -DBOARD_OTG_NOVBUSSENS $(build_args)
  USE_OPT += -fsingle-precision-constant -Wdouble-promotion
endif

# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
  USE_COPT = 
endif

# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
  USE_CPPOPT = -fno-rtti
endif

# Enable this if you want the linker to remove unused code and data
ifeq ($(USE_LINK_GC),)
  USE_LINK_GC = yes
endif

# Linker extra options here.
ifeq ($(USE_LDOPT),)
  USE_LDOPT = 
endif

# Enable this if you want link time optimizations (LTO)
ifeq ($(USE_LTO),)
  USE_LTO = no
endif

# If enabled, this option allows to compile the application in THUMB mode.
ifeq ($(USE_THUMB),)
  USE_THUMB = yes
endif

# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
  USE_VERBOSE_COMPILE = yes
endif

# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
  USE_SMART_BUILD = yes
endif

#
# Build global options
##############################################################################

##############################################################################
# Architecture or project specific options
#

# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
  USE_PROCESS_STACKSIZE = 0x400
endif

# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
  USE_EXCEPTIONS_STACKSIZE = 0x400
endif

# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
ifeq ($(USE_FPU),)
  USE_FPU = hard
endif

# Enable this if you really want to use the STM FWLib.
ifeq ($(USE_FWLIB),)
  USE_FWLIB = yes
endif

#
# Architecture or project specific options
##############################################################################

##############################################################################
# Project, sources and paths
#

# Define project name here
PROJECT = BLDC_4_ChibiOS

# Imported source files and paths
CHIBIOS = ChibiOS_3.0.2
# Startup files.
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
include $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY/board.mk
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
#include $(CHIBIOS)/test/rt/test.mk
include hwconf/hwconf.mk
include applications/applications.mk
include nrf/nrf.mk

# Define linker script file here
LDSCRIPT= ld_eeprom_emu.ld

# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(STARTUPSRC) \
       $(KERNSRC) \
       $(PORTSRC) \
       $(OSALSRC) \
       $(HALSRC) \
       $(PLATFORMSRC) \
       $(BOARDSRC) \
       $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
       $(CHIBIOS)/os/various/syscalls.c \
       main.c \
       comm_usb_serial.c \
       irq_handlers.c \
       buffer.c \
       comm_usb.c \
       crc.c \
       digital_filter.c \
       ledpwm.c \
       mcpwm.c \
       servo_dec.c \
       utils.c \
       servo.c \
       servo_simple.c \
       packet.c \
       terminal.c \
       conf_general.c \
       eeprom.c \
       commands.c \
       timeout.c \
       comm_can.c \
       ws2811.c \
       led_external.c \
       encoder.c \
       flash_helper.c \
       mc_interface.c \
       mcpwm_foc.c \
       $(HWSRC) \
       $(APPSRC) \
       $(NRFSRC)

# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC =

# C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
#       option that results in lower performance and larger code size.
ACSRC =

# C++ sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
#       option that results in lower performance and larger code size.
ACPPSRC =

# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
#       option that results in lower performance and larger code size.
TCSRC =

# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
#       option that results in lower performance and larger code size.
TCPPSRC =

# List ASM source files here
ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)

INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
         $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
         $(CHIBIOS)/os/various \
         $(CHIBIOS)/os/hal/lib/streams \
         mcconf \
         appconf \
         $(HWINC) \
         $(APPINC) \
         $(NRFINC)

#
# Project, sources and paths
##############################################################################

##############################################################################
# Compiler settings
#

MCU  = cortex-m4

#TRGT = arm-elf-
TRGT = arm-none-eabi-
CC   = $(TRGT)gcc
CPPC = $(TRGT)g++
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
#       runtime support makes code size explode.
LD   = $(TRGT)gcc
#LD   = $(TRGT)g++
CP   = $(TRGT)objcopy
AS   = $(TRGT)gcc -x assembler-with-cpp
AR   = $(TRGT)ar
OD   = $(TRGT)objdump
SZ   = $(TRGT)size
HEX  = $(CP) -O ihex
BIN  = $(CP) -O binary

# ARM-specific options here
AOPT =

# THUMB-specific options here
TOPT = -mthumb -DTHUMB

# Define C warning options here
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes

# Define C++ warning options here
CPPWARN = -Wall -Wextra -Wundef

#
# Compiler settings
##############################################################################

##############################################################################
# Start of user section
#

# List all user C define here, like -D_DEBUG=1
UDEFS =

# Define ASM defines here
UADEFS =

# List all user directories here
UINCDIR =

# List the user directory to look for the libraries here
ULIBDIR =

# List all user libraries here
ULIBS = -lm

#
# End of user defines
##############################################################################

ifeq ($(USE_FWLIB),yes)
  include $(CHIBIOS)/ext/stdperiph_stm32f4/stm32lib.mk
  CSRC += $(STM32SRC)
  INCDIR += $(STM32INC)
  USE_OPT += -DUSE_STDPERIPH_DRIVER
endif

build/$(PROJECT).bin: build/$(PROJECT).elf 
    $(BIN) build/$(PROJECT).elf build/$(PROJECT).bin

# Program
upload: build/$(PROJECT).bin
    #qstlink2 --cli --erase --write build/$(PROJECT).bin
    #openocd -f interface/stlink-v2.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x_stlink.cfg -c "program build/$(PROJECT).elf verify reset" # Older openocd
    openocd -f board/stm32f4discovery.cfg -c "reset_config trst_only combined" -c "program build/$(PROJECT).elf verify reset exit" # For openocd 0.9

#program with olimex arm-usb-tiny-h and jtag-swd adapter board. needs openocd>=0.9
upload-olimex: build/$(PROJECT).bin
    openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x.cfg -c "program build/$(PROJECT).elf verify reset"

debug-start:
    openocd -f stm32-bv_openocd.cfg

RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
include $(RULESPATH)/rules.mk

演示 Makefile 看起来像(我添加了源和包含目录):

# Build global options
# NOTE: Can be overridden externally.
#

# Compiler options here.
ifeq ($(USE_OPT),)
  #USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
  USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99
  USE_OPT += -DBOARD_OTG_NOVBUSSENS $(build_args)
  USE_OPT += -fsingle-precision-constant -Wdouble-promotion
endif

# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
  USE_COPT = 
endif

# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
  USE_CPPOPT = -fno-rtti
endif

# Enable this if you want the linker to remove unused code and data.
ifeq ($(USE_LINK_GC),)
  USE_LINK_GC = yes
endif

# Linker extra options here.
ifeq ($(USE_LDOPT),)
  USE_LDOPT = 
endif

# Enable this if you want link time optimizations (LTO).
ifeq ($(USE_LTO),)
  USE_LTO = yes
endif

# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
  USE_VERBOSE_COMPILE = no
endif

# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
  USE_SMART_BUILD = yes
endif

#
# Build global options
##############################################################################

##############################################################################
# Architecture or project specific options
#

# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
  USE_PROCESS_STACKSIZE = 0x400
endif

# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
  USE_EXCEPTIONS_STACKSIZE = 0x400
endif

# Enables the use of FPU (no, softfp, hard).
ifeq ($(USE_FPU),)
  USE_FPU = no
endif

# FPU-related options.
ifeq ($(USE_FPU_OPT),)
  USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv4-sp-d16
endif

#
# Architecture or project specific options
##############################################################################

##############################################################################
# Project, target, sources and paths
#

# Define project name here
PROJECT = ch

# Target settings.
MCU  = cortex-m4

# Imported source files and paths.
CHIBIOS  := ./ChibiOS_20.3.x
CONFDIR  := ./cfg
BUILDDIR := ./build
DEPDIR   := ./.dep

# Licensing files.
include $(CHIBIOS)/os/license/license.mk
# Startup files.
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
include $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY/board.mk
include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Auto-build files in ./source recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional).
include $(CHIBIOS)/test/lib/test.mk
include $(CHIBIOS)/test/rt/rt_test.mk
include $(CHIBIOS)/test/oslib/oslib_test.mk

#My changes
include hwconf/hwconf.mk
include applications/applications.mk
include nrf/nrf.mk

# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F407xG.ld

# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(ALLCSRC) \
       $(TESTSRC) \
       main.c \
       comm_usb_serial.c \
       buffer.c \
       comm_usb.c \
       crc.c \
       digital_filter.c \
       ledpwm.c \
       mcpwm.c \
       servo_dec.c \
       utils.c \
       servo.c \
       servo_simple.c \
       packet.c \
       terminal.c \
       conf_general.c \
       eeprom.c \
       commands.c \
       timeout.c \
       comm_can.c \
       ws2811.c \
       led_external.c \
       encoder.c \
       flash_helper.c \
       mc_interface.c \
       mcpwm_foc.c \
       $(HWSRC) \
       $(APPSRC) \
       $(NRFSRC)

# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(ALLCPPSRC)

# List ASM source files here.
ASMSRC = $(ALLASMSRC)

# List ASM with preprocessor source files here.
ASMXSRC = $(ALLXASMSRC)

# Inclusion directories.
INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC) \
         mcconf \
         appconf \
         $(HWINC) \
         $(APPINC) \
         $(NRFINC)

# THUMB-specific options here
TOPT = -mthumb -DTHUMB

# Define C warning options here.
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes

# Define C++ warning options here.
CPPWARN = -Wall -Wextra -Wundef

#
# Project, target, sources and paths
##############################################################################

##############################################################################
# Start of user section
#

# List all user C define here, like -D_DEBUG=1
UDEFS =

# Define ASM defines here
UADEFS =

# List all user directories here
UINCDIR =

# List the user directory to look for the libraries here
ULIBDIR =

# List all user libraries here
ULIBS = -lm

#
# End of user section
##############################################################################

##############################################################################
# Common rules
#

RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
include $(RULESPATH)/arm-none-eabi.mk
include $(RULESPATH)/rules.mk

#
# Common rules
##############################################################################

##############################################################################
# Custom rules
#

#
# Custom rules
##############################################################################

现在我运行命令时make出现错误,表明该项目无法理解基本语法,如 uint8_t uint16_t .... 甚至没有定义“true”这个词。

错误如下所示:

 2910 |   __I  uint8_t   RESERVED2[3];
      |        ^~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2911:8: error: unknown type name 'uint8_t'
 2911 |   __IO uint8_t   I2CMTX;                    /*!< Master Transmit Data                  */
      |        ^~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2912:8: error: unknown type name 'uint8_t'
 2912 |   __I  uint8_t   RESERVED3[3];
      |        ^~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2913:8: error: unknown type name 'uint16_t'
 2913 |   __IO uint16_t  I2CMRXCNT;                 /*!< Master Receive Data Count             */
      |        ^~~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2914:8: error: unknown type name 'uint16_t'
 2914 |   __I  uint16_t  RESERVED4;
      |        ^~~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2915:8: error: unknown type name 'uint16_t'
 2915 |   __IO uint16_t  I2CMCRXCNT;                /*!< Master Current Receive Data Count     */
      |        ^~~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2916:8: error: unknown type name 'uint16_t'
 2916 |   __I  uint16_t  RESERVED5;
      |        ^~~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2917:8: error: unknown type name 'uint8_t'
 2917 |   __IO uint8_t   I2CADR0;                   /*!< 1st Master Address Byte               */
      |        ^~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2918:8: error: unknown type name 'uint8_t'
 2918 |   __I  uint8_t   RESERVED6[3];
      |        ^~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2919:8: error: unknown type name 'uint8_t'
 2919 |   __IO uint8_t   I2CADR1;                   /*!< 2nd Master Address Byte               */
      |        ^~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2920:8: error: unknown type name 'uint8_t'
 2920 |   __I  uint8_t   RESERVED7[7];
      |        ^~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2921:8: error: unknown type name 'uint16_t'
 2921 |   __IO uint16_t  I2CDIV;                    /*!< Serial clock period divisor register  */
      |        ^~~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2922:8: error: unknown type name 'uint16_t'
 2922 |   __I  uint16_t  RESERVED8;
      |        ^~~~~~~~
./ChibiOS_20.3.x/os/common/startup/ARMCMx/compilers/GCC/../../../../../../../ChibiOS_20.3.x/os/common/startup/ARMCMx/devices/ADUCM36x/../../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/../../../../../../ChibiOS_20.3.x/os/common/ext/ADI/ADUCM36x/ADuCM360.h:2923:8: error: unknown type name 'uint16_t'


14:00:20 Build Failed. 811 errors, 3 warnings. (took 5s.161ms)
4

0 回答 0