我想问一下,我按照你写的那个stm32标准库的makefile文件编译后所用stlink写入到单片机,但是单片机没有任何的反应,这个是什么情况
这个是我写的makefile文件
TARGET=test
CROSS_COMPILE ?= arm-none-eabi-
CC := $(CROSS_COMPILE)gcc
OBJCOPY := $(CROSS_COMPILE)objcopy
RM=rm -f
CORE=3
PWD=$(shell pwd)
CPUFLAGS=-mthumb -mcpu=cortex-m$(CORE)
INCFLAGS=-I$(PWD)/Libraries/CMSIS -I$(PWD)/Libraries/FWlib/inc -I$(PWD)/User
LDFLAGS=-T stm32_flash.ld -Wl,-cref,-u,Reset_Handler -Wl,-Map=$(TARGET).map -Wl,--gc-sections -Wl,--defsym=malloc_getpagesize_P=0x80 -Wl,--start-group -lc -lm -Wl,--end-group
CFLAGS=$(INCFLAGS) -D STM32F10X_HD -D USE_STDPERIPH_DRIVER -Wall -g -c -o
INTERRFACE_CFG=/usr/local/share/openocd/scripts/interface/stlink-v2.cfg
TARGET_CFG=/usr/local/share/openocd/scripts/target/stm32f1x.cfg
START_SRC=$(shell find ./ -name 'startup_stm32f10x_hd.s')
START_OBJ=$(START_SRC:%.s=%.o)
C_SRC=$(shell find ./ -name '*.c')
C_OBJ=$(C_SRC:%.c=%.o)
$(TARGET):$(START_OBJ) $(C_OBJ)
$(CC) $^ $(CPUFLAGS) $(LDFLAGS) $(CFLAGS) -o $(TARGET).elf
$(OBJCOPY) $(TARGET).elf $(TARGET).bin
$(OBJCOPY) $(TARGET).elf -Oihex $(TARGET).hex
$(START_OBJ):$(START_SRC)
$(CC) -c $^ $(CPUFLAGS) $(CFLAGS) -o $@
$(C_OBJ):%.o:%.c
$(CC) -c $^ $(CPUFLAGS) $(CFLAGS) -o $@
clean:
$(RM) $(shell find ./ -name '*.o') $(TARGET).*
download:
openocd -f $(INTERRFACE_CFG) -f $(TARGET_CFG) -c init -c halt -c "flash write_image erase $(PWD)/$(TARGET).bin" -c reset -c shutdown
然后这个是我文件的目录情况
test
├── Doc
│ └── readme.txt
├── Libraries
│ ├── CMSIS
│ │ ├── core_cm3.c
│ │ ├── core_cm3.h
│ │ ├── core_cm3.o
│ │ ├── stm32f10x.h
│ │ ├── system_stm32f10x.c
│ │ ├── system_stm32f10x.h
│ │ └── system_stm32f10x.o
│ ├── FWlib
│ │ ├── inc
│ │ │ ├── misc.h
│ │ │ ├── stm32f10x_adc.h
│ │ │ ├── stm32f10x_bkp.h
│ │ │ ├── stm32f10x_can.h
│ │ │ ├── stm32f10x_cec.h
│ │ │ ├── stm32f10x_crc.h
│ │ │ ├── stm32f10x_dac.h
│ │ │ ├── stm32f10x_dbgmcu.h
│ │ │ ├── stm32f10x_dma.h
│ │ │ ├── stm32f10x_exti.h
│ │ │ ├── stm32f10x_flash.h
│ │ │ ├── stm32f10x_fsmc.h
│ │ │ ├── stm32f10x_gpio.h
│ │ │ ├── stm32f10x_i2c.h
│ │ │ ├── stm32f10x_iwdg.h
│ │ │ ├── stm32f10x_pwr.h
│ │ │ ├── stm32f10x_rcc.h
│ │ │ ├── stm32f10x_rtc.h
│ │ │ ├── stm32f10x_sdio.h
│ │ │ ├── stm32f10x_spi.h
│ │ │ ├── stm32f10x_tim.h
│ │ │ ├── stm32f10x_usart.h
│ │ │ └── stm32f10x_wwdg.h
│ │ └── src
│ │ ├── misc.c
│ │ ├── misc.o
│ │ ├── stm32f10x_adc.c
│ │ ├── stm32f10x_adc.o
│ │ ├── stm32f10x_bkp.c
│ │ ├── stm32f10x_bkp.o
│ │ ├── stm32f10x_can.c
│ │ ├── stm32f10x_can.o
│ │ ├── stm32f10x_cec.c
│ │ ├── stm32f10x_cec.o
│ │ ├── stm32f10x_crc.c
│ │ ├── stm32f10x_crc.o
│ │ ├── stm32f10x_dac.c
│ │ ├── stm32f10x_dac.o
│ │ ├── stm32f10x_dbgmcu.c
│ │ ├── stm32f10x_dbgmcu.o
│ │ ├── stm32f10x_dma.c
│ │ ├── stm32f10x_dma.o
│ │ ├── stm32f10x_exti.c
│ │ ├── stm32f10x_exti.o
│ │ ├── stm32f10x_flash.c
│ │ ├── stm32f10x_flash.o
│ │ ├── stm32f10x_fsmc.c
│ │ ├── stm32f10x_fsmc.o
│ │ ├── stm32f10x_gpio.c
│ │ ├── stm32f10x_gpio.o
│ │ ├── stm32f10x_i2c.c
│ │ ├── stm32f10x_i2c.o
│ │ ├── stm32f10x_iwdg.c
│ │ ├── stm32f10x_iwdg.o
│ │ ├── stm32f10x_pwr.c
│ │ ├── stm32f10x_pwr.o
│ │ ├── stm32f10x_rcc.c
│ │ ├── stm32f10x_rcc.o
│ │ ├── stm32f10x_rtc.c
│ │ ├── stm32f10x_rtc.o
│ │ ├── stm32f10x_sdio.c
│ │ ├── stm32f10x_sdio.o
│ │ ├── stm32f10x_spi.c
│ │ ├── stm32f10x_spi.o
│ │ ├── stm32f10x_tim.c
│ │ ├── stm32f10x_tim.o
│ │ ├── stm32f10x_usart.c
│ │ ├── stm32f10x_usart.o
│ │ ├── stm32f10x_wwdg.c
│ │ └── stm32f10x_wwdg.o
│ └── startup
│ ├── startup_stm32f10x_cl.s
│ ├── startup_stm32f10x_hd.o
│ ├── startup_stm32f10x_hd.s
│ ├── startup_stm32f10x_hd_vl.s
│ ├── startup_stm32f10x_ld.s
│ ├── startup_stm32f10x_ld_vl.s
│ ├── startup_stm32f10x_md.s
│ ├── startup_stm32f10x_md_vl.s
│ └── startup_stm32f10x_xl.s
├── makefile
├── -o
├── stm32_flash.ld
├── test.bin
├── test.elf
├── test.hex
├── test.map
└── User
├── main.c
├── main.o
├── stm32f10x_conf.h
├── stm32f10x_it.c
├── stm32f10x_it.h
└── stm32f10x_it.o
我的main.c文件中的内容如下:
#include "stm32f10x.h"
void main(){
GPIO_InitTypeDef GPIO_InitStruct = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStruct);
while(1){
GPIO_WriteBit(GPIOB, GPIO_Pin_0, 0);
}
return 0;
}
烧录进单片机后没有任何的反映,这个该怎么办?
