Skip to content

Commit

Permalink
Ampere: feature patch directory with README
Browse files Browse the repository at this point in the history
Change-Id: Icfdb387f53dc158eab6ab084281e146ef4dae861
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
  • Loading branch information
dgoehring-ampere committed Jun 4, 2024
1 parent 54f4987 commit 7366708
Show file tree
Hide file tree
Showing 34 changed files with 7,632 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
From 7d91c9de2bab296772d04e9d9de840af8ec5e9c3 Mon Sep 17 00:00:00 2001
From: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Date: Fri, 7 May 2021 15:27:35 -0400
Subject: [PATCH 01/33] build: add Dockerfile and Ampere README files [DO NOT
UPSTREAM]

Change-Id: Ia9ae4963bdb6fc50939461753c5133a152aa93e2
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
---
Dockerfile | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
README.AMPERE | 26 +++++++++++++++++++++++
2 files changed, 85 insertions(+)
create mode 100644 Dockerfile
create mode 100644 README.AMPERE

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..69adde4aa
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021-2022, Ampere Computing LLC
+
+FROM docker.io/ubuntu:18.04
+
+RUN apt-get update -q && \
+ apt-get install -y --no-install-recommends sudo
+RUN adduser --disabled-password --gecos '' openocd && \
+ adduser openocd sudo && \
+ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+USER openocd
+RUN sudo apt-get update -q && \
+ sudo apt-get install -y --no-install-recommends \
+ libftdi-dev \
+ git \
+ libtool \
+ automake \
+ texinfo \
+ pkg-config \
+ libusb-1.0.0-dev \
+ vim \
+ net-tools \
+ usbutils \
+ libpython3.8 \
+ python3.8-minimal \
+ gdb \
+ ddd \
+ telnet \
+ libcapstone-dev \
+ ca-certificates
+
+COPY arm-gnu-toolchain*/bin/aarch64-none-elf-gdb /usr/bin/
+COPY arm-gnu-toolchain*/bin/aarch64-none-elf-gdb-add-index /usr/bin/
+
+COPY arm-gnu-toolchain*/bin/aarch64-none-linux-gnu-gdb /usr/bin/
+COPY arm-gnu-toolchain*/bin/aarch64-none-linux-gnu-gdb-add-index /usr/bin/
+
+COPY arm-gnu-toolchain*/bin/arm-none-eabi-gdb /usr/bin/
+COPY arm-gnu-toolchain*/bin/arm-none-eabi-gdb-add-index /usr/bin/
+
+COPY arm-gnu-toolchain*/bin/arm-none-linux-gnueabihf-gdb /usr/bin/
+COPY arm-gnu-toolchain*/bin/arm-none-linux-gnueabihf-gdb-add-index /usr/bin/
+
+COPY arm-gnu-toolchain*/include/gdb /usr/include/gdb/
+COPY arm-gnu-toolchain*/share/doc/gdb /usr/share/doc/gdb/
+COPY arm-gnu-toolchain*/share/gdb /usr/share/gdb/
+COPY arm-gnu-toolchain*/share/info/gdb.info /usr/share/info/
+
+COPY --chown=openocd:openocd openocd /home/openocd/openocd
+WORKDIR /home/openocd/openocd
+RUN mv README.AMPERE .. 2>/dev/null || true
+RUN ./bootstrap
+RUN ./configure --enable-vdebug --enable-jtag_dpi --enable-ftdi --enable-ft2232_ftd2xx --with-capstone
+RUN make
+RUN sudo make install
+RUN rm -rf .git
+WORKDIR /home/openocd
+
+EXPOSE 3333 3334 3335 3336 3337 3338 4444 4445 5555 5556 6666
diff --git a/README.AMPERE b/README.AMPERE
new file mode 100644
index 000000000..7db9ad8ae
--- /dev/null
+++ b/README.AMPERE
@@ -0,0 +1,26 @@
+This Docker container was built by Ampere Computing using an internal and
+proprietary build process. This container was built using sources from open source
+as well as closed source projects.
+
+The base layer of this container was built using the Ubuntu 18.04 image
+as hosted by DockerHub.
+
+A number of packages were installed using the standard apt package manager. These
+can be discovered using the ```sudo apt list --installed``` command (or equivalent).
+
+In addition to packages installed via the standard Ubuntu package repository,
+the following projects were directly added to this container:
+
+ - OpenOCD With Ampere Patches
+ Placed at location: /home/openocd/openocd/, /home/openocd/openocd/patches/
+
+ - Ampere OpenOCD Dockerfile
+ Placed at location: /home/openocd/openocd/Dockerfile
+ This file is distributed under the BSD-3-Clause license. Full license text for the
+ BSD-3-Clause license can be found at /home/openocd/openocd/LICENSES/preferred/BSD-3-Clause
+
+ - Arm GNU Toolchain
+ Placed at locations: /usr/bin, /usr/include/gdb, /usr/share/, /usr/share/gdb/,
+ /usr/share/doc/gdb/, /usr/share/info/
+ This toolchain is included without modifications and as distributed by Arm at
+ this page: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads/10-3-2021-07
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From f9a2cf11b6a3381443b4f5696917ba3af682c048 Mon Sep 17 00:00:00 2001
From: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Date: Mon, 23 May 2022 19:07:51 -0400
Subject: [PATCH 02/33] Cadence vdebug interface updates [DO NOT UPSTREAM]

Change-Id: I968c005e524b40b9642d03f27fb900304c639e28
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
---
src/jtag/drivers/vdebug.c | 2 +-
tcl/interface/vdebug.cfg | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/jtag/drivers/vdebug.c b/src/jtag/drivers/vdebug.c
index f1fc4535f..0811e7b46 100644
--- a/src/jtag/drivers/vdebug.c
+++ b/src/jtag/drivers/vdebug.c
@@ -53,7 +53,7 @@
#include "helper/log.h"
#include "helper/list.h"

-#define VD_VERSION 48
+#define VD_VERSION 42
#define VD_BUFFER_LEN 4024
#define VD_CHEADER_LEN 24
#define VD_SHEADER_LEN 16
diff --git a/tcl/interface/vdebug.cfg b/tcl/interface/vdebug.cfg
index 7350bb9a9..9faa5bd11 100644
--- a/tcl/interface/vdebug.cfg
+++ b/tcl/interface/vdebug.cfg
@@ -21,10 +21,10 @@ vdebug server $_VDEBUGHOST:$_VDEBUGPORT
#log_output vd_ocd.log

# example config listen on all interfaces, disable tcl/telnet server
-bindto 0.0.0.0
+#bindto 0.0.0.0
#gdb_port 3333
#telnet_port disabled
-tcl_port disabled
+#tcl_port disabled

# transaction batching: 0 - no batching, 1 - (default) wr, 2 - rw
vdebug batching 1
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
From 4f14501eac4eab74b894713b749a9bcd5bb4cb91 Mon Sep 17 00:00:00 2001
From: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Date: Thu, 25 Apr 2019 11:38:04 -0400
Subject: [PATCH 03/33] gdb_server: remove 'fake_thread' workaround for OS
threads. [DO NOT UPSTREAM]

The 'fake_thread' workaround resolves an issue with respect to
GDB debugging multiple OS threads which is outside the scope
of OpenOCD. The workaround breaks HW CPU thread support.
Since OpenOCD only supports debugging from a CPU core
perspective and not OS Threads, it is unnecessary to include
this workaround. My recommendation is to remove the workaround
since it isn't needed and breaks HW CPU thread functionality.

Tested on an Ampere eMAG8180 and Quicksilver silicon.

Change-Id: I7b09d56727a860fb86652bb3ff1e9c2f8cf6fb7b
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
---
src/server/gdb_server.c | 31 -------------------------------
1 file changed, 31 deletions(-)

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 5052bf43b..014f1ce37 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -3033,7 +3033,6 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
/* single-step or step-over-breakpoint */
if (parse[0] == 's') {
gdb_running_type = 's';
- bool fake_step = false;

struct target *ct = target;
int current_pc = 1;
@@ -3055,13 +3054,6 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
rtos_update_threads(target);

target->rtos->gdb_target_for_threadid(connection, thread_id, &ct);
-
- /*
- * check if the thread to be stepped is the current rtos thread
- * if not, we must fake the step
- */
- if (target->rtos->current_thread != thread_id)
- fake_step = true;
}

if (parse[0] == ';') {
@@ -3098,29 +3090,6 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
gdb_connection->output_flag = GDB_OUTPUT_ALL;
target_call_event_callbacks(ct, TARGET_EVENT_GDB_START);

- /*
- * work around an annoying gdb behaviour: when the current thread
- * is changed in gdb, it assumes that the target can follow and also
- * make the thread current. This is an assumption that cannot hold
- * for a real target running a multi-threading OS. We just fake
- * the step to not trigger an internal error in gdb. See
- * https://sourceware.org/bugzilla/show_bug.cgi?id=22925 for details
- */
- if (fake_step) {
- int sig_reply_len;
- char sig_reply[128];
-
- LOG_DEBUG("fake step thread %"PRIx64, thread_id);
-
- sig_reply_len = snprintf(sig_reply, sizeof(sig_reply),
- "T05thread:%016"PRIx64";", thread_id);
-
- gdb_put_packet(connection, sig_reply, sig_reply_len);
- gdb_connection->output_flag = GDB_OUTPUT_NO;
-
- return true;
- }
-
/* support for gdb_sync command */
if (gdb_connection->sync) {
gdb_connection->sync = false;
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From f510faf994243a04ae9a3882dda2167219864bf4 Mon Sep 17 00:00:00 2001
From: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Date: Thu, 25 Apr 2019 11:38:04 -0400
Subject: [PATCH 04/33] gdb_server: fix CPU status reporting for 'step' command

The call to 'rtos_update_threads()' should be after the call
to 'target_step()' and not before. With the update, 'info threads'
reports the current hardware thread state.

Tested on an Ampere eMAG8180 and Quicksilver silicon

Change-Id: I2168d3f965a4d7cceac40bc3dcf198e413ee4fe6
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
---
src/server/gdb_server.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 014f1ce37..aecb470dc 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -3050,9 +3050,6 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
}

if (target->rtos) {
- /* FIXME: why is this necessary? rtos state should be up-to-date here already! */
- rtos_update_threads(target);
-
target->rtos->gdb_target_for_threadid(connection, thread_id, &ct);
}

@@ -3107,6 +3104,11 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
if (retval == ERROR_TARGET_NOT_HALTED)
LOG_INFO("target %s was not halted when step was requested", target_name(ct));

+ if (target->rtos) {
+ /* After executing the 'step' command, update the rtos threads */
+ rtos_update_threads(target);
+ }
+
/* if step was successful send a reply back to gdb */
if (retval == ERROR_OK) {
retval = target_poll(ct);
--
2.25.1

Loading

0 comments on commit 7366708

Please sign in to comment.