# powershell-flash **Repository Path**: opensource_wangyan/powershell-flash ## Basic Information - **Project Name**: powershell-flash - **Description**: 通过openocd来进行程序下载的powershell模块 - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-06-12 - **Last Updated**: 2024-06-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Powershell模块说明 此模块的功能是进行嵌入式固件的下载。我目前使用的`powershell`版本为7.2.4。 # 目前支持的芯片 * efm32pg12 # 安装模块 目前模块已经上传到`powershellgallery`上,所以直接采用`powershell`的模块安装就好。 ```powershell Install-Module -Name powershell-flash ``` ![module安装路径](doc/img/module-01.png) 然后我们需要在`powershell`的启动脚本里导入模块。 打开启动脚本: ```powershell notepad.exe $Profile ``` 在文件里添加: ```powershell Import-Module powershell-flash ``` ![module安装路径](doc/img/module-02.png) 通过如下指令测试模块是否安装完成: ```shell Get-Module ``` ![module安装路径](doc/img/module-03.png) # 更新模块 ```powershell Update-Module -Name powershell-flash ``` # 卸载模块 ```powershell Uninstall-Module -Name powershell-flash ``` 然后把启动文件里的模块导入去掉。 打开启动脚本: ```powershell notepad.exe $Profile ``` 去除模块导入,删除以下行: ```powershell Import-Module powershell-flash ``` # 模块导出的函数 * efm_flash: 下载EFMPG12芯片的固件 * -app_filename: 固件名称(`.hex/.bin`),固定位置0 * -boot_filename_hex: boot固件名称,必须是hex格式,只有在app_filename为bin类型时有效,固定位置1,默认值"bootloader.hex" * -address: 固件地址,只有在app_filename为bin类型时有效,固定位置2,默认值0x5000 * -earse_all: 是否全部擦除芯片,只有在app_filename为bin类型时有效,固定位置3,默认值false * efm_select_factory: 选择EFMPG12芯片的厂测步骤 * efm_unlock: 解锁EFMPG12芯片 * efm_erase_all: EFM32PG12芯片全部擦除 # 使用方式 以efm32pg12芯片为例: ```powershell efm_flash <需要下载固件名称> <需要下载的boot文件(只对bin文件有效,且此文件为hex格式)> <需要下载固件地址(只对bin文件有效)> <是否需要全部擦除(只对bin文件有效)> efm_select_factory efm_unlock efm_erase_all ``` 下载`.hex`文件: ```powershell efm_flash .\openocd\DFV_lock-EFM32x.hex ``` 下载`.bin`文件: ```powershell efm_flash .\factory_mcu_module_application_log_header.bin .\bootload.hex 0x5000 ``` 擦除整个芯片后,下载`.bin`文件: ```powershell efm_flash .\factory_mcu_module_application_log_header.bin .\bootload.hex 0x5000 -earse_all ``` 选择厂测步骤 ```powershell efm_select_factory ``` 解锁芯片 ```powershell efm_unlock ``` 擦除整个芯片 ```powershell efm_erase_all ``` # 外部依赖 ## Jlink 我们需要下载[jlink](https://www.segger.com/downloads/jlink/),目前我使用的版本为7.54a。 下载`jlink`: ![jlink下载](doc/img/jlink.png) 至于`jlink`的安装,直接通过我们下载的`exe`安装就好 ## Simplicity Commander [Simplicity Commander](https://www.silabs.com/developers/mcu-programming-options)是silabs芯片的下载工具。 下载`Simplicity Commander`: ![commander下载](doc/img/commander-1.png) 下载完成后将`Simplicity Commander`解压在一个路径下,然后将这个路经配置到环境变量里: ![commander配置](doc/img/commander-2.png) ## 推送模块到powershellgallery的指令 **测试是否可以提交** ```powershell Publish-Module ` -Path <模块路径> ` -NuGetApiKey ` -ProjectUri <项目的git地址> ` -WhatIf ` -Verbose ``` **正真提交** ```powershell Publish-Module ` -Path <模块路径> ` -NuGetApiKey ` -ProjectUri <项目的git地址> ` -Verbose ```