Change in osmo-ccid-firmware[master]: dbg

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
Tue Nov 26 18:39:13 UTC 2019


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


Change subject: dbg
......................................................................

dbg

Change-Id: I4340cb53f0f903842eb1c4d60a36d44ac9e5cbde
---
M ccid_common/cuart.h
M ccid_common/iso7816_fsm.c
M sysmoOCTSIM/atmel_start.c
M sysmoOCTSIM/cuart_driver_asf4_usart_async.c
M sysmoOCTSIM/driver_init.c
M sysmoOCTSIM/gcc/Makefile
M sysmoOCTSIM/hpl/sercom/hpl_sercom.c
M sysmoOCTSIM/libosmo_emb.c
M sysmoOCTSIM/main.c
9 files changed, 124 insertions(+), 23 deletions(-)



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

diff --git a/ccid_common/cuart.h b/ccid_common/cuart.h
index 9c93b7e..efd70f0 100644
--- a/ccid_common/cuart.h
+++ b/ccid_common/cuart.h
@@ -23,6 +23,7 @@
 
 enum card_uart_ctl {
 	CUART_CTL_RX,		/* enable/disable receiver */
+	CUART_CTL_NO_RXTX,		/* enable/disable receiver */
 	CUART_CTL_POWER,	/* enable/disable ICC power */
 	CUART_CTL_CLOCK,	/* enable/disable ICC clock */
 	CUART_CTL_CLOCK_FREQ, /* set ICC clock frequency (hz)*/
diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index 3d09a84..585d25d 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -305,7 +305,7 @@
 {
 	struct iso7816_3_priv *ip = get_iso7816_3_priv(fi);
 	OSMO_ASSERT(fi->fsm == &iso7816_3_fsm);
-	card_uart_ctrl(ip->uart, CUART_CTL_RX, false);
+	card_uart_ctrl(ip->uart, CUART_CTL_NO_RXTX, true);
 	/* reset the TPDU state machine */
 	osmo_fsm_inst_dispatch(ip->tpdu_fi, ISO7816_E_TPDU_CLEAR_REQ, NULL);
 }
@@ -1135,11 +1135,14 @@
 	}
 }
 
+#include <hal_gpio.h>
 static void tpdu_s_tx_hdr_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	OSMO_ASSERT(fi->fsm == &tpdu_fsm);
 	switch (event) {
 	case ISO7816_E_TX_COMPL:
+
+
 		/* Rx of single byte is already enabled by previous card_uart_tx() call */
 		osmo_fsm_inst_state_chg(fi, TPDU_S_PROCEDURE, 0, 0);
 		break;
@@ -1174,6 +1177,12 @@
 		} else if (byte == tpduh->ins) {
 			if (tfp->is_command) {
 				/* transmit all remaining bytes */
+#if 0
+// rx -> tx delay
+				gpio_set_pin_level(PIN_PB12, true);
+				delay_us(1);
+				gpio_set_pin_level(PIN_PB12, false);
+#endif
 				card_uart_tx(ip->uart, msgb_l2(tfp->tpdu), msgb_l2len(tfp->tpdu), true);
 				osmo_fsm_inst_state_chg(fi, TPDU_S_TX_REMAINING, 0, 0);
 			} else {
diff --git a/sysmoOCTSIM/atmel_start.c b/sysmoOCTSIM/atmel_start.c
index bee1ed2..6670364 100644
--- a/sysmoOCTSIM/atmel_start.c
+++ b/sysmoOCTSIM/atmel_start.c
@@ -14,6 +14,6 @@
 	system_init();
 	dma_memory_init();
 	dma_memory_register_callback(DMA_MEMORY_COMPLETE_CB, M2M_DMA_complete_cb);
-	stdio_redirect_init();
+//	stdio_redirect_init();
 	usb_init();
 }
diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index a8f8044..14fe491 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -348,14 +348,39 @@
 	Sercom *sercom = cuart->u.asf4.usa_pd->device.hw;
 
 	switch (ctl) {
+	case CUART_CTL_NO_RXTX:
+//		if (arg){
+//			uint32_t ctrlb = ((Sercom *)sercom)->USART.CTRLB.reg;
+//			ctrlb &= ~(SERCOM_USART_CTRLB_TXEN | SERCOM_USART_CTRLB_RXEN);
+//			((Sercom *)sercom)->USART.CTRLB.reg = ctrlb;
+//			hri_sercomusart_wait_for_sync(sercom, SERCOM_USART_SYNCBUSY_MASK);
+//		} else {
+//			uint32_t ctrlb = ((Sercom *)sercom)->USART.CTRLB.reg;
+//			ctrlb |= (SERCOM_USART_CTRLB_TXEN | SERCOM_USART_CTRLB_RXEN);
+//			((Sercom *)sercom)->USART.CTRLB.reg = ctrlb;
+//			hri_sercomusart_wait_for_sync(sercom, SERCOM_USART_SYNCBUSY_MASK);
+//		}
+		break;
 	case CUART_CTL_RX:
 		if (arg){
-			sercom->USART.CTRLB.bit.RXEN = 1;
-			sercom->USART.CTRLB.bit.TXEN = 0;
+////			delay_us(cuart->u.asf4.extrawait_after_rx);
+//			uint32_t ctrlb = ((Sercom *)sercom)->USART.CTRLB.reg;
+//			ctrlb &= ~SERCOM_USART_CTRLB_TXEN;
+//			ctrlb |= SERCOM_USART_CTRLB_RXEN;
+//			((Sercom *)sercom)->USART.CTRLB.reg = ctrlb;
+//			hri_sercomusart_wait_for_sync(sercom, SERCOM_USART_SYNCBUSY_MASK);
+//
+////			sercom->USART.CTRLB.bit.TXEN = 0;
+////			sercom->USART.CTRLB.bit.RXEN = 1;
 		} else {
 			delay_us(cuart->u.asf4.extrawait_after_rx);
-			sercom->USART.CTRLB.bit.RXEN = 0;
-			sercom->USART.CTRLB.bit.TXEN = 1;
+////			sercom->USART.CTRLB.bit.RXEN = 0;
+////			sercom->USART.CTRLB.bit.TXEN = 1;
+//			uint32_t ctrlb = ((Sercom *)sercom)->USART.CTRLB.reg;
+//			ctrlb &= ~SERCOM_USART_CTRLB_RXEN;
+//			ctrlb |= SERCOM_USART_CTRLB_TXEN;
+//			((Sercom *)sercom)->USART.CTRLB.reg = ctrlb;
+//			hri_sercomusart_wait_for_sync(sercom, SERCOM_USART_SYNCBUSY_MASK);
 		}
 		break;
 	case CUART_CTL_RST:
diff --git a/sysmoOCTSIM/driver_init.c b/sysmoOCTSIM/driver_init.c
index c373dc2..7071ea5 100644
--- a/sysmoOCTSIM/driver_init.c
+++ b/sysmoOCTSIM/driver_init.c
@@ -33,7 +33,7 @@
 #define SIM6_BUFFER_SIZE 512
 
 /*! The buffer size for USART */
-#define UART_DEBUG_BUFFER_SIZE 256
+#define UART_DEBUG_BUFFER_SIZE 4096
 
 struct usart_async_descriptor SIM0;
 struct usart_async_descriptor SIM1;
diff --git a/sysmoOCTSIM/gcc/Makefile b/sysmoOCTSIM/gcc/Makefile
index 41f5d10..95a582f 100644
--- a/sysmoOCTSIM/gcc/Makefile
+++ b/sysmoOCTSIM/gcc/Makefile
@@ -8,7 +8,7 @@
 CROSS_COMPILE= arm-none-eabi-
 
 CFLAGS_CPU=-D__SAME54N19A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16
-CFLAGS=-x c -mthumb -DDEBUG -O0 -ffunction-sections -fdata-sections -mlong-calls \
+CFLAGS=-x c -mthumb -DDEBUG -Os -ffunction-sections -fdata-sections -mlong-calls \
        -g3 -Wall -c -std=gnu99 $(CFLAGS_CPU)
 
 CC = $(CROSS_COMPILE)gcc
diff --git a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
index f235115..272fb07 100644
--- a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
+++ b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
@@ -577,7 +577,7 @@
 		hri_sercomusart_write_INTEN_ERROR_bit(device->hw, state);
 	}
 }
-
+#include <hal_gpio.h>
 /**
  * \internal Sercom interrupt handler
  *
@@ -591,6 +591,12 @@
 		hri_sercomusart_clear_INTEN_DRE_bit(hw);
 		device->usart_cb.tx_byte_sent(device);
 	} else if (hri_sercomusart_get_interrupt_TXC_bit(hw) && hri_sercomusart_get_INTEN_TXC_bit(hw)) {
+#if 0
+// tx byte last edge <-> txc irq delay
+				gpio_set_pin_level(PIN_PB12, true);
+				delay_us(1);
+				gpio_set_pin_level(PIN_PB12, false);
+#endif
 		hri_sercomusart_clear_INTEN_TXC_bit(hw);
 		device->usart_cb.tx_done_cb(device);
 	} else if (hri_sercomusart_get_interrupt_RXC_bit(hw)) {
@@ -600,8 +606,20 @@
 			hri_sercomusart_clear_STATUS_reg(hw, SERCOM_USART_STATUS_MASK);
 			return;
 		}
+#if 0
+// rx byte last edge <-> rxc irq delay
+				gpio_set_pin_level(PIN_PB12, true);
+				delay_us(1);
+				gpio_set_pin_level(PIN_PB12, false);
+#endif
 
 		device->usart_cb.rx_done_cb(device, hri_sercomusart_read_DATA_reg(hw));
+#if 0
+// rx byte last edge <-> rxc irq end delay
+				gpio_set_pin_level(PIN_PB12, true);
+				delay_us(1);
+				gpio_set_pin_level(PIN_PB12, false);
+#endif
 	} else if (hri_sercomusart_get_interrupt_ERROR_bit(hw)) {
 		uint32_t status;
 
diff --git a/sysmoOCTSIM/libosmo_emb.c b/sysmoOCTSIM/libosmo_emb.c
index 09555f3..e550b07 100644
--- a/sysmoOCTSIM/libosmo_emb.c
+++ b/sysmoOCTSIM/libosmo_emb.c
@@ -41,43 +41,43 @@
 	[DUSB] = {
 		.name = "USB",
 		.description = "USB Transport",
-		.enabled = 1,
+		.enabled = 0,
 		.loglevel = LOGL_NOTICE,
 	},
 	[DCCID] = {
 		.name = "CCID",
 		.description = "USB-CCID Protocol",
-		.enabled = 1,
+		.enabled = 0,
 		.loglevel = LOGL_DEBUG,
 	},
 	[DISO7816] = {
 		.name = "ISO7816",
 		.description = "ISO7816-3 State machines",
-		.enabled = 1,
+		.enabled = 0,
 		.loglevel = LOGL_DEBUG,
 	},
 	[DATR] = {
 		.name = "ATR",
 		.description = "ATR (Answer To Reset) FSM",
-		.enabled = 1,
+		.enabled = 0,
 		.loglevel = LOGL_DEBUG,
 	},
 	[DTPDU] = {
 		.name = "TPDU",
 		.description = "TPDU FSM",
-		.enabled = 1,
+		.enabled = 0,
 		.loglevel = LOGL_DEBUG,
 	},
 	[DPPS] = {
 		.name = "PPS",
 		.description = "PPS (Protocol and Parameter Selection) FSM",
-		.enabled = 1,
+		.enabled = 0,
 		.loglevel = LOGL_DEBUG,
 	},
 	[DCARD] = {
 		.name = "CARD",
 		.description = "Card FSM",
-		.enabled = 1,
+		.enabled = 0,
 		.loglevel = LOGL_DEBUG,
 	},
 };
@@ -150,13 +150,13 @@
 	struct log_target *stderr_target;
 
 	/* msgb */
-	g_msgb_ctx = talloc_pool(g_tall_ctx, 20480);
+//	g_msgb_ctx = talloc_pool(g_tall_ctx, 20480);
 	//talloc_set_memlimit(g_msgb_ctx, 20480);
-	msgb_talloc_ctx_init(g_msgb_ctx, 0);
+//	msgb_talloc_ctx_init(g_msgb_ctx, 0);
 
 	/* logging */
 	log_init(&log_info, g_tall_ctx);
-	stderr_target = log_target_create_stderr_raw();
+//	stderr_target = log_target_create_stderr_raw();
 	//log_add_target(stderr_target);
 	//log_set_all_filter(stderr_target, 1);
 
diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index d81f189..189d764 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -151,7 +151,7 @@
 	/* bit-mask of card-insert status, as determined from NCN8025 IRQ output */
 	uint8_t card_insert_mask;
 };
-static struct ccid_state g_ccid_s;
+static volatile struct ccid_state g_ccid_s;
 
 static void ccid_out_read_compl(const uint8_t ep, enum usb_xfer_code code, uint32_t transferred);
 static void ccid_in_write_compl(const uint8_t ep, enum usb_xfer_code code, uint32_t transferred);
@@ -1131,6 +1131,38 @@
 	char sernr_buf[16*2+1];
 	char rstcause_buf[RSTCAUSE_STR_SIZE];
 
+#if 0
+CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ; //| /* tracing*/
+////CoreDebug_DEMCR_MON_EN_Msk; /* mon interupt catcher */
+
+
+DWT->COMP0 = 0x40003028; /* sercom 0 data */
+//DWT->COMP0 = 0x40003428; /* sercom 1 data */
+DWT->MASK0 = 0; /* 0 */
+DWT->FUNCTION0 = 0; /* has to be 0 for linked address */
+
+DWT->COMP1 = 0xa5;     /* value */
+DWT->MASK1 = 0;     /* match all bits */
+DWT->FUNCTION1 =    (0b10 << DWT_FUNCTION_DATAVSIZE_Pos) |  /* DATAVSIZE 10 - dword */
+#if 1
+(0 << DWT_FUNCTION_DATAVADDR0_Pos) | /* Data Match linked addr pointer in COMP0 */
+#else
+(1 << DWT_FUNCTION_DATAVADDR0_Pos) | /* Data Match on any addr -> own number */
+#endif
+(1 << DWT_FUNCTION_DATAVMATCH_Pos) | /* DATAVMATCH Enable data comparation */
+(0b0111 << DWT_FUNCTION_FUNCTION_Pos);  /* generate a watchpoint event on rw */
+
+#endif
+
+#if 0
+	dwt_init();
+	//geht
+	//	int a = request_dwt_watchpoint(0x40003428, 0, WDE_DATA_RW, 0, false);
+	int a = request_dwt_watchpoint(0x40003428, 0, WDE_DATA_RW, 0, false);
+//	int b = request_dwt_watchpoint(0, 0, WDE_DATA_RW, a, true);
+	enable_dwt_comp(a);
+//	enable_dwt_comp(b);
+#endif
 	atmel_start_init();
 	get_chip_unique_serial_str(sernr_buf, sizeof(sernr_buf));
 	get_rstcause_str(rstcause_buf);
@@ -1154,6 +1186,9 @@
 //	command_register(&cmd_get_time);
 //	command_register(&cmd_test_timer);
 
+
+
+
 	printf("\r\n\r\n"
 		"=============================================================================\n\r"
 		"sysmoOCTSIM firmware " GIT_VERSION "\n\r"
@@ -1166,12 +1201,14 @@
 	g_tall_ctx = talloc_named_const(NULL, 0, "global");
 	printf("g_tall_ctx=%p\r\n", g_tall_ctx);
 
+	//FIXME osmo_emb has a pool?
+	msgb_talloc_ctx_init(g_tall_ctx, 0);
+
 	libosmo_emb_init();
 
 	LOGP(DUSB, LOGL_ERROR, "foobar usb\n");
 
-	//FIXME osmo_emb has a pool?
-	//msgb_set_talloc_ctx(g_tall_ctx);
+
 
 	//prevent spurious interrupts before our driver structs are ready
 	CRITICAL_SECTION_ENTER()
@@ -1186,11 +1223,22 @@
 	}
 	submit_next_out();
 	CRITICAL_SECTION_LEAVE()
+#if 0
+	/* CAN_RX */
+	gpio_set_pin_function(PIN_PB12, GPIO_PIN_FUNCTION_OFF);
+	gpio_set_pin_direction(PIN_PB12, GPIO_DIRECTION_OUT);
+	gpio_set_pin_level(PIN_PB12, false);
 
+	/* CAN_TX */
+	gpio_set_pin_function(PIN_PB13, GPIO_PIN_FUNCTION_OFF);
+	gpio_set_pin_direction(PIN_PB13, GPIO_DIRECTION_OUT);
+	gpio_set_pin_level(PIN_PB13, false);
+#endif
+	poll_card_detect();
 //	command_print_prompt();
 	while (true) { // main loop
 		command_try_recv();
-		poll_card_detect();
+//		poll_card_detect();
 		submit_next_irq();
 		feed_ccid();
 		osmo_timers_update();

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16243
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: I4340cb53f0f903842eb1c4d60a36d44ac9e5cbde
Gerrit-Change-Number: 16243
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/20191126/49054ec1/attachment.htm>


More information about the gerrit-log mailing list