1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2009 by Dimitar Dimitrov <dinuxbg@gmail.com> *
5 * based on Dominic Rath's and Benedikt Sauter's usbprog.c *
6 ***************************************************************************/
12 #include <jtag/interface.h>
13 #include <jtag/commands.h>
14 #include "helper/system.h"
15 #include "libusb_helper.h"
17 #define USB_VID 0x15ba
18 #define USB_PID 0x001e
20 #define ARMJTAGEW_EPT_BULK_OUT 0x01u
21 #define ARMJTAGEW_EPT_BULK_IN 0x82u
23 #define ARMJTAGEW_USB_TIMEOUT 2000
25 #define ARMJTAGEW_IN_BUFFER_SIZE (4*1024)
26 #define ARMJTAGEW_OUT_BUFFER_SIZE (4*1024)
28 /* USB command request codes. */
29 #define CMD_GET_VERSION 0x00
30 #define CMD_SELECT_DPIMPL 0x10
31 #define CMD_SET_TCK_FREQUENCY 0x11
32 #define CMD_GET_TCK_FREQUENCY 0x12
33 #define CMD_MEASURE_MAX_TCK_FREQ 0x15
34 #define CMD_MEASURE_RTCK_RESPONSE 0x16
35 #define CMD_TAP_SHIFT 0x17
36 #define CMD_SET_TAPHW_STATE 0x20
37 #define CMD_GET_TAPHW_STATE 0x21
38 #define CMD_TGPWR_SETUP 0x22
40 /* Global USB buffers */
41 static uint8_t usb_in_buffer
[ARMJTAGEW_IN_BUFFER_SIZE
];
42 static uint8_t usb_out_buffer
[ARMJTAGEW_OUT_BUFFER_SIZE
];
44 /* Queue command functions */
45 static void armjtagew_end_state(tap_state_t state
);
46 static void armjtagew_state_move(void);
47 static void armjtagew_path_move(int num_states
, tap_state_t
*path
);
48 static void armjtagew_runtest(int num_cycles
);
49 static void armjtagew_scan(bool ir_scan
,
53 struct scan_command
*command
);
54 static void armjtagew_reset(int trst
, int srst
);
55 /* static void armjtagew_simple_command(uint8_t command); */
56 static int armjtagew_get_status(void);
58 /* tap buffer functions */
59 static void armjtagew_tap_init(void);
60 static int armjtagew_tap_execute(void);
61 static void armjtagew_tap_ensure_space(int scans
, int bits
);
62 static void armjtagew_tap_append_step(int tms
, int tdi
);
63 static void armjtagew_tap_append_scan(int length
, uint8_t *buffer
, struct scan_command
*command
);
65 /* ARM-JTAG-EW lowlevel functions */
67 struct libusb_device_handle
*usb_handle
;
70 static struct armjtagew
*armjtagew_usb_open(void);
71 static void armjtagew_usb_close(struct armjtagew
*armjtagew
);
72 static int armjtagew_usb_message(struct armjtagew
*armjtagew
, int out_length
, int in_length
);
73 static int armjtagew_usb_write(struct armjtagew
*armjtagew
, int out_length
);
74 static int armjtagew_usb_read(struct armjtagew
*armjtagew
, int exp_in_length
);
76 /* helper functions */
77 static int armjtagew_get_version_info(void);
79 #ifdef _DEBUG_USB_COMMS_
80 static void armjtagew_debug_buffer(uint8_t *buffer
, int length
);
83 static struct armjtagew
*armjtagew_handle
;
85 /**************************************************************************
86 * External interface implementation */
88 static int armjtagew_execute_queue(void)
90 struct jtag_command
*cmd
= jtag_command_queue
;
98 LOG_DEBUG_IO("runtest %i cycles, end in %i",
99 cmd
->cmd
.runtest
->num_cycles
,
100 cmd
->cmd
.runtest
->end_state
);
102 armjtagew_end_state(cmd
->cmd
.runtest
->end_state
);
103 armjtagew_runtest(cmd
->cmd
.runtest
->num_cycles
);
107 LOG_DEBUG_IO("statemove end in %i", cmd
->cmd
.statemove
->end_state
);
109 armjtagew_end_state(cmd
->cmd
.statemove
->end_state
);
110 armjtagew_state_move();
114 LOG_DEBUG_IO("pathmove: %i states, end in %i",
115 cmd
->cmd
.pathmove
->num_states
,
116 cmd
->cmd
.pathmove
->path
[cmd
->cmd
.pathmove
->num_states
- 1]);
118 armjtagew_path_move(cmd
->cmd
.pathmove
->num_states
,
119 cmd
->cmd
.pathmove
->path
);
123 LOG_DEBUG_IO("scan end in %i", cmd
->cmd
.scan
->end_state
);
125 armjtagew_end_state(cmd
->cmd
.scan
->end_state
);
127 scan_size
= jtag_build_buffer(cmd
->cmd
.scan
, &buffer
);
128 LOG_DEBUG_IO("scan input, length = %d", scan_size
);
130 #ifdef _DEBUG_USB_COMMS_
131 armjtagew_debug_buffer(buffer
, (scan_size
+ 7) / 8);
133 type
= jtag_scan_type(cmd
->cmd
.scan
);
134 armjtagew_scan(cmd
->cmd
.scan
->ir_scan
,
136 scan_size
, cmd
->cmd
.scan
);
140 LOG_DEBUG_IO("reset trst: %i srst %i",
141 cmd
->cmd
.reset
->trst
,
142 cmd
->cmd
.reset
->srst
);
144 armjtagew_tap_execute();
146 if (cmd
->cmd
.reset
->trst
== 1)
147 tap_set_state(TAP_RESET
);
148 armjtagew_reset(cmd
->cmd
.reset
->trst
, cmd
->cmd
.reset
->srst
);
152 LOG_DEBUG_IO("sleep %" PRIu32
, cmd
->cmd
.sleep
->us
);
153 armjtagew_tap_execute();
154 jtag_sleep(cmd
->cmd
.sleep
->us
);
158 LOG_ERROR("BUG: unknown JTAG command type encountered");
164 return armjtagew_tap_execute();
167 /* Sets speed in kHz. */
168 static int armjtagew_speed(int speed
)
174 usb_out_buffer
[0] = CMD_SET_TCK_FREQUENCY
;
175 buf_set_u32(usb_out_buffer
+ 1, 0, 32, speed
*1000);
177 result
= armjtagew_usb_message(armjtagew_handle
, 5, 4);
180 LOG_ERROR("ARM-JTAG-EW setting speed failed (%d)", result
);
181 return ERROR_JTAG_DEVICE_ERROR
;
184 usb_out_buffer
[0] = CMD_GET_TCK_FREQUENCY
;
185 result
= armjtagew_usb_message(armjtagew_handle
, 1, 4);
186 speed_real
= (int)buf_get_u32(usb_in_buffer
, 0, 32) / 1000;
188 LOG_ERROR("ARM-JTAG-EW getting speed failed (%d)", result
);
189 return ERROR_JTAG_DEVICE_ERROR
;
191 LOG_INFO("Requested speed %dkHz, emulator reported %dkHz.", speed
, speed_real
);
196 static int armjtagew_khz(int khz
, int *jtag_speed
)
203 static int armjtagew_speed_div(int speed
, int *khz
)
210 static int armjtagew_init(void)
214 armjtagew_handle
= armjtagew_usb_open();
216 if (armjtagew_handle
== 0) {
218 "Cannot find ARM-JTAG-EW Interface! Please check connection and permissions.");
219 return ERROR_JTAG_INIT_FAILED
;
223 while (check_cnt
< 3) {
224 if (armjtagew_get_version_info() == ERROR_OK
) {
225 /* attempt to get status */
226 armjtagew_get_status();
234 LOG_INFO("ARM-JTAG-EW initial read failed, don't worry");
236 /* Initial JTAG speed (for reset and initialization): 32 kHz */
239 LOG_INFO("ARM-JTAG-EW JTAG Interface ready");
241 armjtagew_reset(0, 0);
242 armjtagew_tap_init();
247 static int armjtagew_quit(void)
249 armjtagew_usb_close(armjtagew_handle
);
253 /**************************************************************************
254 * Queue command implementations */
256 static void armjtagew_end_state(tap_state_t state
)
258 if (tap_is_state_stable(state
))
259 tap_set_end_state(state
);
261 LOG_ERROR("BUG: %i is not a valid end state", state
);
266 /* Goes to the end state. */
267 static void armjtagew_state_move(void)
271 uint8_t tms_scan
= tap_get_tms_path(tap_get_state(), tap_get_end_state());
272 int tms_count
= tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
274 for (i
= 0; i
< tms_count
; i
++) {
275 tms
= (tms_scan
>> i
) & 1;
276 armjtagew_tap_append_step(tms
, 0);
279 tap_set_state(tap_get_end_state());
282 static void armjtagew_path_move(int num_states
, tap_state_t
*path
)
286 for (i
= 0; i
< num_states
; i
++) {
288 * TODO: The ARM-JTAG-EW hardware delays TDI with 3 TCK cycles when in RTCK mode.
289 * Either handle that here, or update the documentation with examples
290 * how to fix that in the configuration files.
292 if (path
[i
] == tap_state_transition(tap_get_state(), false))
293 armjtagew_tap_append_step(0, 0);
294 else if (path
[i
] == tap_state_transition(tap_get_state(), true))
295 armjtagew_tap_append_step(1, 0);
297 LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
298 tap_state_name(tap_get_state()), tap_state_name(path
[i
]));
302 tap_set_state(path
[i
]);
305 tap_set_end_state(tap_get_state());
308 static void armjtagew_runtest(int num_cycles
)
312 tap_state_t saved_end_state
= tap_get_end_state();
314 /* only do a state_move when we're not already in IDLE */
315 if (tap_get_state() != TAP_IDLE
) {
316 armjtagew_end_state(TAP_IDLE
);
317 armjtagew_state_move();
320 /* execute num_cycles */
321 for (i
= 0; i
< num_cycles
; i
++)
322 armjtagew_tap_append_step(0, 0);
324 /* finish in end_state */
325 armjtagew_end_state(saved_end_state
);
326 if (tap_get_state() != tap_get_end_state())
327 armjtagew_state_move();
330 static void armjtagew_scan(bool ir_scan
,
334 struct scan_command
*command
)
336 tap_state_t saved_end_state
;
338 armjtagew_tap_ensure_space(1, scan_size
+ 8);
340 saved_end_state
= tap_get_end_state();
342 /* Move to appropriate scan state */
343 armjtagew_end_state(ir_scan
? TAP_IRSHIFT
: TAP_DRSHIFT
);
345 /* Only move if we're not already there */
346 if (tap_get_state() != tap_get_end_state())
347 armjtagew_state_move();
349 armjtagew_end_state(saved_end_state
);
352 armjtagew_tap_append_scan(scan_size
, buffer
, command
);
354 /* We are in Exit1, go to Pause */
355 armjtagew_tap_append_step(0, 0);
357 tap_set_state(ir_scan
? TAP_IRPAUSE
: TAP_DRPAUSE
);
359 if (tap_get_state() != tap_get_end_state())
360 armjtagew_state_move();
363 static void armjtagew_reset(int trst
, int srst
)
365 const uint8_t trst_mask
= (1u << 5);
366 const uint8_t srst_mask
= (1u << 6);
369 uint8_t change_mask
= 0;
372 LOG_DEBUG("trst: %i, srst: %i", trst
, srst
);
376 outp_en
&= ~srst_mask
; /* tristate */
377 change_mask
|= srst_mask
;
378 } else if (srst
== 1) {
380 outp_en
|= srst_mask
;
381 change_mask
|= srst_mask
;
386 outp_en
&= ~trst_mask
; /* tristate */
387 change_mask
|= trst_mask
;
388 } else if (trst
== 1) {
390 outp_en
|= trst_mask
;
391 change_mask
|= trst_mask
;
394 usb_out_buffer
[0] = CMD_SET_TAPHW_STATE
;
395 usb_out_buffer
[1] = val
;
396 usb_out_buffer
[2] = outp_en
;
397 usb_out_buffer
[3] = change_mask
;
398 result
= armjtagew_usb_write(armjtagew_handle
, 4);
400 LOG_ERROR("ARM-JTAG-EW TRST/SRST pin set failed failed (%d)", result
);
403 static int armjtagew_get_status(void)
407 usb_out_buffer
[0] = CMD_GET_TAPHW_STATE
;
408 result
= armjtagew_usb_message(armjtagew_handle
, 1, 12);
411 unsigned int u_tg
= buf_get_u32(usb_in_buffer
, 0, 16);
413 "U_tg = %d mV, U_aux = %d mV, U_tgpwr = %d mV, I_tgpwr = %d mA, D1 = %d, Target power %s %s",
414 (int)(buf_get_u32(usb_in_buffer
+ 0, 0, 16)),
415 (int)(buf_get_u32(usb_in_buffer
+ 2, 0, 16)),
416 (int)(buf_get_u32(usb_in_buffer
+ 4, 0, 16)),
417 (int)(buf_get_u32(usb_in_buffer
+ 6, 0, 16)),
419 usb_in_buffer
[11] ? "OVERCURRENT" : "OK",
420 usb_in_buffer
[10] ? "enabled" : "disabled");
423 LOG_ERROR("Vref too low. Check Target Power");
425 LOG_ERROR("ARM-JTAG-EW command CMD_GET_TAPHW_STATE failed (%d)", result
);
430 static int armjtagew_get_version_info(void)
436 /* query hardware version */
437 usb_out_buffer
[0] = CMD_GET_VERSION
;
438 result
= armjtagew_usb_message(armjtagew_handle
, 1, 4 + 15 + 256);
441 LOG_ERROR("ARM-JTAG-EW command CMD_GET_VERSION failed (%d)", result
);
442 return ERROR_JTAG_DEVICE_ERROR
;
445 memcpy(sn
, usb_in_buffer
+ 4, 15);
447 memcpy(auxinfo
, usb_in_buffer
+ 4+15, 256);
451 "ARM-JTAG-EW firmware version %d.%d, hardware revision %c, SN=%s, Additional info: %s",
454 isgraph(usb_in_buffer
[2]) ? usb_in_buffer
[2] : 'X',
458 if (1 != usb_in_buffer
[1] || 6 != usb_in_buffer
[0])
460 "ARM-JTAG-EW firmware version %d.%d is untested with this version of OpenOCD. You might experience unexpected behavior.",
466 COMMAND_HANDLER(armjtagew_handle_armjtagew_info_command
)
468 if (armjtagew_get_version_info() == ERROR_OK
) {
469 /* attempt to get status */
470 armjtagew_get_status();
476 static const struct command_registration armjtagew_command_handlers
[] = {
478 .name
= "armjtagew_info",
479 .handler
= &armjtagew_handle_armjtagew_info_command
,
480 .mode
= COMMAND_EXEC
,
481 .help
= "query armjtagew info",
484 COMMAND_REGISTRATION_DONE
487 static struct jtag_interface armjtagew_interface
= {
488 .execute_queue
= armjtagew_execute_queue
,
491 struct adapter_driver armjtagew_adapter_driver
= {
492 .name
= "arm-jtag-ew",
493 .transports
= jtag_only
,
494 .commands
= armjtagew_command_handlers
,
496 .init
= armjtagew_init
,
497 .quit
= armjtagew_quit
,
498 .speed
= armjtagew_speed
,
499 .khz
= armjtagew_khz
,
500 .speed_div
= armjtagew_speed_div
,
502 .jtag_ops
= &armjtagew_interface
,
505 /**************************************************************************
506 * ARM-JTAG-EW tap functions */
508 /* 2048 is the max value we can use here */
509 #define ARMJTAGEW_TAP_BUFFER_SIZE 2048
511 static int tap_length
;
512 static uint8_t tms_buffer
[ARMJTAGEW_TAP_BUFFER_SIZE
];
513 static uint8_t tdi_buffer
[ARMJTAGEW_TAP_BUFFER_SIZE
];
514 static uint8_t tdo_buffer
[ARMJTAGEW_TAP_BUFFER_SIZE
];
516 struct pending_scan_result
{
517 int first
; /* First bit position in tdo_buffer to read */
518 int length
; /* Number of bits to read */
519 struct scan_command
*command
; /* Corresponding scan command */
523 #define MAX_PENDING_SCAN_RESULTS 256
525 static int pending_scan_results_length
;
526 static struct pending_scan_result pending_scan_results_buffer
[MAX_PENDING_SCAN_RESULTS
];
530 static void armjtagew_tap_init(void)
533 pending_scan_results_length
= 0;
536 static void armjtagew_tap_ensure_space(int scans
, int bits
)
538 int available_scans
= MAX_PENDING_SCAN_RESULTS
- pending_scan_results_length
;
539 int available_bits
= ARMJTAGEW_TAP_BUFFER_SIZE
* 8 - tap_length
;
541 if (scans
> available_scans
|| bits
> available_bits
)
542 armjtagew_tap_execute();
545 static void armjtagew_tap_append_step(int tms
, int tdi
)
548 int index_local
= tap_length
/ 8;
550 if (index_local
< ARMJTAGEW_TAP_BUFFER_SIZE
) {
551 int bit_index
= tap_length
% 8;
552 uint8_t bit
= 1 << bit_index
;
555 tms_buffer
[index_local
] |= bit
;
557 tms_buffer
[index_local
] &= ~bit
;
560 tdi_buffer
[index_local
] |= bit
;
562 tdi_buffer
[index_local
] &= ~bit
;
566 LOG_ERROR("armjtagew_tap_append_step, overflow");
569 void armjtagew_tap_append_scan(int length
, uint8_t *buffer
, struct scan_command
*command
)
571 struct pending_scan_result
*pending_scan_result
=
572 &pending_scan_results_buffer
[pending_scan_results_length
];
575 pending_scan_result
->first
= tap_length
;
576 pending_scan_result
->length
= length
;
577 pending_scan_result
->command
= command
;
578 pending_scan_result
->buffer
= buffer
;
580 for (i
= 0; i
< length
; i
++)
581 armjtagew_tap_append_step((i
< length
-1 ? 0 : 1), (buffer
[i
/8] >> (i
%8)) & 1);
582 pending_scan_results_length
++;
585 /* Pad and send a tap sequence to the device, and receive the answer.
586 * For the purpose of padding we assume that we are in idle or pause state. */
587 static int armjtagew_tap_execute(void)
595 if (tap_length
> 0) {
596 /* Pad last byte so that tap_length is divisible by 8 */
597 while (tap_length
% 8 != 0) {
598 /* More of the last TMS value keeps us in the same state,
599 * analogous to free-running JTAG interfaces. */
600 armjtagew_tap_append_step(last_tms
, 0);
603 byte_length
= tap_length
/ 8;
605 usb_out_buffer
[0] = CMD_TAP_SHIFT
;
606 buf_set_u32(usb_out_buffer
+ 1, 0, 16, byte_length
);
609 for (i
= 0; i
< byte_length
; i
++)
610 usb_out_buffer
[tms_offset
+ i
] = flip_u32(tms_buffer
[i
], 8);
612 tdi_offset
= tms_offset
+ byte_length
;
613 for (i
= 0; i
< byte_length
; i
++)
614 usb_out_buffer
[tdi_offset
+ i
] = flip_u32(tdi_buffer
[i
], 8);
616 result
= armjtagew_usb_message(armjtagew_handle
,
623 stat_local
= (int)buf_get_u32(usb_in_buffer
+ byte_length
, 0, 32);
626 "armjtagew_tap_execute, emulator returned error code %d for a CMD_TAP_SHIFT command",
628 return ERROR_JTAG_QUEUE_FAILED
;
631 for (i
= 0; i
< byte_length
; i
++)
632 tdo_buffer
[i
] = flip_u32(usb_in_buffer
[i
], 8);
634 for (i
= 0; i
< pending_scan_results_length
; i
++) {
635 struct pending_scan_result
*pending_scan_result
=
636 &pending_scan_results_buffer
[i
];
637 uint8_t *buffer
= pending_scan_result
->buffer
;
638 int length
= pending_scan_result
->length
;
639 int first
= pending_scan_result
->first
;
640 struct scan_command
*command
= pending_scan_result
->command
;
643 buf_set_buf(tdo_buffer
, first
, buffer
, 0, length
);
645 LOG_DEBUG_IO("pending scan result, length = %d", length
);
647 #ifdef _DEBUG_USB_COMMS_
648 armjtagew_debug_buffer(buffer
, byte_length
);
651 if (jtag_read_buffer(buffer
, command
) != ERROR_OK
) {
652 armjtagew_tap_init();
653 return ERROR_JTAG_QUEUE_FAILED
;
656 free(pending_scan_result
->buffer
);
659 LOG_ERROR("armjtagew_tap_execute, wrong result %d, expected %d",
662 return ERROR_JTAG_QUEUE_FAILED
;
665 armjtagew_tap_init();
671 /****************************************************************************
672 * JLink USB low-level functions */
674 static struct armjtagew
*armjtagew_usb_open(void)
676 const uint16_t vids
[] = { USB_VID
, 0 };
677 const uint16_t pids
[] = { USB_PID
, 0 };
678 struct libusb_device_handle
*dev
;
680 if (jtag_libusb_open(vids
, pids
, &dev
, NULL
) != ERROR_OK
)
683 struct armjtagew
*result
= malloc(sizeof(struct armjtagew
));
684 result
->usb_handle
= dev
;
687 /* libusb_set_configuration required under win32 */
688 struct libusb_config_descriptor
*config
;
689 struct libusb_device
*usb_dev
= libusb_get_device(dev
);
690 libusb_get_config_descriptor(usb_dev
, 0, &config
);
691 libusb_set_configuration(dev
, config
->bConfigurationValue
);
693 libusb_claim_interface(dev
, 0);
696 * This makes problems under Mac OS X. And is not needed
697 * under Windows. Hopefully this will not break a linux build
699 libusb_set_interface_alt_setting(dev
, 0, 0);
704 static void armjtagew_usb_close(struct armjtagew
*armjtagew
)
706 libusb_close(armjtagew
->usb_handle
);
710 /* Send a message and receive the reply. */
711 static int armjtagew_usb_message(struct armjtagew
*armjtagew
, int out_length
, int in_length
)
715 result
= armjtagew_usb_write(armjtagew
, out_length
);
716 if (result
== out_length
) {
717 result
= armjtagew_usb_read(armjtagew
, in_length
);
718 if (result
!= in_length
) {
719 LOG_ERROR("jtag_libusb_bulk_read failed (requested=%d, result=%d)",
725 LOG_ERROR("jtag_libusb_bulk_write failed (requested=%d, result=%d)", out_length
, result
);
731 /* Write data from out_buffer to USB. */
732 static int armjtagew_usb_write(struct armjtagew
*armjtagew
, int out_length
)
737 if (out_length
> ARMJTAGEW_OUT_BUFFER_SIZE
) {
738 LOG_ERROR("armjtagew_write illegal out_length=%d (max=%d)",
740 ARMJTAGEW_OUT_BUFFER_SIZE
);
744 result
= jtag_libusb_bulk_write(armjtagew
->usb_handle
, ARMJTAGEW_EPT_BULK_OUT
,
745 (char *)usb_out_buffer
, out_length
, ARMJTAGEW_USB_TIMEOUT
, &transferred
);
747 LOG_DEBUG_IO("armjtagew_usb_write, out_length = %d, result = %d", out_length
, result
);
749 #ifdef _DEBUG_USB_COMMS_
750 armjtagew_debug_buffer(usb_out_buffer
, out_length
);
752 if (result
!= ERROR_OK
)
757 /* Read data from USB into in_buffer. */
758 static int armjtagew_usb_read(struct armjtagew
*armjtagew
, int exp_in_length
)
761 int result
= jtag_libusb_bulk_read(armjtagew
->usb_handle
, ARMJTAGEW_EPT_BULK_IN
,
762 (char *)usb_in_buffer
, exp_in_length
, ARMJTAGEW_USB_TIMEOUT
, &transferred
);
764 LOG_DEBUG_IO("armjtagew_usb_read, result = %d", result
);
766 #ifdef _DEBUG_USB_COMMS_
767 armjtagew_debug_buffer(usb_in_buffer
, result
);
769 if (result
!= ERROR_OK
)
774 #ifdef _DEBUG_USB_COMMS_
775 #define BYTES_PER_LINE 16
777 static void armjtagew_debug_buffer(uint8_t *buffer
, int length
)
784 for (i
= 0; i
< length
; i
+= BYTES_PER_LINE
) {
785 snprintf(line
, 5, "%04x", i
);
786 for (j
= i
; j
< i
+ BYTES_PER_LINE
&& j
< length
; j
++) {
787 snprintf(s
, 4, " %02x", buffer
[j
]);
790 LOG_DEBUG("%s", line
);
792 /* Prevent GDB timeout (writing to log might take some time) */