最近项目中需要用到F0批量下载,找到了坛友分享的下载器:
https://www.amobbs.com/thread-5707404-1-1.html?_dsign=c0fd7dd4
作为一个新手,遇到了很多坑,第一步就是安装python一定要安装python2.7 并且是32位版本
python2.7:
https://www.python.org/ftp/python/2.7.14/python-2.7.14rc1.msi
Pyqt一定也要是32位的
PyQT4:
https://master.dl.sourceforge.ne ... 2.7-Qt4.8.6-x32.exe
安装64位的python会导致Python调试出现OSError: [WinError 193] %1 不是有效的 Win32 应用程序,
一般来讲是因为python位数和dll位数不一样导致的,dll是32位的,而python是64位的。
我的系统是64位Win10安装了64位的python,当调用32位dll的时候,就报错。
如何解决:
1、安装64位的dll(一般很难找到JlinkArm.dll好像没有64位的)
2、安装32位的python
但是在安装pyinstaller,进入目录输入pyinstaller -F MCUProg.py后又会一闪而过,截图截到提示的 API 'QString' has already been set to version 1
这里就需要进入D:Python27Libsite-packagesPyInstallerloader
thookspyi_rth_qt4plugins.py修改如下:
- import os
- import sys
- import sip
- sip.setapi(u'QDate', 2)
- sip.setapi(u'QDateTime', 2)
- sip.setapi(u'QString', 2)
- sip.setapi(u'QTextStream', 2)
- sip.setapi(u'QTime', 2)
- sip.setapi(u'QUrl', 2)
- sip.setapi(u'QVariant', 2)
- d = "qt4_plugins"
- d = os.path.join(sys._MEIPASS, d)
- # We remove QT_PLUGIN_PATH variable, beasuse we want Qt4 to load
- # plugins only from one path.
- if 'QT_PLUGIN_PATH' in os.environ:
- # On some platforms (e.g. AIX) 'os.unsetenv()' is not available and then
- # deleting the var from os.environ does not delete it from the environment.
- # In those cases we cannot delete the variable but only set it to the
- # empty string.
- os.environ['QT_PLUGIN_PATH'] = ''
- del os.environ['QT_PLUGIN_PATH']
- # We cannot use QT_PLUGIN_PATH here, because it would not work when
- # PyQt4 is compiled with a different CRT from Python (eg: it happens
- # with Riverbank's GPL package).
- # Suppose that the user usually does not use both (PySide and PyQt4)
- # in the same app.
- # First try importing PySide and then fallback to PyQt4.
- try:
- from PySide.QtCore import QCoreApplication
- except ImportError:
- from PyQt4.QtCore import QCoreApplication
- # We set "qt4_plugins" as only one path for Qt4 plugins
- QCoreApplication.setLibraryPaths([os.path.abspath(d)])
复制代码
改好后打包即可。
在这两个都安装好了之后即可运行添加器件的操作,
我以STM32F0单片机为例说明以下:
第一步:从Keil MDK的*.FLM文件中解析出烧写算法代码和信息
将 D:SoftwareKeil_v5ARMPacksKeilSTM32F0xx_DFP1.5.0FlashSTM32F0xx_16.FLM 文件拷贝到 JMCUProgFastFlashAlgo 目录下,双击该目录下的 flash_algo.py 文件执行,会在该目录下生成 STM32F0xx_16.py
第二步:为想要添加的器件新建一个类
在 JMCUProgFastdevice 目录下新建 STM32F030.py 文件,并添加如下内容:
- #coding: utf-8
- from .flash import Flash
- class STM32F030F4(object):
- CHIP_CORE = 'Cortex-M0'
-
- PAGE_SIZE = 1024 * 1
- SECT_SIZE = 1024 * 1
- CHIP_SIZE = 1024 * 16
- def __init__(self, jlink):
- super(STM32F030F4, self).__init__()
-
- self.jlink = jlink
- self.flash = Flash(self.jlink, STM32F030F4_flash_algo)
- def sect_erase(self, addr, size):
- self.flash.Init(0, 0, 1)
- for i in range(addr // self.SECT_SIZE, (addr + size + (self.SECT_SIZE - 1)) // self.SECT_SIZE):
- self.flash.EraseSector(self.SECT_SIZE * i)
- self.flash.UnInit(1)
- def chip_write(self, addr, data):
- if len(data)%self.PAGE_SIZE:
- data = data + [0xFF] * (self.PAGE_SIZE - len(data)%self.PAGE_SIZE)
- self.sect_erase(addr, len(data))
- self.flash.Init(0, 0, 2)
- for i in range(0, len(data)//self.PAGE_SIZE):
- self.flash.ProgramPage(0x08000000 + addr + self.PAGE_SIZE * i, data[self.PAGE_SIZE*i : self.PAGE_SIZE*(i+1)])
- self.flash.UnInit(2)
- def chip_read(self, addr, size, buff):
- data = self.jlink.read_mem(0x08000000 + addr, size)
- buff.extend([ord(x) for x in data])
- STM32F030F4_flash_algo = {
- 'load_address' : 0x20000000,
- 'instructions' : [
- 0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
- 0x49454846, 0x49466041, 0x21006041, 0x68C16001, 0x43112214, 0x69C060C1, 0xD4060740, 0x49414842,
- 0x21066001, 0x49416041, 0x20006081, 0x483B4770, 0x22806901, 0x61014311, 0x47702000, 0x4837B530,
- 0x241468C1, 0x60C14321, 0x25046901, 0x61014329, 0x22406901, 0x61014311, 0x4A334935, 0x6011E000,
- 0x07DB68C3, 0x6901D1FB, 0x610143A9, 0x422168C1, 0x68C1D004, 0x60C14321, 0xBD302001, 0xBD302000,
- 0x4926B530, 0x231468CA, 0x60CA431A, 0x2402690A, 0x610A4322, 0x69086148, 0x43102240, 0x48246108,
- 0xE0004A21, 0x68CD6010, 0xD1FB07ED, 0x43A06908, 0x68C86108, 0xD0034018, 0x431868C8, 0x200160C8,
- 0xB5F0BD30, 0x1C494D15, 0x68EB0849, 0x24040049, 0x60EB4323, 0x4C162714, 0x692BE01A, 0x43332601,
- 0x8813612B, 0x4B108003, 0x601CE000, 0x07F668EE, 0x692BD1FB, 0x005B085B, 0x68EB612B, 0xD004423B,
- 0x433868E8, 0x200160E8, 0x1C80BDF0, 0x1E891C92, 0xD1E22900, 0xBDF02000, 0x45670123, 0x40022000,
- 0xCDEF89AB, 0x00005555, 0x40003000, 0x00000FFF, 0x0000AAAA, 0x00000000
- ],
- 'pc_Init' : 0x20000021,
- 'pc_UnInit' : 0x2000004F,
- 'pc_EraseSector' : 0x200000A1,
- 'pc_ProgramPage' : 0x200000E3,
- 'pc_Verify' : 0x12000001F,
- 'pc_EraseChip' : 0x2000005D,
- 'pc_BlankCheck' : 0x12000001F,
- 'pc_Read' : 0x12000001F,
-
- 'static_base' : 0x20000400,
- 'begin_data' : 0x20000800,
- 'begin_stack' : 0x20001000,
- 'analyzer_supported' : False,
- # Relative region addresses and sizes
- 'ro_start' : 0x00000000,
- 'ro_size' : 0x00000134,
- 'rw_start' : 0x00000134,
- 'rw_size' : 0x00000004,
- 'zi_start' : 0x00000138,
- 'zi_size' : 0x00000000,
- # Flash information
- 'flash_start' : 0x08000000,
- 'flash_size' : 0x00004000,
- 'flash_page_size' : 0x00000400,
- 'sector_sizes': (
- (0x00000, 0x00400),
- )
- }
复制代码
然后即可运行打包!
附上我打包好的:
编程器.zip
(11.63 MB, 下载次数: 6)
2019-10-11 13:58 上传
点击文件名下载附件
一周热门 更多>