对不起,我的英语不好。我的 PC 上有一个 Ubuntu,我用它来编程我的STM32L-DISCOVERY。好吧,程序成功编译,但是在链接应用程序时出现错误。我是开发此类设备的新手。所以,我使用 Eclipse 作为 IDE 和 Code Sourcery 工具。我使用命令arm-none-linux-gnueabi-gcc编译程序以使用该标志进行编译:
-DSTM32L1XX_MD -DUSE_STDPERIPH_DRIVER -I/usr/CodeSourcery/Libraries/CMSIS/Include -I/usr
/CodeSourcery/Libraries/STMTouch_Driver/inc -I/usr/CodeSourcery/Libraries
/STMTouch_Driver/src -I/usr/CodeSourcery/Libraries/CMSIS/Device/ST/STM32L1xx/Include
-I/usr/CodeSourcery/Libraries/STM32L1xx_StdPeriph_Driver/inc -I/usr/CodeSourcery /Libraries
/STM32L1xx_StdPeriph_Driver/src -O2 -ffunction-sections -fdata-sections -Wall
-Wa,-adhlns="$@.lst" -c -fmessage-length=0 -march=armv7-m -mcpu=cortex-m3 -mthumb -g3
-gdwarf-2
我正在使用相同的命令与该标志链接:
-T"/home/luka/workspace/stm32ld_template/stm32l152rb.ld" -nostartfiles -Xlinker
--gc-sections -Wl,-Map,stm32ld_template.map -march=armv7-m -mcpu=cortex-m3
-mthumb -g3 -gdwarf-2
好吧,在使用最后一个命令执行后,它给了我这样的错误:
错误:/usr/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../arm-none-linux-gnueabi/libc/thumb2/lib/ld-linux.so.3:冲突的架构配置文件A/M stm32ld_template C/C++ 问题错误:/ usr/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../arm-none-linux-gnueabi/libc/thumb2/lib/libc.so.6:冲突的架构配置文件A/M stm32ld_template C/C++ 问题错误:/usr/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux /bin/../arm-none-linux-gnueabi/libc/thumb2/lib/libgcc_s.so.1:架构配置文件冲突 A/M stm32ld_template C/C++ 问题
当我在链接命令中删除标志-mthumb时,没有错误。但是,当我尝试调试程序时,它会以Function main not defined
. 我也使用st-util进行调试,当我尝试调试时,它会显示:
recv: qSupported:multiprocess+;qRelocInsn+
query: Supported;multiprocess+;qRelocInsn+
send: PacketSize=3fff;qXfer:memory-map:read+
recv: !
send: OK
recv: Hg0
send:
recv: ?
send: S05
recv: Hc-1
send:
recv: qC
send:
recv: qAttached
query: Attached;
send:
recv: g
send: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c6c6962ffffffff2e6c642d
recv: qXfer:memory-map:read::0,fff
query: Xfer;memory-map:read::0,fff
Xfer: type:memory-map;op:read;annex:;addr:0;length:4095
send: m<?xml version="1.0"?><!DOCTYPE memory-map PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN" "http://sourceware.org/gdb/gdb-memory-map.dtd"><memory-map> <memory type="rom" start="0x00000000" length="0x10000"/> <memory type="ram" start="0x20000000" length="0x4000"/> <memory type="flash" start="0x08000000" length="0x10000"> <property name="blocksize">0x100</property> </memory> <memory type="ram" start="0x40000000" length="0x1fffffff"/> <memory type="ram" start="0xe0000000" length="0x1fffffff"/> <memory type="rom" start="0x1ff00000" length="0x1000"/> <memory type="rom" start="0x1ffff800" length="0x8"/></memory-map>
recv: qXfer:memory-map:read::27c,d83
query: Xfer;memory-map:read::27c,d83
Xfer: type:memory-map;op:read;annex:;addr:636;length:3459
send: l
recv: qTStatus
query: TStatus;
send:
recv: X20000000,0:
send:
recv: M20000000,70:0100000001000000010000000f0000000400000030000008050000001400000806000000140000080a000000190000000b000000100000001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
send: OK
recv: M20000070,c:000000200000000000000000
send: OK
recv: vFlashErase:08000000,00000100
FlashErase: addr:08000000,len:0100
send: OK
recv: vFlashWrite:8000000:/lib/ld-linux.so.3
binary packet 19 -> 20
send: OK
recv: vFlashWrite:8000014:
binary packet 25 -> 26
send: OK
recv: vFlashWrite:8000030:
binary packet 12 -> 12
send: OK
recv: vFlashDone
flash_do: block 08000000 -> 0100
flash_do: page 08000000
2013-09-27T18:23:14 INFO src/stlink-common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
2013-09-27T18:23:14 INFO src/stlink-common.c: Finished erasing 1 pages of 256 (0x100) bytes
2013-09-27T18:23:14 INFO src/stlink-common.c: Starting Half page flash write for STM32L core id
2013-09-27T18:23:14 INFO src/stlink-common.c: Successfully loaded flash loader in sram
2013-09-27T18:23:14 INFO src/stlink-common.c: Starting verification of write complete
2013-09-27T18:23:14 INFO src/stlink-common.c: Flash written and verified! jolly good!
send: OK
recv: Pf=00000008
send: OK
recv: p19
send: 00000001
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qfThreadInfo
query: fThreadInfo;
send:
recv: qL1200000000000000000
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qSymbol::
query: Symbol;:
send:
recv: g
send: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c6c6962ffffffff00000008
recv: qL1200000000000000000
send:
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: p19
send: 00000001
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: vKill;a410
send: OK
recv: ?
send: OK
recv: vRun;
send:
recv: R0
KARL - should read back as 0x03, not 60 02 00 00
init watchpoints
send: OK
cannot recv: -2
closing connection
KARL - should read back as 0x03, not 60 02 00 00
init watchpoints
Listening at *:4242...
GDB connected.
recv: qSupported:multiprocess+;qRelocInsn+
query: Supported;multiprocess+;qRelocInsn+
send: PacketSize=3fff;qXfer:memory-map:read+
recv: !
send: OK
recv: Hg0
send:
recv: ?
send: S05
recv: Hc-1
send:
recv: qC
send:
recv: qAttached
query: Attached;
send:
recv: g
send: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c6c6962ffffffff2e6c642d
recv: qXfer:memory-map:read::0,fff
query: Xfer;memory-map:read::0,fff
Xfer: type:memory-map;op:read;annex:;addr:0;length:4095
send: m<?xml version="1.0"?><!DOCTYPE memory-map PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN" "http://sourceware.org/gdb/gdb-memory-map.dtd"><memory-map> <memory type="rom" start="0x00000000" length="0x10000"/> <memory type="ram" start="0x20000000" length="0x4000"/> <memory type="flash" start="0x08000000" length="0x10000"> <property name="blocksize">0x100</property> </memory> <memory type="ram" start="0x40000000" length="0x1fffffff"/> <memory type="ram" start="0xe0000000" length="0x1fffffff"/> <memory type="rom" start="0x1ff00000" length="0x1000"/> <memory type="rom" start="0x1ffff800" length="0x8"/></memory-map>
recv: qXfer:memory-map:read::27c,d83
query: Xfer;memory-map:read::27c,d83
Xfer: type:memory-map;op:read;annex:;addr:636;length:3459
send: l
recv: qTStatus
query: TStatus;
send:
recv: X20000000,0:
send:
recv: M20000000,70:0100000001000000010000000f0000000400000030000008050000001400000806000000140000080a000000190000000b000000100000001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
send: OK
recv: M20000070,c:000000200000000000000000
send: OK
recv: vFlashErase:08000000,00000100
FlashErase: addr:08000000,len:0100
send: OK
recv: vFlashWrite:8000000:/lib/ld-linux.so.3
binary packet 19 -> 20
send: OK
recv: vFlashWrite:8000014:
binary packet 25 -> 26
send: OK
recv: vFlashWrite:8000030:
binary packet 12 -> 12
send: OK
recv: vFlashDone
flash_do: block 08000000 -> 0100
flash_do: page 08000000
2013-09-27T18:23:59 INFO src/stlink-common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
2013-09-27T18:23:59 INFO src/stlink-common.c: Finished erasing 1 pages of 256 (0x100) bytes
2013-09-27T18:23:59 INFO src/stlink-common.c: Starting Half page flash write for STM32L core id
2013-09-27T18:23:59 INFO src/stlink-common.c: Successfully loaded flash loader in sram
2013-09-27T18:23:59 INFO src/stlink-common.c: Starting verification of write complete
2013-09-27T18:23:59 INFO src/stlink-common.c: Flash written and verified! jolly good!
send: OK
recv: Pf=00000008
send: OK
recv: p19
send: 00000001
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qfThreadInfo
query: fThreadInfo;
send:
recv: qL1200000000000000000
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: qSymbol::
query: Symbol;:
send:
recv: g
send: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c6c6962ffffffff00000008
recv: qL1200000000000000000
send:
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: m8000000,4
send: 2f6c6962
recv: p19
send: 00000001
recv: qTStatus
query: TStatus;
send:
recv: qTStatus
query: TStatus;
send:
recv: vKill;a410
send: OK
recv: ?
send: OK
recv: vRun;
send:
recv: R0
KARL - should read back as 0x03, not 60 02 00 00
init watchpoints
send: OK
cannot recv: -2
closing connection
KARL - should read back as 0x03, not 60 02 00 00
init watchpoints
Listening at *:4242...
我的main.c:
#include <stm32l1xx.h>
#include <stm32l1xx_rcc.h>
#include <stm32l1xx_gpio.h>
int main()
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM9, ENABLE);
GPIO_InitTypeDef gpio;
gpio.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
gpio.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOC, &gpio);
GPIO_SetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9);
do __NOP(); while (1);
}
我做错了什么?我感谢任何帮助我的人。
编辑1:
我已将 -nodefaultlibs 添加到链接命令中,因此它现在可以很好地链接。但调试仍然无法正常工作。