From baf08b0a1ad656434583e3c102a350d4cf885bf9 Mon Sep 17 00:00:00 2001 From: Tomas Vanek Date: Sat, 19 Dec 2015 12:34:31 +0100 Subject: flash Kinetis: new KVx family added Cortex-M0+ and M4 motor control MCUs KV10, KV11, KV30, KV31, KV42, KV44 and KV46 added to SDID identification. Watchdog disable code changed to work on Cortex-M0+ (KV1x) Protection size set to 1K for 16K flash devices (KV10Z16) - cherry picked from Andrey Smirnov's change #2051 Change-Id: Ia6f4868eaf7e2cb6ad6a736210c703a67e0027be Signed-off-by: Tomas Vanek Reviewed-on: http://openocd.zylin.com/3235 Tested-by: jenkins Reviewed-by: Kyle Manna Reviewed-by: Freddie Chopin --- contrib/loaders/watchdog/Makefile | 19 +++++++ contrib/loaders/watchdog/armv7m_kinetis_wdog.inc | 4 ++ contrib/loaders/watchdog/armv7m_kinetis_wdog.s | 64 ++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 contrib/loaders/watchdog/Makefile create mode 100644 contrib/loaders/watchdog/armv7m_kinetis_wdog.inc create mode 100644 contrib/loaders/watchdog/armv7m_kinetis_wdog.s (limited to 'contrib') diff --git a/contrib/loaders/watchdog/Makefile b/contrib/loaders/watchdog/Makefile new file mode 100644 index 00000000..d9ef1d2c --- /dev/null +++ b/contrib/loaders/watchdog/Makefile @@ -0,0 +1,19 @@ +BIN2C = ../../../src/helper/bin2char.sh + +ARM_CROSS_COMPILE ?= arm-none-eabi- +ARM_AS ?= $(ARM_CROSS_COMPILE)as +ARM_OBJCOPY ?= $(ARM_CROSS_COMPILE)objcopy + +arm: armv7m_kinetis_wdog.inc + +armv7m_%.elf: armv7m_%.s + $(ARM_AS) -mthumb $< -o $@ + +armv7m_%.bin: armv7m_%.elf + $(ARM_OBJCOPY) -Obinary $< $@ + +armv7m_%.inc: armv7m_%.bin + $(BIN2C) < $< > $@ + +clean: + -rm -f *.elf *.bin *.inc diff --git a/contrib/loaders/watchdog/armv7m_kinetis_wdog.inc b/contrib/loaders/watchdog/armv7m_kinetis_wdog.inc new file mode 100644 index 00000000..4b6579e0 --- /dev/null +++ b/contrib/loaders/watchdog/armv7m_kinetis_wdog.inc @@ -0,0 +1,4 @@ +/* Autogenerated with ../../../src/helper/bin2char.sh */ +0x04,0x4b,0x05,0x4a,0xda,0x81,0x05,0x4a,0xda,0x81,0x01,0x24,0x1a,0x88,0xa2,0x43, +0x1a,0x80,0x06,0xe0,0x00,0x20,0x05,0x40,0x20,0xc5,0x00,0x00,0x28,0xd9,0x00,0x00, +0x00,0x00,0x00,0xbe, diff --git a/contrib/loaders/watchdog/armv7m_kinetis_wdog.s b/contrib/loaders/watchdog/armv7m_kinetis_wdog.s new file mode 100644 index 00000000..bac924ab --- /dev/null +++ b/contrib/loaders/watchdog/armv7m_kinetis_wdog.s @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2015 Tomas Vanek * + * vanekt@fbl.cz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc. * + ***************************************************************************/ + +/* + Disable watchdog for Kinetis Kx and KVx + Parameters: none + Used instruction set should work on both Cortex-M4 and M0+ +*/ + + .text + .syntax unified + .cpu cortex-m0 + .thumb + +WDOG_ADDR = 0x40052000 +/* WDOG registers offsets */ +WDOG_STCTRLH = 0 +WDOG_UNLOCK = 0x0e + +WDOG_KEY1 = 0xc520 +WDOG_KEY2 = 0xd928 + + .thumb_func +start: +/* WDOG_UNLOCK = 0xC520 */ + ldr r3, =WDOG_ADDR + ldr r2, =WDOG_KEY1 + strh r2, [r3, WDOG_UNLOCK] +/* WDOG_UNLOCK = 0xD928 */ + ldr r2, =WDOG_KEY2 + strh r2, [r3, WDOG_UNLOCK] +/* WDOG_STCTRLH clear bit 0 */ + movs r4, #1 + ldrh r2, [r3, WDOG_STCTRLH] + bics r2, r4 + strh r2, [r3, WDOG_STCTRLH] +/* OpenOCD checks exit point address. Jump to the very end. */ + b done + + .pool + +/* Avoid padding at .text segment end. Otherwise exit point check fails. */ + .skip ( . - start + 2) & 2, 0 +done: + bkpt #0 + + .end + -- cgit v1.2.3-18-g5258