但愿给工做中偶尔要用的一些辅助板卡(例如运行信息现场记录)找一个快速开发的手段,Arduino做为流行的开源嵌入硬件框架,组件丰富,资料众多,因此想以Arduino做为平台。可是Arduino板子基本上基于AVR,可是目前平常工做以ARM为主,并且手头也有很多STM32F103的开发板,因此想看一下在一些开发板上跑Arduino的可能性,通过搜索,找到如下两个方案(这是搭建过程记录,比较没有条理):php
Arduino_STM32下载之后,直接放到目录<arduino_dir>\hardware下(例如“C:\arduino\hardware\Arduino_STM32”)。重启之后,在板卡列表里面,就能够看到新增长的板卡类型了。git
BootLoader,用JLink烧写,STM32duino-bootloader\binaries\generic_boot20_pc13.bin直接烧写就能够,在手头的STM32F103板子上,PC13上加一个LED,跳线J5跳到2-3上(即把USB口配成generic_f103板),驱动须要运行 Arduino_STM32\drivers\win下的install_drivers.bat来安装,具体缘由见:Maple drivers。简单地说,就是用“wdi-simple”来生成Windows须要的签名驱动程序。github
更新程序须要链接串口,而后手动复位板卡到Bootloader,而后下载。json
板卡如何下载程序能够参考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 64bitoop
主要参考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”安装。ui
增长相似的板卡变种:Add a new variant (board)spa
因为手头最相似的板子是Nucleo F072RB,故须要在“Nucleo F091RC”基础上作一些修改,增长“Nucleo F072RB”板:“%LOCALAPPDATA%\Arduino15\packages\STM32\hardware\stm32\1.5.0\variants”下,复制“NUCLEO_F091RC”为“NUCLEO_F072RB”,更改“ldscript.ld”里面的芯片存储器定义,去掉“PeripheralPins.c”里面的“I2C1”和“USART5~USART8”相关的定义,运行LED和串口测试程序:code
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。