Конфликтующие профили архитектуры Ошибка A/M при использовании arm-none-linux-gnueabi-gcc
Извините за мой плохой английский. У меня на компьютере есть 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++ Ошибка: /bin/../arm-none-linux-gnueabi/libc/thumb2/lib/libgcc_s.so.1: Конфликтующие профили архитектуры A/M stm32ld_template C/C++ Проблема
Когда я удаляю флаг -mthumb в команде link, ошибок нет. Но когда я пытаюсь отладить программу, она заканчивается 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 в команду link, так что теперь она хорошо работает. Но отладка все еще не работает.
1 ответ
Я думаю, что у вас не тот набор инструментов.
Вы используете набор инструментов ARM Linux, но я думаю, что вам может понадобиться набор инструментов "ARM EABI". Это будет правильно делать с -mcpu=cortex-m3 -mthumb
,