You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2022/01/19 08:25:58 UTC

[incubator-nuttx] 02/02: boards: cxd56xx: Add board serial string for usb devices

This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 13d35276427e9eefd290b3f32c0cdc42986842b9
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Tue Jan 18 10:37:19 2022 +0900

    boards: cxd56xx: Add board serial string for usb devices
    
    Add obtaining board unique serial string logic for USB devices.
    
    refs #13909
---
 boards/arm/cxd56xx/common/src/Make.defs            |  4 ++
 .../arm/cxd56xx/common/src/cxd56_usbdevserialstr.c | 52 ++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/boards/arm/cxd56xx/common/src/Make.defs b/boards/arm/cxd56xx/common/src/Make.defs
index 239b844..97c02de 100644
--- a/boards/arm/cxd56xx/common/src/Make.defs
+++ b/boards/arm/cxd56xx/common/src/Make.defs
@@ -164,6 +164,10 @@ ifeq ($(CONFIG_CXD56_SPISD),y)
   CSRCS += cxd56_spisd.c
 endif
 
+ifeq ($(CONFIG_BOARD_USBDEV_SERIALSTR),y)
+  CSRCS += cxd56_usbdevserialstr.c
+endif
+
 DEPPATH += --dep-path src
 VPATH += :src
 CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
diff --git a/boards/arm/cxd56xx/common/src/cxd56_usbdevserialstr.c b/boards/arm/cxd56xx/common/src/cxd56_usbdevserialstr.c
new file mode 100644
index 0000000..93cdef2
--- /dev/null
+++ b/boards/arm/cxd56xx/common/src/cxd56_usbdevserialstr.c
@@ -0,0 +1,52 @@
+/****************************************************************************
+ * boards/arm/cxd56xx/common/src/cxd56_usbdevserialstr.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+
+#include "cxd56_uid.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARD_USBDEV_SERIALSTR
+
+static char g_serialstr[CONFIG_BOARDCTL_UNIQUEID_SIZE * 2 + 1];
+
+FAR const char *board_usbdev_serialstr(void)
+{
+  uint8_t uid[CONFIG_BOARDCTL_UNIQUEID_SIZE];
+
+  cxd56_get_uniqueid(uid);
+
+  snprintf(g_serialstr, sizeof(g_serialstr),
+           "%02X%02X%02X%02X%02X",
+           uid[0], uid[1], uid[2], uid[3], uid[4]);
+
+  return g_serialstr;
+}
+
+#endif