You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用OpenOCD解锁nrf51822芯片的Flash?

解锁nRF51822锁定的Flash

问题背景

购买的nRF51822芯片Flash被锁定,使用树莓派上的OpenOCD-spi调试时出现以下日志:

Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

Info : only one transport option; autoselect 'swd'
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : BCM2835 SPI SWD driver
Info : SWD only mode enabled
Info : clock speed 31200 kHz
Info : SWD DPIDR 0x0bb11477
Error: Could not find MEM-AP to control the core <--- locked flash
Info : Listening on port 3333 for gdb connections

备注:

  • 在Raspberry Pi上使用OpenOCD-spi
  • 芯片已被正确识别
  • 尝试设置nrf52的解锁寄存器,但无效

解决方案

nRF51822的Flash解锁逻辑和nRF52完全不同,不要混用寄存器操作,按以下步骤操作:

1. 适配nRF51822的OpenOCD配置

确保使用针对nRF51系列的配置文件,而非nRF52的。可以创建或修改nrf51.cfg文件,内容如下:

source [find interface/bcm2835spi.cfg]
transport select swd

source [find target/nrf51.cfg]

2. 执行全擦除解锁

通过OpenOCD的telnet接口执行全擦除(此操作会清除Flash所有内容,包括锁定信息):

  1. 启动OpenOCD:openocd -f nrf51.cfg
  2. 新开终端连接telnet:telnet localhost 4444
  3. 在telnet会话中输入命令:
nrf51 mass_erase

执行完成后重启OpenOCD,即可正常访问MEM-AP和芯片核心。

3. 降低SWD时钟提升稳定性

如果操作失败,尝试降低SWD时钟速度,在配置文件中修改:

adapter speed 1000  # 将31200kHz降至1000kHz

树莓派SPI转SWD在高速下容易出现连接不稳定问题,降速可提升可靠性。

4. 硬件复位配合操作

若仍无法解锁,可结合硬件复位操作:

  • 按住芯片RESET引脚保持低电平
  • 在telnet中输入nrf51 mass_erase
  • 松开RESET引脚,等待命令执行完成

内容的提问来源于stack exchange,提问作者aguaviva

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 04:40:33