Change in osmo-ccid-firmware[master]: fix the host/emulation build

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Hoernchen gerrit-no-reply at lists.osmocom.org
Thu Nov 28 16:32:06 UTC 2019


Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16319 )


Change subject: fix the host/emulation build
......................................................................

fix the host/emulation build

Going for __ARM__ to distinguish host and firmware builds is not
sufficient here, since we might be building on a ARM host, so there is
now a OCTSIMFWBUILD define.

Change-Id: Ib07a58b6102b1709f295d08a764c6f118a2d0b9e
---
M ccid_common/ccid_slot_fsm.c
M ccid_common/iso7816_3.c
M ccid_common/iso7816_fsm.c
M ccid_host/Makefile
M sysmoOCTSIM/gcc/Makefile
5 files changed, 32 insertions(+), 19 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/19/16319/1

diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index 29bffa0..0993cfc 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -98,7 +98,11 @@
 	osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_POWER_UP_IND, NULL);
 	cs->icc_powered = true;
 	card_uart_ctrl(ss->cuart, CUART_CTL_CLOCK, true);
+#ifdef OCTSIMFWBUILD
 	delay_us(10000);
+#else
+	usleep(10000);
+#endif
 
 	osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_RESET_REL_IND, NULL);
 	card_uart_ctrl(ss->cuart, CUART_CTL_RST, false);
@@ -119,7 +123,9 @@
 	case ISO7816_E_PPS_DONE_IND:
 	case ISO7816_E_PPS_FAILED_IND:
 		cs->event_data = data;
+#ifdef OCTSIMFWBUILD
 		asm volatile("dmb st": : :"memory");
+#endif
 		cs->event = event;
 		break;
 	default:
@@ -328,35 +334,38 @@
 	void *ctx = cs->ci->talloc_ctx;
 	struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
 	struct card_uart *cuart = talloc_zero(ctx, struct card_uart);
-	char id_buf[16] = "SIM0";
-	char devname[] = "foobar";
+	char id_buf[3+2+1];
+	char devname[2+1];
+	char *devnamep = 0;
+	char *drivername = "asf4";
 	int rc;
 
 	LOGPCS(cs, LOGL_DEBUG, "%s\n", __func__);
 
-	/* HACK: make this in some way configurable so it works both in the firmware
-	 * and on the host (functionfs) */
-//	if (cs->slot_nr == 0) {
-//		cs->icc_present = true;
-//		devname = "/dev/ttyUSB5";
-//	}
-	devname[0] = cs->slot_nr +0x30;
-	devname[1] = 0;
-	//sprintf(devname, "%d", cs->slot_nr);
+	snprintf(id_buf, sizeof(id_buf), "SIM%d", cs->slot_nr);
+#ifdef OCTSIMFWBUILD
+	snprintf(devname, sizeof(devname), "%d", cs->slot_nr);
+	devnamep = devname;
+#else
+	if (cs->slot_nr == 0) {
+		cs->icc_present = true;
+		devnamep = "/dev/ttyUSB5";
+	}
+	drivername = "tty";
+#endif
 
 	if (!cuart)
 		return -ENOMEM;
 
-	//snprintf(id_buf, sizeof(id_buf), "SIM%d", cs->slot_nr);
-	id_buf[3] = cs->slot_nr +0x30;
-	if (devname) {
-		rc = card_uart_open(cuart, "asf4", devname);
+	if (devnamep) {
+		rc = card_uart_open(cuart, drivername, devnamep);
 		if (rc < 0) {
 			LOGPCS(cs, LOGL_ERROR, "Cannot open UART %s: %d\n", devname, rc);
 			talloc_free(cuart);
 			return rc;
 		}
 	}
+
 	ss->fi = iso7816_fsm_alloc(ctx, LOGL_DEBUG, id_buf, cuart, iso_fsm_clot_user_cb, ss);
 	if (!ss->fi) {
 		LOGPCS(cs, LOGL_ERROR, "Cannot allocate ISO FSM\n");
diff --git a/ccid_common/iso7816_3.c b/ccid_common/iso7816_3.c
index f7262fb..e4273bd 100644
--- a/ccid_common/iso7816_3.c
+++ b/ccid_common/iso7816_3.c
@@ -18,7 +18,7 @@
 #include <stdint.h>
 #include <stddef.h>
 
-#include "utils.h"
+#include "osmocom/core/utils.h"
 #include "iso7816_3.h"
 
 const uint16_t iso7816_3_fi_table[16] = {
diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index 412bea7..399c321 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -1193,7 +1193,7 @@
 	}
 }
 
-#include <hal_gpio.h>
+
 static void tpdu_s_tx_hdr_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct osmo_fsm_inst *parent_fi = fi->proc.parent;
@@ -1213,7 +1213,9 @@
 }
 
 
-
+#if 0
+#include <hal_gpio.h>
+#endif
 static void tpdu_s_procedure_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct tpdu_fsm_priv *tfp = get_tpdu_fsm_priv(fi);
diff --git a/ccid_host/Makefile b/ccid_host/Makefile
index e9f34cc..7625177 100644
--- a/ccid_host/Makefile
+++ b/ccid_host/Makefile
@@ -11,6 +11,7 @@
 		 ../ccid_common/ccid_proto.o \
 		 ../ccid_common/ccid_device.o \
 		 ../ccid_common/ccid_slot_fsm.o \
+		 ../ccid_common/iso7816_3.o \
 		 ../ccid_common/iso7816_fsm.o
 	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -laio
 
@@ -28,6 +29,7 @@
 		cuart_driver_tty.o \
 		utils_ringbuffer.o \
 		../ccid_common/iso7816_fsm.o \
+		../ccid_common/iso7816_3.o \
 		../ccid_common/cuart.o
 	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(shell pkg-config --libs libosmosim)
 
diff --git a/sysmoOCTSIM/gcc/Makefile b/sysmoOCTSIM/gcc/Makefile
index 7a37036..6c0974f 100644
--- a/sysmoOCTSIM/gcc/Makefile
+++ b/sysmoOCTSIM/gcc/Makefile
@@ -9,7 +9,7 @@
 
 CFLAGS_CPU=-D__SAME54N19A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16
 CFLAGS=-x c -mthumb -DDEBUG -Os -ffunction-sections -fdata-sections -mlong-calls \
-       -g3 -Wall -c -std=gnu99 $(CFLAGS_CPU)
+       -g3 -Wall -c -std=gnu99 $(CFLAGS_CPU) -DOCTSIMFWBUILD
 
 CC = $(CROSS_COMPILE)gcc
 LD = $(CROSS_COMPILE)ld

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16319
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: Ib07a58b6102b1709f295d08a764c6f118a2d0b9e
Gerrit-Change-Number: 16319
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191128/c20dc709/attachment.htm>


More information about the gerrit-log mailing list