首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

Mac osX下STM32F10x的快速开发(3)

Mac osX下STM32F10x的快速开发(3)

自己根据硬件来定。
6、用make生成hex文件,在Windows下将使用ST-Link的Jtag或Swd写入芯片。也可以用openocd在Mac osx下写入,或者用Stm32Flash和Sloadhost用USB转serialport方式写入,怎么用方便都可以,不过在Mac下用串口写的方式没试过。
7、至此STM32F10x的板子就可以支持USB下载程序,要记住的是,Dfuse中定义的用户空间开始位置--0x08003000,下一步会用到。

/*
  *  第二步:准备Dfuse工具
  */
1、网上有开源的Dfu-util软件和修改后的支持Dfuse的非官方版本,用后者;dfuse-dfu-util;
有相应的安装说明,用git下载来安装。不知为何?也没时间深究。下载程序到芯片中不能运行。
用ST的下载工具查看,芯片中偶数的扇区都没内容,修改了dfuse.c文件,让软件先擦除完所有扇区再写,问题就解决了,有点奇怪。
2、使用dfu-util只要在makefile文件中加入相关命令即可,不用生成DFU文件,直接下载bin文件,很方便。
Makefile文件和上边的类似,内容如下:

# options and settings
PROJECT    = wrt

# directory define
PRJDIR    = ..
SRCDIR  = ..
OBJ_DIR = .
STM32_LIB_DIR = ../../..
# USR_LIBS += -I $(STM32_LIB_DIR)/Libraries
#
# available OPT:
# 0 - 3: low optimization - high optimization
# s: size optimization
OPT    = s

#_HARDWARE_VER            = 0x15
# HSE_VALUE         = 8000000

# Dfu-util set // ref to dfu-util usage
#### need to modify stm32.ld linker script file also !!!!!!!
FLASH_LOAD_OFFSET    = 0x08004000

LD_FILE         = STM32F10x.ld
TARGET_STM32         = HighDensity


USB_VG             = 0483:DF11

# set to yes to include USB library
INCLUDE_USB_LIB = yes

# User source files/includes/macros
# add .c source files to USR_SRCS
# add .h header files to USR_INCS
# add pre-defines to USR_DEFS
# add library directory to USR_LIBS


# User
USR_SRCS+= $(SRCDIR)/src/hw_config.c
USR_SRCS+= $(SRCDIR)/src/board.c
USR_SRCS+= $(SRCDIR)/src/main.c
USR_SRCS+= $(SRCDIR)/src/stm32f10x_it.c
USR_SRCS+= $(SRCDIR)/src/usb_desc.c
USR_SRCS+= $(SRCDIR)/src/usb_endp.c
USR_SRCS+= $(SRCDIR)/src/usb_istr.c
USR_SRCS+= $(SRCDIR)/src/usb_prop.c
USR_SRCS+= $(SRCDIR)/src/usb_pwr.c
USR_INCS+= -I $(SRCDIR)/inc

USR_DEFS = -DUSE_WRT_001

# STM32_EVAL
#USR_SRCS+= $(SRCDIR)/../../Utilities/STM32_EVAL/stm32_eval.c
#USR_INCS+= -I $(SRCDIR)/../../Utilities/STM32_EVAL

# LIBSTM32_LIB
ifeq ($(TARGET_STM32),LowDensity)
  LIBSTM32_ASM_SRCS = \
    $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_ld.s
  LIBSTM32_DEFS = -DUSE_STDPERIPH_DRIVER -DSTM32F10X_LD
else
  ifeq ($(TARGET_STM32),LowDensityValueLine)
    LIBSTM32_ASM_SRCS = \
      $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_ld_vl.s
    LIBSTM32_DEFS = -DUSE_STDPERIPH_DRIVER -DSTM32F10X_LD_VL
  else
    ifeq ($(TARGET_STM32),MediumDensity)
      LIBSTM32_ASM_SRCS = \
        $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_md.s
      LIBSTM32_DEFS = -DUSE_STDPERIPH_DRIVER -DSTM32F10X_MD
    else
      ifeq ($(TARGET_STM32),MediumDensityValueLine)
        LIBSTM32_ASM_SRCS = \
          $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_md_vl.s
        LIBSTM32_DEFS = -DUSE_STDPERIPH_DRIVER -DSTM32F10X_MD_VL
      else
        ifeq ($(TARGET_STM32),HighDensity)
          LIBSTM32_ASM_SRCS = \
            $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_hd.s
          LIBSTM32_DEFS = -DUSE_STDPERIPH_DRIVER -DSTM32F10X_HD
        else
          ifeq ($(TARGET_STM32),ConnectivityLine)
            LIBSTM32_ASM_SRCS = \
              $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_cl.s
            LIBSTM32_DEFS = -DUSE_STDPERIPH_DRIVER -DSTM32F10X_CL
          else
            Invalid STM32 Target
          endif
        endif
      endif
    endif
  endif
endif
LIBSTM32_SRCS = \
  $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/CoreSupport/core_cm3.c \
  $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c \
  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/misc.c \
  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c \
  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c \
  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c \
  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dma.c \
  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_spi.c \
  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c

#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_fsmc.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_adc.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_bkp.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_can.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_cec.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_crc.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dac.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dbgmcu.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_pwr.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c \
#  $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c

LIBSTM32_INCS = \
  -I $(STM32_LIB_DIR)/Libraries/STM32F10x_StdPeriph_Driver/inc \
  -I $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x \
  -I $(STM32_LIB_DIR)/Libraries/CMSIS/CM3/CoreSupport

# LIBSTM32_USB_LIB
ifeq (${INCLUDE_USB_LIB},yes)
  LIBSTM32_SRCS+= \
    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/usb_core.c \
    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/usb_init.c \
    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/usb_int.c \
    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/usb_mem.c \
    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/usb_regs.c \
    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/usb_sil.c
#    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/otgd_fs_cal.c \
#    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/otgd_fs_dev.c \
#    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/otgd_fs_int.c \
#    $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/src/otgd_fs_pcd.c
  LIBSTM32_INCS+= \
    -I $(STM32_LIB_DIR)/Libraries/STM32_USB-FS-Device_Driver/inc
endif
继承事业,薪火相传
返回列表