使用python制作nRF52832升级包和合成烧录文件的经验(nRF52832 DFU经验分享)
阅读原文时间:2023年07月08日阅读:1

使用python制作nRF52832升级包和合成烧录文件,青风开发板的作者已经说得很明白,不过作者使用的python是2.7的,已经很落后了。目前python已经更新到3.10.4了。所以我换了台电脑之后,安装最新的python,然后就一系列错误。错误主要如下:

ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\longzhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\longzhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "C:\Users\longzhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\commands\install.py", line 405, in run
    installed = install_given_reqs(
  File "C:\Users\longzhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\__init__.py", line 68, in install_given_reqs
    uninstalled_pathset = requirement.uninstall(auto_confirm=True)
  File "C:\Users\longzhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_install.py", line 637, in uninstall
    uninstalled_pathset = UninstallPathSet.from_dist(dist)
  File "C:\Users\longzhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_uninstall.py", line 554, in from_dist
    for script in dist.iterdir("scripts"):
  File "C:\Users\longzhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\metadata\pkg_resources.py", line 156, in iterdir
    if not self._dist.isdir(name):
  File "C:\Users\longzhi\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2816, in __getattr__
    return getattr(self._provider, attr)
AttributeError: 'EggMetadata' object has no attribute 'isdir'

本公司使用的电脑很多文件还是加密的,一直怀疑是因为加密的原因没有制作成功,还到处找人帮忙解密python目录下的加密文件。

起始后来发现方向都错了。总结如下:

一、使用新版本的python,然后使用青风给的pc-nrfutil-master包。

二、使用python2.7,然后使用最新下载的pc-nrfutil-master(6.1.3)

三、使用python3.10.4,然后使用最新下载的pc-nrfutil-master(6.1.3)

四、使用python3.9.13,然后使用最新下载的pc-nrfutil-master(6.1.3),此步骤可以使用nrfutil工具,但是找不到mergehex.exe

上面这些步骤都是错误的体验。最后成功的是使用python3.8.5,然后加载pc-nrfutil-master(6.1.3),加载命令:使用命令行进入pc-nrfutil-master这个文件夹,然后输入"python setup.py install",然后就等待安装,安装完成就可以使用命令制作升级包了。

升级包命令过程如下:

E:\>cd hex

E:\hex>nrfutil pkg generate --application app32_new.hex --application-version 3 --hw-version 52 --sd-req 0xB7 --key-file priv.pem SDK153_app_s132.zip
Zip created at SDK153_app_s132.zip

E:\hex>nrfutil settings generate --family NRF52 --application app32_new.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 settings.hex

Note: Generating a DFU settings page with backup page included.
This is only required for bootloaders from nRF5 SDK 15.1 and newer.
If you want to skip backup page generation, use --no-backup option.

Generated Bootloader DFU settings .hex file and stored it in: settings.hex

Bootloader DFU Settings:
* File: settings.hex
* Family: nRF52
* Start Address: 0x0007F000
* CRC: 0x27DF04E1
* Settings Version: 0x00000002 (2)
* App Version: 0x00000000 (0)
* Bootloader Version: 0x00000000 (0)
* Bank Layout: 0x00000000
* Current Bank: 0x00000000
* Application Size: 0x00014030 (81968 bytes)
* Application CRC: 0x008F0116
* Bank0 Bank Code: 0x00000001
* Softdevice Size: 0x00000000 (0 bytes)
* Boot Validation CRC: 0x614833DB
* SD Boot Validation Type: 0x00000000 (0)
* App Boot Validation Type: 0x00000001 (1)

E:\hex>mergehex.exe --merge bootloader32.hex settings.hex --output b1_temp.hex
Parsing input hex files.
Merging files.
Storing merged file.

E:\hex>mergehex.exe --merge b1_temp.hex app32_new.hex s132_nrf52_6.1.1_softdevice.hex --output whole32.hex
Parsing input hex files.
Merging files.
Storing merged file.

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章