hla: enable DWT component and fix watchpoints
[openocd.git] / src / target / hla_target.c
index 1791997a5d1171d43cd82766b6285c2d0b36651f..1a95d8808bc6c29f7e031284d5f96866f2944482 100644 (file)
@@ -339,7 +339,7 @@ static int adapter_debug_entry(struct target *target)
        adapter_load_context(target);
 
        /* make sure we clear the vector catch bit */
-       adapter->layout->api->write_debug_reg(adapter->fd, DCB_DEMCR, 0);
+       adapter->layout->api->write_debug_reg(adapter->fd, DCB_DEMCR, TRCENA);
 
        r = armv7m->core_cache->reg_list + ARMV7M_xPSR;
        xPSR = buf_get_u32(r->value, 0, 32);
@@ -434,9 +434,9 @@ static int adapter_assert_reset(struct target *target)
 
        /* only set vector catch if halt is requested */
        if (target->reset_halt)
-               adapter->layout->api->write_debug_reg(adapter->fd, DCB_DEMCR, VC_CORERESET);
+               adapter->layout->api->write_debug_reg(adapter->fd, DCB_DEMCR, TRCENA|VC_CORERESET);
        else
-               adapter->layout->api->write_debug_reg(adapter->fd, DCB_DEMCR, 0);
+               adapter->layout->api->write_debug_reg(adapter->fd, DCB_DEMCR, TRCENA);
 
        if (jtag_reset_config & RESET_HAS_SRST) {
                if (!srst_asserted) {
@@ -551,6 +551,12 @@ static int adapter_resume(struct target *target, int current,
                return ERROR_TARGET_NOT_HALTED;
        }
 
+       if (!debug_execution) {
+               target_free_all_working_areas(target);
+               cortex_m3_enable_breakpoints(target);
+               cortex_m3_enable_watchpoints(target);
+       }
+
        pc = armv7m->arm.pc;
        if (!current) {
                buf_set_u32(pc->value, 0, 32, address);
@@ -565,6 +571,11 @@ static int adapter_resume(struct target *target, int current,
 
        resume_pc = buf_get_u32(pc->value, 0, 32);
 
+       /* write any user vector flags */
+       res = target_write_u32(target, DCB_DEMCR, TRCENA | armv7m->demcr);
+       if (res != ERROR_OK)
+               return res;
+
        armv7m_restore_context(target);
 
        /* registers are now invalid */
@@ -665,11 +676,11 @@ static int adapter_read_memory(struct target *target, uint32_t address,
                uint32_t size, uint32_t count,
                uint8_t *buffer)
 {
+       struct hl_interface_s *adapter = target_to_adapter(target);
        int res;
-       uint32_t buffer_threshold = 128;
+       uint32_t buffer_threshold = (adapter->param.max_buffer / 4);
        uint32_t addr_increment = 4;
        uint32_t c;
-       struct hl_interface_s *adapter = target_to_adapter(target);
 
        if (!count || !buffer)
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -681,7 +692,7 @@ static int adapter_read_memory(struct target *target, uint32_t address,
         */
        if (size != 4) {
                count *= size;
-               buffer_threshold = 64;
+               buffer_threshold = (adapter->param.max_buffer / 4) / 2;
                addr_increment = 1;
        }
 
@@ -713,11 +724,11 @@ static int adapter_write_memory(struct target *target, uint32_t address,
                uint32_t size, uint32_t count,
                const uint8_t *buffer)
 {
+       struct hl_interface_s *adapter = target_to_adapter(target);
        int res;
-       uint32_t buffer_threshold = 128;
+       uint32_t buffer_threshold = (adapter->param.max_buffer / 4);
        uint32_t addr_increment = 4;
        uint32_t c;
-       struct hl_interface_s *adapter = target_to_adapter(target);
 
        if (!count || !buffer)
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -729,7 +740,7 @@ static int adapter_write_memory(struct target *target, uint32_t address,
         */
        if (size != 4) {
                count *= size;
-               buffer_threshold = 64;
+               buffer_threshold = (adapter->param.max_buffer / 4) / 2;
                addr_increment = 1;
        }
 
@@ -771,8 +782,9 @@ static const struct command_registration adapter_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct target_type stm32_stlink_target = {
-       .name = "stm32_stlink",
+struct target_type hla_target = {
+       .name = "hla_target",
+       .deprecated_name = "stm32_stlink",
 
        .init_target = adapter_init_target,
        .target_create = adapter_target_create,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)