Change in osmo-ccid-firmware[master]: obtain chip-unique serial number and print it during startup.

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Apr 19 22:24:35 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13710


Change subject: obtain chip-unique serial number and print it during startup.
......................................................................

obtain chip-unique serial number and print it during startup.

Change-Id: I298942e12f9ffd6f571555253fda160baece5c6c
---
M sysmoOCTSIM/main.c
1 file changed, 36 insertions(+), 0 deletions(-)



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

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 843652b..1e34e20 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <parts.h>
+#include <errno.h>
 #include <hal_cache.h>
 #include <hri_port_e54.h>
 
@@ -304,9 +305,43 @@
 
 extern void testmode_init(void);
 
+/* Section 9.6 of SAMD5x/E5x Family Data Sheet */
+static int get_chip_unique_serial(uint8_t *out, size_t len)
+{
+	uint32_t *out32 = (uint32_t *)out;
+	if (len < 16)
+		return -EINVAL;
+
+	out32[0] = *(uint32_t *)0x008061fc;
+	out32[1] = *(uint32_t *)0x00806010;
+	out32[2] = *(uint32_t *)0x00806014;
+	out32[3] = *(uint32_t *)0x00806018;
+
+	return 0;
+}
+
+/* same as get_chip_unique_serial but in hex-string format */
+static int get_chip_unique_serial_str(char *out, size_t len)
+{
+	uint8_t buf[16];
+	int rc;
+
+	if (len < 16*2 + 1)
+		return -EINVAL;
+
+	rc = get_chip_unique_serial(buf, sizeof(buf));
+	if (rc < 0)
+		return rc;
+	osmo_hexdump_buf(out, len, buf, sizeof(buf), NULL, false);
+	return 0;
+}
+
 int main(void)
 {
+	char sernr_buf[16*2+1];
+
 	atmel_start_init();
+	get_chip_unique_serial_str(sernr_buf, sizeof(sernr_buf));
 
 	usart_sync_enable(&UART_debug);
 
@@ -324,6 +359,7 @@
 	testmode_init();
 
 	printf("\r\n\r\nsysmocom sysmoOCTSIM\r\n");
+	printf("Chip-Id %s\r\n", sernr_buf);
 
 	command_print_prompt();
 	while (true) { // main loop

-- 
To view, visit https://gerrit.osmocom.org/13710
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I298942e12f9ffd6f571555253fda160baece5c6c
Gerrit-Change-Number: 13710
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190419/582e634c/attachment.htm>


More information about the gerrit-log mailing list