抱歉我的英语不好。我的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 ++问题
当我在link命令中删除标志 -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);
}
我做错了什么?我感谢任何帮助我的人。
EDIT1:
我已经在链接命令中添加了-nodefaultlibs,所以它现在链接得很好。但调试仍无法正常工作。
答案 0 :(得分:0)
我认为你的工具链错了。
您正在使用ARM Linux工具链,但我认为您可能需要“ARM EABI”工具链。这将使用-mcpu=cortex-m3 -mthumb
做正确的事。