Add renode_kelvin library into kelvin_sim target

The library is used as the wrapper layer between kelvin_sim and renode

Change-Id: I654723cc08df98554663ae8505979ed4becae08a
diff --git a/platforms/nexus/kelvin.mk b/platforms/nexus/kelvin.mk
index e27e504..94ac8f8 100644
--- a/platforms/nexus/kelvin.mk
+++ b/platforms/nexus/kelvin.mk
@@ -100,9 +100,11 @@
 # Use /tmp as the bazel tmpfs to unblock CI
 kelvin_sim: | $(KELVIN_SIM_OUT_DIR)
 	cd "$(KELVIN_SIM_SRC_DIR)" && \
-		bazel build --sandbox_tmpfs_path=/tmp //sim:kelvin_sim
+		bazel build --sandbox_tmpfs_path=/tmp //sim:kelvin_sim \
+		  //sim/renode:renode_kelvin
 	cd "$(KELVIN_SIM_SRC_DIR)/bazel-bin" && \
-		cp -f sim/kelvin_sim "$(KELVIN_SIM_OUT_DIR)"
+		cp -f sim/kelvin_sim "$(KELVIN_SIM_OUT_DIR)" && \
+		cp -f sim/renode/librenode_kelvin.so "$(KELVIN_SIM_OUT_DIR)"
 
 ## Clean Kelvin ISS
 #
diff --git a/platforms/nexus/setup.sh b/platforms/nexus/setup.sh
index 3d03417..0cf98a4 100644
--- a/platforms/nexus/setup.sh
+++ b/platforms/nexus/setup.sh
@@ -91,11 +91,9 @@
     # Run the Bin program with renode
     local bin_file=$(realpath $1)
     local command="start;"
-    if [[ "$2" == "debug" ]]; then
-        command="machine StartGdbServer 3333;"
-    fi
-    (cd "${ROOTDIR}" && renode -e "\$bin=@${bin_file}; i @sim/config/kelvin.resc; \
-        ${command} sysbus.vec_controlblock WriteDoubleWord 0xc 0" \
+    # TODO(hcindyl): Use vec_controlblock
+    (cd "${ROOTDIR}" && renode -e "\$bin=@${bin_file}; i @sim/config/kelvin_external_cpu.resc; \
+        ${command} sysbus.cpu2 PC 0; sysbus.cpu2 IsHalted false" \
         --disable-xwt --console)
 
 }
diff --git a/platforms/shodan/kelvin.mk b/platforms/shodan/kelvin.mk
index bbfe9ff..80cca4a 100644
--- a/platforms/shodan/kelvin.mk
+++ b/platforms/shodan/kelvin.mk
@@ -88,9 +88,11 @@
 # Use /tmp as the bazel tmpfs to unblock CI
 kelvin_sim: | $(KELVIN_SIM_OUT_DIR)
 	cd "$(KELVIN_SIM_SRC_DIR)" && \
-		bazel build --sandbox_tmpfs_path=/tmp //sim:kelvin_sim
+		bazel build --sandbox_tmpfs_path=/tmp //sim:kelvin_sim \
+		  //sim/renode:renode_kelvin
 	cd "$(KELVIN_SIM_SRC_DIR)/bazel-bin" && \
-		cp -f sim/kelvin_sim "$(KELVIN_SIM_OUT_DIR)"
+		cp -f sim/kelvin_sim "$(KELVIN_SIM_OUT_DIR)" && \
+		cp -f sim/renode/librenode_kelvin.so "$(KELVIN_SIM_OUT_DIR)"
 
 ## Clean Kelvin ISS
 #
diff --git a/platforms/shodan/setup.sh b/platforms/shodan/setup.sh
index 02cb66b..1e81060 100644
--- a/platforms/shodan/setup.sh
+++ b/platforms/shodan/setup.sh
@@ -110,11 +110,9 @@
     # Run the Bin program with renode
     local bin_file=$(realpath $1)
     local command="start;"
-    if [[ "$2" == "debug" ]]; then
-        command="machine StartGdbServer 3333;"
-    fi
-    (cd "${ROOTDIR}" && renode -e "\$bin=@${bin_file}; i @sim/config/kelvin.resc; \
-        ${command} sysbus.vec_controlblock WriteDoubleWord 0xc 0" \
+    # TODO(hcindyl): Use vec_controlblock
+    (cd "${ROOTDIR}" && renode -e "\$bin=@${bin_file}; i @sim/config/kelvin_external_cpu.resc; \
+        ${command} sysbus.cpu2 PC 0; sysbus.cpu2 IsHalted false" \
         --disable-xwt --console)
 
 }