stm32-arduino-f103

希望给工作中偶尔要用的一些辅助板卡(例如运行信息现场记录)找一个快速开发的手段,Arduino作为流行的开源嵌入硬件框架,组件丰富,资料众多,所以想以Arduino作为平台。但是Arduino板子基本上基于AVR,但是目前日常工作以ARM为主,而且手头也有不少STM32F103的开发板,所以想看一下在一些开发板上跑Arduino的可能性,经过搜索,找到以下两个方案(这是搭建过程记录,比较没有条理):

Arduino_STM32

Arduino_STM32下载以后,直接放到目录<arduino_dir>hardware下(例如“C:arduinohardwareArduino_STM32”)。重启以后,在板卡列表里面,就可以看到新增加的板卡类型了。

BootLoader,用JLink烧写,STM32duino-bootloaderinariesgeneric_boot20_pc13.bin直接烧写就可以,在手头的STM32F103板子上,PC13上加一个LED,跳线J5跳到2-3上(即把USB口配成generic_f103板),驱动需要运行 Arduino_STM32driverswin下的install_drivers.bat来安装,具体原因见:Maple drivers。简单地说,就是用“wdi-simple”来生成Windows需要的签名驱动程序。

更新程序需要连接串口,然后手动复位板卡到Bootloader,然后下载。

板卡如何下载程序可以参考Uploading_a_sketch,目前的结果Boot下的USB下载可以工作,但是串口不行。解决方法是选“STM32duino bootloader”下载,然后在下载的时候,看到信息提示按复位,进入Bootloader,用USB下载。

下载时候出现错误提示:“error resetting after download: usb_reset: could not reset device, win error: The system cannot find the file specified.”,可以直接忽略,见STM32 Bootloader on Win7 64bit

stm32duino

主要参考Getting Started,这应该是偏向于官方的支持,比较正规有条理。

IDE的菜单“File->Perference”,在对话框的“Additional Boards Managers URLs”里,填写“https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json”,然后在菜单“Tools->Board: xxxxxx->Board Manager …”,在对话框中,选择“STM32 Cores”安装。

增加类似的板卡变种:Add a new variant (board)

由于手头最类似的板子是Nucleo F072RB,故需要在“Nucleo F091RC”基础上做一些修改,增加“Nucleo F072RB”板:“%LOCALAPPDATA%Arduino15packagesSTM32hardwarestm321.5.0variants”下,复制“NUCLEO_F091RC”为“NUCLEO_F072RB”,更改“ldscript.ld”里面的芯片存储器定义,去掉“PeripheralPins.c”里面的“I2C1”和“USART5~USART8”相关的定义,运行LED和串口测试程序:

const int pin = 13;
void setup() {
  // put your setup code here, to run once:
  pinMode(pin, OUTPUT);
  Serial.begin(115200);
}
int n = 0;
void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(pin, HIGH);
  delay(1000);
  digitalWrite(pin, LOW);
  delay(1000);
  Serial.print("n=");
  Serial.println(n++);
}

运行正常,LD2闪烁,虚拟串口可以收到打印的信息,OK。

原文地址:https://www.cnblogs.com/dabbler/p/10721318.html