From 7f50be8d730f71247bce50df354382c0c9ef4dfa Mon Sep 17 00:00:00 2001 From: micooke Date: Mon, 21 Aug 2017 15:07:53 +0930 Subject: [PATCH 1/5] Add support for Black Magic Probe --- platform.txt | 32 ++++++++++++++++++++++++++++---- programmers.txt | 28 ++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/platform.txt b/platform.txt index 8fc5e800..972d416a 100644 --- a/platform.txt +++ b/platform.txt @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA name=Nordic Semiconductor nRF5 Boards -version=0.4.0 +version=0.3.0 # Compile variables # ----------------- @@ -116,11 +116,11 @@ tools.openocd.cmd.windows=bin/openocd.exe tools.openocd.upload.params.verbose=-d2 tools.openocd.upload.params.quiet=-d0 -tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -f interface/{upload.protocol}.cfg -c "{upload.setup_command}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" tools.openocd.program.params.verbose=-d2 tools.openocd.program.params.quiet=-d0 -tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -f interface/{program.protocol}.cfg -c "{program.setup_command}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" tools.openocd.erase.params.verbose=-d3 tools.openocd.erase.params.quiet=-d0 @@ -128,4 +128,28 @@ tools.openocd.erase.pattern= tools.openocd.bootloader.params.verbose=-d2 tools.openocd.bootloader.params.quiet=-d0 -tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -f interface/{program.protocol}.cfg -c "{program.setup_command}" -f target/{upload.target}.cfg -c "init; halt; nrf51 mass_erase; program {{{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/{softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex}} verify reset; shutdown;" + +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "init; halt; nrf51 mass_erase; program {{{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/{softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex}} verify reset; shutdown;" + +# blackmagic probe upload +tools.bmp_upload.cmd=arm-none-eabi-gdb +tools.bmp_upload.path={runtime.tools.gcc-arm-none-eabi-5_2-2015q4.path}/bin/ + +tools.bmp_upload.upload.speed=230400 + +tools.bmp_upload.erase.params.verbose= +tools.bmp_upload.erase.params.quiet=-q --batch-silent +tools.bmp_upload.erase.pattern="{path}{cmd}" -quiet -cd "{build.path}" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "monitor erase mass" -ex "echo \n\n\Erase finished!" -ex "detach" -ex "quit" + +tools.bmp_upload.upload.params.verbose= +tools.bmp_upload.upload.params.quiet=-q --batch-silent +tools.bmp_upload.upload.pattern="{path}{cmd}" -quiet -cd "{build.path}" -b {upload.speed} -l 10 -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 10" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "file {build.project_name}.elf" -ex "load" -ex "tbreak main" -ex "run" -ex "echo \n\n\nUpload finished!\n" -ex "quit" + +tools.bmp_upload.program.params.verbose= +tools.bmp_upload.program.params.quiet=-q --batch-silent +tools.bmp_upload.program.pattern="{path}{cmd}" -quiet -cd "{build.path}" -b {upload.speed} -l 10 -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 10" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "file {build.project_name}.elf" -ex "load" -ex "tbreak main" -ex "run" -ex "echo \n\n\nProgram finished!\n" -ex "quit" +#tools.bmp_upload.program.pattern="{path}{cmd}" -quiet -cd "{build.path}" -b {upload.speed} -l 10 -ex "set debug remote 0" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "file {build.project_name}.elf" -ex "load" -ex "run" -ex "echo \n\n\nProgram finished!\n" -ex "quit" + +tools.bmp_upload.bootloader.params.verbose= +tools.bmp_upload.bootloader.params.quiet=-q --batch-silent +tools.bmp_upload.bootloader.pattern="{path}/{cmd}" -quiet -cd "{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "monitor erase mass" -ex "detach" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "load {softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex" -ex "echo \n\n\nSoftdevice Uploaded!\n" -ex "detach" -ex "quit" \ No newline at end of file diff --git a/programmers.txt b/programmers.txt index 45663a61..93321584 100644 --- a/programmers.txt +++ b/programmers.txt @@ -1,20 +1,36 @@ jlink.name=J-Link jlink.communication=USB jlink.protocol=jlink -jlink.program.protocol=jlink +jlink.program.protocol= jlink.program.tool=openocd -jlink.program.setup_command=transport select swd; set WORKAREASIZE 0; +#jlink.program.interface=jlink +#jlink.program.setup_command=transport select swd; set WORKAREASIZE 0; +jlink.program.extra_params=transport select swd; set WORKAREASIZE 0; stlink.name=ST-Link V2 stlink.communication=USB stlink.protocol=stlink-v2 -stlink.program.protocol=stlink-v2 +stlink.program.protocol= stlink.program.tool=openocd -stlink.program.setup_command=transport select hla_swd; set WORKAREASIZE 0x4000; +#stlink.program.interface=stlink-v2 +#stlink.program.setup_command=transport select hla_swd; set WORKAREASIZE 0x4000; +stlink.program.extra_params=transport select hla_swd; set WORKAREASIZE 0x4000; cmsisdap.name=CMSIS-DAP cmsisdap.communication=USB cmsisdap.protocol=cmsis-dap -cmsisdap.program.protocol=cmsis-dap +cmsisdap.program.protocol= cmsisdap.program.tool=openocd -cmsisdap.program.setup_command=; +#cmsisdap.program.interface=cmsis-dap +#cmsisdap.program.setup_command=; +cmsisdap.program.extra_params=; + +bmp.name=BMP (Black Magic Probe) +bmp.communication=USB +bmp.protocol= +bmp.program.protocol= +bmp.erase.tool=bmp_upload +bmp.upload.tool=bmp_upload +bmp.program.tool=bmp_upload +bmp.bootloader.tool=bmp_upload +bmp.program.extra_params=; From f27bf9b6da2de467dbec59421be846cc837e50e3 Mon Sep 17 00:00:00 2001 From: micooke Date: Tue, 22 Aug 2017 08:43:04 +0930 Subject: [PATCH 2/5] Revert changes to openocd methods to be inline with version 0.4.0 --- platform.txt | 9 ++++----- programmers.txt | 18 ++++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/platform.txt b/platform.txt index 972d416a..24d9f536 100644 --- a/platform.txt +++ b/platform.txt @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA name=Nordic Semiconductor nRF5 Boards -version=0.3.0 +version=0.4.0 # Compile variables # ----------------- @@ -116,11 +116,11 @@ tools.openocd.cmd.windows=bin/openocd.exe tools.openocd.upload.params.verbose=-d2 tools.openocd.upload.params.quiet=-d0 -tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -f interface/{upload.protocol}.cfg -c "{upload.setup_command}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" tools.openocd.program.params.verbose=-d2 tools.openocd.program.params.quiet=-d0 -tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -f interface/{program.protocol}.cfg -c "{program.setup_command}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" tools.openocd.erase.params.verbose=-d3 tools.openocd.erase.params.quiet=-d0 @@ -128,8 +128,7 @@ tools.openocd.erase.pattern= tools.openocd.bootloader.params.verbose=-d2 tools.openocd.bootloader.params.quiet=-d0 - -tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "init; halt; nrf51 mass_erase; program {{{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/{softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex}} verify reset; shutdown;" +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -f interface/{program.protocol}.cfg -c "{program.setup_command}" -f target/{upload.target}.cfg -c "init; halt; nrf51 mass_erase; program {{{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/{softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex}} verify reset; shutdown;" # blackmagic probe upload tools.bmp_upload.cmd=arm-none-eabi-gdb diff --git a/programmers.txt b/programmers.txt index 93321584..8516ce56 100644 --- a/programmers.txt +++ b/programmers.txt @@ -1,29 +1,23 @@ jlink.name=J-Link jlink.communication=USB jlink.protocol=jlink -jlink.program.protocol= +jlink.program.protocol=jlink jlink.program.tool=openocd -#jlink.program.interface=jlink -#jlink.program.setup_command=transport select swd; set WORKAREASIZE 0; -jlink.program.extra_params=transport select swd; set WORKAREASIZE 0; +jlink.program.setup_command=transport select swd; set WORKAREASIZE 0; stlink.name=ST-Link V2 stlink.communication=USB stlink.protocol=stlink-v2 -stlink.program.protocol= +stlink.program.protocol=stlink-v2 stlink.program.tool=openocd -#stlink.program.interface=stlink-v2 -#stlink.program.setup_command=transport select hla_swd; set WORKAREASIZE 0x4000; -stlink.program.extra_params=transport select hla_swd; set WORKAREASIZE 0x4000; +stlink.program.setup_command=transport select hla_swd; set WORKAREASIZE 0x4000; cmsisdap.name=CMSIS-DAP cmsisdap.communication=USB cmsisdap.protocol=cmsis-dap -cmsisdap.program.protocol= +cmsisdap.program.protocol=cmsis-dap cmsisdap.program.tool=openocd -#cmsisdap.program.interface=cmsis-dap -#cmsisdap.program.setup_command=; -cmsisdap.program.extra_params=; +cmsisdap.program.setup_command=; bmp.name=BMP (Black Magic Probe) bmp.communication=USB From 9c9bc3fd0481c2cdae7f31b3194631dfb3d1f92e Mon Sep 17 00:00:00 2001 From: micooke Date: Tue, 22 Aug 2017 08:43:04 +0930 Subject: [PATCH 3/5] * Revert changes to openocd methods to be inline with version 0.4.0 * Incorporate changes based off feedback from @sandeepmistry and @dmikhalsky --- README.md | 7 +++++++ platform.txt | 42 +++++++++++++++++++++--------------------- programmers.txt | 28 +++++++++++----------------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index b3fc0e2c..134065fd 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,13 @@ For 64-bit Linux users, ```libc6:i386```, ```libstdc++6:i386```, ```libncurses5 __NOTE__: To roll back to the original driver go to: Device Manager -> Right click on device -> Check box for "Delete the driver software for this device" and click Uninstall +###### Driver Setup for Black Magic Probe +1. Download .inf file drivers from [blacksphere github](https://github.com/blacksphere/blackmagic/tree/master/driver) +2. Plugin Black Magic Probe +3. Point the installer to the folder containing blackmagic.inf + +__NOTE__: If using Windows 10 or Linux then two UART COM ports will be visible without requiring additional drivers + ### Selecting a SoftDevice SoftDevices contain the BLE stack and housekeeping, and must be downloaded once before a sketch using BLE can be loaded. The SD consumes ~5k of Ram + some extra based on actual BLE configuration. diff --git a/platform.txt b/platform.txt index 972d416a..e5241f01 100644 --- a/platform.txt +++ b/platform.txt @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA name=Nordic Semiconductor nRF5 Boards -version=0.3.0 +version=0.4.0 # Compile variables # ----------------- @@ -116,11 +116,11 @@ tools.openocd.cmd.windows=bin/openocd.exe tools.openocd.upload.params.verbose=-d2 tools.openocd.upload.params.quiet=-d0 -tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -f interface/{upload.protocol}.cfg -c "{upload.setup_command}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" tools.openocd.program.params.verbose=-d2 tools.openocd.program.params.quiet=-d0 -tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -f interface/{program.protocol}.cfg -c "{program.setup_command}" -f target/{upload.target}.cfg -c "program {{{build.path}/{build.project_name}.hex}} verify reset; shutdown;" tools.openocd.erase.params.verbose=-d3 tools.openocd.erase.params.quiet=-d0 @@ -128,28 +128,28 @@ tools.openocd.erase.pattern= tools.openocd.bootloader.params.verbose=-d2 tools.openocd.bootloader.params.quiet=-d0 +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -f interface/{program.protocol}.cfg -c "{program.setup_command}" -f target/{upload.target}.cfg -c "init; halt; nrf51 mass_erase; program {{{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/{softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex}} verify reset; shutdown;" -tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -f interface/{protocol}.cfg -c "{program.extra_params}" -f target/{upload.target}.cfg -c "init; halt; nrf51 mass_erase; program {{{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/{softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex}} verify reset; shutdown;" - +# # blackmagic probe upload -tools.bmp_upload.cmd=arm-none-eabi-gdb -tools.bmp_upload.path={runtime.tools.gcc-arm-none-eabi-5_2-2015q4.path}/bin/ +# +tools.blackmagicprobe.path={runtime.tools.gcc-arm-none-eabi-5_2-2015q4.path}/bin/ +tools.blackmagicprobe.cmd=arm-none-eabi-gdb -tools.bmp_upload.upload.speed=230400 +tools.blackmagicprobe.upload.speed=230400 -tools.bmp_upload.erase.params.verbose= -tools.bmp_upload.erase.params.quiet=-q --batch-silent -tools.bmp_upload.erase.pattern="{path}{cmd}" -quiet -cd "{build.path}" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "monitor erase mass" -ex "echo \n\n\Erase finished!" -ex "detach" -ex "quit" +tools.blackmagicprobe.erase.params.verbose= +tools.blackmagicprobe.erase.params.quiet=-q --batch-silent +tools.blackmagicprobe.erase.pattern="{path}{cmd}" -quiet -cd "{build.path}" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "monitor erase mass" -ex "echo \nErase finished!\n" -ex "detach" -ex "quit" -tools.bmp_upload.upload.params.verbose= -tools.bmp_upload.upload.params.quiet=-q --batch-silent -tools.bmp_upload.upload.pattern="{path}{cmd}" -quiet -cd "{build.path}" -b {upload.speed} -l 10 -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 10" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "file {build.project_name}.elf" -ex "load" -ex "tbreak main" -ex "run" -ex "echo \n\n\nUpload finished!\n" -ex "quit" +tools.blackmagicprobe.upload.params.verbose= +tools.blackmagicprobe.upload.params.quiet=-q --batch-silent +tools.blackmagicprobe.upload.pattern="{path}{cmd}" -quiet -cd "{build.path}" -b {upload.speed} -l 10 -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 10" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "file {build.project_name}.elf" -ex "load" -ex "tbreak main" -ex "run" -ex "echo \nUpload complete!\n" -ex "quit" -tools.bmp_upload.program.params.verbose= -tools.bmp_upload.program.params.quiet=-q --batch-silent -tools.bmp_upload.program.pattern="{path}{cmd}" -quiet -cd "{build.path}" -b {upload.speed} -l 10 -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 10" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "file {build.project_name}.elf" -ex "load" -ex "tbreak main" -ex "run" -ex "echo \n\n\nProgram finished!\n" -ex "quit" -#tools.bmp_upload.program.pattern="{path}{cmd}" -quiet -cd "{build.path}" -b {upload.speed} -l 10 -ex "set debug remote 0" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "file {build.project_name}.elf" -ex "load" -ex "run" -ex "echo \n\n\nProgram finished!\n" -ex "quit" +tools.blackmagicprobe.program.params.verbose= +tools.blackmagicprobe.program.params.quiet=-q --batch-silent +tools.blackmagicprobe.program.pattern="{path}{cmd}" -quiet -cd "{build.path}" -b {upload.speed} -l 10 -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 10" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "file {build.project_name}.elf" -ex "load" -ex "tbreak main" -ex "run" -ex "echo \nProgram complete!\n" -ex "quit" -tools.bmp_upload.bootloader.params.verbose= -tools.bmp_upload.bootloader.params.quiet=-q --batch-silent -tools.bmp_upload.bootloader.pattern="{path}/{cmd}" -quiet -cd "{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "monitor erase mass" -ex "detach" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "load {softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex" -ex "echo \n\n\nSoftdevice Uploaded!\n" -ex "detach" -ex "quit" \ No newline at end of file +tools.blackmagicprobe.bootloader.params.verbose= +tools.blackmagicprobe.bootloader.params.quiet=-q --batch-silent +tools.blackmagicprobe.bootloader.pattern="{path}{cmd}" -quiet -cd "{runtime.platform.path}/cores/nRF5/SDK/components/softdevice/{softdevice}/hex/" -ex "target extended-remote \\.\{serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "monitor erase mass" -ex "load {softdevice}_{upload.target}_{softdeviceversion}_softdevice.hex" -ex "echo \nSoftdevice upload complete!\n" -ex "detach" -ex "quit" \ No newline at end of file diff --git a/programmers.txt b/programmers.txt index 93321584..31aa30be 100644 --- a/programmers.txt +++ b/programmers.txt @@ -1,36 +1,30 @@ jlink.name=J-Link jlink.communication=USB jlink.protocol=jlink -jlink.program.protocol= +jlink.program.protocol=jlink jlink.program.tool=openocd -#jlink.program.interface=jlink -#jlink.program.setup_command=transport select swd; set WORKAREASIZE 0; -jlink.program.extra_params=transport select swd; set WORKAREASIZE 0; +jlink.program.setup_command=transport select swd; set WORKAREASIZE 0; stlink.name=ST-Link V2 stlink.communication=USB stlink.protocol=stlink-v2 -stlink.program.protocol= +stlink.program.protocol=stlink-v2 stlink.program.tool=openocd -#stlink.program.interface=stlink-v2 -#stlink.program.setup_command=transport select hla_swd; set WORKAREASIZE 0x4000; -stlink.program.extra_params=transport select hla_swd; set WORKAREASIZE 0x4000; +stlink.program.setup_command=transport select hla_swd; set WORKAREASIZE 0x4000; cmsisdap.name=CMSIS-DAP cmsisdap.communication=USB cmsisdap.protocol=cmsis-dap -cmsisdap.program.protocol= +cmsisdap.program.protocol=cmsis-dap cmsisdap.program.tool=openocd -#cmsisdap.program.interface=cmsis-dap -#cmsisdap.program.setup_command=; -cmsisdap.program.extra_params=; +cmsisdap.program.setup_command=; -bmp.name=BMP (Black Magic Probe) +bmp.name=Black Magic Probe (GDB) bmp.communication=USB bmp.protocol= bmp.program.protocol= -bmp.erase.tool=bmp_upload -bmp.upload.tool=bmp_upload -bmp.program.tool=bmp_upload -bmp.bootloader.tool=bmp_upload +bmp.erase.tool=blackmagicprobe +bmp.upload.tool=blackmagicprobe +bmp.program.tool=blackmagicprobe +bmp.bootloader.tool=blackmagicprobe bmp.program.extra_params=; From 0a3b66e52494f78daccde71349e810fe7174ff32 Mon Sep 17 00:00:00 2001 From: micooke Date: Tue, 5 Sep 2017 16:37:55 +0930 Subject: [PATCH 4/5] * Add softdevice variant 'none' to enable flashing of an empty bootloader/hex --- boards.txt | 18 ++++++++++++++++++ .../none/hex/none_nrf51__softdevice.hex | 2 ++ .../none/hex/none_nrf52__softdevice.hex | 2 ++ 3 files changed, 22 insertions(+) create mode 100644 cores/nRF5/SDK/components/softdevice/none/hex/none_nrf51__softdevice.hex create mode 100644 cores/nRF5/SDK/components/softdevice/none/hex/none_nrf52__softdevice.hex diff --git a/boards.txt b/boards.txt index 9df22849..0d30e3af 100644 --- a/boards.txt +++ b/boards.txt @@ -44,6 +44,7 @@ Generic_nRF52832.build.ldscript=nrf52_xxaa.ld Generic_nRF52832.menu.softdevice.none=None Generic_nRF52832.menu.softdevice.none.softdevice=none +Generic_nRF52832.menu.softdevice.none.softdeviceversion= Generic_nRF52832.menu.softdevice.s132=S132 Generic_nRF52832.menu.softdevice.s132.softdevice=s132 @@ -81,6 +82,7 @@ bluey.build.ldscript=nrf52_xxaa.ld bluey.menu.softdevice.none=None bluey.menu.softdevice.none.softdevice=none +bluey.menu.softdevice.none.softdeviceversion= bluey.menu.softdevice.s132=S132 bluey.menu.softdevice.s132.softdevice=s132 @@ -128,6 +130,7 @@ Blend2.build.lfclk_flags=-DUSE_LFXO Blend2.menu.softdevice.none=None Blend2.menu.softdevice.none.softdevice=none +Blend2.menu.softdevice.none.softdeviceversion= Blend2.menu.softdevice.s132=S132 Blend2.menu.softdevice.s132.softdevice=s132 @@ -167,6 +170,7 @@ BLENano2.build.lfclk_flags=-DUSE_LFXO BLENano2.menu.softdevice.none=None BLENano2.menu.softdevice.none.softdevice=none +BLENano2.menu.softdevice.none.softdeviceversion= BLENano2.menu.softdevice.s132=S132 BLENano2.menu.softdevice.s132.softdevice=s132 @@ -206,6 +210,7 @@ nRF52DK.build.lfclk_flags=-DUSE_LFXO nRF52DK.menu.softdevice.none=None nRF52DK.menu.softdevice.none.softdevice=none +nRF52DK.menu.softdevice.none.softdeviceversion= nRF52DK.menu.softdevice.s132=S132 nRF52DK.menu.softdevice.s132.softdevice=s132 @@ -237,6 +242,7 @@ STCT_nRF52_minidev.build.lfclk_flags=-DUSE_LFXO STCT_nRF52_minidev.menu.softdevice.none=None STCT_nRF52_minidev.menu.softdevice.none.softdevice=none +STCT_nRF52_minidev.menu.softdevice.none.softdeviceversion= STCT_nRF52_minidev.menu.softdevice.s132=S132 STCT_nRF52_minidev.menu.softdevice.s132.softdevice=s132 @@ -274,6 +280,7 @@ Generic_nRF51822.menu.chip.xxac.build.chip=xxac Generic_nRF51822.menu.softdevice.none=None Generic_nRF51822.menu.softdevice.none.softdevice=none +Generic_nRF51822.menu.softdevice.none.softdeviceversion= Generic_nRF51822.menu.softdevice.s110=S110 Generic_nRF51822.menu.softdevice.s110.softdevice=s110 @@ -326,6 +333,7 @@ BBCmicrobit.build.lfclk_flags=-DUSE_LFRC BBCmicrobit.menu.softdevice.none=None BBCmicrobit.menu.softdevice.none.softdevice=none +BBCmicrobit.menu.softdevice.none.softdeviceversion= BBCmicrobit.menu.softdevice.s110=S110 BBCmicrobit.menu.softdevice.s110.softdevice=s110 @@ -364,6 +372,7 @@ BluzDK.build.lfclk_flags=-DUSE_LFXO BluzDK.menu.softdevice.none=None BluzDK.menu.softdevice.none.softdevice=none +BluzDK.menu.softdevice.none.softdeviceversion= BluzDK.menu.softdevice.s110=S110 BluzDK.menu.softdevice.s110.softdevice=s110 @@ -413,6 +422,7 @@ PCA1000X.menu.board_variant.nrf6310.board.variant=NRF6310 PCA1000X.menu.softdevice.none=None PCA1000X.menu.softdevice.none.softdevice=none +PCA1000X.menu.softdevice.none.softdeviceversion= PCA1000X.menu.softdevice.s110=S110 PCA1000X.menu.softdevice.s110.softdevice=s110 @@ -463,6 +473,7 @@ nRF51Dongle.menu.version.1_1_0.build.chip=xxac nRF51Dongle.menu.softdevice.none=None nRF51Dongle.menu.softdevice.none.softdevice=none +nRF51Dongle.menu.softdevice.none.softdeviceversion= nRF51Dongle.menu.softdevice.s110=S110 nRF51Dongle.menu.softdevice.s110.softdevice=s110 @@ -500,6 +511,7 @@ Beacon_PCA20006.build.lfclk_flags=-DUSE_LFXO Beacon_PCA20006.menu.softdevice.none=None Beacon_PCA20006.menu.softdevice.none.softdevice=none +Beacon_PCA20006.menu.softdevice.none.softdeviceversion= Beacon_PCA20006.menu.softdevice.s110=S110 Beacon_PCA20006.menu.softdevice.s110.softdevice=s110 @@ -540,6 +552,7 @@ TinyBLE.build.lfclk_flags=-DUSE_LFXO TinyBLE.menu.softdevice.none=None TinyBLE.menu.softdevice.none.softdevice=none +TinyBLE.menu.softdevice.none.softdeviceversion= TinyBLE.menu.softdevice.s110=S110 TinyBLE.menu.softdevice.s110.softdevice=s110 @@ -578,6 +591,7 @@ OSHChip.build.lfclk_flags=-DUSE_LFRC OSHChip.menu.softdevice.none=None OSHChip.menu.softdevice.none.softdevice=none +OSHChip.menu.softdevice.none.softdeviceversion= OSHChip.menu.softdevice.s110=S110 OSHChip.menu.softdevice.s110.softdevice=s110 @@ -623,6 +637,7 @@ BLENano.menu.version.1_5.build.chip=xxac BLENano.menu.softdevice.none=None BLENano.menu.softdevice.none.softdevice=none +BLENano.menu.softdevice.none.softdeviceversion= BLENano.menu.softdevice.s110=S110 BLENano.menu.softdevice.s110.softdevice=s110 @@ -668,6 +683,7 @@ RedBearLab_nRF51822.menu.version.1_5.build.chip=xxac RedBearLab_nRF51822.menu.softdevice.none=None RedBearLab_nRF51822.menu.softdevice.none.softdevice=none +RedBearLab_nRF51822.menu.softdevice.none.softdeviceversion= RedBearLab_nRF51822.menu.softdevice.s110=S110 RedBearLab_nRF51822.menu.softdevice.s110.softdevice=s110 @@ -711,6 +727,7 @@ Waveshare_BLE400.menu.chip.xxac.build.chip=xxac Waveshare_BLE400.menu.softdevice.none=None Waveshare_BLE400.menu.softdevice.none.softdevice=none +Waveshare_BLE400.menu.softdevice.none.softdeviceversion= Waveshare_BLE400.menu.softdevice.s110=S110 Waveshare_BLE400.menu.softdevice.s110.softdevice=s110 @@ -749,6 +766,7 @@ ng_beacon.build.lfclk_flags=-DUSE_LFRC ng_beacon.menu.softdevice.none=None ng_beacon.menu.softdevice.none.softdevice=none +ng_beacon.menu.softdevice.none.softdeviceversion= ng_beacon.menu.softdevice.s110=S110 ng_beacon.menu.softdevice.s110.softdevice=s110 diff --git a/cores/nRF5/SDK/components/softdevice/none/hex/none_nrf51__softdevice.hex b/cores/nRF5/SDK/components/softdevice/none/hex/none_nrf51__softdevice.hex new file mode 100644 index 00000000..64f0ed1e --- /dev/null +++ b/cores/nRF5/SDK/components/softdevice/none/hex/none_nrf51__softdevice.hex @@ -0,0 +1,2 @@ +:020000040000FA +:00000001FF diff --git a/cores/nRF5/SDK/components/softdevice/none/hex/none_nrf52__softdevice.hex b/cores/nRF5/SDK/components/softdevice/none/hex/none_nrf52__softdevice.hex new file mode 100644 index 00000000..64f0ed1e --- /dev/null +++ b/cores/nRF5/SDK/components/softdevice/none/hex/none_nrf52__softdevice.hex @@ -0,0 +1,2 @@ +:020000040000FA +:00000001FF From 9dea5b5d4cbe5041cd930e6a4a7230b0f232465c Mon Sep 17 00:00:00 2001 From: micooke Date: Mon, 18 Sep 2017 09:20:38 +0930 Subject: [PATCH 5/5] * Fix bug #169 * wiring_analog_* : fallback to digitalWrite if no available PWM channel (copied from AVR core) * wiring_analog_nRF52.c : convert pwmChannelPins & pwmChannelSequence -> pwmContext to semi-standardise pwm pin allocation and pwm status between nRF51 and nRF52 * wiring_private.h : Move pwm structures defines out of wiring_analog_* into wiring_private and make the instantiation of these structure externs instead of statics * wiring_digital.c : disable the appropriate pwm timer when a digitalWrite is sent to an allocated (from analogWrite) pwm pin, and free up the pwm channel for re-allocation --- cores/nRF5/wiring_analog_nRF51.c | 39 ++++++++++++++------------------ cores/nRF5/wiring_analog_nRF52.c | 37 ++++++++++++++++++------------ cores/nRF5/wiring_digital.c | 39 ++++++++++++++++++++++++++++---- cores/nRF5/wiring_private.h | 19 +++++++++++++++- 4 files changed, 93 insertions(+), 41 deletions(-) diff --git a/cores/nRF5/wiring_analog_nRF51.c b/cores/nRF5/wiring_analog_nRF51.c index f22a8b5d..0feda151 100644 --- a/cores/nRF5/wiring_analog_nRF51.c +++ b/cores/nRF5/wiring_analog_nRF51.c @@ -28,27 +28,16 @@ extern "C" { #endif -#define PWM_COUNT 3 -#define PIN_FREE 0xffffffff - -struct PWMContext { - uint32_t pin; - uint32_t value; - uint32_t channel; - uint32_t mask; - uint32_t event; -}; +static uint32_t adcReference = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling; +static uint32_t adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling; -static struct PWMContext pwmContext[PWM_COUNT] = { +struct PWMContext pwmContext[PWM_COUNT] = { { PIN_FREE, 0, 1, TIMER_INTENSET_COMPARE1_Msk, 1 }, { PIN_FREE, 0, 2, TIMER_INTENSET_COMPARE2_Msk, 2 }, { PIN_FREE, 0, 3, TIMER_INTENSET_COMPARE3_Msk, 3 } }; -static int timerEnabled = 0; - -static uint32_t adcReference = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling; -static uint32_t adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling; +struct PWMStatus pwmStatus[PWM_TIMER_COUNT] = {0, TIMER1_IRQn}; static uint32_t readResolution = 10; static uint32_t writeResolution = 8; @@ -229,7 +218,7 @@ void analogWrite( uint32_t ulPin, uint32_t ulValue ) ulPin = g_ADigitalPinMap[ulPin]; - if (!timerEnabled) { + if (pwmStatus[0].numActive == 0) { NVIC_SetPriority(TIMER1_IRQn, 3); NVIC_ClearPendingIRQ(TIMER1_IRQn); NVIC_EnableIRQ(TIMER1_IRQn); @@ -245,8 +234,6 @@ void analogWrite( uint32_t ulPin, uint32_t ulValue ) NRF_TIMER1->INTENSET = TIMER_INTENSET_COMPARE0_Msk; NRF_TIMER1->TASKS_START = 0x1UL; - - timerEnabled = true; } for (int i = 0; i < PWM_COUNT; i++) { @@ -259,17 +246,25 @@ void analogWrite( uint32_t ulPin, uint32_t ulValue ) | ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) | ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos); - ulValue = mapResolution(ulValue, writeResolution, 8); - pwmContext[i].value = ulValue; NRF_TIMER1->CC[pwmContext[i].channel] = ulValue; NRF_TIMER1->INTENSET = pwmContext[i].mask; - - break; + pwmStatus[0].numActive++; + return; } } + + // fallback to digitalWrite if no available PWM channel + if (ulValue < 128) + { + digitalWrite(ulPin, LOW); + } + else + { + digitalWrite(ulPin, LOW); + } } void TIMER1_IRQHandler(void) diff --git a/cores/nRF5/wiring_analog_nRF52.c b/cores/nRF5/wiring_analog_nRF52.c index b6999468..e62582f7 100644 --- a/cores/nRF5/wiring_analog_nRF52.c +++ b/cores/nRF5/wiring_analog_nRF52.c @@ -31,20 +31,19 @@ extern "C" { static uint32_t saadcReference = SAADC_CH_CONFIG_REFSEL_Internal; static uint32_t saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_5; -#define PWM_COUNT 3 - -static NRF_PWM_Type* pwms[PWM_COUNT] = { +NRF_PWM_Type* pwms[PWM_COUNT] = { NRF_PWM0, NRF_PWM1, NRF_PWM2 }; -static uint32_t pwmChannelPins[PWM_COUNT] = { - 0xFFFFFFFF, - 0xFFFFFFFF, - 0xFFFFFFFF +struct PWMContext pwmContext[PWM_COUNT] = { + { PIN_FREE, 0 }, + { PIN_FREE, 0 }, + { PIN_FREE, 0 } }; -static uint16_t pwmChannelSequence[PWM_COUNT]; + +struct PWMStatus pwmStatus[PWM_TIMER_COUNT] = {0, 0}; static int readResolution = 10; static int writeResolution = 8; @@ -220,9 +219,9 @@ void analogWrite( uint32_t ulPin, uint32_t ulValue ) ulPin = g_ADigitalPinMap[ulPin]; for (int i = 0; i < PWM_COUNT; i++) { - if (pwmChannelPins[i] == 0xFFFFFFFF || pwmChannelPins[i] == ulPin) { - pwmChannelPins[i] = ulPin; - pwmChannelSequence[i] = ulValue | bit(15); + if (pwmContext[i].pin == PIN_FREE || pwmContext[i].pin == ulPin) { + pwmContext[i].pin = ulPin; + pwmContext[i].value = ulValue; NRF_PWM_Type* pwm = pwms[i]; @@ -236,15 +235,25 @@ void analogWrite( uint32_t ulPin, uint32_t ulValue ) pwm->COUNTERTOP = (1 << writeResolution) - 1; pwm->LOOP = 0; pwm->DECODER = ((uint32_t)PWM_DECODER_LOAD_Common << PWM_DECODER_LOAD_Pos) | ((uint32_t)PWM_DECODER_MODE_RefreshCount << PWM_DECODER_MODE_Pos); - pwm->SEQ[0].PTR = (uint32_t)&pwmChannelSequence[i]; + pwm->SEQ[0].PTR = (uint32_t)&(pwmContext[i].value); pwm->SEQ[0].CNT = 1; pwm->SEQ[0].REFRESH = 1; pwm->SEQ[0].ENDDELAY = 0; pwm->TASKS_SEQSTART[0] = 0x1UL; - - break; + pwmStatus[0].numActive++; + return; } } + + // fallback to digitalWrite if no available PWM channel + if (ulValue < 128) + { + digitalWrite(ulPin, LOW); + } + else + { + digitalWrite(ulPin, LOW); + } } #ifdef __cplusplus diff --git a/cores/nRF5/wiring_digital.c b/cores/nRF5/wiring_digital.c index 1d9c27fd..8b9df904 100644 --- a/cores/nRF5/wiring_digital.c +++ b/cores/nRF5/wiring_digital.c @@ -20,6 +20,13 @@ #include "nrf.h" #include "Arduino.h" +#include "wiring_private.h" + +extern struct PWMContext pwmContext[PWM_COUNT]; +extern struct PWMStatus pwmStatus[PWM_TIMER_COUNT]; +#ifdef NRF52 +extern NRF_PWM_Type* pwms[PWM_COUNT]; +#endif #ifdef __cplusplus extern "C" { @@ -86,18 +93,42 @@ void digitalWrite( uint32_t ulPin, uint32_t ulVal ) ulPin = g_ADigitalPinMap[ulPin]; + for (uint8_t i = 0; i < PWM_COUNT; i++) + { + if (pwmContext[i].pin == ulPin) + { + pwmContext[i].pin = PIN_FREE; + #ifdef NRF52 + // Disable the PWM + NRF_PWM_Type* pwm = pwms[i]; + pwm->ENABLE = (PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos); + #endif + pwmStatus[0].numActive--; + } + } + + #ifdef NRF51 + // Turn off the Timer if no pwm signals are allocated + for (uint8_t i = 0; i < PWM_TIMER_COUNT; i++) + { + if (pwmStatus[i].numActive == 0) + { + NVIC_ClearPendingIRQ(pwmStatus[i].irqNumber); + NVIC_DisableIRQ(pwmStatus[i].irqNumber); + } + } + #endif + switch ( ulVal ) { case LOW: NRF_GPIO->OUTCLR = (1UL << ulPin); - break ; + break; default: NRF_GPIO->OUTSET = (1UL << ulPin); - break ; + break; } - - return ; } int digitalRead( uint32_t ulPin ) diff --git a/cores/nRF5/wiring_private.h b/cores/nRF5/wiring_private.h index 1907c234..ff85af11 100644 --- a/cores/nRF5/wiring_private.h +++ b/cores/nRF5/wiring_private.h @@ -26,9 +26,26 @@ extern "C" { #endif - #include "wiring_constants.h" +#define PWM_COUNT 3 +#define PWM_TIMER_COUNT 1 // 3 channels of TIMER1 are used. TIMER2 also could be used for PWM +#define PIN_FREE 0xffffffff + +struct PWMContext { + uint32_t pin; + uint32_t value; + #ifdef NRF51 + uint32_t channel; + uint32_t mask; + uint32_t event; + #endif +}; + +struct PWMStatus { + int8_t numActive; + int8_t irqNumber; +}; #ifdef __cplusplus } // extern "C"