This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to flash nRF52832 using ST-link v2 in ubuntu 16.04 ??

devzone.nordicsemi.com/.../

Using this link I'm able to build sample code in nRF52 SDK in Ubuntu.

I've customized board based on nrf52832 (Bluey Board) & ST-link v2. As per my understanding we can program nRF52832 using ST-link V2 since it is cortex-m4. But I don't know how ?

How to use nrfjprog utility along with ST-link v2 to flash nRF52832 ?

If it is not possible with nrfjprog then how to do it using openOCD (in Ubuntu 16.04) ?

Thank You !!

Parents
  • primalcortex.wordpress.com/.../

    This link solved my own issue.

    step 1: git clone git://git.code.sf.net/p/openocd/code openocd-code

    step 2: cd openocd-code

    step 3: git pull openocd.zylin.com/openocd refs/changes/15/3215/2

    setp 4: After this we have three conflicting files that have changes that we must deal manually.

    4.1 Replace src/flash/nor/drivers.c with file on this link https://pastebin.com/5X4e9QC2

    And remove or comment line no. 49,50,54,55,105,106,110,111

    4.2 Replace src/flash/nor/Makefile.am with file on this link https://pastebin.com/WaJrKete

    4.3

    Edit tcl/target/nrf52.cfg as

    #---------------------------------------------------------------------------------------------------------------------------------
    #
    # Nordic nRF52 series: ARM Cortex-M4 @ 64 MHz
    #
    
    source [find target/swj-dp.tcl]
    
    if { [info exists CHIPNAME] } {
            set _CHIPNAME $CHIPNAME
    } else {
            set _CHIPNAME nrf52
    }
    
    # Work-area is a space in RAM used for flash programming
    # By default use 16kB
    if { [info exists WORKAREASIZE] } {
       set _WORKAREASIZE $WORKAREASIZE
    } else {
       set _WORKAREASIZE 0x4000
    }
    
    if { [info exists CPUTAPID] } {
            set _CPUTAPID $CPUTAPID
    } else {
            set _CPUTAPID 0x2ba01477
    }
    
    # Work-area is a space in RAM used for flash programming
    # By default use 16kB
    if { [info exists WORKAREASIZE] } {
       set _WORKAREASIZE $WORKAREASIZE
    } else {
       set _WORKAREASIZE 0x4000
    }
    
    swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
    
    set _TARGETNAME $_CHIPNAME.cpu
    target create $_TARGETNAME cortex_m -chain-position $_TARGETNAME
    
    
    adapter_khz 1000
    
    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
    
    flash bank $_CHIPNAME.flash nrf52 0x00000000 0 1 1 $_TARGETNAME
    flash bank $_CHIPNAME.uicr nrf52 0x10001000 0 1 1 $_TARGETNAME
    
    if { ![using_hla] } {
            cortex_m reset_config sysresetreq
    }
    
    #---------------------------------------------------------------------------------------------------------------------------------
    

    4.4 create empty file src/flash/nor/nrf51.c

    step 5: Edit openocd-code/src/flash/nor/nrf52.c as per primalcortex.wordpress.com/.../

    step 6:

    ./bootstrap
    ./configure
    make 
    make install
    

    step 7: create nrf52832.cfg file & add following lines in it

    #nRF52832 Target
    source [find interface/stlink-v2.cfg]
    
    transport select hla_swd
    
    source [find target/nrf52.cfg]
    

    step 8: execute

    openocd -d2 -f nrf52832.cfg 
    

    step 9: Open another terminal & execute ->

    telnet localhosta 4444 
    

    then

    > reset
    > reset halt
    > nrf52 mass_erase
    > program demo.hex verify
    > reset
    

    This will load the code into nRF52832 flash.

    Hope this will help.

Reply
  • primalcortex.wordpress.com/.../

    This link solved my own issue.

    step 1: git clone git://git.code.sf.net/p/openocd/code openocd-code

    step 2: cd openocd-code

    step 3: git pull openocd.zylin.com/openocd refs/changes/15/3215/2

    setp 4: After this we have three conflicting files that have changes that we must deal manually.

    4.1 Replace src/flash/nor/drivers.c with file on this link https://pastebin.com/5X4e9QC2

    And remove or comment line no. 49,50,54,55,105,106,110,111

    4.2 Replace src/flash/nor/Makefile.am with file on this link https://pastebin.com/WaJrKete

    4.3

    Edit tcl/target/nrf52.cfg as

    #---------------------------------------------------------------------------------------------------------------------------------
    #
    # Nordic nRF52 series: ARM Cortex-M4 @ 64 MHz
    #
    
    source [find target/swj-dp.tcl]
    
    if { [info exists CHIPNAME] } {
            set _CHIPNAME $CHIPNAME
    } else {
            set _CHIPNAME nrf52
    }
    
    # Work-area is a space in RAM used for flash programming
    # By default use 16kB
    if { [info exists WORKAREASIZE] } {
       set _WORKAREASIZE $WORKAREASIZE
    } else {
       set _WORKAREASIZE 0x4000
    }
    
    if { [info exists CPUTAPID] } {
            set _CPUTAPID $CPUTAPID
    } else {
            set _CPUTAPID 0x2ba01477
    }
    
    # Work-area is a space in RAM used for flash programming
    # By default use 16kB
    if { [info exists WORKAREASIZE] } {
       set _WORKAREASIZE $WORKAREASIZE
    } else {
       set _WORKAREASIZE 0x4000
    }
    
    swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
    
    set _TARGETNAME $_CHIPNAME.cpu
    target create $_TARGETNAME cortex_m -chain-position $_TARGETNAME
    
    
    adapter_khz 1000
    
    $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
    
    flash bank $_CHIPNAME.flash nrf52 0x00000000 0 1 1 $_TARGETNAME
    flash bank $_CHIPNAME.uicr nrf52 0x10001000 0 1 1 $_TARGETNAME
    
    if { ![using_hla] } {
            cortex_m reset_config sysresetreq
    }
    
    #---------------------------------------------------------------------------------------------------------------------------------
    

    4.4 create empty file src/flash/nor/nrf51.c

    step 5: Edit openocd-code/src/flash/nor/nrf52.c as per primalcortex.wordpress.com/.../

    step 6:

    ./bootstrap
    ./configure
    make 
    make install
    

    step 7: create nrf52832.cfg file & add following lines in it

    #nRF52832 Target
    source [find interface/stlink-v2.cfg]
    
    transport select hla_swd
    
    source [find target/nrf52.cfg]
    

    step 8: execute

    openocd -d2 -f nrf52832.cfg 
    

    step 9: Open another terminal & execute ->

    telnet localhosta 4444 
    

    then

    > reset
    > reset halt
    > nrf52 mass_erase
    > program demo.hex verify
    > reset
    

    This will load the code into nRF52832 flash.

    Hope this will help.

Children
No Data
Related