You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/09/22 02:13:06 UTC
[59/59] [abbrv] incubator-mynewt-core git commit: Conclude merge from
sterly_refactor.
Conclude merge from sterly_refactor.
Additional changes to fix post-merge build failures.
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/8dffea7d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8dffea7d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8dffea7d
Branch: refs/heads/develop
Commit: 8dffea7d030262f574ce2c0f8e3d7dd2599b74f8
Parents: c5901fc
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Sep 21 19:07:36 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Sep 21 19:07:36 2016 -0700
----------------------------------------------------------------------
apps/blecent/src/main.c | 3 +-
apps/blehci/src/main.c | 6 -
apps/bleprph/pkg.yml | 2 -
apps/bleprph/src/main.c | 5 +-
apps/bleuart/src/main.c | 14 -
apps/slinky/src/main.c | 15 +-
apps/splitty/src/main.c | 116 +-
hw/bsp/native/include/bsp/bsp.h | 6 +-
hw/bsp/native/pkg.yml | 1 +
hw/bsp/nrf51dk/pkg.yml | 4 +-
hw/mcu/native/src/hal_uart.c | 2 +
libs/boot_serial/test/pkg.yml | 3 +
libs/bootutil/pkg.yml | 3 -
libs/bootutil/src/bootutil_misc.c | 3 +
libs/bootutil/src/loader.c | 6 -
libs/bootutil/test/src/boot_serial_test.c | 1171 ------------------
.../stub/include/console/console_prompt.h | 35 -
libs/console/stub/include/console/prompt.h | 34 +
libs/imgmgr/src/imgmgr.c | 2 +
libs/imgmgr/src/imgmgr_cli.c | 6 +-
libs/newtmgr_oic/pkg.yml | 11 +-
libs/os/src/test/callout_test.c | 330 -----
libs/os/test/src/callout_test.c | 330 +++++
libs/shell/src/shell.c | 5 +-
libs/util/src/test/hex_test.c | 125 --
libs/util/test/src/hex_test.c | 125 ++
net/nimble/controller/pkg.yml | 2 +-
net/nimble/controller/src/ble_ll_adv.c | 8 +-
net/nimble/controller/src/ble_ll_conn.c | 56 +-
net/nimble/controller/src/ble_ll_conn_hci.c | 4 +-
net/nimble/controller/src/ble_ll_scan.c | 6 +-
.../gap/include/services/gap/ble_svc_gap.h | 2 +-
net/nimble/host/services/gap/pkg.yml | 3 +
net/nimble/host/services/gap/src/ble_svc_gap.c | 14 +-
.../gatt/include/services/gatt/ble_svc_gatt.h | 2 +-
net/nimble/host/services/gatt/pkg.yml | 2 +-
.../host/services/gatt/src/ble_svc_gatt.c | 13 +-
.../services/mandatory/src/ble_svc_mandatory.c | 36 -
net/nimble/host/src/ble_gap.c | 2 +-
net/nimble/host/src/ble_hs.c | 20 -
net/nimble/host/src/test/ble_hs_hci_test.c | 99 --
net/nimble/host/test/src/ble_gap_test.c | 28 +-
net/nimble/host/test/src/ble_hs_test_util.c | 17 -
net/nimble/transport/ram/src/ble_hci_ram.c | 2 +
net/nimble/transport/uart/src/ble_hci_uart.c | 28 +-
sys/config/pkg.yml | 2 +-
sys/config/test/pkg.yml | 4 +
sys/mn_socket/test/src/mn_sock_test.c | 2 +-
sys/reboot/pkg.yml | 2 +-
sys/stats/pkg.yml | 2 +-
50 files changed, 630 insertions(+), 2089 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/apps/blecent/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blecent/src/main.c b/apps/blecent/src/main.c
index c9ae8a4..fbab587 100755
--- a/apps/blecent/src/main.c
+++ b/apps/blecent/src/main.c
@@ -504,8 +504,7 @@ main(void)
os_init();
/* Initialize the blecent log. */
- log_console_handler_init(&blecent_log_console_handler);
- log_register("blecent", &blecent_log, &blecent_log_console_handler);
+ log_register("blecent", &blecent_log, &log_console_handler, NULL);
/* Initialize the eventq for the application task. */
os_eventq_init(&blecent_evq);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/apps/blehci/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blehci/src/main.c b/apps/blehci/src/main.c
index 1c75528..c2b894b 100755
--- a/apps/blehci/src/main.c
+++ b/apps/blehci/src/main.c
@@ -19,12 +19,6 @@
#include <assert.h>
#include "os/os.h"
-/* Our global device address (public) */
-uint8_t g_dev_addr[6] = { 0 };
-
-/* Our random address (in case we need it) */
-uint8_t g_random_addr[BLE_DEV_ADDR_LEN] = { 0 };
-
int
main(void)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/apps/bleprph/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/bleprph/pkg.yml b/apps/bleprph/pkg.yml
index 89549f7..4e15338 100644
--- a/apps/bleprph/pkg.yml
+++ b/apps/bleprph/pkg.yml
@@ -52,5 +52,3 @@ pkg.syscfg_vals:
# Disable unused eddystone feature.
BLE_EDDYSTONE: 0
-
- BLE_SM: 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index 6792b50..6d27e00 100755
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -32,7 +32,7 @@
/* BLE */
#include "nimble/ble.h"
#include "host/ble_hs.h"
-#include "services/mandatory/ble_svc_gap.h"
+#include "services/gap/ble_svc_gap.h"
/* Application-specified header. */
#include "bleprph.h"
@@ -305,8 +305,7 @@ main(void)
os_init();
/* Initialize the bleprph log. */
- log_console_handler_init(&bleprph_log_console_handler);
- log_register("bleprph", &bleprph_log, &bleprph_log_console_handler);
+ log_register("bleprph", &bleprph_log, &log_console_handler, NULL);
/* Initialize eventq */
os_eventq_init(&bleprph_evq);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/apps/bleuart/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleuart/src/main.c b/apps/bleuart/src/main.c
index d0df368..f5d9387 100755
--- a/apps/bleuart/src/main.c
+++ b/apps/bleuart/src/main.c
@@ -55,20 +55,6 @@
#include "nmgrble/newtmgr_ble.h"
#include "bleuart/bleuart.h"
-/** Mbuf settings. */
-#define MBUF_NUM_MBUFS (12)
-#define MBUF_BUF_SIZE OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
-#define MBUF_MEMBLOCK_SIZE (MBUF_BUF_SIZE + BLE_MBUF_MEMBLOCK_OVERHEAD)
-#define MBUF_MEMPOOL_SIZE OS_MEMPOOL_SIZE(MBUF_NUM_MBUFS, MBUF_MEMBLOCK_SIZE)
-
-#define MAX_CONSOLE_INPUT 120
-static os_membuf_t bleuart_mbuf_mpool_data[MBUF_MEMPOOL_SIZE];
-struct os_mbuf_pool bleuart_mbuf_pool;
-struct os_mempool bleuart_mbuf_mpool;
-
-/** Priority of the nimble host and controller tasks. */
-#define BLE_LL_TASK_PRI (OS_TASK_PRI_HIGHEST)
-
/** bleuart task settings. */
#define bleuart_TASK_PRIO 1
#define bleuart_STACK_SIZE (OS_STACK_ALIGN(336))
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index 02a5d34..9cb9cdf 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -32,11 +32,11 @@
#if defined SPLIT_LOADER || defined SPLIT_APPLICATION
#include <split/split.h>
#endif
-#if MYNEWT_PKG_FS_NFFS
+#if MYNEWT_VAL(CONFIG_NFFS)
#include <fs/fs.h>
#include <nffs/nffs.h>
#include <config/config_file.h>
-#elif MYNEWT_PKG_SYS_FCB
+#elif MYNEWT_VAL(CONFIG_FCB)
#include <fcb/fcb.h>
#include <config/config_fcb.h>
#else
@@ -95,6 +95,15 @@ static STATS_NAME_START(gpio_stats)
STATS_NAME(gpio_stats, toggles)
STATS_NAME_END(gpio_stats)
+#if !MYNEWT_VAL(CONFIG_NFFS)
+struct flash_area conf_fcb_area[NFFS_AREA_MAX + 1];
+
+static struct conf_fcb my_conf = {
+ .cf_fcb.f_magic = 0xc09f6e5e,
+ .cf_fcb.f_sectors = conf_fcb_area
+};
+#endif
+
static char *test_conf_get(int argc, char **argv, char *val, int max_len);
static int test_conf_set(int argc, char **argv, char *val);
static int test_conf_commit(void);
@@ -295,8 +304,6 @@ int
main(int argc, char **argv)
{
int rc;
- os_stack_t *pstack;
-
#ifdef ARCH_sim
mcu_sim_parse_args(argc, argv);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/apps/splitty/src/main.c
----------------------------------------------------------------------
diff --git a/apps/splitty/src/main.c b/apps/splitty/src/main.c
index acdc750..d050a62 100755
--- a/apps/splitty/src/main.c
+++ b/apps/splitty/src/main.c
@@ -30,11 +30,11 @@
#if defined SPLIT_APPLICATION
#include <split/split.h>
#endif
-#ifdef NFFS_PRESENT
+#if MYNEWT_VAL(CONFIG_NFFS)
#include <fs/fs.h>
#include <nffs/nffs.h>
#include <config/config_file.h>
-#elif FCB_PRESENT
+#elif MYNEWT_VAL(CONFIG_FCB)
#include <fcb/fcb.h>
#include <config/config_fcb.h>
#else
@@ -71,13 +71,6 @@ static volatile int g_task1_loops;
#define TASK2_STACK_SIZE OS_STACK_ALIGN(128)
static struct os_task task2;
-#define SHELL_TASK_PRIO (3)
-#define SHELL_MAX_INPUT_LEN (256)
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(384))
-
-#define NEWTMGR_TASK_PRIO (4)
-#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(896))
-
static struct log my_log;
static volatile int g_task2_loops;
@@ -94,21 +87,11 @@ STATS_SECT_END
static STATS_SECT_DECL(gpio_stats) g_stats_gpio_toggle;
-static STATS_NAME_START(gpio_stats)
+STATS_NAME_START(gpio_stats)
STATS_NAME(gpio_stats, toggles)
STATS_NAME_END(gpio_stats)
-#ifdef NFFS_PRESENT
-/* configuration file */
-#define MY_CONFIG_DIR "/cfg"
-#define MY_CONFIG_FILE "/cfg/run"
-#define MY_CONFIG_MAX_LINES 32
-
-static struct conf_file my_conf = {
- .cf_name = MY_CONFIG_FILE,
- .cf_maxlines = MY_CONFIG_MAX_LINES
-};
-#elif FCB_PRESENT
+#if !MYNEWT_VAL(CONFIG_NFFS)
struct flash_area conf_fcb_area[NFFS_AREA_MAX + 1];
static struct conf_fcb my_conf = {
@@ -117,15 +100,6 @@ static struct conf_fcb my_conf = {
};
#endif
-#define DEFAULT_MBUF_MPOOL_BUF_LEN (256)
-#define DEFAULT_MBUF_MPOOL_NBUFS (9)
-
-static uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
- DEFAULT_MBUF_MPOOL_NBUFS];
-
-static struct os_mbuf_pool default_mbuf_pool;
-static struct os_mempool default_mbuf_mpool;
-
static uint32_t cbmem_buf[MAX_CBMEM_BUF];
static struct cbmem cbmem;
@@ -199,6 +173,7 @@ int
init_tasks(void)
{
os_stack_t *pstack;
+
/* Initialize global test semaphore */
os_sem_init(&g_test_sem, 0);
@@ -218,41 +193,7 @@ init_tasks(void)
return 0;
}
-#ifdef NFFS_PRESENT
-static void
-setup_for_nffs(void)
-{
- /* NFFS_AREA_MAX is defined in the BSP-specified bsp.h header file. */
- struct nffs_area_desc descs[NFFS_AREA_MAX + 1];
- int cnt;
- int rc;
-
- /* Initialize nffs's internal state. */
- rc = nffs_init();
- assert(rc == 0);
-
- /* Convert the set of flash blocks we intend to use for nffs into an array
- * of nffs area descriptors.
- */
- cnt = NFFS_AREA_MAX;
- rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
- assert(rc == 0);
-
- /* Attempt to restore an existing nffs file system from flash. */
- if (nffs_detect(descs) == FS_ECORRUPT) {
- /* No valid nffs instance detected; format a new one. */
- rc = nffs_format(descs);
- assert(rc == 0);
- }
-
- fs_mkdir(MY_CONFIG_DIR);
- rc = conf_file_src(&my_conf);
- assert(rc == 0);
- rc = conf_file_dst(&my_conf);
- assert(rc == 0);
-}
-
-#elif FCB_PRESENT
+#if !MYNEWT_VAL(CONFIG_NFFS)
static void
setup_for_fcb(void)
@@ -295,66 +236,26 @@ int
main(int argc, char **argv)
{
int rc;
- os_stack_t *pstack;
-
#ifdef ARCH_sim
mcu_sim_parse_args(argc, argv);
#endif
- conf_init();
+ os_init();
- log_init();
cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF);
log_register("log", &my_log, &log_cbmem_handler, &cbmem);
- os_init();
-
- rc = os_mempool_init(&default_mbuf_mpool, DEFAULT_MBUF_MPOOL_NBUFS,
- DEFAULT_MBUF_MPOOL_BUF_LEN, default_mbuf_mpool_data,
- "default_mbuf_data");
- assert(rc == 0);
-
- rc = os_mbuf_pool_init(&default_mbuf_pool, &default_mbuf_mpool,
- DEFAULT_MBUF_MPOOL_BUF_LEN, DEFAULT_MBUF_MPOOL_NBUFS);
- assert(rc == 0);
-
- rc = os_msys_register(&default_mbuf_pool);
- assert(rc == 0);
-
- rc = hal_flash_init();
- assert(rc == 0);
-
-#ifdef NFFS_PRESENT
- setup_for_nffs();
-#elif FCB_PRESENT
+#if !MYNEWT_VAL(CONFIG_NFFS)
setup_for_fcb();
#endif
- id_init();
-
- pstack = malloc(sizeof(os_stack_t) * SHELL_TASK_STACK_SIZE);
- assert(pstack);
-
- shell_task_init(SHELL_TASK_PRIO, pstack, SHELL_TASK_STACK_SIZE,
- SHELL_MAX_INPUT_LEN);
-
- pstack = malloc(sizeof(os_stack_t) * NEWTMGR_TASK_STACK_SIZE);
- assert(pstack);
-#
- nmgr_task_init(NEWTMGR_TASK_PRIO, pstack, NEWTMGR_TASK_STACK_SIZE);
- imgmgr_module_init();
-
- stats_module_init();
-
stats_init(STATS_HDR(g_stats_gpio_toggle),
STATS_SIZE_INIT_PARMS(g_stats_gpio_toggle, STATS_SIZE_32),
STATS_NAME_INIT_PARMS(gpio_stats));
stats_register("gpio_toggle", STATS_HDR(g_stats_gpio_toggle));
- reboot_init_handler(LOG_TYPE_STORAGE, 10);
-
#if defined SPLIT_APPLICATION
split_app_init();
#endif
@@ -372,4 +273,3 @@ main(int argc, char **argv)
return rc;
}
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/hw/bsp/native/include/bsp/bsp.h
----------------------------------------------------------------------
diff --git a/hw/bsp/native/include/bsp/bsp.h b/hw/bsp/native/include/bsp/bsp.h
index 42a53f4..d4cedc3 100644
--- a/hw/bsp/native/include/bsp/bsp.h
+++ b/hw/bsp/native/include/bsp/bsp.h
@@ -34,9 +34,9 @@ extern "C" {
/* LED pins */
#define LED_BLINK_PIN (0x1)
-/* Logical UART ports */
-#define UART_CNT 2
-#define CONSOLE_UART 0
+/* UART info */
+#define CONSOLE_UART "uart1"
+#define CONSOLE_UART_SPEED 9600
#define NFFS_AREA_MAX (8)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/hw/bsp/native/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/pkg.yml b/hw/bsp/native/pkg.yml
index ede1525..bbbb708 100644
--- a/hw/bsp/native/pkg.yml
+++ b/hw/bsp/native/pkg.yml
@@ -31,6 +31,7 @@ pkg.arch: sim
pkg.compiler: compiler/sim
pkg.deps:
- hw/mcu/native
+ - drivers/uart/uart_hal
pkg.deps.BLE_DEVICE:
- net/nimble/drivers/native
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/hw/bsp/nrf51dk/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml
index beee6fc..2be9fc2 100644
--- a/hw/bsp/nrf51dk/pkg.yml
+++ b/hw/bsp/nrf51dk/pkg.yml
@@ -65,7 +65,7 @@ pkg.syscfg_defs:
ADC_0:
description: 'TBD'
- value: 1
+ value: 0
ADC_0_RESOLUTION:
description: 'TBD'
value: 'SAADC_CONFIG_RESOLUTION'
@@ -94,7 +94,7 @@ pkg.syscfg_defs:
SPI_MASTER:
description: 'TBD'
- value: 1
+ value: 0
SPI_SLAVE:
description: 'TBD'
value: 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/hw/mcu/native/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/hal_uart.c b/hw/mcu/native/src/hal_uart.c
index 58f6b96..0db339f 100644
--- a/hw/mcu/native/src/hal_uart.c
+++ b/hw/mcu/native/src/hal_uart.c
@@ -34,6 +34,8 @@
#include <unistd.h>
#include <string.h>
+#define UART_CNT 2
+
#define UART_MAX_BYTES_PER_POLL 64
#define UART_POLLER_STACK_SZ OS_STACK_ALIGN(1024)
#define UART_POLLER_PRIO 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/boot_serial/test/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/boot_serial/test/pkg.yml b/libs/boot_serial/test/pkg.yml
index e123ce1..561c94b 100644
--- a/libs/boot_serial/test/pkg.yml
+++ b/libs/boot_serial/test/pkg.yml
@@ -28,3 +28,6 @@ pkg.deps:
pkg.deps.SELFTEST:
- libs/console/stub
+
+pkg.syscfg_vals.SELFTEST:
+ CONFIG_FCB: 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/bootutil/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/bootutil/pkg.yml b/libs/bootutil/pkg.yml
index 4d78647..1293ea8 100644
--- a/libs/bootutil/pkg.yml
+++ b/libs/bootutil/pkg.yml
@@ -34,9 +34,6 @@ pkg.deps:
pkg.deps.BOOTUTIL_NFFS:
- fs/nffs
-pkg.init_function: bootutil_pkg_init
-pkg.init_stage: 5
-
pkg.syscfg_defs:
BOOTUTIL_NFFS:
description: 'TBD'
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/bootutil/src/bootutil_misc.c
----------------------------------------------------------------------
diff --git a/libs/bootutil/src/bootutil_misc.c b/libs/bootutil/src/bootutil_misc.c
index 0f9a2ce..b6a1c31 100644
--- a/libs/bootutil/src/bootutil_misc.c
+++ b/libs/bootutil/src/bootutil_misc.c
@@ -17,11 +17,14 @@
* under the License.
*/
+#include <assert.h>
#include <string.h>
#include <inttypes.h>
#include "syscfg/syscfg.h"
+#include "hal/hal_bsp.h"
#include "hal/hal_flash.h"
+#include "hal/flash_map.h"
#include "config/config.h"
#include "os/os.h"
#include "bootutil/image.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/bootutil/src/loader.c
----------------------------------------------------------------------
diff --git a/libs/bootutil/src/loader.c b/libs/bootutil/src/loader.c
index c8f419d..e2d4cfa 100644
--- a/libs/bootutil/src/loader.c
+++ b/libs/bootutil/src/loader.c
@@ -650,9 +650,3 @@ split_app_go_end:
free(descs);
return rc;
}
-
-void
-bootutil_pkg_init(void)
-{
- bootutil_cfg_register();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/bootutil/test/src/boot_serial_test.c
----------------------------------------------------------------------
diff --git a/libs/bootutil/test/src/boot_serial_test.c b/libs/bootutil/test/src/boot_serial_test.c
deleted file mode 100644
index 420a802..0000000
--- a/libs/bootutil/test/src/boot_serial_test.c
+++ /dev/null
@@ -1,1171 +0,0 @@
-/**
- * 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 <assert.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include "syscfg/syscfg.h"
-#include "os/endian.h"
-#include "testutil/testutil.h"
-#include "hal/hal_flash.h"
-#include "hal/flash_map.h"
-#include "fs/fs.h"
-#include "nffs/nffs.h"
-#include "config/config_file.h"
-#include "bootutil/image.h"
-#include "bootutil/loader.h"
-#include "bootutil/bootutil_misc.h"
-#include "../src/bootutil_priv.h"
-
-#include "mbedtls/sha256.h"
-
-#define BOOT_TEST_HEADER_SIZE 0x200
-
-/** Internal flash layout. */
-static struct flash_area boot_test_area_descs[] = {
- [0] = { .fa_off = 0x00020000, .fa_size = 128 * 1024 },
- [1] = { .fa_off = 0x00040000, .fa_size = 128 * 1024 },
- [2] = { .fa_off = 0x00060000, .fa_size = 128 * 1024 },
- [3] = { .fa_off = 0x00080000, .fa_size = 128 * 1024 },
- [4] = { .fa_off = 0x000a0000, .fa_size = 128 * 1024 },
- [5] = { .fa_off = 0x000c0000, .fa_size = 128 * 1024 },
- [6] = { .fa_off = 0x000e0000, .fa_size = 128 * 1024 },
-};
-
-static const struct flash_area boot_test_format_descs[] = {
- [0] = { .fa_off = 0x00004000, .fa_size = 16 * 1024 },
- [1] = { .fa_off = 0x00008000, .fa_size = 16 * 1024 },
- [2] = { .fa_off = 0x0000c000, .fa_size = 16 * 1024 },
- [3] = { .fa_off = 0, .fa_size = 0 },
-};
-
-/** Areas representing the beginning of image slots. */
-static uint8_t boot_test_slot_areas[] = {
- 0, 3,
-};
-
-/** Flash offsets of the two image slots. */
-static struct {
- uint8_t flash_id;
- uint32_t address;
-} boot_test_img_addrs[] = {
- { 0, 0x20000 },
- { 0, 0x80000 },
-};
-
-#define BOOT_TEST_AREA_IDX_SCRATCH 6
-
-#define MY_CONF_PATH "/cfg/run"
-
-static struct conf_file my_conf = {
- .cf_name = MY_CONF_PATH
-};
-
-static uint8_t
-boot_test_util_byte_at(int img_msb, uint32_t image_offset)
-{
- uint32_t u32;
- uint8_t *u8p;
-
- TEST_ASSERT(image_offset < 0x01000000);
- u32 = image_offset + (img_msb << 24);
- u8p = (void *)&u32;
- return u8p[image_offset % 4];
-}
-
-static void
-boot_test_util_init_flash(void)
-{
- const struct flash_area *area_desc;
- int rc;
- struct nffs_area_desc nffs_descs[32];
- int cnt;
-
- rc = hal_flash_init();
- TEST_ASSERT(rc == 0);
-
- for (area_desc = boot_test_area_descs;
- area_desc->fa_size != 0;
- area_desc++) {
-
- rc = flash_area_erase(area_desc, 0, area_desc->fa_size);
- TEST_ASSERT(rc == 0);
- }
- cnt = 32;
-
- rc = nffs_misc_desc_from_flash_area(FLASH_AREA_NFFS, &cnt, nffs_descs);
- TEST_ASSERT(rc == 0);
-
- rc = nffs_init();
- TEST_ASSERT(rc == 0);
- rc = nffs_format(nffs_descs);
- TEST_ASSERT(rc == 0);
-
- fs_mkdir("/cfg");
-}
-
-static void
-boot_test_util_copy_area(int from_area_idx, int to_area_idx)
-{
- const struct flash_area *from_area_desc;
- const struct flash_area *to_area_desc;
- void *buf;
- int rc;
-
- from_area_desc = boot_test_area_descs + from_area_idx;
- to_area_desc = boot_test_area_descs + to_area_idx;
-
- TEST_ASSERT(from_area_desc->fa_size == to_area_desc->fa_size);
-
- buf = malloc(from_area_desc->fa_size);
- TEST_ASSERT(buf != NULL);
-
- rc = flash_area_read(from_area_desc, 0, buf,
- from_area_desc->fa_size);
- TEST_ASSERT(rc == 0);
-
- rc = flash_area_erase(to_area_desc,
- 0,
- to_area_desc->fa_size);
- TEST_ASSERT(rc == 0);
-
- rc = flash_area_write(to_area_desc, 0, buf,
- to_area_desc->fa_size);
- TEST_ASSERT(rc == 0);
-
- free(buf);
-}
-
-static void
-boot_test_util_swap_areas(int area_idx1, int area_idx2)
-{
- const struct flash_area *area_desc1;
- const struct flash_area *area_desc2;
- void *buf1;
- void *buf2;
- int rc;
-
- area_desc1 = boot_test_area_descs + area_idx1;
- area_desc2 = boot_test_area_descs + area_idx2;
-
- TEST_ASSERT(area_desc1->fa_size == area_desc2->fa_size);
-
- buf1 = malloc(area_desc1->fa_size);
- TEST_ASSERT(buf1 != NULL);
-
- buf2 = malloc(area_desc2->fa_size);
- TEST_ASSERT(buf2 != NULL);
-
- rc = flash_area_read(area_desc1, 0, buf1, area_desc1->fa_size);
- TEST_ASSERT(rc == 0);
-
- rc = flash_area_read(area_desc2, 0, buf2, area_desc2->fa_size);
- TEST_ASSERT(rc == 0);
-
- rc = flash_area_erase(area_desc1, 0, area_desc1->fa_size);
- TEST_ASSERT(rc == 0);
-
- rc = flash_area_erase(area_desc2, 0, area_desc2->fa_size);
- TEST_ASSERT(rc == 0);
-
- rc = flash_area_write(area_desc1, 0, buf2, area_desc1->fa_size);
- TEST_ASSERT(rc == 0);
-
- rc = flash_area_write(area_desc2, 0, buf1, area_desc2->fa_size);
- TEST_ASSERT(rc == 0);
-
- free(buf1);
- free(buf2);
-}
-
-static void
-boot_test_util_write_image(const struct image_header *hdr, int slot)
-{
- uint32_t image_off;
- uint32_t off;
- uint8_t flash_id;
- uint8_t buf[256];
- int chunk_sz;
- int rc;
- int i;
-
- TEST_ASSERT(slot == 0 || slot == 1);
-
- flash_id = boot_test_img_addrs[slot].flash_id;
- off = boot_test_img_addrs[slot].address;
-
- rc = hal_flash_write(flash_id, off, hdr, sizeof *hdr);
- TEST_ASSERT(rc == 0);
-
- off += hdr->ih_hdr_size;
-
- image_off = 0;
- while (image_off < hdr->ih_img_size) {
- if (hdr->ih_img_size - image_off > sizeof buf) {
- chunk_sz = sizeof buf;
- } else {
- chunk_sz = hdr->ih_img_size - image_off;
- }
-
- for (i = 0; i < chunk_sz; i++) {
- buf[i] = boot_test_util_byte_at(slot, image_off + i);
- }
-
- rc = hal_flash_write(flash_id, off + image_off, buf, chunk_sz);
- TEST_ASSERT(rc == 0);
-
- image_off += chunk_sz;
- }
-}
-
-static void
-boot_test_util_write_hash(const struct image_header *hdr, int slot)
-{
- uint8_t tmpdata[1024];
- uint8_t hash[32];
- int rc;
- uint32_t off;
- uint32_t blk_sz;
- uint32_t sz;
- mbedtls_sha256_context ctx;
- uint8_t flash_id;
- uint32_t addr;
- struct image_tlv tlv;
-
- mbedtls_sha256_init(&ctx);
- mbedtls_sha256_starts(&ctx, 0);
-
- flash_id = boot_test_img_addrs[slot].flash_id;
- addr = boot_test_img_addrs[slot].address;
-
- sz = hdr->ih_hdr_size + hdr->ih_img_size;
- for (off = 0; off < sz; off += blk_sz) {
- blk_sz = sz - off;
- if (blk_sz > sizeof(tmpdata)) {
- blk_sz = sizeof(tmpdata);
- }
- rc = hal_flash_read(flash_id, addr + off, tmpdata, blk_sz);
- TEST_ASSERT(rc == 0);
- mbedtls_sha256_update(&ctx, tmpdata, blk_sz);
- }
- mbedtls_sha256_finish(&ctx, hash);
-
- tlv.it_type = IMAGE_TLV_SHA256;
- tlv._pad = 0;
- tlv.it_len = sizeof(hash);
-
- rc = hal_flash_write(flash_id, addr + off, &tlv, sizeof(tlv));
- TEST_ASSERT(rc == 0);
- off += sizeof(tlv);
- rc = hal_flash_write(flash_id, addr + off, hash, sizeof(hash));
- TEST_ASSERT(rc == 0);
-}
-
-static void
-boot_test_util_verify_area(const struct flash_area *area_desc,
- const struct image_header *hdr,
- uint32_t image_addr, int img_msb)
-{
- struct image_header temp_hdr;
- uint32_t area_end;
- uint32_t img_size;
- uint32_t img_off;
- uint32_t img_end;
- uint32_t addr;
- uint8_t buf[256];
- int rem_area;
- int past_image;
- int chunk_sz;
- int rem_img;
- int rc;
- int i;
-
- addr = area_desc->fa_off;
-
- if (hdr != NULL) {
- img_size = hdr->ih_img_size;
-
- if (addr == image_addr) {
- rc = hal_flash_read(area_desc->fa_flash_id, image_addr,
- &temp_hdr, sizeof temp_hdr);
- TEST_ASSERT(rc == 0);
- TEST_ASSERT(memcmp(&temp_hdr, hdr, sizeof *hdr) == 0);
-
- addr += hdr->ih_hdr_size;
- }
- } else {
- img_size = 0;
- }
-
- area_end = area_desc->fa_off + area_desc->fa_size;
- img_end = image_addr + img_size;
- past_image = addr >= img_end;
-
- while (addr < area_end) {
- rem_area = area_end - addr;
- rem_img = img_end - addr;
-
- if (hdr != NULL) {
- img_off = addr - image_addr - hdr->ih_hdr_size;
- } else {
- img_off = 0;
- }
-
- if (rem_area > sizeof buf) {
- chunk_sz = sizeof buf;
- } else {
- chunk_sz = rem_area;
- }
-
- rc = hal_flash_read(area_desc->fa_flash_id, addr, buf, chunk_sz);
- TEST_ASSERT(rc == 0);
-
- for (i = 0; i < chunk_sz; i++) {
- if (rem_img > 0) {
- TEST_ASSERT(buf[i] == boot_test_util_byte_at(img_msb,
- img_off + i));
- } else if (past_image) {
- TEST_ASSERT(buf[i] == 0xff);
- }
- }
-
- addr += chunk_sz;
- }
-}
-
-static void
-boot_test_util_verify_status_clear(void)
-{
- struct fs_file *file;
- int rc;
- int empty = 1;
- char *needle = "boot/status=";
- int nlen = strlen(needle);
- uint32_t len, hlen;
- char *haystack, *ptr;
-
- rc = fs_open(MY_CONF_PATH, FS_ACCESS_READ, &file);
- if (rc != 0) {
- return;
- }
- rc = fs_filelen(file, &len);
- TEST_ASSERT(rc == 0);
-
- haystack = malloc(len + 1);
- TEST_ASSERT(haystack);
-
- rc = fs_read(file, len, haystack, &hlen);
- TEST_ASSERT(rc == 0);
- TEST_ASSERT(hlen == len);
- haystack[len] = '\0';
-
- fs_close(file);
-
- ptr = haystack;
- while ((ptr = strstr(ptr, needle))) {
- if (ptr[nlen] == '\n') {
- empty = 1;
- } else {
- empty = 0;
- }
- ptr += nlen;
- }
- TEST_ASSERT(empty == 1);
- free(haystack);
-
- rc = fs_open(BOOT_PATH_STATUS, FS_ACCESS_READ, &file);
- TEST_ASSERT(rc == FS_ENOENT);
-}
-
-static void
-boot_test_util_verify_flash(const struct image_header *hdr0, int orig_slot_0,
- const struct image_header *hdr1, int orig_slot_1)
-{
- const struct flash_area *area_desc;
- int area_idx;
-
- area_idx = 0;
-
- while (1) {
- area_desc = boot_test_area_descs + area_idx;
- if (area_desc->fa_off == boot_test_img_addrs[1].address &&
- area_desc->fa_flash_id == boot_test_img_addrs[1].flash_id) {
- break;
- }
-
- boot_test_util_verify_area(area_desc, hdr0,
- boot_test_img_addrs[0].address, orig_slot_0);
- area_idx++;
- }
-
- while (1) {
- if (area_idx == BOOT_TEST_AREA_IDX_SCRATCH) {
- break;
- }
-
- area_desc = boot_test_area_descs + area_idx;
- boot_test_util_verify_area(area_desc, hdr1,
- boot_test_img_addrs[1].address, orig_slot_1);
- area_idx++;
- }
-}
-
-TEST_CASE(boot_test_setup)
-{
- int rc;
-
- rc = conf_file_src(&my_conf);
- assert(rc == 0);
- rc = conf_file_dst(&my_conf);
- assert(rc == 0);
-
- bootutil_cfg_register();
-}
-
-TEST_CASE(boot_test_nv_ns_10)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 12 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 2, 3, 4 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr, 0);
- boot_test_util_write_hash(&hdr, 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr, sizeof hdr) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr, 0, NULL, 0xff);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_nv_ns_01)
-{
- struct boot_rsp rsp;
- int rc;
-
-
- struct image_header hdr = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 10 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 2, 3, 432 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr, 1);
- boot_test_util_write_hash(&hdr, 1);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr, sizeof hdr) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr, 1, NULL, 0xff);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_nv_ns_11)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr0 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 5 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 5, 21, 432 },
- };
-
- struct image_header hdr1 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 32 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 2, 3, 432 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr0, 0);
- boot_test_util_write_hash(&hdr0, 0);
- boot_test_util_write_image(&hdr1, 1);
- boot_test_util_write_hash(&hdr1, 1);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr0, sizeof hdr0) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr0, 0, &hdr1, 1);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_vm_ns_10)
-{
- struct boot_rsp rsp;
- int rc;
-
-
- struct image_header hdr = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 12 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 2, 3, 4 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr, 0);
- boot_test_util_write_hash(&hdr, 0);
-
- rc = boot_vect_write_main(&hdr.ih_ver);
- TEST_ASSERT(rc == 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr, sizeof hdr) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr, 0, NULL, 0xff);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_vm_ns_01)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 10 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 2, 3, 432 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr, 1);
- boot_test_util_write_hash(&hdr, 1);
-
- rc = boot_vect_write_main(&hdr.ih_ver);
- TEST_ASSERT(rc == 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr, sizeof hdr) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr, 1, NULL, 0xff);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_vm_ns_11_a)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr0 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 5 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 5, 21, 432 },
- };
-
- struct image_header hdr1 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 32 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 2, 3, 432 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr0, 0);
- boot_test_util_write_hash(&hdr0, 0);
- boot_test_util_write_image(&hdr1, 1);
- boot_test_util_write_hash(&hdr1, 1);
-
- rc = boot_vect_write_main(&hdr0.ih_ver);
- TEST_ASSERT(rc == 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr0, sizeof hdr0) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr0, 0, &hdr1, 1);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_vm_ns_11_b)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr0 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 5 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 5, 21, 432 },
- };
-
- struct image_header hdr1 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 32 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 2, 3, 432 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr0, 0);
- boot_test_util_write_hash(&hdr0, 0);
- boot_test_util_write_image(&hdr1, 1);
- boot_test_util_write_hash(&hdr1, 1);
-
- rc = boot_vect_write_main(&hdr1.ih_ver);
- TEST_ASSERT(rc == 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr1, sizeof hdr1) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr1, 1, &hdr0, 0);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_vm_ns_11_2areas)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr0 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 5 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 5, 21, 432 },
- };
-
- struct image_header hdr1 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 196 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 2, 3, 432 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr0, 0);
- boot_test_util_write_hash(&hdr0, 0);
- boot_test_util_write_image(&hdr1, 1);
- boot_test_util_write_hash(&hdr1, 1);
-
- rc = boot_vect_write_main(&hdr1.ih_ver);
- TEST_ASSERT(rc == 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr1, sizeof hdr1) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr1, 1, &hdr0, 0);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_nv_bs_10)
-{
- struct boot_status status;
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 12 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 2, 3, 4 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr, 0);
- boot_test_util_write_hash(&hdr, 0);
- boot_test_util_swap_areas(boot_test_slot_areas[1],
- BOOT_TEST_AREA_IDX_SCRATCH);
-
- status.length = hdr.ih_hdr_size + hdr.ih_img_size + hdr.ih_tlv_size;
- status.state = 1;
-
- rc = boot_write_status(&status);
- TEST_ASSERT(rc == 0);
- conf_load();
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr, sizeof hdr) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr, 0, NULL, 0xff);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_nv_bs_11)
-{
- struct boot_status status;
- struct boot_rsp rsp;
- int len;
- int rc;
-
- struct image_header hdr0 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 12 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 2, 3, 4 },
- };
-
- struct image_header hdr1 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 17 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 1, 5, 5 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr0, 0);
- boot_test_util_write_hash(&hdr0, 0);
- boot_test_util_write_image(&hdr1, 1);
- boot_test_util_write_hash(&hdr1, 1);
- boot_test_util_copy_area(boot_test_slot_areas[1],
- BOOT_TEST_AREA_IDX_SCRATCH);
-
- status.length = hdr0.ih_hdr_size + hdr0.ih_img_size + hdr0.ih_tlv_size;
- len = hdr1.ih_hdr_size + hdr1.ih_img_size + hdr1.ih_tlv_size;
- if (len > status.length) {
- status.length = len;
- }
- status.state = 1;
-
- rc = boot_write_status(&status);
- TEST_ASSERT(rc == 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr1, sizeof hdr1) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr1, 1, &hdr0, 0);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_nv_bs_11_2areas)
-{
- struct boot_status status;
- struct boot_rsp rsp;
- int rc;
- int len;
-
- struct image_header hdr0 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 150 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 5, 21, 432 },
- };
-
- struct image_header hdr1 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 190 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 2, 3, 432 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr0, 0);
- boot_test_util_write_hash(&hdr0, 0);
- boot_test_util_write_image(&hdr1, 1);
- boot_test_util_write_hash(&hdr1, 1);
- boot_test_util_swap_areas(boot_test_slot_areas[0],
- boot_test_slot_areas[1]);
-
- status.length = hdr0.ih_hdr_size + hdr0.ih_img_size + hdr0.ih_tlv_size;
- len = hdr1.ih_hdr_size + hdr1.ih_img_size + hdr1.ih_tlv_size;
- if (len > status.length) {
- status.length = len;
- }
- status.state = 1 << 8;
-
- rc = boot_write_status(&status);
- TEST_ASSERT(rc == 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr1, sizeof hdr1) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr1, 1, &hdr0, 0);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_vb_ns_11)
-{
- struct boot_rsp rsp;
- int rc;
- int i;
-
- struct image_header hdr0 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 5 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 5, 21, 432 },
- };
-
- struct image_header hdr1 = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 32 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 1, 2, 3, 432 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr0, 0);
- boot_test_util_write_image(&hdr1, 1);
- boot_test_util_write_hash(&hdr0, 0);
- boot_test_util_write_hash(&hdr1, 1);
-
- rc = boot_vect_write_main(&hdr0.ih_ver);
- TEST_ASSERT(rc == 0);
-
- rc = boot_vect_write_test(&hdr1.ih_ver);
- TEST_ASSERT(rc == 0);
-
- /* First boot should use the test image. */
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr1, sizeof hdr1) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr1, 1, &hdr0, 0);
- boot_test_util_verify_status_clear();
-
- /* Ensure all subsequent boots use the main image. */
- for (i = 0; i < 10; i++) {
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc == 0);
-
- TEST_ASSERT(memcmp(rsp.br_hdr, &hdr0, sizeof hdr0) == 0);
- TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
-
- boot_test_util_verify_flash(&hdr0, 0, &hdr1, 1);
- boot_test_util_verify_status_clear();
- }
-}
-
-TEST_CASE(boot_test_no_hash)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 0,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 12 * 1024,
- .ih_flags = 0,
- .ih_ver = { 0, 2, 3, 4 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr, 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc != 0);
-
- boot_test_util_verify_flash(&hdr, 0, NULL, 0xff);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_no_flag_has_hash)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 12 * 1024,
- .ih_flags = 0,
- .ih_ver = { 0, 2, 3, 4 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr, 0);
- boot_test_util_write_hash(&hdr, 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc != 0);
-
- boot_test_util_verify_flash(&hdr, 0, NULL, 0xff);
- boot_test_util_verify_status_clear();
-}
-
-TEST_CASE(boot_test_invalid_hash)
-{
- struct boot_rsp rsp;
- int rc;
-
- struct image_header hdr = {
- .ih_magic = IMAGE_MAGIC,
- .ih_tlv_size = 4 + 32,
- .ih_hdr_size = BOOT_TEST_HEADER_SIZE,
- .ih_img_size = 12 * 1024,
- .ih_flags = IMAGE_F_SHA256,
- .ih_ver = { 0, 2, 3, 4 },
- };
-
- struct boot_req req = {
- .br_area_descs = boot_test_area_descs,
- .br_slot_areas = boot_test_slot_areas,
- .br_num_image_areas = BOOT_TEST_AREA_IDX_SCRATCH + 1,
- .br_scratch_area_idx = BOOT_TEST_AREA_IDX_SCRATCH,
- };
-
- struct image_tlv tlv = {
- .it_type = IMAGE_TLV_SHA256,
- .it_len = 32
- };
- boot_test_util_init_flash();
- boot_test_util_write_image(&hdr, 0);
- rc = hal_flash_write(boot_test_img_addrs[0].flash_id,
- boot_test_img_addrs[0].address + hdr.ih_hdr_size + hdr.ih_img_size,
- &tlv, sizeof(tlv));
- TEST_ASSERT(rc == 0);
-
- rc = boot_go(&req, &rsp);
- TEST_ASSERT(rc != 0);
-
- boot_test_util_verify_flash(&hdr, 0, NULL, 0xff);
- boot_test_util_verify_status_clear();
-}
-
-TEST_SUITE(boot_test_main)
-{
- boot_test_setup();
- boot_test_nv_ns_10();
- boot_test_nv_ns_01();
- boot_test_nv_ns_11();
- boot_test_vm_ns_10();
- boot_test_vm_ns_01();
- boot_test_vm_ns_11_a();
- boot_test_vm_ns_11_b();
- boot_test_vm_ns_11_2areas();
- boot_test_nv_bs_10();
- boot_test_nv_bs_11();
- boot_test_nv_bs_11_2areas();
- boot_test_vb_ns_11();
- boot_test_no_hash();
- boot_test_no_flag_has_hash();
- boot_test_invalid_hash();
-}
-
-int
-boot_test_all(void)
-{
- boot_test_main();
- return tu_any_failed;
-}
-
-#if MYNEWT_VAL(SELFTEST)
-
-int
-main(void)
-{
- tu_config.tc_print_results = 1;
- tu_init();
-
- boot_test_all();
-
- return tu_any_failed;
-}
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/console/stub/include/console/console_prompt.h
----------------------------------------------------------------------
diff --git a/libs/console/stub/include/console/console_prompt.h b/libs/console/stub/include/console/console_prompt.h
deleted file mode 100644
index 8cbda7c..0000000
--- a/libs/console/stub/include/console/console_prompt.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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 __CONSOLE_H__
-#define __CONSOLE_H__
-
-#include <stdarg.h>
-
-
-/* print console prompt */
-void console_print_prompt(void);
-/* set the console prompt character */
-void console_set_prompt(char);
-
-
-extern char console_prompt[2];
-
-
-#endif /* __CONSOLE_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/console/stub/include/console/prompt.h
----------------------------------------------------------------------
diff --git a/libs/console/stub/include/console/prompt.h b/libs/console/stub/include/console/prompt.h
new file mode 100644
index 0000000..9d7f622
--- /dev/null
+++ b/libs/console/stub/include/console/prompt.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_CONSOLE_PROMPT_
+#define H_CONSOLE_PROMPT_
+
+#include <stdarg.h>
+
+/* print console prompt */
+void console_print_prompt(void);
+/* set the console prompt character */
+void console_set_prompt(char);
+
+
+extern char console_prompt[2];
+
+
+#endif /* __CONSOLE_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/imgmgr/src/imgmgr.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr.c b/libs/imgmgr/src/imgmgr.c
index d204cc4..04ec43c 100644
--- a/libs/imgmgr/src/imgmgr.c
+++ b/libs/imgmgr/src/imgmgr.c
@@ -28,6 +28,8 @@
#include "json/json.h"
#include "util/base64.h"
#include "bootutil/image.h"
+#include "bootutil/bootutil_misc.h"
+#include "newtmgr/newtmgr.h"
#include "imgmgr/imgmgr.h"
#include "imgmgr_priv.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/imgmgr/src/imgmgr_cli.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_cli.c b/libs/imgmgr/src/imgmgr_cli.c
index 2b70890..da1c0bf 100644
--- a/libs/imgmgr/src/imgmgr_cli.c
+++ b/libs/imgmgr/src/imgmgr_cli.c
@@ -17,7 +17,9 @@
* under the License.
*/
-#ifdef SHELL_PRESENT
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(IMGMGR_CLI)
#include <string.h>
@@ -136,4 +138,4 @@ imgr_cli_register(void)
{
return shell_cmd_register(&shell_imgr_cmd);
}
-#endif
+#endif /* MYNEWT_VAL(IMGMGR_CLI) */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/newtmgr_oic/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/newtmgr_oic/pkg.yml b/libs/newtmgr_oic/pkg.yml
index 75d20f5..69cc00b 100644
--- a/libs/newtmgr_oic/pkg.yml
+++ b/libs/newtmgr_oic/pkg.yml
@@ -39,6 +39,11 @@ pkg.cflags:
pkg.apis:
- newtmgr
-pkg.features:
- - NEWTMGR
- - OC_SERVER
+pkg.syscfg_defs:
+ ### These should be renamed with a proper prefix.
+ NEWTMGR:
+ description: 'TBD'
+ value: 1
+ OC_SERVER:
+ description: 'TBD'
+ value: 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/os/src/test/callout_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/callout_test.c b/libs/os/src/test/callout_test.c
deleted file mode 100644
index 4e3811d..0000000
--- a/libs/os/src/test/callout_test.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/**
- * 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 "testutil/testutil.h"
-#include "os/os.h"
-#include "os_test_priv.h"
-#include "os/os_eventq.h"
-#include "os/os_callout.h"
-#include "os/os_time.h"
-
-/* Task 1 for sending */
-#define CALLOUT_STACK_SIZE (5120)
-#define SEND_CALLOUT_TASK_PRIO (1)
-struct os_task callout_task_struct_send;
-os_stack_t callout_task_stack_send[CALLOUT_STACK_SIZE];
-
-#define RECEIVE_CALLOUT_TASK_PRIO (2)
-struct os_task callout_task_struct_receive;
-os_stack_t callout_task_stack_receive[CALLOUT_STACK_SIZE];
-
-/* Delearing variables for callout_func */
-struct os_callout_func callout_func_test;
-
-/* The event to be sent*/
-struct os_eventq callout_evq;
-struct os_event callout_ev;
-
-/* The callout_stop task */
-#define SEND_STOP_CALLOUT_TASK_PRIO (3)
-struct os_task callout_task_struct_stop_send;
-os_stack_t callout_task_stack_stop_send[CALLOUT_STACK_SIZE];
-
-#define RECEIVE_STOP_CALLOUT_TASK_PRIO (4)
-struct os_task callout_task_struct_stop_receive;
-os_stack_t callout_task_stack_stop_receive[CALLOUT_STACK_SIZE];
-
-/* Delearing variables for callout_stop_func */
-#define MULTI_SIZE (2)
-struct os_callout_func callout_func_stop_test[MULTI_SIZE];
-
-/* The event to be sent*/
-struct os_eventq callout_stop_evq[MULTI_SIZE];
-struct os_event callout_stop_ev;
-
-/* Declearing varables for callout_speak */
-#define SPEAK_CALLOUT_TASK_PRIO (5)
-struct os_task callout_task_struct_speak;
-os_stack_t callout_task_stack_speak[CALLOUT_STACK_SIZE];
-
-/* Declearing varaibles for listen */
-#define LISTEN_CALLOUT_TASK_PRIO (6)
-struct os_task callout_task_struct_listen;
-os_stack_t callout_task_stack_listen[CALLOUT_STACK_SIZE];
-
-struct os_callout_func callout_func_speak;
-
-/* Global variables to be used by the callout functions */
-int p;
-int q;
-int t;
-/* This is the function for callout_init*/
-void
-my_callout_func(void *arg)
-{
- p = 4;
-}
-
-/* This is the function for callout_init of stop test_case*/
-void
-my_callout_stop_func(void *arg)
-{
- q = 1;
-}
-/* This is the function for callout_init for speak test_case*/
-void
-my_callout_speak_func(void *arg)
-{
- t = 2;
-}
-
-/* This is a callout task to send data */
-void
-callout_task_send(void *arg )
-{
- int i;
- /* Should say whether callout is armed or not */
- i= os_callout_queued(&callout_func_test.cf_c);
- TEST_ASSERT(i == 0);
-
- /* Arm the callout */
- i = os_callout_reset(&callout_func_test.cf_c, OS_TICKS_PER_SEC/ 50);
- TEST_ASSERT_FATAL(i == 0);
-
- /* Should say whether callout is armed or not */
- i = os_callout_queued(&callout_func_test.cf_c);
- TEST_ASSERT(i == 1);
-
- /* Send the callout */
- os_time_delay(OS_TICKS_PER_SEC );
-}
-
-/* This is the callout to receive data */
-void
-callout_task_receive( void *arg)
-{
- int i;
- struct os_event *event;
- struct os_callout_func *callout;
- os_time_t now;
- os_time_t tm;
- os_sr_t sr;
- /* Recieve using the os_eventq_poll */
- event = os_eventq_poll(&callout_func_test.cf_c.c_evq, 1, OS_WAIT_FOREVER);
- TEST_ASSERT(event->ev_type == OS_EVENT_T_TIMER);
- TEST_ASSERT(event->ev_arg == NULL);
- callout = (struct os_callout_func *)event;
- TEST_ASSERT(callout->cf_func == my_callout_func);
-
- /* Should say whether callout is armed or not */
- i = os_callout_queued(&callout_func_test.cf_c);
- TEST_ASSERT(i == 0);
-
- OS_ENTER_CRITICAL(sr);
- now = os_time_get();
- tm = os_callout_wakeup_ticks(now);
- TEST_ASSERT(tm == OS_TIMEOUT_NEVER);
- OS_EXIT_CRITICAL(sr);
-
- /* Finishes the test when OS has been started */
- os_test_restart();
-
-}
-
-/* This is callout to send the stop_callout */
-void
-callout_task_stop_send( void *arg)
-{
- int k;
- int j;
- /* Should say whether callout is armed or not */
- for(k = 0; k<MULTI_SIZE; k++){
- j = os_callout_queued(&callout_func_stop_test[k].cf_c);
- TEST_ASSERT(j == 0);
- }
-
-
- /* Show that callout is not armed after calling callout_stop */
- for(k = 0; k<MULTI_SIZE; k++){
- os_callout_stop(&callout_func_stop_test[k].cf_c);
- j = os_callout_queued(&callout_func_stop_test[k].cf_c);
- TEST_ASSERT(j == 0);
- }
- /* Arm the callout */
- for(k = 0; k<MULTI_SIZE; k++){
- j = os_callout_reset(&callout_func_stop_test[k].cf_c, OS_TICKS_PER_SEC/ 50);
- TEST_ASSERT_FATAL(j == 0);
- }
- os_time_delay( OS_TICKS_PER_SEC );
-}
-
-/* This is the callout to receive stop_callout data */
-void
-callout_task_stop_receive( void *arg )
-{
- int k;
- struct os_event *event;
- struct os_callout_func *callout;
- /* Recieving using the os_eventq_poll */
- for(k=0; k<MULTI_SIZE; k++){
- event = os_eventq_poll(&callout_func_stop_test[k].cf_c.c_evq, 1,
- OS_WAIT_FOREVER);
- TEST_ASSERT(event->ev_type == OS_EVENT_T_TIMER);
- TEST_ASSERT(event->ev_arg == NULL);
- callout = (struct os_callout_func *)event;
- TEST_ASSERT(callout->cf_func == my_callout_stop_func);
-
-
- }
-
- /* Show that event is removed from the queued after calling callout_stop */
- for(k=0; k<MULTI_SIZE; k++){
- os_callout_stop(&callout_func_stop_test[k].cf_c);
- /* Testing that the event has been removed from queue */
- TEST_ASSERT_FATAL(1);
- }
- /* Finishes the test when OS has been started */
- os_test_restart();
-
-}
-
-/* This is a callout task to send data */
-void
-callout_task_stop_speak( void *arg )
-{
- int i;
- /* Arm the callout */
- i = os_callout_reset(&callout_func_speak.cf_c, OS_TICKS_PER_SEC/ 50);
- TEST_ASSERT_FATAL(i == 0);
-
- /* should say whether callout is armed or not */
- i = os_callout_queued(&callout_func_speak.cf_c);
- TEST_ASSERT(i == 1);
-
- os_callout_stop(&callout_func_speak.cf_c);
-
- /* Send the callout */
- os_time_delay(OS_TICKS_PER_SEC/ 100 );
- /* Finishes the test when OS has been started */
- os_test_restart();
-}
-
-void
-callout_task_stop_listen( void *arg )
-{
- struct os_event *event;
- struct os_callout_func *callout;
- event = os_eventq_get(callout_func_speak.cf_c.c_evq);
- TEST_ASSERT_FATAL(0);
- callout = (struct os_callout_func *)event;
- TEST_ASSERT(callout->cf_func == my_callout_speak_func);
-
-}
-
-/* Test case to test the basics of the callout */
-TEST_CASE(callout_test)
-{
-
- /* Initializing the OS */
- os_init();
-
- /* Initialize the sending task */
- os_task_init(&callout_task_struct_send, "callout_task_send",
- callout_task_send, NULL, SEND_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
- callout_task_stack_send, CALLOUT_STACK_SIZE);
-
- /* Initialize the receive task */
- os_task_init(&callout_task_struct_receive, "callout_task_receive",
- callout_task_receive, NULL, RECEIVE_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
- callout_task_stack_receive, CALLOUT_STACK_SIZE);
-
- os_eventq_init(&callout_evq);
-
- /* Initialize the callout function */
- os_callout_func_init(&callout_func_test, &callout_evq,
- my_callout_func, NULL);
-
- /* Does not return until OS_restart is called */
- os_start();
-}
-
-/* Test case of the callout_task_stop */
-TEST_CASE(callout_test_stop)
-{
- int k;
- /* Initializing the OS */
- os_init();
-
- /* Initialize the sending task */
- os_task_init(&callout_task_struct_stop_send, "callout_task_stop_send",
- callout_task_stop_send, NULL, SEND_STOP_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
- callout_task_stack_stop_send, CALLOUT_STACK_SIZE);
-
- /* Initialize the receiving task */
- os_task_init(&callout_task_struct_stop_receive, "callout_task_stop_receive",
- callout_task_stop_receive, NULL, RECEIVE_STOP_CALLOUT_TASK_PRIO,
- OS_WAIT_FOREVER, callout_task_stack_stop_receive, CALLOUT_STACK_SIZE);
-
- for(k = 0; k< MULTI_SIZE; k++){
- os_eventq_init(&callout_stop_evq[k]);
- }
-
- /* Initialize the callout function */
- for(k = 0; k<MULTI_SIZE; k++){
- os_callout_func_init(&callout_func_stop_test[k], &callout_stop_evq[k],
- my_callout_stop_func, NULL);
- }
-
- /* Does not return until OS_restart is called */
- os_start();
-
-}
-
-/* Test case to test case for speak and listen */
-TEST_CASE(callout_test_speak)
-{
- /* Initializing the OS */
- os_init();
-
- /* Initialize the sending task */
- os_task_init(&callout_task_struct_speak, "callout_task_speak",
- callout_task_stop_speak, NULL, SPEAK_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
- callout_task_stack_speak, CALLOUT_STACK_SIZE);
-
- /* Initialize the receive task */
- os_task_init(&callout_task_struct_listen, "callout_task_listen",
- callout_task_stop_listen, NULL, LISTEN_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
- callout_task_stack_listen, CALLOUT_STACK_SIZE);
-
- os_eventq_init(&callout_evq);
-
- /* Initialize the callout function */
- os_callout_func_init(&callout_func_speak, &callout_evq,
- my_callout_speak_func, NULL);
- /* Does not return until OS_restart is called */
- os_start();
-
-}
-
-TEST_SUITE(os_callout_test_suite)
-{
- callout_test();
- callout_test_stop();
- callout_test_speak();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/os/test/src/callout_test.c
----------------------------------------------------------------------
diff --git a/libs/os/test/src/callout_test.c b/libs/os/test/src/callout_test.c
new file mode 100644
index 0000000..4e3811d
--- /dev/null
+++ b/libs/os/test/src/callout_test.c
@@ -0,0 +1,330 @@
+/**
+ * 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 "testutil/testutil.h"
+#include "os/os.h"
+#include "os_test_priv.h"
+#include "os/os_eventq.h"
+#include "os/os_callout.h"
+#include "os/os_time.h"
+
+/* Task 1 for sending */
+#define CALLOUT_STACK_SIZE (5120)
+#define SEND_CALLOUT_TASK_PRIO (1)
+struct os_task callout_task_struct_send;
+os_stack_t callout_task_stack_send[CALLOUT_STACK_SIZE];
+
+#define RECEIVE_CALLOUT_TASK_PRIO (2)
+struct os_task callout_task_struct_receive;
+os_stack_t callout_task_stack_receive[CALLOUT_STACK_SIZE];
+
+/* Delearing variables for callout_func */
+struct os_callout_func callout_func_test;
+
+/* The event to be sent*/
+struct os_eventq callout_evq;
+struct os_event callout_ev;
+
+/* The callout_stop task */
+#define SEND_STOP_CALLOUT_TASK_PRIO (3)
+struct os_task callout_task_struct_stop_send;
+os_stack_t callout_task_stack_stop_send[CALLOUT_STACK_SIZE];
+
+#define RECEIVE_STOP_CALLOUT_TASK_PRIO (4)
+struct os_task callout_task_struct_stop_receive;
+os_stack_t callout_task_stack_stop_receive[CALLOUT_STACK_SIZE];
+
+/* Delearing variables for callout_stop_func */
+#define MULTI_SIZE (2)
+struct os_callout_func callout_func_stop_test[MULTI_SIZE];
+
+/* The event to be sent*/
+struct os_eventq callout_stop_evq[MULTI_SIZE];
+struct os_event callout_stop_ev;
+
+/* Declearing varables for callout_speak */
+#define SPEAK_CALLOUT_TASK_PRIO (5)
+struct os_task callout_task_struct_speak;
+os_stack_t callout_task_stack_speak[CALLOUT_STACK_SIZE];
+
+/* Declearing varaibles for listen */
+#define LISTEN_CALLOUT_TASK_PRIO (6)
+struct os_task callout_task_struct_listen;
+os_stack_t callout_task_stack_listen[CALLOUT_STACK_SIZE];
+
+struct os_callout_func callout_func_speak;
+
+/* Global variables to be used by the callout functions */
+int p;
+int q;
+int t;
+/* This is the function for callout_init*/
+void
+my_callout_func(void *arg)
+{
+ p = 4;
+}
+
+/* This is the function for callout_init of stop test_case*/
+void
+my_callout_stop_func(void *arg)
+{
+ q = 1;
+}
+/* This is the function for callout_init for speak test_case*/
+void
+my_callout_speak_func(void *arg)
+{
+ t = 2;
+}
+
+/* This is a callout task to send data */
+void
+callout_task_send(void *arg )
+{
+ int i;
+ /* Should say whether callout is armed or not */
+ i= os_callout_queued(&callout_func_test.cf_c);
+ TEST_ASSERT(i == 0);
+
+ /* Arm the callout */
+ i = os_callout_reset(&callout_func_test.cf_c, OS_TICKS_PER_SEC/ 50);
+ TEST_ASSERT_FATAL(i == 0);
+
+ /* Should say whether callout is armed or not */
+ i = os_callout_queued(&callout_func_test.cf_c);
+ TEST_ASSERT(i == 1);
+
+ /* Send the callout */
+ os_time_delay(OS_TICKS_PER_SEC );
+}
+
+/* This is the callout to receive data */
+void
+callout_task_receive( void *arg)
+{
+ int i;
+ struct os_event *event;
+ struct os_callout_func *callout;
+ os_time_t now;
+ os_time_t tm;
+ os_sr_t sr;
+ /* Recieve using the os_eventq_poll */
+ event = os_eventq_poll(&callout_func_test.cf_c.c_evq, 1, OS_WAIT_FOREVER);
+ TEST_ASSERT(event->ev_type == OS_EVENT_T_TIMER);
+ TEST_ASSERT(event->ev_arg == NULL);
+ callout = (struct os_callout_func *)event;
+ TEST_ASSERT(callout->cf_func == my_callout_func);
+
+ /* Should say whether callout is armed or not */
+ i = os_callout_queued(&callout_func_test.cf_c);
+ TEST_ASSERT(i == 0);
+
+ OS_ENTER_CRITICAL(sr);
+ now = os_time_get();
+ tm = os_callout_wakeup_ticks(now);
+ TEST_ASSERT(tm == OS_TIMEOUT_NEVER);
+ OS_EXIT_CRITICAL(sr);
+
+ /* Finishes the test when OS has been started */
+ os_test_restart();
+
+}
+
+/* This is callout to send the stop_callout */
+void
+callout_task_stop_send( void *arg)
+{
+ int k;
+ int j;
+ /* Should say whether callout is armed or not */
+ for(k = 0; k<MULTI_SIZE; k++){
+ j = os_callout_queued(&callout_func_stop_test[k].cf_c);
+ TEST_ASSERT(j == 0);
+ }
+
+
+ /* Show that callout is not armed after calling callout_stop */
+ for(k = 0; k<MULTI_SIZE; k++){
+ os_callout_stop(&callout_func_stop_test[k].cf_c);
+ j = os_callout_queued(&callout_func_stop_test[k].cf_c);
+ TEST_ASSERT(j == 0);
+ }
+ /* Arm the callout */
+ for(k = 0; k<MULTI_SIZE; k++){
+ j = os_callout_reset(&callout_func_stop_test[k].cf_c, OS_TICKS_PER_SEC/ 50);
+ TEST_ASSERT_FATAL(j == 0);
+ }
+ os_time_delay( OS_TICKS_PER_SEC );
+}
+
+/* This is the callout to receive stop_callout data */
+void
+callout_task_stop_receive( void *arg )
+{
+ int k;
+ struct os_event *event;
+ struct os_callout_func *callout;
+ /* Recieving using the os_eventq_poll */
+ for(k=0; k<MULTI_SIZE; k++){
+ event = os_eventq_poll(&callout_func_stop_test[k].cf_c.c_evq, 1,
+ OS_WAIT_FOREVER);
+ TEST_ASSERT(event->ev_type == OS_EVENT_T_TIMER);
+ TEST_ASSERT(event->ev_arg == NULL);
+ callout = (struct os_callout_func *)event;
+ TEST_ASSERT(callout->cf_func == my_callout_stop_func);
+
+
+ }
+
+ /* Show that event is removed from the queued after calling callout_stop */
+ for(k=0; k<MULTI_SIZE; k++){
+ os_callout_stop(&callout_func_stop_test[k].cf_c);
+ /* Testing that the event has been removed from queue */
+ TEST_ASSERT_FATAL(1);
+ }
+ /* Finishes the test when OS has been started */
+ os_test_restart();
+
+}
+
+/* This is a callout task to send data */
+void
+callout_task_stop_speak( void *arg )
+{
+ int i;
+ /* Arm the callout */
+ i = os_callout_reset(&callout_func_speak.cf_c, OS_TICKS_PER_SEC/ 50);
+ TEST_ASSERT_FATAL(i == 0);
+
+ /* should say whether callout is armed or not */
+ i = os_callout_queued(&callout_func_speak.cf_c);
+ TEST_ASSERT(i == 1);
+
+ os_callout_stop(&callout_func_speak.cf_c);
+
+ /* Send the callout */
+ os_time_delay(OS_TICKS_PER_SEC/ 100 );
+ /* Finishes the test when OS has been started */
+ os_test_restart();
+}
+
+void
+callout_task_stop_listen( void *arg )
+{
+ struct os_event *event;
+ struct os_callout_func *callout;
+ event = os_eventq_get(callout_func_speak.cf_c.c_evq);
+ TEST_ASSERT_FATAL(0);
+ callout = (struct os_callout_func *)event;
+ TEST_ASSERT(callout->cf_func == my_callout_speak_func);
+
+}
+
+/* Test case to test the basics of the callout */
+TEST_CASE(callout_test)
+{
+
+ /* Initializing the OS */
+ os_init();
+
+ /* Initialize the sending task */
+ os_task_init(&callout_task_struct_send, "callout_task_send",
+ callout_task_send, NULL, SEND_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
+ callout_task_stack_send, CALLOUT_STACK_SIZE);
+
+ /* Initialize the receive task */
+ os_task_init(&callout_task_struct_receive, "callout_task_receive",
+ callout_task_receive, NULL, RECEIVE_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
+ callout_task_stack_receive, CALLOUT_STACK_SIZE);
+
+ os_eventq_init(&callout_evq);
+
+ /* Initialize the callout function */
+ os_callout_func_init(&callout_func_test, &callout_evq,
+ my_callout_func, NULL);
+
+ /* Does not return until OS_restart is called */
+ os_start();
+}
+
+/* Test case of the callout_task_stop */
+TEST_CASE(callout_test_stop)
+{
+ int k;
+ /* Initializing the OS */
+ os_init();
+
+ /* Initialize the sending task */
+ os_task_init(&callout_task_struct_stop_send, "callout_task_stop_send",
+ callout_task_stop_send, NULL, SEND_STOP_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
+ callout_task_stack_stop_send, CALLOUT_STACK_SIZE);
+
+ /* Initialize the receiving task */
+ os_task_init(&callout_task_struct_stop_receive, "callout_task_stop_receive",
+ callout_task_stop_receive, NULL, RECEIVE_STOP_CALLOUT_TASK_PRIO,
+ OS_WAIT_FOREVER, callout_task_stack_stop_receive, CALLOUT_STACK_SIZE);
+
+ for(k = 0; k< MULTI_SIZE; k++){
+ os_eventq_init(&callout_stop_evq[k]);
+ }
+
+ /* Initialize the callout function */
+ for(k = 0; k<MULTI_SIZE; k++){
+ os_callout_func_init(&callout_func_stop_test[k], &callout_stop_evq[k],
+ my_callout_stop_func, NULL);
+ }
+
+ /* Does not return until OS_restart is called */
+ os_start();
+
+}
+
+/* Test case to test case for speak and listen */
+TEST_CASE(callout_test_speak)
+{
+ /* Initializing the OS */
+ os_init();
+
+ /* Initialize the sending task */
+ os_task_init(&callout_task_struct_speak, "callout_task_speak",
+ callout_task_stop_speak, NULL, SPEAK_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
+ callout_task_stack_speak, CALLOUT_STACK_SIZE);
+
+ /* Initialize the receive task */
+ os_task_init(&callout_task_struct_listen, "callout_task_listen",
+ callout_task_stop_listen, NULL, LISTEN_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
+ callout_task_stack_listen, CALLOUT_STACK_SIZE);
+
+ os_eventq_init(&callout_evq);
+
+ /* Initialize the callout function */
+ os_callout_func_init(&callout_func_speak, &callout_evq,
+ my_callout_speak_func, NULL);
+ /* Does not return until OS_restart is called */
+ os_start();
+
+}
+
+TEST_SUITE(os_callout_test_suite)
+{
+ callout_test();
+ callout_test_stop();
+ callout_test_speak();
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/shell/src/shell.c
----------------------------------------------------------------------
diff --git a/libs/shell/src/shell.c b/libs/shell/src/shell.c
index 18f040a..1cb88de 100644
--- a/libs/shell/src/shell.c
+++ b/libs/shell/src/shell.c
@@ -24,6 +24,7 @@
#include "sysinit/sysinit.h"
#include "syscfg/syscfg.h"
#include "console/console.h"
+#include "console/prompt.h"
#include "os/os.h"
#include "os/endian.h"
#include "util/base64.h"
@@ -554,9 +555,7 @@ shell_init(void)
SYSINIT_PANIC_ASSERT(rc == 0);
rc = shell_cmd_register(&g_shell_prompt_cmd);
- if (rc != 0) {
- goto err;
- }
+ SYSINIT_PANIC_ASSERT(rc == 0);
rc = shell_cmd_register(&g_shell_os_tasks_display_cmd);
SYSINIT_PANIC_ASSERT(rc == 0);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/util/src/test/hex_test.c
----------------------------------------------------------------------
diff --git a/libs/util/src/test/hex_test.c b/libs/util/src/test/hex_test.c
deleted file mode 100644
index 8183425..0000000
--- a/libs/util/src/test/hex_test.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * 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 <stdio.h>
-#include <string.h>
-
-#include "testutil/testutil.h"
-#include "util/hex.h"
-
-TEST_CASE(hex2str)
-{
- int i;
- char *ret;
- char cmp_data[8];
-
- struct {
- char *in;
- int inlen;
- char *out;
- int outlen;
- } test_data[] = {
- [0] = {
- .in = "\x01",
- .inlen = 1,
- .out = "01",
- .outlen = 2,
- },
- [1] = {
- .in = "\xaf\xf2",
- .inlen = 2,
- .out = "aff2",
- .outlen = 4,
- }
- };
-
- for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) {
- ret = hex_format(test_data[i].in, test_data[i].inlen,
- cmp_data, sizeof(cmp_data));
- TEST_ASSERT(ret == cmp_data);
- TEST_ASSERT(strlen(cmp_data) == test_data[i].outlen);
- TEST_ASSERT(!strcmp(test_data[i].out, cmp_data));
- }
-
- /*
- * Test not enough space. Must have space for '\0' at the end.
- */
- ret = hex_format("\x01\x02", 2, cmp_data, 1);
- TEST_ASSERT(ret == NULL);
-
- ret = hex_format("\x01\x02", 2, cmp_data, 2);
- TEST_ASSERT(ret == NULL);
-}
-
-TEST_CASE(str2hex)
-{
- int i;
- char cmp_data[8];
- int rc;
-
- struct {
- char *in;
- int inlen;
- char *out;
- int outlen;
- } test_data[] = {
- [0] = {
- .in = "01",
- .inlen = 2,
- .out = "\x01",
- .outlen = 1,
- },
- [1] = {
- .in = "AfF2",
- .inlen = 4,
- .out = "\xaf\xf2",
- .outlen = 2,
- }
- };
-
- for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) {
- rc = hex_parse(test_data[i].in, test_data[i].inlen,
- cmp_data, sizeof(cmp_data));
- TEST_ASSERT(rc == test_data[i].outlen);
- TEST_ASSERT(!memcmp(test_data[i].out, cmp_data, rc));
- }
-
- /*
- * Test invalid input
- */
- rc = hex_parse("HJ", 2, cmp_data, sizeof(cmp_data));
- TEST_ASSERT(rc < 0);
-
- rc = hex_parse("a", 1, cmp_data, sizeof(cmp_data));
- TEST_ASSERT(rc < 0);
-
- rc = hex_parse("0102", 4, cmp_data, 1);
- TEST_ASSERT(rc < 0);
-
- /*
- * This should be valid.
- */
- rc = hex_parse("0102", 4, cmp_data, 2);
- TEST_ASSERT(rc == 2);
-}
-
-TEST_SUITE(hex_fmt_test_suite)
-{
- hex2str();
- str2hex();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/libs/util/test/src/hex_test.c
----------------------------------------------------------------------
diff --git a/libs/util/test/src/hex_test.c b/libs/util/test/src/hex_test.c
new file mode 100644
index 0000000..8183425
--- /dev/null
+++ b/libs/util/test/src/hex_test.c
@@ -0,0 +1,125 @@
+/**
+ * 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 <stdio.h>
+#include <string.h>
+
+#include "testutil/testutil.h"
+#include "util/hex.h"
+
+TEST_CASE(hex2str)
+{
+ int i;
+ char *ret;
+ char cmp_data[8];
+
+ struct {
+ char *in;
+ int inlen;
+ char *out;
+ int outlen;
+ } test_data[] = {
+ [0] = {
+ .in = "\x01",
+ .inlen = 1,
+ .out = "01",
+ .outlen = 2,
+ },
+ [1] = {
+ .in = "\xaf\xf2",
+ .inlen = 2,
+ .out = "aff2",
+ .outlen = 4,
+ }
+ };
+
+ for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) {
+ ret = hex_format(test_data[i].in, test_data[i].inlen,
+ cmp_data, sizeof(cmp_data));
+ TEST_ASSERT(ret == cmp_data);
+ TEST_ASSERT(strlen(cmp_data) == test_data[i].outlen);
+ TEST_ASSERT(!strcmp(test_data[i].out, cmp_data));
+ }
+
+ /*
+ * Test not enough space. Must have space for '\0' at the end.
+ */
+ ret = hex_format("\x01\x02", 2, cmp_data, 1);
+ TEST_ASSERT(ret == NULL);
+
+ ret = hex_format("\x01\x02", 2, cmp_data, 2);
+ TEST_ASSERT(ret == NULL);
+}
+
+TEST_CASE(str2hex)
+{
+ int i;
+ char cmp_data[8];
+ int rc;
+
+ struct {
+ char *in;
+ int inlen;
+ char *out;
+ int outlen;
+ } test_data[] = {
+ [0] = {
+ .in = "01",
+ .inlen = 2,
+ .out = "\x01",
+ .outlen = 1,
+ },
+ [1] = {
+ .in = "AfF2",
+ .inlen = 4,
+ .out = "\xaf\xf2",
+ .outlen = 2,
+ }
+ };
+
+ for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) {
+ rc = hex_parse(test_data[i].in, test_data[i].inlen,
+ cmp_data, sizeof(cmp_data));
+ TEST_ASSERT(rc == test_data[i].outlen);
+ TEST_ASSERT(!memcmp(test_data[i].out, cmp_data, rc));
+ }
+
+ /*
+ * Test invalid input
+ */
+ rc = hex_parse("HJ", 2, cmp_data, sizeof(cmp_data));
+ TEST_ASSERT(rc < 0);
+
+ rc = hex_parse("a", 1, cmp_data, sizeof(cmp_data));
+ TEST_ASSERT(rc < 0);
+
+ rc = hex_parse("0102", 4, cmp_data, 1);
+ TEST_ASSERT(rc < 0);
+
+ /*
+ * This should be valid.
+ */
+ rc = hex_parse("0102", 4, cmp_data, 2);
+ TEST_ASSERT(rc == 2);
+}
+
+TEST_SUITE(hex_fmt_test_suite)
+{
+ hex2str();
+ str2hex();
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/controller/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/pkg.yml b/net/nimble/controller/pkg.yml
index 19846bb..7b5a4eb 100644
--- a/net/nimble/controller/pkg.yml
+++ b/net/nimble/controller/pkg.yml
@@ -173,7 +173,7 @@ pkg.syscfg_defs:
This option allows a controller to send/receive LE pings.
Currently, this feature is not implemented by the controller so
turning it on or off has no effect.
- value: '1'
+ value: 'MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION'
BLE_LL_CFG_FEAT_DATA_LEN_EXT:
description: >
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dffea7d/net/nimble/controller/src/ble_ll_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c
index 64f5e23..34c1f04 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -1019,7 +1019,7 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
{
int valid;
uint8_t pyld_len;
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
uint8_t resolved;
#endif
uint8_t addr_type;
@@ -1030,7 +1030,7 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
/* Check filter policy. */
valid = 0;
-#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
resolved = BLE_MBUF_HDR_RESOLVED(hdr);
#endif
advsm = &g_ble_ll_adv_sm;
@@ -1052,7 +1052,7 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
(advsm->adv_type == BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD)) {
ident_addr = inita;
-#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
if (resolved) {
ident_addr = g_ble_ll_resolv_list[advsm->adv_rpa_index].rl_identity_addr;
addr_type = g_ble_ll_resolv_list[advsm->adv_rpa_index].rl_addr_type;
@@ -1066,7 +1066,7 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
}
if (valid) {
-#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
if (resolved) {
/* Retain the resolvable private address that we received. */
memcpy(advsm->adv_rpa, inita, BLE_DEV_ADDR_LEN);