召唤手臂工具链和eclipse
在Linuxmint Nadia MATE中,我花了很长时间来使用召唤臂工具链与eclipse一起工作。我试图编译一个简单的LED闪烁器示例。我已经将STM32F4的所有目录添加到include路径和#include语句resolve中,但是我得到了各种各样的未解析引用~/bin/sat在我的$PATH中,工具链显然正在被找到。我还得到了一个有趣的未定义的对“\u exit”的引用,它指向了我下载目录中的某个地方,我不明白为什么Eclipse会在那里查看 我是Eclipse(可能很明显)和ARM平台的真正新手,但在windows环境中编程图片方面相当有经验 我有一种感觉,我错过了一些相当简单的事情(除了“退出”这件事),但我还没有找到启发性的时刻(即使相同类型的问题不断出现,我似乎找不到解决方案)。我想在尝试库考克斯之前再问一次召唤手臂工具链和eclipse,c,eclipse,arm,stm32,C,Eclipse,Arm,Stm32,在Linuxmint Nadia MATE中,我花了很长时间来使用召唤臂工具链与eclipse一起工作。我试图编译一个简单的LED闪烁器示例。我已经将STM32F4的所有目录添加到include路径和#include语句resolve中,但是我得到了各种各样的未解析引用~/bin/sat在我的$PATH中,工具链显然正在被找到。我还得到了一个有趣的未定义的对“\u exit”的引用,它指向了我下载目录中的某个地方,我不明白为什么Eclipse会在那里查看 我是Eclipse(可能很明显)和ARM
#include <stm32f4xx_conf.h>
#include "stm32f4xx_gpio.h"
#include "stm32f4_discovery.h"
#include "stm32f4xx_rcc.h"
void Delay(__IO uint32_t nCount) {
while(nCount--) {
}
}
void init_GPIO(void){
GPIO_InitTypeDef GPIO_InitStruct;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13 | GPIO_Pin_12;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStruct);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0; // we want to configure PA0
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN; // we want it to be an input
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;//this sets the GPIO modules clock speed
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; // this sets the pin type to push / pull (as opposed to open drain)
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; // this enables the pulldown resistor --> we want to detect a high level
GPIO_Init(GPIOA, &GPIO_InitStruct); // this passes the configuration to the Init function which takes care of the low level stuff
}
void main(){
init_GPIO();
GPIOD->BSRRL = 0xF000; // set PD12 thru PD15
Delay(1000000L); // wait a short period of time
GPIOD->BSRRH = 0xF000; // reset PD12 thru PD15
uint8_t i = 0;
while(1){
/* Every GPIO port has an input and
* output data register, ODR and IDR
* respectively, which hold the status of the pin
*
* Here the IDR of GPIOA is checked whether bit 0 is
* set or not. If it's set the button is pressed
*/
if(GPIOA->IDR & 0x0001){
// if the number of button presses is greater than 4, reset the counter (we start counting from 0!)
if(i > 3){
i = 0;
}
else{ // if it's smaller than 4, switch the LEDs
switch(i){
case 0:
GPIOD->BSRRL = 0x1000; // this sets LED1 (green)
GPIOD->BSRRH = 0x8000; // this resets LED4 (blue)
break;
case 1:
GPIOD->BSRRL = 0x2000; // this sets LED2 (orange)
GPIOD->BSRRH = 0x1000; // this resets LED1
break;
case 2:
GPIOD->BSRRL = 0x4000; // this sets LED3 (red)
GPIOD->BSRRH = 0x2000; // this resets LED2
break;
case 3:
GPIOD->BSRRL = 0x8000; // this sets LED4
GPIOD->BSRRH = 0x4000; // this resets LED3
break;
}
i++; // increase the counter every time the switch is pressed
}
Delay(3000000L); // add a small delay to debounce the switch
}
}
}
您的工具链正在使用newlib C库。Newlib是一个非常灵活的最小C库,这种灵活性是通过允许您定义库中的一些函数来实现的。这些函数称为“存根”,请参见一些newlib存根的示例实现。例如,通过定义这些函数,您可以使用UART、USB等实现
printf
您案例中的文件exit.c
正在调用存根\u exit
的实现。您可以实现虚拟存根,因为在嵌入式系统上通常不需要此系统调用
编辑:
您可能使用提供的构建脚本构建了召唤臂工具链。此脚本下载newlib并在GCC安装文件夹中添加指向newlib下载位置的符号链接:
# line 420 and 421 of the script:
log "Adding newlib symlink to gcc"
ln -f -s `pwd`/${NEWLIB}/newlib ${GCC}
由于您可能是在文件夹
/home/scott/Downloads/callous arm toolchain master/
中构建工具链的,因此newlib库现在位于此路径的子文件夹中,构建脚本在其中下载了它。您对我的答案满意吗?不太满意。主要部分是stm32库中未解析的调用,以及为什么exit调用正在查找它甚至应该知道的目录。不过谢谢你。我开始认为我可能需要在我的链接路径中包含库中的.c文件,但还没有机会测试这个yetOkay,我编辑了我的答案并给出了解释。关于stm32库,由于没有添加库的.c文件,因此会出现未定义的引用错误,您必须将这些文件添加到正在编译的文件列表中。谢谢。我将尝试验证是否需要将库中的c文件包含在include路径中。在过去的好日子里从没见过这样的场面!谢谢所以我只需要找到链接并指向正确的路径,然后自己退出
# line 420 and 421 of the script:
log "Adding newlib symlink to gcc"
ln -f -s `pwd`/${NEWLIB}/newlib ${GCC}