IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    J-Link 命令行工具烧写 N32G430 MCU 固件

    Hacper\'s Blog发表于 2025-05-23 00:49:37
    love 0

    J-Link 提供一个叫做 J-Link Commander (JLink.exe) 的命令行工具,可以使用 J-Link Command File (.jlink script) 方式批量自动化烧录。

    创建一个.jlink后缀的 J-Link 脚本:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    USB
    Device N32G430K8
    If SWD
    Speed 4000
    r
    h
    loadbin firmware.bin, 0x08000000
    r
    g
    exit
    

    在命令行调用指令:

    1
    
    JLink.exe -CommanderScript C:\Users\xxxx\Desktop\j.jlink
    

    烧写固件示例 log:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    
    ~\Desktop via 🐍 v2.7.18
    ❯ JLink.exe -CommanderScript C:\Users\xxxx\Desktop\j.jlink
    SEGGER J-Link Commander V7.94a (Compiled Dec  6 2023 16:07:38)
    DLL version V7.94a, compiled Dec  6 2023 16:06:16
    
    
    J-Link Command File read successfully.
    Processing script file...
    J-Link>USB
    Connecting to J-Link via USB...O.K.
    Firmware: J-Link OB-STM32F072-CortexM compiled Jan  7 2019 14:09:37
    Hardware version: V1.00
    J-Link uptime (since boot): N/A (Not supported by this model)
    S/N: -1
    License(s): GDB, RDI, FlashBP, FlashDL, JFlash, RDDI
    VTref=3.300V
    J-Link>Device N32G430K8
    J-Link>If SWD
    Selecting SWD as current target interface.
    J-Link>Speed 4000
    Selecting 4000 kHz as target interface speed
    J-Link>r
    Target connection not established yet but required for command.
    Device "N32G430K8" selected.
    
    
    Connecting to target via SWD
    Found SW-DP with ID 0x2BA01477
    DPv0 detected
    CoreSight SoC-400 or earlier
    Scanning AP map to find all available APs
    AP[1]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    [0][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7
    [0][1]: E0001000 CID B105E00D PID 003BB002 DWT
    [0][2]: E0002000 CID B105E00D PID 002BB003 FPB
    [0][3]: E0000000 CID B105E00D PID 003BB001 ITM
    [0][4]: E0040000 CID B105900D PID 000BB9A1 TPIU
    Memory zones:
      Zone: "Default" Description: Default access mode
    Cortex-M4 identified.
    Reset delay: 0 ms
    Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    J-Link>h
    PC = 08003244, CycleCnt = 00000000
    R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
    R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
    R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
    R12= 00000000
    SP(R13)= 20004000, MSP= 20004000, PSP= 00000000, R14(LR) = FFFFFFFF
    XPSR = 01000000: APSR = nzcvq, EPSR = 01000000, IPSR = 000 (NoException)
    CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
    
    FPS0 = 00000000, FPS1 = 00000000, FPS2 = 00000000, FPS3 = 00000000
    FPS4 = 00000000, FPS5 = 00000000, FPS6 = 00000000, FPS7 = 00000000
    FPS8 = 00000000, FPS9 = 00000000, FPS10= 00000000, FPS11= 00000000
    FPS12= 00000000, FPS13= 00000000, FPS14= 00000000, FPS15= 00000000
    FPS16= 00000000, FPS17= 00000000, FPS18= 00000000, FPS19= 00000000
    FPS20= 00000000, FPS21= 00000000, FPS22= 00000000, FPS23= 00000000
    FPS24= 00000000, FPS25= 00000000, FPS26= 00000000, FPS27= 00000000
    FPS28= 00000000, FPS29= 00000000, FPS30= 00000000, FPS31= 00000000
    FPSCR= 00000000
    J-Link>loadbin firmware.bin, 0x08000000
    'loadbin': Performing implicit reset & halt of MCU.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    Downloading file [firmware.bin]...
    J-Link: Flash download: Bank 0 @ 0x08000000: Skipped. Contents already match
    O.K.
    J-Link>r
    Reset delay: 0 ms
    Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    J-Link>g
    Memory map 'after startup completion point' is active
    J-Link>exit
    
    Script processing completed.
    


沪ICP备19023445号-2号
友情链接