diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 63b40c687..e179e8208 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1503,15 +1503,20 @@ static void deinit_target(struct target *target)
 	info->version_specific = NULL;
 }
 
-static int set_haltgroup(struct target *target, bool *supported)
+typedef enum {
+	HALTGROUP,
+	RESUMEGROUP
+} grouptype_t;
+static int set_group(struct target *target, bool *supported, unsigned group, grouptype_t grouptype)
 {
-	uint32_t write = set_field(DM_DMCS2_HGWRITE, DM_DMCS2_GROUP, target->smp);
+	uint32_t write = set_field(DM_DMCS2_HGWRITE, DM_DMCS2_GROUP, group);
+	write = set_field(write, DM_DMCS2_GROUPTYPE, 1);
 	if (dmi_write(target, DM_DMCS2, write) != ERROR_OK)
 		return ERROR_FAIL;
 	uint32_t read;
 	if (dmi_read(target, &read, DM_DMCS2) != ERROR_OK)
 		return ERROR_FAIL;
-	*supported = get_field(read, DM_DMCS2_GROUP) == (unsigned)target->smp;
+	*supported = get_field(read, DM_DMCS2_GROUP) == group;
 	return ERROR_OK;
 }
 
@@ -1754,7 +1759,7 @@ static int examine(struct target *target)
 
 	if (target->smp) {
 		bool haltgroup_supported;
-		if (set_haltgroup(target, &haltgroup_supported) != ERROR_OK)
+		if (set_group(target, &haltgroup_supported, target->smp, HALTGROUP) != ERROR_OK)
 			return ERROR_FAIL;
 		if (haltgroup_supported)
 			LOG_INFO("Core %d made part of halt group %d.", target->coreid,