James Tavares has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/26864 )
Change subject: simtrace2-tool: hack: kick the comms by sending a fake message ......................................................................
simtrace2-tool: hack: kick the comms by sending a fake message
This is a workaround until the root cause of the communications failure between simtrace2-tool and simtrace2 firmware is identified. Additional details provided on simtrace mailing list.
Change-Id: I40fa06bee5d8194516497e16597e069124ddf0fb --- M host/include/osmocom/simtrace2/simtrace2_api.h M host/lib/simtrace2_api.c M host/src/simtrace2-tool.c 3 files changed, 23 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/64/26864/1
diff --git a/host/include/osmocom/simtrace2/simtrace2_api.h b/host/include/osmocom/simtrace2/simtrace2_api.h index d658d16..3a7e5ae 100644 --- a/host/include/osmocom/simtrace2/simtrace2_api.h +++ b/host/include/osmocom/simtrace2/simtrace2_api.h @@ -44,6 +44,7 @@ int osmo_st2_slot_tx_msg(struct osmo_st2_slot *slot, struct msgb *msg, uint8_t msg_class, uint8_t msg_type);
+int osmo_st2_generic_do_error_none(struct osmo_st2_cardem_inst *ci);
int osmo_st2_cardem_request_card_insert(struct osmo_st2_cardem_inst *ci, bool inserted); int osmo_st2_cardem_request_pb_and_rx(struct osmo_st2_cardem_inst *ci, uint8_t pb, uint8_t le); diff --git a/host/lib/simtrace2_api.c b/host/lib/simtrace2_api.c index 4ad7eb7..beb6de4 100644 --- a/host/lib/simtrace2_api.c +++ b/host/lib/simtrace2_api.c @@ -155,6 +155,24 @@ }
/*********************************************************************** + * Generic protocol + ***********************************************************************/ + +/*! \brief Send an empty DO_ERROR message to the simtrace2 board */ +int osmo_st2_generic_do_error_none(struct osmo_st2_cardem_inst *ci) +{ + struct msgb *msg = st_msgb_alloc(); + struct cardemu_usb_msg_error *err; + + LOGSLOT(ci->slot, LOGL_NOTICE, "<= %s\n", __func__); + + err = (struct cardemu_usb_msg_error *) msgb_put(msg, sizeof(*err)); + memset(err, 0, sizeof(*err)); + + return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_GENERIC, SIMTRACE_CMD_DO_ERROR); +} + +/*********************************************************************** * Card Emulation protocol ***********************************************************************/
diff --git a/host/src/simtrace2-tool.c b/host/src/simtrace2-tool.c index d92638f..407eac9 100644 --- a/host/src/simtrace2-tool.c +++ b/host/src/simtrace2-tool.c @@ -297,6 +297,10 @@ fprintf(stderr, "can't obtain EP addrs; rc=%d\n", rc); goto close_exit; } + + // HACK: kick the board with a fake message to get subsequent messages to be accepted + // TODO: figure out the real problem, and remove this + osmo_st2_generic_do_error_none(ci); }
if (argc - optind <= 0) {
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/26864 )
Change subject: simtrace2-tool: hack: kick the comms by sending a fake message ......................................................................
Patch Set 1:
I think we had a similar hack / work-around already in the past, but I couldn't immediately find it. The first command had to be sent twice to work, but even that didn't reliably make it work in all situations, nor did the problem reilably occur when the first command is sent just as-is. My suspicion also was that it depends a lot on the host OS/driver/controller.
Attention is currently required from: jtavares. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/26864 )
Change subject: simtrace2-tool: hack: kick the comms by sending a fake message ......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1: I think this might be the same issue as I attempted to fix in https://gerrit.osmocom.org/c/simtrace2/+/16910 - unfortunately never found the time to fully resolve this.
jtavares has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/26864 )
Change subject: simtrace2-tool: hack: kick the comms by sending a fake message ......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1: Hello All,
Just bumping this commit for reconsideration. I know it is hack, but it has proved very useful in our environment. Some additional background:
The simtrace2 firmware appears to have a problem (probably a race condition of some sort, with the USB stack) where it accepts the first USB message sent by simtrace2-list after a reset, but then ignores others. During investigation, it was noticed that when sending two commands in a row from a single instance of simtrace2, the first is ignored, and the second is processed. So, a hack was put into `simtrace2-tool` so that it sends a fake, empty, error message, to kick the remote SIM firmware into accepting the second, real message. The strange thing is, that when you send two messages like this, it has the side effect of keeping the processor from getting stuck.
So, something about sending two messages has two effects 1.) it kicks the SIM firmware, if it is stuck, and 2.) prevents the SIM firmware from getting stuck in the first place.
Attention is currently required from: jtavares. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/26864 )
Change subject: simtrace2-tool: hack: kick the comms by sending a fake message ......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Hello All, […]
Well, the first thing should always be to file a bug report about a bug. I've just copy+pasted your comment here and created https://osmocom.org/issues/5770
Second, we should try to resolve the actual problem, and if that fails we can still look at the work-around.
Let's follow-up in the redmine issue.
Attention is currently required from: jtavares. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/26864 )
Change subject: simtrace2-tool: hack: kick the comms by sending a fake message ......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1: Can you plase confirm if https://gerrit.osmocom.org/c/simtrace2/+/16910 resolves your problem? I've re-discovered this almost three year old patch in a branch...