You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/06/23 23:38:24 UTC
[1/2] incubator-mynewt-core git commit: MYNEWT-273;
implement bsp_hw_id() for nordic and STM32F4.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop e0c73d247 -> 7bd50b3b2
MYNEWT-273; implement bsp_hw_id() for nordic and STM32F4.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7bd50b3b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7bd50b3b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7bd50b3b
Branch: refs/heads/develop
Commit: 7bd50b3b24d09f3c8e0052d38a440a5013a67450
Parents: b633dfb
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jun 23 16:36:24 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jun 23 16:37:53 2016 -0700
----------------------------------------------------------------------
hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c | 48 +++++++++++++++++++++++++
hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c | 48 +++++++++++++++++++++++++
hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c | 42 ++++++++++++++++++++++
3 files changed, 138 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7bd50b3b/hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c b/hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c
new file mode 100644
index 0000000..81279ac
--- /dev/null
+++ b/hw/mcu/nordic/nrf51xxx/src/nrf51_hw_id.c
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+#include <inttypes.h>
+#include <string.h>
+
+#include <hal/hal_bsp.h>
+
+#include "mcu/nrf51.h"
+
+#ifndef min
+#define min(a, b) ((a)<(b)?(a):(b))
+#endif
+
+/*
+ * These values are generated at random.
+ * DEVICEID[0-1] and DEVICEADDR[0-1].
+ */
+int
+bsp_hw_id(uint8_t *id, int max_len)
+{
+ int len, cnt;
+
+ cnt = min(sizeof(NRF_FICR->DEVICEID), max_len);
+ memcpy(id, (void *)NRF_FICR->DEVICEID, cnt);
+ len = cnt;
+
+ cnt = min(sizeof(NRF_FICR->DEVICEADDR), max_len - len);
+ memcpy(id + len, (void *)NRF_FICR->DEVICEID, cnt);
+
+ return len + cnt;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7bd50b3b/hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c b/hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c
new file mode 100644
index 0000000..9042153
--- /dev/null
+++ b/hw/mcu/nordic/nrf52xxx/src/nrf52_hw_id.c
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+#include <inttypes.h>
+#include <string.h>
+
+#include <hal/hal_bsp.h>
+
+#include "mcu/nrf52.h"
+
+#ifndef min
+#define min(a, b) ((a)<(b)?(a):(b))
+#endif
+
+/*
+ * These values are generated at random.
+ * DEVICEID[0-1] and DEVICEADDR[0-1].
+ */
+int
+bsp_hw_id(uint8_t *id, int max_len)
+{
+ int len, cnt;
+
+ cnt = min(sizeof(NRF_FICR->DEVICEID), max_len);
+ memcpy(id, (void *)NRF_FICR->DEVICEID, cnt);
+ len = cnt;
+
+ cnt = min(sizeof(NRF_FICR->DEVICEADDR), max_len - len);
+ memcpy(id + len, (void *)NRF_FICR->DEVICEID, cnt);
+
+ return len + cnt;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7bd50b3b/hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c b/hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c
new file mode 100644
index 0000000..c08e8fe
--- /dev/null
+++ b/hw/mcu/stm/stm32f4xx/src/stm32f4xx_hw_id.c
@@ -0,0 +1,42 @@
+/**
+ * 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.
+ */
+
+#include <inttypes.h>
+#include <string.h>
+
+#include <hal/hal_bsp.h>
+
+#ifndef min
+#define min(a, b) ((a)<(b)?(a):(b))
+#endif
+
+/*
+ * STM32F4 has a unique 96-bit id at address 0x1FFF7A10.
+ * See ref manual chapter 39.1.
+ */
+int
+bsp_hw_id(uint8_t *id, int max_len)
+{
+ int cnt;
+
+ cnt = min(12, max_len);
+ memcpy(id, (void *)0x1FFF7A10, cnt);
+
+ return cnt;
+}
[2/2] incubator-mynewt-core git commit: MYNEWT-273;
hal - add prototype for bsp_hw_id().
Posted by ma...@apache.org.
MYNEWT-273; hal - add prototype for bsp_hw_id().
This should return unique ID for the BSP. Preferably serial
number of the MCU.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b633dfb7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b633dfb7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b633dfb7
Branch: refs/heads/develop
Commit: b633dfb7869f14d6502105ef0a0bfc012a76358b
Parents: e0c73d2
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jun 23 16:31:19 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jun 23 16:37:53 2016 -0700
----------------------------------------------------------------------
hw/hal/include/hal/hal_bsp.h | 9 +++++++++
1 file changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b633dfb7/hw/hal/include/hal/hal_bsp.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_bsp.h b/hw/hal/include/hal/hal_bsp.h
index 848a7c5..ae96789 100644
--- a/hw/hal/include/hal/hal_bsp.h
+++ b/hw/hal/include/hal/hal_bsp.h
@@ -48,6 +48,9 @@ int bsp_imgr_current_slot(void);
*/
void *_sbrk(int incr);
+/*
+ * Report which memory areas should be included inside a coredump.
+ */
struct bsp_mem_dump {
void *bmd_start;
uint32_t bmd_size;
@@ -55,6 +58,12 @@ struct bsp_mem_dump {
const struct bsp_mem_dump *bsp_core_dump(int *area_cnt);
+/*
+ * Get unique HW identifier/serial number for platform.
+ * Returns the number of bytes filled in.
+ */
+int bsp_hw_id(uint8_t *id, int max_len);
+
#ifdef __cplusplus
}
#endif