micropython compiling with arm-none-eadi- in cygwin

六月ゝ 毕业季﹏ 提交于 2020-01-13 09:48:59

 

1. Download & Decompression 

1.1 download micropython  

path: http://micropython.org/download/

  

Note: 使用公司的网络git没有安全认证,没有搞定网络,索性就直接下载完整包,本地解压

 

~/micropython
$ git clone https://github.com/micropython/micropython
Cloning into 'micropython'...
remote: Enumerating objects: 75723, done.
remote: Total 75723 (delta 0), reused 0 (delta 0), pack-reused 75723
Receiving objects: 100% (75723/75723), 41.91 MiB | 18.00 KiB/s, done.
Resolving deltas: 100% (54847/54847), done.
Checking out files: 100% (3427/3427), done.

1.2 download gcc-arm-none-eadi compiler

Path:  https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

gcc-arm-none-eabi-8-2019-q3-update-win32.zip

 

1.3 decompression

将下载的文件放入cygwin/home/xxx/ 下,解压缩

unzip micropython-1.12.zip 
mkdir gcc-arm
cd gcc-arm
mv ../gcc-arm-none-eabi-8-2019-q3-update-win32.zip ./
unzip gcc-arm-none-eabi-8-2019-q3-update-win32.zip

2 cygwin environment setting

2.1 cygwin 加载make,pkg-config,gcc-g++,unzip,python3,

复制setup-x86.exe到cygwin安装目录下,点击setup-x86.exe

一路选择next,到Chose a Download Site时,我添加了香港一个URL链接,http://mirror-hk.koddos.net/cygwin/

(在这个网站中找距离你近的网站,方便下载速度https://cygwin.com/mirrors.html)然后再 next。

在 Select Packages中搜索Python3,等需要安装的包,然后next。

2.2 配置cygwin的环境变量,将arm-none-eabi的路径export到PATH变量中

The PATH environment variable is used by Cygwin applications as a list of directories to search for executable files to run. This environment variable is converted from Windows format (e.g. C:\Windows\system32;C:\Windows) to UNIX format (e.g., /cygdrive/c/Windows/system32:/cygdrive/c/Windows) when a Cygwin process first starts. 

临时使用该 环境状态,使用export:

$ export PATH=$PATH:/home/xx/gcc-arm/bin/
$ export PATH=$PATH:/home/xx/gcc-arm/lib/
$ export PATH=$PATH:/home/xx/gcc-arm/arm-none-eabi/bin/
$ export PATH=$PATH:/home/xx/gcc-arm/arm-none-eabi/lib/
$ export PATH=$PATH:/home/xx/gcc-arm/arm-none-eabi/include/
$ export PATH=$PATH:/home/xx/gcc-arm/arm-none-eabi/share/
$ export PATH=$PATH:/home/xx/gcc-arm/share/
$ export PATH=$PATH:/home/xx/gcc-arm/lib/gcc/arm-none-eabi/8.3.1/
$ export PATH=$PATH:/home/xx/gcc-arm/lib/gcc/arm-none-eabi/8.3.1/include
$ export PATH=$PATH:/home/xx/gcc-arm/lib/gcc/arm-none-eabi/8.3.1/bin
$ export PATH=$PATH:/home/xx/gcc-arm/lib/gcc/arm-none-eabi/8.3.1/lib
$ export PATH=$PATH:/home/xx/gcc-arm/lib/gcc/arm-none-eabi/8.3.1/share

永久性的设置环境变量:

To add a directory to the path permanently, add it to the Windows PATH variable: in Start Menu/Settings/Control Panel/System/Advanced/Environment Variables, Edit the variable PATH

3.Compiling

REF: https://github.com/micropython/micropython

3.1 The MicroPython cross-compiler, mpy-cross

Most ports require the MicroPython cross-compiler to be built first. This program, called mpy-cross, is used to pre-compile Python scripts to .mpy files which can then be included (frozen) into the firmware/executable for a port. To build mpy-cross use:

$ cd mpy-cross
$ make

 

3.2 The STM32 version

The "stm32" port requires an ARM compiler, arm-none-eabi-gcc, and associated bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils, arm-none-eabi-gcc and arm-none-eabi-newlib packages. Otherwise, try here: https://launchpad.net/gcc-arm-embedded

To build:

$ cp -r STM32F4DISC MYBOARD

$ cd ../

$ make BOARD=MYBOARD

 

XXX@XXX ~/micropython-1.12/ports/stm32/boards
$ cp -r STM32F4DISC MYBOARD

XXX@XXX ~/micropython-1.12/ports/stm32/boards
$ cd ../

XXX@XXX ~/micropython-1.12/ports/stm32
$ make BOARD=MYBOARD
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
mkdir -p build-MYBOARD/genhdr
GEN build-MYBOARD/genhdr/pins.h
GEN stmconst build-MYBOARD/modstm_qstr.h
.
.
.
LINK build-MYBOARD/firmware.elf
   text    data     bss     dec     hex filename
 324284      32   26980  351296   55c40 build-MYBOARD/firmware.elf
GEN build-MYBOARD/firmware.dfu
GEN build-MYBOARD/firmware.hex

 

4 Flash the firmware.hex or firmware.dfu to your Board

connect BOOT0 to 3V3

USE STM32 ST-LINK Unity  tool for flashing “firmware.hex”.

5 ISSUE: " /bin/sh: -c: line 0: syntax error near unexpected token `(' "

CC ../../lib/oofatfs/ffunicode.c
CC build-HIBOARD/pins_HIBOARD.c
LINK build-HIBOARD/firmware.elf
/bin/sh: -c: line 0: syntax error near unexpected token `('
 

这个应该是编译器放置的路径问题Windows中的路径有空格和()的话,要加转义字符反斜杠 \ 到空格和()前。编译器要是识别有问题,就会报错,解决的方法就是将arm编译工具链放到cygwin下。

 

6 实现STM32407板子使用dfu firmware

待续。。。

 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!