恰柠 2024-02-25 22:39 采纳率: 50%
浏览 29
已结题

ubuntu所用stm32标准库开发烧录没反映

我想问一下,我按照你写的那个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;
}

烧录进单片机后没有任何的反映,这个该怎么办?

  • 写回答

17条回答 默认 最新

  • 百锦再@新空间 优质创作者: 编程框架技术领域 2024-02-25 23:26
    关注


    从你提供的信息来看,可能有几个地方出现了问题:

    1. 你的 makefile 文件中有一些错误,比如可能缺少了一些命令或者参数,可能会导致编译失败。你可以检查一下 makefile 文件,确保所有的命令和参数都是正确的。

    2. 在你的 main.c 文件中,你的 main 函数看起来不正确,缺少了函数的声明和定义,可能会导致程序无法正常执行。你需要正确编写 main 函数,确保程序可以正常执行。

    3. 另外,你应该检查一下烧录的过程,确保烧录的命令和参数都是正确的,以及确保烧录工具和设备都正常工作。

    总的来说,你应该逐步排查问题,检查 makefile 文件、main.c 文件和烧录过程,确定哪个环节出现了问题,然后进行修改和调试。希望这些信息能帮助你解决问题。


    评论 编辑记录

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 2月28日
  • 创建了问题 2月25日