aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorErhan Kurubas <erhan.kurubas@espressif.com>2023-07-10 23:47:06 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2023-12-10 13:31:57 +0000
commit4003762177b1aec2ab27eaa6946b47f13c457bbc (patch)
treeddeb6b57c126b8f29d2796249fe730b4e3f7a2ed /contrib
parentd06d8ea3e4d0057dd13a6dac792b1ad7c246aebb (diff)
downloadriscv-openocd-4003762177b1aec2ab27eaa6946b47f13c457bbc.zip
riscv-openocd-4003762177b1aec2ab27eaa6946b47f13c457bbc.tar.gz
riscv-openocd-4003762177b1aec2ab27eaa6946b47f13c457bbc.tar.bz2
target/espressif: add algorithm support to xtensa chips
Also includes esp_xtensa flasher stub jumper binary. Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: I054ce31033ca6a87afe9b5325b545338a7d8fe8f Reviewed-on: https://review.openocd.org/c/openocd/+/7772 Tested-by: jenkins Reviewed-by: Ian Thompson <ianst@cadence.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/loaders/trampoline/espressif/xtensa/Makefile38
-rw-r--r--contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.S41
-rw-r--r--contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.inc3
3 files changed, 82 insertions, 0 deletions
diff --git a/contrib/loaders/trampoline/espressif/xtensa/Makefile b/contrib/loaders/trampoline/espressif/xtensa/Makefile
new file mode 100644
index 0000000..bd1f630
--- /dev/null
+++ b/contrib/loaders/trampoline/espressif/xtensa/Makefile
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# Espressif Xtensa Makefile to compile flasher stub wrapper
+# Copyright (C) 2023 Espressif Systems Ltd.
+
+# Prefix for Espressif xtensa cross compilers (can include a directory path)
+CROSS ?= xtensa-esp32-elf-
+
+APP_ARCH := xtensa
+APP_CHIP_PATH := $(shell pwd)
+SRCS := $(APP_CHIP_PATH)/esp_xtensa_stub_tramp_win.S
+
+BIN2C = ../../../../../src/helper/bin2char.sh
+BUILD_DIR = build
+
+APP = esp_xtensa_stub_tramp_win
+APP_OBJ = $(BUILD_DIR)/$(APP).o
+APP_BIN = $(BUILD_DIR)/$(APP).bin
+APP_CODE = $(APP).inc
+
+.PHONY: all clean
+
+all: $(BUILD_DIR) $(APP_OBJ) $(APP_CODE)
+
+$(BUILD_DIR):
+ $(Q) mkdir $@
+
+$(APP_OBJ): $(SRCS)
+ @echo " CC $^ -> $@"
+ $(Q) $(CROSS)gcc -c $(CFLAGS) -o $@ $^
+
+$(APP_CODE): $(APP_OBJ)
+ @echo " CC $^ -> $@"
+ $(Q) $(CROSS)objcopy -O binary -j.text $^ $(APP_BIN)
+ $(Q) $(BIN2C) < $(APP_BIN) > $@
+
+clean:
+ $(Q) rm -rf $(BUILD_DIR)
diff --git a/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.S b/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.S
new file mode 100644
index 0000000..e0c827d
--- /dev/null
+++ b/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.S
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/***************************************************************************
+ * Xtensa flasher stub wrapper *
+ * Copyright (C) 2017 Espressif Systems Ltd. *
+ ***************************************************************************/
+
+/*
+ * Expects :
+ * a0 = zero
+ * a1 = stack_base + stack_size - 16, 16 bytes aligned
+ * a8 = address of the function to call
+ * Params :
+ * a2 = command arg0, result (out)
+ * a3 = command arg1
+ * a4 = command arg2
+ * a5 = command arg3
+ * a6 = command arg4
+ * Maximum 5 user args
+ */
+ .text
+
+ .align 4
+_stub_enter:
+ /* initialize initial stack frame for callx8 */
+ addi a9, sp, 32 /* point 16 past extra save area */
+ s32e a9, sp, -12 /* access to extra save area */
+ /* prepare args */
+ mov a10, a2
+ mov a11, a3
+ mov a12, a4
+ mov a13, a5
+ mov a14, a6
+ /* call stub */
+ callx8 a8
+ /* prepare return value */
+ mov a2, a10
+ break 0,0
+
+_idle_loop:
+ j _idle_loop
diff --git a/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.inc b/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.inc
new file mode 100644
index 0000000..1657223
--- /dev/null
+++ b/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.inc
@@ -0,0 +1,3 @@
+/* Autogenerated with ../../../../../src/helper/bin2char.sh */
+0x92,0xc1,0x20,0x90,0xd1,0x49,0xad,0x02,0xbd,0x03,0xcd,0x04,0xdd,0x05,0x60,0xe6,
+0x20,0xe0,0x08,0x00,0x2d,0x0a,0x00,0x40,0x00,0x06,0xff,0xff,