You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/02/16 11:29:12 UTC

[mynewt-nimble] branch master updated (32281f2 -> 883f953)

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

andk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


    from 32281f2  travis: Allow ports build to fail
     new cb76bcd  apps: Add main() wrappers for BabbleSim
     new 06a19ab  babblesim: Add hal_flash and hal_hw_id
     new 883f953  babblesim: Add sample targets

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 apps/blecent/src/main.c                            |  17 +-
 apps/bleprph/src/main.c                            |  17 +-
 apps/btshell/src/main.c                            |  17 +-
 babblesim/hw/bsp/nrf52_bsim/src/hal_bsp.c          |  33 +--
 babblesim/hw/bsp/nrf52_bsim/syscfg.yml             |   1 -
 .../mcu/nordic/nrf52_bsim/include/mcu/native_bsp.h |  14 +-
 babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_flash.c | 289 +++++++++++++++++++++
 babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_hw_id.c |  73 ++++++
 .../src/{hal_watchdog.c => hal_native_priv.h}      |  19 +-
 babblesim/hw/mcu/nordic/nrf52_bsim/syscfg.yml      |   4 +-
 .../targets/blecent}/pkg.yml                       |   7 +-
 .../util => babblesim/targets/blecent}/syscfg.yml  |   3 +-
 .../targets/blecent}/target.yml                    |   5 +-
 .../targets/blehci}/pkg.yml                        |   7 +-
 .../util => babblesim/targets/blehci}/syscfg.yml   |   4 +-
 .../targets/blehci}/target.yml                     |   3 +-
 .../targets/bleprph}/pkg.yml                       |   7 +-
 .../util => babblesim/targets/bleprph}/syscfg.yml  |   3 +-
 .../targets/bleprph}/target.yml                    |   5 +-
 .../targets/btshell}/pkg.yml                       |   7 +-
 .../util => babblesim/targets/btshell}/syscfg.yml  |   3 +-
 .../targets/btshell}/target.yml                    |   5 +-
 22 files changed, 456 insertions(+), 87 deletions(-)
 copy nimble/include/nimble/nimble_opt.h => babblesim/hw/mcu/nordic/nrf52_bsim/include/mcu/native_bsp.h (83%)
 create mode 100644 babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_flash.c
 create mode 100644 babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_hw_id.c
 copy babblesim/hw/mcu/nordic/nrf52_bsim/src/{hal_watchdog.c => hal_native_priv.h} (82%)
 copy {targets/dialog_cmac => babblesim/targets/blecent}/pkg.yml (85%)
 copy {nimble/host/util => babblesim/targets/blecent}/syscfg.yml (93%)
 copy {targets/nordic_pca10095_net-blehci => babblesim/targets/blecent}/target.yml (87%)
 copy {targets/dialog_cmac => babblesim/targets/blehci}/pkg.yml (85%)
 copy {nimble/host/util => babblesim/targets/blehci}/syscfg.yml (90%)
 copy {targets/nordic_pca10095_net-blehci => babblesim/targets/blehci}/target.yml (93%)
 copy {targets/dialog_cmac => babblesim/targets/bleprph}/pkg.yml (85%)
 copy {nimble/host/util => babblesim/targets/bleprph}/syscfg.yml (93%)
 copy {targets/nordic_pca10095_net-blehci => babblesim/targets/bleprph}/target.yml (87%)
 copy {targets/dialog_cmac => babblesim/targets/btshell}/pkg.yml (85%)
 copy {nimble/host/util => babblesim/targets/btshell}/syscfg.yml (93%)
 copy {targets/nordic_pca10095_net-blehci => babblesim/targets/btshell}/target.yml (87%)

[mynewt-nimble] 02/03: babblesim: Add hal_flash and hal_hw_id

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 06a19ab940c6c35943477e3cacf0108b6053ca33
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Feb 14 12:27:16 2022 +0100

    babblesim: Add hal_flash and hal_hw_id
    
    This allows to run more apps on BabbleSim, e.g. blecent and bleprph.
---
 babblesim/hw/bsp/nrf52_bsim/src/hal_bsp.c          |  33 +--
 babblesim/hw/bsp/nrf52_bsim/syscfg.yml             |   1 -
 .../mcu/nordic/nrf52_bsim/include/mcu/native_bsp.h |  34 +++
 babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_flash.c | 289 +++++++++++++++++++++
 babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_hw_id.c |  73 ++++++
 .../hw/mcu/nordic/nrf52_bsim/src/hal_native_priv.h |  27 ++
 babblesim/hw/mcu/nordic/nrf52_bsim/syscfg.yml      |   4 +-
 7 files changed, 432 insertions(+), 29 deletions(-)

diff --git a/babblesim/hw/bsp/nrf52_bsim/src/hal_bsp.c b/babblesim/hw/bsp/nrf52_bsim/src/hal_bsp.c
index 4250249..821e9ed 100644
--- a/babblesim/hw/bsp/nrf52_bsim/src/hal_bsp.c
+++ b/babblesim/hw/bsp/nrf52_bsim/src/hal_bsp.c
@@ -28,13 +28,11 @@
 #include "hal/hal_system.h"
 #include "mcu/nrf52_hal.h"
 #include "mcu/nrf52_periph.h"
+#include "mcu/native_bsp.h"
 #include "bsp/bsp.h"
 #include "defs/sections.h"
 #include "uart_hal/uart_hal.h"
 #include "uart/uart.h"
-#if MYNEWT_VAL(ENC_FLASH_DEV)
-#include <ef_nrf5x/ef_nrf5x.h>
-#endif
 
 /*
  * What memory to include in coredump.
@@ -46,32 +44,15 @@ static const struct hal_bsp_mem_dump dump_cfg[] = {
     }
 };
 
-#if MYNEWT_VAL(ENC_FLASH_DEV)
-static sec_data_secret struct eflash_nrf5x_dev enc_flash_dev0 = {
-    .end_dev = {
-        .efd_hal = {
-            .hf_itf = &enc_flash_funcs,
-        },
-        .efd_hwdev = &nrf52k_flash_dev
-    }
-};
-#endif
-
 const struct hal_flash *
 hal_bsp_flash_dev(uint8_t id)
 {
-//    /*
-//     * Internal flash mapped to id 0.
-//     */
-//    if (id == 0) {
-//        return &nrf52k_flash_dev;
-//    }
-//#if MYNEWT_VAL(ENC_FLASH_DEV)
-//    if (id == 1) {
-//        return &enc_flash_dev0.end_dev.efd_hal;
-//    }
-//#endif
-    return NULL;
+    switch (id) {
+    case 0:
+        return &native_flash_dev;
+    default:
+        return NULL;
+    }
 }
 
 const struct hal_bsp_mem_dump *
diff --git a/babblesim/hw/bsp/nrf52_bsim/syscfg.yml b/babblesim/hw/bsp/nrf52_bsim/syscfg.yml
index 0e9eb60..2070c69 100644
--- a/babblesim/hw/bsp/nrf52_bsim/syscfg.yml
+++ b/babblesim/hw/bsp/nrf52_bsim/syscfg.yml
@@ -35,7 +35,6 @@ syscfg.defs:
 
 syscfg.vals:
     OS_MAIN_STACK_SIZE: 8000
-    BLE_HCI_TRANSPORT: uart
     MCU_TIMER_POLLER_PRIO: 0
     BLE_LL_PRIO: 1
     MCU_UART_POLLER_PRIO: 2
diff --git a/babblesim/hw/mcu/nordic/nrf52_bsim/include/mcu/native_bsp.h b/babblesim/hw/mcu/nordic/nrf52_bsim/include/mcu/native_bsp.h
new file mode 100644
index 0000000..dd79487
--- /dev/null
+++ b/babblesim/hw/mcu/nordic/nrf52_bsim/include/mcu/native_bsp.h
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+#ifndef H_NATIVE_BSP_
+#define H_NATIVE_BSP_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const struct hal_flash native_flash_dev;
+
+int uart_set_dev(int port, const char *dev_str);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_NATIVE_BSP_ */
diff --git a/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_flash.c b/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_flash.c
new file mode 100644
index 0000000..b39b515
--- /dev/null
+++ b/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_flash.c
@@ -0,0 +1,289 @@
+/*
+ * 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 <sys/mman.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <string.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "os/mynewt.h"
+
+#include "hal/hal_flash_int.h"
+#include "mcu/mcu_sim.h"
+
+char *native_flash_file;
+static int file = -1;
+static void *file_loc;
+
+static int native_flash_init(const struct hal_flash *dev);
+static int native_flash_read(const struct hal_flash *dev, uint32_t address,
+        void *dst, uint32_t length);
+static int native_flash_write(const struct hal_flash *dev, uint32_t address,
+        const void *src, uint32_t length);
+static int native_flash_erase_sector(const struct hal_flash *dev,
+        uint32_t sector_address);
+static int native_flash_sector_info(const struct hal_flash *dev, int idx,
+        uint32_t *address, uint32_t *size);
+
+static const struct hal_flash_funcs native_flash_funcs = {
+    .hff_read = native_flash_read,
+    .hff_write = native_flash_write,
+    .hff_erase_sector = native_flash_erase_sector,
+    .hff_sector_info = native_flash_sector_info,
+    .hff_init = native_flash_init
+};
+
+#if MYNEWT_VAL(MCU_FLASH_STYLE_ST)
+static const uint32_t native_flash_sectors[] = {
+    0x00000000, /* 16 * 1024 */
+    0x00004000, /* 16 * 1024 */
+    0x00008000, /* 16 * 1024 */
+    0x0000c000, /* 16 * 1024 */
+    0x00010000, /* 64 * 1024 */
+    0x00020000, /* 128 * 1024 */
+    0x00040000, /* 128 * 1024 */
+    0x00060000, /* 128 * 1024 */
+    0x00080000, /* 128 * 1024 */
+    0x000a0000, /* 128 * 1024 */
+    0x000c0000, /* 128 * 1024 */
+    0x000e0000, /* 128 * 1024 */
+};
+#elif MYNEWT_VAL(MCU_FLASH_STYLE_NORDIC)
+static uint32_t native_flash_sectors[1024 * 1024 / 2048];
+#else
+#error "Need to specify either MCU_FLASH_STYLE_NORDIC or MCU_FLASH_STYLE_ST"
+#endif
+
+#define FLASH_NUM_AREAS   (int)(sizeof native_flash_sectors /           \
+                                sizeof native_flash_sectors[0])
+
+const struct hal_flash native_flash_dev = {
+    .hf_itf = &native_flash_funcs,
+    .hf_base_addr = 0,
+    .hf_size = 1024 * 1024,
+    .hf_sector_cnt = FLASH_NUM_AREAS,
+    .hf_align = MYNEWT_VAL(MCU_FLASH_MIN_WRITE_SIZE),
+    .hf_erased_val = 0xff,
+};
+
+static void
+flash_native_erase(uint32_t addr, uint32_t len)
+{
+    memset(file_loc + addr, 0xff, len);
+}
+
+static void
+flash_native_file_open(char *name)
+{
+    int created = 0;
+    char tmpl[] = "/tmp/native_flash.XXXXXX";
+
+    extern int ftruncate(int fd, off_t length);
+
+    if (file != -1) {
+        close(file);
+        file = -1;
+    }
+
+    if (name) {
+        file = open(name, O_RDWR);
+        if (file < 0) {
+            file = open(name, O_RDWR | O_CREAT, 0660);
+            assert(file > 0);
+            created = 1;
+        }
+    } else {
+        file = mkstemp(tmpl);
+        assert(file > 0);
+        created = 1;
+    }
+
+    if (created) {
+        if (ftruncate(file, native_flash_dev.hf_size) < 0) {
+            assert(0);
+        }
+    }
+
+    if (file_loc != NULL) {
+        munmap(file_loc, native_flash_dev.hf_size);
+    }
+
+    file_loc = mmap(0, native_flash_dev.hf_size,
+          PROT_READ | PROT_WRITE, MAP_SHARED, file, 0);
+    assert(file_loc != MAP_FAILED);
+    if (created) {
+        flash_native_erase(0, native_flash_dev.hf_size);
+    }
+
+    /* If using a temporary file, unlink it immediately. */
+    if (name == NULL) {
+        remove(tmpl);
+    }
+}
+
+static void
+flash_native_ensure_file_open(void)
+{
+    if (file == 0) {
+        flash_native_file_open(NULL);
+    }
+}
+
+static int
+flash_native_write_internal(uint32_t address, const void *src, uint32_t length,
+                            int allow_overwrite)
+{
+    static uint8_t buf[256];
+    uint32_t cur;
+    uint32_t end;
+    int chunk_sz;
+    int rc;
+    int i;
+
+    if (length == 0) {
+        return 0;
+    }
+
+    end = address + length;
+
+    flash_native_ensure_file_open();
+
+    cur = address;
+    while (cur < end) {
+        if (end - cur < sizeof buf) {
+            chunk_sz = end - cur;
+        } else {
+            chunk_sz = sizeof buf;
+        }
+
+        /* Ensure data is not being overwritten. */
+        if (!allow_overwrite) {
+            rc = native_flash_read(NULL, cur, buf, chunk_sz);
+            assert(rc == 0);
+            for (i = 0; i < chunk_sz; i++) {
+                assert(buf[i] == 0xff);
+            }
+        }
+
+        cur += chunk_sz;
+    }
+
+    memcpy((char *)file_loc + address, src, length);
+
+    return 0;
+}
+
+static int
+native_flash_write(const struct hal_flash *dev, uint32_t address,
+        const void *src, uint32_t length)
+{
+    assert(address % native_flash_dev.hf_align == 0);
+    return flash_native_write_internal(address, src, length, 0);
+}
+
+int
+flash_native_memset(uint32_t offset, uint8_t c, uint32_t len)
+{
+    memset(file_loc + offset, c, len);
+    return 0;
+}
+
+static int
+native_flash_read(const struct hal_flash *dev, uint32_t address, void *dst,
+        uint32_t length)
+{
+    flash_native_ensure_file_open();
+    memcpy(dst, (char *)file_loc + address, length);
+
+    return 0;
+}
+
+static int
+find_area(uint32_t address)
+{
+    int i;
+
+    for (i = 0; i < FLASH_NUM_AREAS; i++) {
+        if (native_flash_sectors[i] == address) {
+            return i;
+        }
+    }
+
+    return -1;
+}
+
+static int
+flash_sector_len(int sector)
+{
+    uint32_t end;
+
+    if (sector == FLASH_NUM_AREAS - 1) {
+        end = native_flash_dev.hf_size + native_flash_sectors[0];
+    } else {
+        end = native_flash_sectors[sector + 1];
+    }
+    return end - native_flash_sectors[sector];
+}
+
+static int
+native_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_address)
+{
+    int area_id;
+    uint32_t len;
+
+    flash_native_ensure_file_open();
+
+    area_id = find_area(sector_address);
+    if (area_id == -1) {
+        return -1;
+    }
+    len = flash_sector_len(area_id);
+    flash_native_erase(sector_address, len);
+    return 0;
+}
+
+static int
+native_flash_sector_info(const struct hal_flash *dev, int idx,
+        uint32_t *address, uint32_t *size)
+{
+    assert(idx < FLASH_NUM_AREAS);
+
+    *address = native_flash_sectors[idx];
+    *size = flash_sector_len(idx);
+    return 0;
+}
+
+static int
+native_flash_init(const struct hal_flash *dev)
+{
+    //if (native_flash_file) {
+        flash_native_file_open(native_flash_file);
+    //}
+#if MYNEWT_VAL(MCU_FLASH_STYLE_NORDIC)
+    int i;
+
+    for (i = 0; i < FLASH_NUM_AREAS; i++) {
+        native_flash_sectors[i] = i * 2048;
+    }
+#endif
+    return 0;
+}
diff --git a/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_hw_id.c b/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_hw_id.c
new file mode 100644
index 0000000..09e3980
--- /dev/null
+++ b/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_hw_id.c
@@ -0,0 +1,73 @@
+/*
+ * 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 "hal_native_priv.h"
+
+#ifndef min
+#define min(a, b) ((a)<(b)?(a):(b))
+#endif
+
+static uint8_t hal_hw_id[HAL_BSP_MAX_ID_LEN];
+static uint8_t hal_hw_id_len;
+
+int
+hal_bsp_hw_id_len(void)
+{
+    if (hal_hw_id_len != 0) {
+        return hal_hw_id_len;
+    } else {
+        return HAL_BSP_MAX_ID_LEN;
+    }
+}
+
+/*
+ * This can be used as the unique hardware identifier for the platform, as
+ * it's supposed to be unique for this particular MCU.
+ */
+int
+hal_bsp_hw_id(uint8_t *id, int max_len)
+{
+    if (hal_hw_id_len) {
+        if (max_len > hal_hw_id_len) {
+            max_len = hal_hw_id_len;
+        }
+        memcpy(id, hal_hw_id, max_len);
+        return max_len;
+    }
+    if (max_len > HAL_BSP_MAX_ID_LEN) {
+        max_len = HAL_BSP_MAX_ID_LEN;
+    }
+    memset(id, 0x42, max_len);
+    return max_len;
+}
+
+void
+hal_bsp_set_hw_id(const uint8_t *id, int len)
+{
+    if (len > HAL_BSP_MAX_ID_LEN) {
+        len = HAL_BSP_MAX_ID_LEN;
+    }
+    hal_hw_id_len = len;
+    memcpy(hal_hw_id, id, len);
+}
diff --git a/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_native_priv.h b/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_native_priv.h
new file mode 100644
index 0000000..1060053
--- /dev/null
+++ b/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_native_priv.h
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+#ifndef __HAL_NATIVE_PRIV_H__
+#define __HAL_NATIVE_PRIV_H__
+
+#include <stdint.h>
+
+void hal_bsp_set_hw_id(const uint8_t *id, int len);
+
+#endif /*  __HAL_NATIVE_PRIV_H__ */
diff --git a/babblesim/hw/mcu/nordic/nrf52_bsim/syscfg.yml b/babblesim/hw/mcu/nordic/nrf52_bsim/syscfg.yml
index b1bc4b8..d6b6695 100644
--- a/babblesim/hw/mcu/nordic/nrf52_bsim/syscfg.yml
+++ b/babblesim/hw/mcu/nordic/nrf52_bsim/syscfg.yml
@@ -478,13 +478,13 @@ syscfg.defs:
         value: 1
     MCU_FLASH_STYLE_ST:
         description: Emulated flash layout is similar to one in STM32.
-        value: 1
+        value: 0
         restrictions:
             - "!MCU_FLASH_STYLE_NORDIC"
     MCU_FLASH_STYLE_NORDIC:
         description: >
             Emulated flash layout is similar to one in NRF51/2 and SAMD21.
-        value: 0
+        value: 1
         restrictions:
             - "!MCU_FLASH_STYLE_ST"
     MCU_UART_POLLER_PRIO:

[mynewt-nimble] 03/03: babblesim: Add sample targets

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 883f953476645a05491a3071dd0bbb2bf34c31e9
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Wed Feb 16 09:52:34 2022 +0100

    babblesim: Add sample targets
---
 babblesim/targets/blecent/pkg.yml    | 23 +++++++++++++++++++++++
 babblesim/targets/blecent/syscfg.yml | 20 ++++++++++++++++++++
 babblesim/targets/blecent/target.yml | 21 +++++++++++++++++++++
 babblesim/targets/blehci/pkg.yml     | 23 +++++++++++++++++++++++
 babblesim/targets/blehci/syscfg.yml  | 21 +++++++++++++++++++++
 babblesim/targets/blehci/target.yml  | 21 +++++++++++++++++++++
 babblesim/targets/bleprph/pkg.yml    | 23 +++++++++++++++++++++++
 babblesim/targets/bleprph/syscfg.yml | 20 ++++++++++++++++++++
 babblesim/targets/bleprph/target.yml | 21 +++++++++++++++++++++
 babblesim/targets/btshell/pkg.yml    | 23 +++++++++++++++++++++++
 babblesim/targets/btshell/syscfg.yml | 20 ++++++++++++++++++++
 babblesim/targets/btshell/target.yml | 21 +++++++++++++++++++++
 12 files changed, 257 insertions(+)

diff --git a/babblesim/targets/blecent/pkg.yml b/babblesim/targets/blecent/pkg.yml
new file mode 100644
index 0000000..4518219
--- /dev/null
+++ b/babblesim/targets/blecent/pkg.yml
@@ -0,0 +1,23 @@
+# 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.
+#
+
+pkg.name: babblesim/targets/blecent
+pkg.type: target
+pkg.descrption: Sample target for running blecent on BabbleSim
+pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
+pkg.homepage: "https://mynewt.apache.org/"
diff --git a/babblesim/targets/blecent/syscfg.yml b/babblesim/targets/blecent/syscfg.yml
new file mode 100644
index 0000000..eb7d46e
--- /dev/null
+++ b/babblesim/targets/blecent/syscfg.yml
@@ -0,0 +1,20 @@
+# 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.
+#
+
+syscfg.vals:
+  BLE_LL_PUBLIC_DEV_ADDR: 0xbabb1e000002
diff --git a/babblesim/targets/blecent/target.yml b/babblesim/targets/blecent/target.yml
new file mode 100644
index 0000000..b4e6967
--- /dev/null
+++ b/babblesim/targets/blecent/target.yml
@@ -0,0 +1,21 @@
+# 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.
+#
+
+target.app: "@apache-mynewt-nimble/apps/blecent"
+target.bsp: "@apache-mynewt-nimble/babblesim/hw/bsp/nrf52_bsim"
+target.build_profile: debug
diff --git a/babblesim/targets/blehci/pkg.yml b/babblesim/targets/blehci/pkg.yml
new file mode 100644
index 0000000..c8cdf78
--- /dev/null
+++ b/babblesim/targets/blehci/pkg.yml
@@ -0,0 +1,23 @@
+# 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.
+#
+
+pkg.name: babblesim/targets/blehci
+pkg.type: target
+pkg.descrption: Sample target for running blehci on BabbleSim
+pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
+pkg.homepage: "https://mynewt.apache.org/"
diff --git a/babblesim/targets/blehci/syscfg.yml b/babblesim/targets/blehci/syscfg.yml
new file mode 100644
index 0000000..aec4c4a
--- /dev/null
+++ b/babblesim/targets/blehci/syscfg.yml
@@ -0,0 +1,21 @@
+# 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.
+#
+
+syscfg.vals:
+  BLE_LL_PUBLIC_DEV_ADDR: 0xbabb1e000001
+  BLE_HCI_TRANSPORT: uart
diff --git a/babblesim/targets/blehci/target.yml b/babblesim/targets/blehci/target.yml
new file mode 100644
index 0000000..23953eb
--- /dev/null
+++ b/babblesim/targets/blehci/target.yml
@@ -0,0 +1,21 @@
+# 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.
+#
+
+target.app: "@apache-mynewt-nimble/apps/blehci"
+target.bsp: "@apache-mynewt-nimble/babblesim/hw/bsp/nrf52_bsim"
+target.build_profile: debug
diff --git a/babblesim/targets/bleprph/pkg.yml b/babblesim/targets/bleprph/pkg.yml
new file mode 100644
index 0000000..e8209bd
--- /dev/null
+++ b/babblesim/targets/bleprph/pkg.yml
@@ -0,0 +1,23 @@
+# 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.
+#
+
+pkg.name: babblesim/targets/bleprph
+pkg.type: target
+pkg.descrption: Sample target for running bleprph on BabbleSim
+pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
+pkg.homepage: "https://mynewt.apache.org/"
diff --git a/babblesim/targets/bleprph/syscfg.yml b/babblesim/targets/bleprph/syscfg.yml
new file mode 100644
index 0000000..279d94a
--- /dev/null
+++ b/babblesim/targets/bleprph/syscfg.yml
@@ -0,0 +1,20 @@
+# 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.
+#
+
+syscfg.vals:
+  BLE_LL_PUBLIC_DEV_ADDR: 0xbabb1e000003
diff --git a/babblesim/targets/bleprph/target.yml b/babblesim/targets/bleprph/target.yml
new file mode 100644
index 0000000..e7a0854
--- /dev/null
+++ b/babblesim/targets/bleprph/target.yml
@@ -0,0 +1,21 @@
+# 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.
+#
+
+target.app: "@apache-mynewt-nimble/apps/bleprph"
+target.bsp: "@apache-mynewt-nimble/babblesim/hw/bsp/nrf52_bsim"
+target.build_profile: debug
diff --git a/babblesim/targets/btshell/pkg.yml b/babblesim/targets/btshell/pkg.yml
new file mode 100644
index 0000000..cc0b4bc
--- /dev/null
+++ b/babblesim/targets/btshell/pkg.yml
@@ -0,0 +1,23 @@
+# 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.
+#
+
+pkg.name: babblesim/targets/btshell
+pkg.type: target
+pkg.descrption: Sample target for running btshell on BabbleSim
+pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
+pkg.homepage: "https://mynewt.apache.org/"
diff --git a/babblesim/targets/btshell/syscfg.yml b/babblesim/targets/btshell/syscfg.yml
new file mode 100644
index 0000000..152a665
--- /dev/null
+++ b/babblesim/targets/btshell/syscfg.yml
@@ -0,0 +1,20 @@
+# 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.
+#
+
+syscfg.vals:
+  BLE_LL_PUBLIC_DEV_ADDR: 0xbabb1e000004
diff --git a/babblesim/targets/btshell/target.yml b/babblesim/targets/btshell/target.yml
new file mode 100644
index 0000000..3545e2d
--- /dev/null
+++ b/babblesim/targets/btshell/target.yml
@@ -0,0 +1,21 @@
+# 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.
+#
+
+target.app: "@apache-mynewt-nimble/apps/btshell"
+target.bsp: "@apache-mynewt-nimble/babblesim/hw/bsp/nrf52_bsim"
+target.build_profile: debug

[mynewt-nimble] 01/03: apps: Add main() wrappers for BabbleSim

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit cb76bcdbea0be1cedb3551b3bb0a15c19a62b4dd
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Feb 14 12:06:05 2022 +0100

    apps: Add main() wrappers for BabbleSim
---
 apps/blecent/src/main.c | 17 +++++++++++++++--
 apps/bleprph/src/main.c | 17 +++++++++++++++--
 apps/btshell/src/main.c | 17 +++++++++++++++--
 3 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/apps/blecent/src/main.c b/apps/blecent/src/main.c
index 788f211..7f1c5f1 100644
--- a/apps/blecent/src/main.c
+++ b/apps/blecent/src/main.c
@@ -495,8 +495,8 @@ blecent_on_sync(void)
  *
  * @return int NOTE: this function should never return!
  */
-int
-main(void)
+static int
+main_fn(int argc, char **argv)
 {
     int rc;
 
@@ -523,3 +523,16 @@ main(void)
 
     return 0;
 }
+
+int
+main(int argc, char **argv)
+{
+#if BABBLESIM
+    extern void bsim_init(int argc, char** argv, void *main_fn);
+    bsim_init(argc, argv, main_fn);
+#else
+    main_fn(argc, argv);
+#endif
+
+    return 0;
+}
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index 66f9bac..60a3aea 100644
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -302,8 +302,8 @@ bleprph_on_sync(void)
  *
  * @return int NOTE: this function should never return!
  */
-int
-main(void)
+static int
+main_fn(int argc, char **argv)
 {
 #if MYNEWT_VAL(BLE_SVC_DIS_FIRMWARE_REVISION_READ_PERM) >= 0
     struct image_version ver;
@@ -357,3 +357,16 @@ main(void)
     }
     return 0;
 }
+
+int
+main(int argc, char **argv)
+{
+#if BABBLESIM
+    extern void bsim_init(int argc, char** argv, void *main_fn);
+    bsim_init(argc, argv, main_fn);
+#else
+    main_fn(argc, argv);
+#endif
+
+    return 0;
+}
diff --git a/apps/btshell/src/main.c b/apps/btshell/src/main.c
index 99f0a79..f4f864e 100644
--- a/apps/btshell/src/main.c
+++ b/apps/btshell/src/main.c
@@ -2557,8 +2557,8 @@ btshell_init_ext_adv_restart(void)
  *
  * @return int NOTE: this function should never return!
  */
-int
-main(int argc, char **argv)
+static int
+main_fn(int argc, char **argv)
 {
     int rc;
 
@@ -2634,3 +2634,16 @@ main(int argc, char **argv)
 
     return 0;
 }
+
+int
+main(int argc, char **argv)
+{
+#if BABBLESIM
+    extern void bsim_init(int argc, char** argv, void *main_fn);
+    bsim_init(argc, argv, main_fn);
+#else
+    main_fn(argc, argv);
+#endif
+
+    return 0;
+}