Raspberry Pi ISP tools for Embedded Pi

Embedded Pi(http://www.coocox.org/epi.html)是CooCox官方专门为Rspberry Pi的爱好者推出的一款扩展板,它板载STM32F103RB处理器,在兼容Arduino接口的同时也扩展了其他接口,丰富了可接入的设备类型,大大扩展了树莓派的控制功能。但是作为一个Linux用户,对STM32下载是件很困扰的事情,因为Embedded Pi的手册中提到可以用SWD接口和ISP方式下载,但是SWD方式下载会需要一个调试器和Windows操作系统!而ISP方式,手册中并没有提到树莓派下的ISP工具!所以提供一种下载方式很有必要,本文主要介绍如何安装并使用树莓派下的ISP工具。



    You can get STM32Loader from  https://github.com/coocox/stm32loader.   This tool is writen by python .Python script which will talk to the STM32 bootloader to upload and download firmware.Original Version by: Ivan A-R <ivan@tuxotronic.org>


Usage: ./stm32loader.py [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin]
    -h          This help
    -q          Quiet
    -V          Verbose
    -e          Erase
    -w          Write
    -v          Verify
    -r          Read
    -l length   Length of read
    -p port     Serial port (default: /dev/tty.usbserial-ftCYPMYJ)
    -b baud     Baud speed (default: 115200)
    -a addr     Target address


In isp mode raspberry pi can programs the MCU onboard via the serial port(JP7-TX1 and JP7-RX1).refer to 3.6.1(in embedded pi manual). 

To use this mode,you need to do the following things:
1. you need to set BOOT0 to 1 (high level), and BOOT1 to 0 (low level) – which has been done on hardware. In this case, you only need to press the BOOT0 button to enter this mode when Embedded Pi is powered on.

2. you need to connect raspberry pi's uart to embedded pi's uart1 by wires,show as the image:


Then open a Terminal session, 'cd' to wherever you downloaded STM32Loader and then issue the following command to dowmload bin file to embedded pi.


  
  
    
    
  1. sudo python stm32loader.py -e -w -v Test.bin
这时,会提示错误,原因是没有安装PySerial 库(系统默认已经安装了python2.7版本,如果你的树莓派没装,需要安装,这里不给安装过程),下面介绍如何安装 PySerial  库 :

Install PySerial

Whatever your operating system, download the .tar.gz install package for PySerial 2.6 from

https://pypi.python.org/pypi/pyserial

This will give you a file called: pyserial-2.6.tar.gz

If you are using windows you need to uncompress this into a folder. Unfortunately, it is not a normal zip file, so you may need to download a tool such as 7-zip (http://www.7-zip.org/).

If you are using a Mac or Linux computer, then open a Terminal session, 'cd' to wherever you downloaded pyserial-2.6.tar.gz and then issue the following command to unpack the installation folder.

    
    
  1. $ tar -xzf pyserial-2.6.tar.gz

The rest of the procedure is the same whatever your operating system. Use you Comamnd Prompt / Terminal session and “cd” into the pyserial-2.6 folder, then run the command:



    
    
  1. sudo python setup.py install

pyserial_install_dos_1.png

When finished install,then issue the following command to dowmload bin file to embedded pi.


  
  
    
    
  1. sudo python stm32loader.py -e -w -v Test.bin
如果一直提示“NONE”,请重新执行上面的步骤一(按住boot0,reset MCU)。
如果提示NACK之类的错误,请再次执行这个命令。
This will pre-erase flash, write Test.bin to the flash on the device, and then perform a verification after writing is finished.
如下所示,看到Verification OK表示下载成功。


重启 embedded pi 你会看到LED闪烁。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值