hla: add ability to configure read/write buffer size 48/948/3
authorSpencer Oliver <spen@spen-soft.co.uk>
Thu, 1 Nov 2012 11:19:29 +0000 (11:19 +0000)
committerSpencer Oliver <spen@spen-soft.co.uk>
Sun, 23 Dec 2012 21:46:10 +0000 (21:46 +0000)
Other adapters (TI ICDI) that use this driver can use a larger
read/write buffer size than the original stlink could.

Change-Id: I9beb7748049097cbe29a2340799c450bd74e199d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/948
Tested-by: jenkins
src/jtag/drivers/stlink_usb.c
src/jtag/hla/hla_interface.c
src/jtag/hla/hla_interface.h
src/jtag/hla/hla_layout.c
src/target/hla_target.c

index 2a78f7956a088da176150e9c01f147f066e90c2a..bb4df239181484ad6e8794f6155bf1f40fae6df1 100644 (file)
@@ -1160,6 +1160,9 @@ static int stlink_usb_open(struct hl_interface_param_s *param, void **fd)
 
        h->transport = param->transport;
 
+       /* set max read/write buffer size in bytes */
+       param->max_buffer = 512;
+
        const uint16_t vids[] = { param->vid, 0 };
        const uint16_t pids[] = { param->pid, 0 };
 
index eb9b43dc69c07a6da827972ec59e82f119d1e345..5f493ffe2454df739b94401b062bfe04e26f2810 100644 (file)
@@ -37,7 +37,7 @@
 
 #include <target/target.h>
 
-static struct hl_interface_s hl_if = { {0, 0, 0, 0, 0, 0}, 0, 0 };
+static struct hl_interface_s hl_if = { {0, 0, 0, 0, 0, 0, 0}, 0, 0 };
 
 int hl_interface_open(enum hl_transports tr)
 {
index cbeee5a14493ded6aebd884efab05043e11915dc..5b63ab855cbf3dcf94efd0352989915ca9c5c654 100644 (file)
@@ -44,6 +44,8 @@ struct hl_interface_param_s {
        unsigned api;
        /** */
        enum hl_transports transport;
+       /** */
+       int max_buffer;
 };
 
 struct hl_interface_s {
index 04b50d7f5b195b8282358161cda50a159a255844..55657294c250f738c0a8165a6bf2e38194798272 100644 (file)
@@ -50,6 +50,12 @@ static int hl_layout_open(struct hl_interface_s *adapter)
                return res;
        }
 
+       /* make sure adapter has set the buffer size */
+       if (!adapter->param.max_buffer) {
+               LOG_ERROR("buffer size not set");
+               return ERROR_FAIL;
+       }
+
        return ERROR_OK;
 }
 
index 3c3b84175704acc6ca84e9f3ff3f4da5b5e19ee1..8d2a4291a634e81047e56ccbd7c7ee732a49c661 100644 (file)
@@ -671,11 +671,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;
@@ -687,7 +687,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;
        }
 
@@ -719,11 +719,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;
@@ -735,7 +735,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;
        }
 

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)