You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/01/15 21:34:31 UTC
incubator-mynewt-tadpole git commit: Update tadpole with larva
changes.
Repository: incubator-mynewt-tadpole
Updated Branches:
refs/heads/master f42a66b19 -> 86701063b
Update tadpole with larva changes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/commit/86701063
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/tree/86701063
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/diff/86701063
Branch: refs/heads/master
Commit: 86701063b7850f6857871c96af610aeb29fe4b12
Parents: f42a66b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Jan 15 12:33:44 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Jan 15 12:33:44 2016 -0800
----------------------------------------------------------------------
hw/bsp/native/egg.yml | 1 -
hw/bsp/native/include/bsp/bsp.h | 2 +
hw/bsp/native/src/os_bsp.c | 20 +-
hw/hal/egg.yml | 3 +
hw/hal/include/hal/flash_map.h | 88 +++++++
hw/hal/src/flash_map.c | 179 +++++++++++++
hw/hal/src/test/flash_map_test.c | 166 ++++++++++++
hw/mcu/native/include/mcu/mcu_sim.h | 1 +
hw/mcu/native/src/hal_system.c | 10 +-
hw/mcu/native/src/hal_uart.c | 75 ++++++
libs/os/include/os/arch/sim/os/os_arch.h | 1 +
libs/os/include/os/os_mbuf.h | 3 +-
libs/os/src/arch/cortex_m4/os_fault.c | 14 +-
libs/os/src/arch/sim/os_arch_sim.c | 39 +++
libs/os/src/os_info.c | 12 +-
libs/os/src/os_mbuf.c | 5 +-
libs/testutil/include/testutil/testutil.h | 1 +
libs/testutil/src/arch/sim/testutil_arch_sim.c | 3 +
libs/testutil/src/case.c | 4 +
libs/util/egg.yml | 7 -
libs/util/include/util/flash_map.h | 88 -------
libs/util/include/util/log.h | 61 -----
libs/util/include/util/stats.h | 108 --------
libs/util/src/flash_map.c | 179 -------------
libs/util/src/log.c | 274 --------------------
libs/util/src/stats.c | 221 ----------------
libs/util/src/test/flash_map_test.c | 151 -----------
libs/util/src/test/util_test.c | 1 -
libs/util/src/test/util_test_priv.h | 1 -
29 files changed, 604 insertions(+), 1114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/hw/bsp/native/egg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/egg.yml b/hw/bsp/native/egg.yml
index 8e0741c..efd33e5 100644
--- a/hw/bsp/native/egg.yml
+++ b/hw/bsp/native/egg.yml
@@ -1,6 +1,5 @@
egg.name: "hw/bsp/native"
egg.deps:
- hw/mcu/native
- - libs/util
egg.deps.BLE_DEVICE:
- net/nimble/drivers/native
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/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 bebb514..b89f3bd 100644
--- a/hw/bsp/native/include/bsp/bsp.h
+++ b/hw/bsp/native/include/bsp/bsp.h
@@ -27,6 +27,8 @@ extern "C" {
#define UART_CNT 2
#define CONSOLE_UART 0
+int bsp_imgr_current_slot(void);
+
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/hw/bsp/native/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/native/src/os_bsp.c b/hw/bsp/native/src/os_bsp.c
index cc414da..5a73817 100644
--- a/hw/bsp/native/src/os_bsp.c
+++ b/hw/bsp/native/src/os_bsp.c
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <util/flash_map.h>
+#include <hal/flash_map.h>
+#include <mcu/native_bsp.h>
static struct flash_area bsp_flash_areas[] = {
[FLASH_AREA_BOOTLOADER] = {
@@ -45,7 +46,22 @@ static struct flash_area bsp_flash_areas[] = {
};
-void os_bsp_init(void)
+/*
+ * Returns the flash map slot where the currently active image is located.
+ * If executing from internal flash from fixed location, that slot would
+ * be easy to find.
+ * If images are in external flash, and copied to RAM for execution, then
+ * this routine would have to figure out which one of those slots is being
+ * used.
+ */
+int
+bsp_imgr_current_slot(void)
+{
+ return FLASH_AREA_IMAGE_0;
+}
+
+void
+os_bsp_init(void)
{
flash_area_init(bsp_flash_areas,
sizeof(bsp_flash_areas) / sizeof(bsp_flash_areas[0]));
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/hw/hal/egg.yml
----------------------------------------------------------------------
diff --git a/hw/hal/egg.yml b/hw/hal/egg.yml
index 63c5f28..7c4971b 100644
--- a/hw/hal/egg.yml
+++ b/hw/hal/egg.yml
@@ -1,3 +1,6 @@
egg.name: hw/hal
egg.vers: 0.1
egg.deps: libs/os
+egg.deps.NFFS:
+ - fs/nffs
+egg.cflags.NFFS: -DNFFS_PRESENT
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/hw/hal/include/hal/flash_map.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/flash_map.h b/hw/hal/include/hal/flash_map.h
new file mode 100644
index 0000000..3b77c86
--- /dev/null
+++ b/hw/hal/include/hal/flash_map.h
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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_UTIL_FLASH_MAP_
+#define H_UTIL_FLASH_MAP_
+
+/**
+ *
+ * Provides abstraction of flash regions for type of use.
+ * I.e. dude where's my image?
+ *
+ * System will contain a map which contains flash areas. Every
+ * region will contain flash identifier, offset within flash and length.
+ *
+ * 1. This system map could be in a file within filesystem (Initializer
+ * must know/figure out where the filesystem is at).
+ * 2. Map could be at fixed location for project (compiled to code)
+ * 3. Map could be at specific place in flash (put in place at mfg time).
+ *
+ * Note that the map you use must be valid for BSP it's for,
+ * match the linker scripts when platform executes from flash,
+ * and match the target offset specified in download script.
+ */
+#include <inttypes.h>
+
+struct flash_area {
+ uint8_t fa_flash_id;
+ uint8_t _pad[3];
+ uint32_t fa_off;
+ uint32_t fa_size;
+};
+
+/*
+ * Flash area types
+ */
+#define FLASH_AREA_BOOTLOADER 0
+#define FLASH_AREA_IMAGE_0 1
+#define FLASH_AREA_IMAGE_1 2
+#define FLASH_AREA_IMAGE_SCRATCH 3
+#define FLASH_AREA_NFFS 4
+
+/*
+ * Initializes flash map. Memory will be referenced by flash_map code
+ * from this on.
+ */
+void flash_area_init(const struct flash_area *map, int map_entries);
+
+/*
+ * Start using flash area.
+ */
+int flash_area_open(int idx, const struct flash_area **);
+
+void flash_area_close(const struct flash_area *);
+
+/*
+ * Read/write/erase. Offset is relative from beginning of flash area.
+ */
+int flash_area_read(const struct flash_area *, uint32_t off, void *dst,
+ uint32_t len);
+int flash_area_write(const struct flash_area *, uint32_t off, void *src,
+ uint32_t len);
+int flash_area_erase(const struct flash_area *, uint32_t off, uint32_t len);
+
+/*
+ * Given flash map index, return info about sectors within the area.
+ */
+int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret);
+
+/*
+ * Given flash map index, return sector info in NFFS area desc format.
+ */
+struct nffs_area_desc;
+int flash_area_to_nffs_desc(int idx, int *cnt, struct nffs_area_desc *nad);
+
+#endif /* H_UTIL_FLASH_MAP_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/hw/hal/src/flash_map.c
----------------------------------------------------------------------
diff --git a/hw/hal/src/flash_map.c b/hw/hal/src/flash_map.c
new file mode 100644
index 0000000..ce4ccaf
--- /dev/null
+++ b/hw/hal/src/flash_map.c
@@ -0,0 +1,179 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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 <string.h>
+
+#include "hal/hal_flash.h"
+#include "hal/hal_flash_int.h"
+#ifdef NFFS_PRESENT
+#include <nffs/nffs.h>
+#endif
+#include "hal/flash_map.h"
+
+static const struct flash_area *flash_map;
+static int flash_map_entries;
+
+void
+flash_area_init(const struct flash_area *map, int map_entries)
+{
+ flash_map = map;
+ flash_map_entries = map_entries;
+ /*
+ * XXX should we validate this against current flashes?
+ */
+}
+
+int
+flash_area_open(int idx, const struct flash_area **fap)
+{
+ if (!flash_map || idx >= flash_map_entries) {
+ return -1;
+ }
+ *fap = &flash_map[idx];
+ return 0;
+}
+
+void
+flash_area_close(const struct flash_area *fa)
+{
+ /* nothing to do for now */
+}
+
+int
+flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret)
+{
+ int i;
+ const struct hal_flash *hf;
+ const struct flash_area *fa;
+ uint32_t start, size;
+
+ if (!flash_map || idx >= flash_map_entries) {
+ return -1;
+ }
+ *cnt = 0;
+ fa = &flash_map[idx];
+
+ hf = bsp_flash_dev(fa->fa_flash_id);
+ for (i = 0; i < hf->hf_sector_cnt; i++) {
+ hf->hf_itf->hff_sector_info(i, &start, &size);
+ if (start >= fa->fa_off && start < fa->fa_off + fa->fa_size) {
+ if (ret) {
+ ret->fa_flash_id = fa->fa_flash_id;
+ ret->fa_off = start;
+ ret->fa_size = size;
+ ret++;
+ }
+ *cnt = *cnt + 1;
+ }
+ }
+ return 0;
+}
+
+#ifdef NFFS_PRESENT
+/*
+ * Turn flash region into a set of areas for NFFS use.
+ *
+ * Limit the number of regions we return to be less than *cnt.
+ * If sector count within region exceeds that, collect multiple sectors
+ * to a region.
+ */
+int
+flash_area_to_nffs_desc(int idx, int *cnt, struct nffs_area_desc *nad)
+{
+ int i, j;
+ const struct hal_flash *hf;
+ const struct flash_area *fa;
+ int max_cnt, move_on;
+ int first_idx, last_idx;
+ uint32_t start, size;
+ uint32_t min_size;
+
+ if (!flash_map || idx >= flash_map_entries) {
+ return -1;
+ }
+ first_idx = last_idx = -1;
+ max_cnt = *cnt;
+ *cnt = 0;
+
+ fa = &flash_map[idx];
+
+ hf = bsp_flash_dev(fa->fa_flash_id);
+ for (i = 0; i < hf->hf_sector_cnt; i++) {
+ hf->hf_itf->hff_sector_info(i, &start, &size);
+ if (start >= fa->fa_off && start < fa->fa_off + fa->fa_size) {
+ if (first_idx == -1) {
+ first_idx = i;
+ }
+ last_idx = i;
+ *cnt = *cnt + 1;
+ }
+ }
+ if (*cnt > max_cnt) {
+ min_size = fa->fa_size / max_cnt;
+ } else {
+ min_size = 0;
+ }
+ *cnt = 0;
+
+ move_on = 1;
+ for (i = first_idx, j = 0; i < last_idx + 1; i++) {
+ hf->hf_itf->hff_sector_info(i, &start, &size);
+ if (move_on) {
+ nad[j].nad_flash_id = fa->fa_flash_id;
+ nad[j].nad_offset = start;
+ nad[j].nad_length = size;
+ *cnt = *cnt + 1;
+ move_on = 0;
+ } else {
+ nad[j].nad_length += size;
+ }
+ if (nad[j].nad_length >= min_size) {
+ j++;
+ move_on = 1;
+ }
+ }
+ nad[*cnt].nad_length = 0;
+ return 0;
+}
+#endif /* NFFS_PRESENT */
+
+int
+flash_area_read(const struct flash_area *fa, uint32_t off, void *dst,
+ uint32_t len)
+{
+ if (off > fa->fa_size || off + len > fa->fa_size) {
+ return -1;
+ }
+ return hal_flash_read(fa->fa_flash_id, fa->fa_off + off, dst, len);
+}
+
+int
+flash_area_write(const struct flash_area *fa, uint32_t off, void *src,
+ uint32_t len)
+{
+ if (off > fa->fa_size || off + len > fa->fa_size) {
+ return -1;
+ }
+ return hal_flash_write(fa->fa_flash_id, fa->fa_off + off, src, len);
+}
+
+int
+flash_area_erase(const struct flash_area *fa, uint32_t off, uint32_t len)
+{
+ if (off > fa->fa_size || off + len > fa->fa_size) {
+ return -1;
+ }
+ return hal_flash_erase(fa->fa_flash_id, fa->fa_off + off, len);
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/hw/hal/src/test/flash_map_test.c
----------------------------------------------------------------------
diff --git a/hw/hal/src/test/flash_map_test.c b/hw/hal/src/test/flash_map_test.c
new file mode 100644
index 0000000..da104fa
--- /dev/null
+++ b/hw/hal/src/test/flash_map_test.c
@@ -0,0 +1,166 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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 <os/os.h>
+#include <testutil/testutil.h>
+#include "hal/flash_map.h"
+
+#include "hal/hal_flash.h"
+#include "hal/hal_flash_int.h"
+
+/*
+ * Test flash_area_to_sectors()
+ */
+TEST_CASE(flash_map_test_case_1)
+{
+ const struct flash_area *fa;
+ int areas_checked = 0;
+ int i, j, rc;
+ const struct hal_flash *hf;
+ struct flash_area my_secs[32];
+ int my_sec_cnt;
+ uint32_t end;
+
+ os_init();
+
+ for (i = 0; i < 8; i++) {
+ rc = flash_area_open(i, &fa);
+ if (rc) {
+ continue;
+ }
+
+ hf = bsp_flash_dev(fa->fa_flash_id);
+ TEST_ASSERT_FATAL(hf != NULL, "bsp_flash_dev");
+
+ rc = flash_area_to_sectors(i, &my_sec_cnt, my_secs);
+ TEST_ASSERT_FATAL(rc == 0, "flash_area_to_sectors failed");
+
+ end = fa->fa_off;
+ for (j = 0; j < my_sec_cnt; j++) {
+ TEST_ASSERT_FATAL(end == my_secs[j].fa_off, "Non contiguous area");
+ TEST_ASSERT_FATAL(my_secs[j].fa_flash_id == fa->fa_flash_id,
+ "Sectors not in same flash?");
+ end = my_secs[j].fa_off + my_secs[j].fa_size;
+ }
+ if (my_sec_cnt) {
+ areas_checked++;
+ TEST_ASSERT_FATAL(my_secs[my_sec_cnt - 1].fa_off +
+ my_secs[my_sec_cnt - 1].fa_size == fa->fa_off + fa->fa_size,
+ "Last sector not in the end");
+ }
+ }
+ TEST_ASSERT_FATAL(areas_checked != 0, "No flash map areas to check!");
+}
+
+/*
+ * Test flash_erase
+ */
+TEST_CASE(flash_map_test_case_2)
+{
+ const struct flash_area *fa;
+ struct flash_area secs[32];
+ int sec_cnt;
+ int i;
+ int rc;
+ uint32_t off;
+ uint8_t wd[256];
+ uint8_t rd[256];
+
+ os_init();
+
+ rc = flash_area_open(FLASH_AREA_IMAGE_0, &fa);
+ TEST_ASSERT_FATAL(rc == 0, "flash_area_open() fail");
+
+ rc = flash_area_to_sectors(FLASH_AREA_IMAGE_0, &sec_cnt, secs);
+ TEST_ASSERT_FATAL(rc == 0, "flash_area_to_sectors failed");
+
+ /*
+ * First erase the area so it's ready for use.
+ */
+ for (i = 0; i < sec_cnt; i++) {
+ rc = hal_flash_erase_sector(secs[i].fa_flash_id, secs[i].fa_off);
+ TEST_ASSERT_FATAL(rc == 0, "hal_flash_erase_sector() failed");
+ }
+ TEST_ASSERT_FATAL(rc == 0, "read data != write data");
+
+ memset(wd, 0xa5, sizeof(wd));
+
+ /* write stuff to beginning of every sector */
+ off = 0;
+ for (i = 0; i < sec_cnt; i++) {
+ rc = flash_area_write(fa, off, wd, sizeof(wd));
+ TEST_ASSERT_FATAL(rc == 0, "flash_area_write() fail");
+
+ /* read it back via hal_flash_Read() */
+ rc = hal_flash_read(fa->fa_flash_id, fa->fa_off + off, rd, sizeof(rd));
+ TEST_ASSERT_FATAL(rc == 0, "hal_flash_read() fail");
+
+ rc = memcmp(wd, rd, sizeof(wd));
+ TEST_ASSERT_FATAL(rc == 0, "read data != write data");
+
+ /* write stuff to end of area */
+ rc = hal_flash_write(fa->fa_flash_id,
+ fa->fa_off + off + secs[i].fa_size - sizeof(wd), wd, sizeof(wd));
+ TEST_ASSERT_FATAL(rc == 0, "hal_flash_write() fail");
+
+ /* and read it back */
+ memset(rd, 0, sizeof(rd));
+ rc = flash_area_read(fa, off + secs[i].fa_size - sizeof(rd),
+ rd, sizeof(rd));
+ TEST_ASSERT_FATAL(rc == 0, "hal_flash_read() fail");
+
+ rc = memcmp(wd, rd, sizeof(rd));
+ TEST_ASSERT_FATAL(rc == 0, "read data != write data");
+
+ off += secs[i].fa_size;
+ }
+ /* erase it */
+ rc = flash_area_erase(fa, 0, fa->fa_size);
+ TEST_ASSERT_FATAL(rc == 0, "read data != write data");
+
+ /* should read back ff all throughout*/
+ memset(wd, 0xff, sizeof(wd));
+ for (off = 0; off < fa->fa_size; off += sizeof(rd)) {
+ rc = flash_area_read(fa, off, rd, sizeof(rd));
+ TEST_ASSERT_FATAL(rc == 0, "hal_flash_read() fail");
+
+ rc = memcmp(wd, rd, sizeof(rd));
+ TEST_ASSERT_FATAL(rc == 0, "area not erased");
+ }
+}
+
+TEST_SUITE(flash_map_test_suite)
+{
+ flash_map_test_case_1();
+ flash_map_test_case_2();
+}
+
+#ifdef PKG_TEST
+
+int
+main(int argc, char **argv)
+{
+ tu_config.tc_print_results = 1;
+ tu_init();
+
+ flash_map_test_suite();
+
+ return tu_any_failed;
+}
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/hw/mcu/native/include/mcu/mcu_sim.h
----------------------------------------------------------------------
diff --git a/hw/mcu/native/include/mcu/mcu_sim.h b/hw/mcu/native/include/mcu/mcu_sim.h
index 7ab0842..33ea83c 100644
--- a/hw/mcu/native/include/mcu/mcu_sim.h
+++ b/hw/mcu/native/include/mcu/mcu_sim.h
@@ -17,6 +17,7 @@
#define __MCU_SIM_H__
extern char *native_flash_file;
+extern char *native_uart_log_file;
void mcu_sim_parse_args(int argc, char **argv);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/hw/mcu/native/src/hal_system.c
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/hal_system.c b/hw/mcu/native/src/hal_system.c
index eb64b60..191ce8f 100644
--- a/hw/mcu/native/src/hal_system.c
+++ b/hw/mcu/native/src/hal_system.c
@@ -36,9 +36,10 @@ static void
usage(char *progname, int rc)
{
const char msg[] =
- "Usage: %s [-f flash_file]\n"
+ "Usage: %s [-f flash_file] [-u uart_log_file]\n"
" -f flash_file tells where binary flash file is located. It gets\n"
- " created if it doesn't already exist.\n";
+ " created if it doesn't already exist.\n"
+ " -u uart_log_file puts all UART data exchanges into a logfile.\n";
write(2, msg, strlen(msg));
exit(rc);
@@ -50,11 +51,14 @@ mcu_sim_parse_args(int argc, char **argv)
int ch;
char *progname = argv[0];
- while ((ch = getopt(argc, argv, "hf:")) != -1) {
+ while ((ch = getopt(argc, argv, "hf:u:")) != -1) {
switch (ch) {
case 'f':
native_flash_file = optarg;
break;
+ case 'u':
+ native_uart_log_file = optarg;
+ break;
case 'h':
usage(progname, 0);
break;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/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 2f66016..196ac6c 100644
--- a/hw/mcu/native/src/hal_uart.c
+++ b/hw/mcu/native/src/hal_uart.c
@@ -24,6 +24,7 @@
#ifdef MN_OSX
#include <util.h>
#endif
+#include <ctype.h>
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
@@ -49,12 +50,82 @@ struct uart {
* XXXX should try to use O_ASYNC/SIGIO for byte arrival notification,
* so we wouldn't need an OS for pseudo ttys.
*/
+char *native_uart_log_file;
+static int uart_log_fd = -1;
+
static struct uart uarts[UART_CNT];
static int uart_poller_running;
static struct os_task uart_poller_task;
static os_stack_t uart_poller_stack[UART_POLLER_STACK_SZ];
static void
+uart_open_log(void)
+{
+ if (native_uart_log_file && uart_log_fd < 0) {
+ uart_log_fd = open(native_uart_log_file, O_WRONLY | O_CREAT | O_TRUNC,
+ 0666);
+ assert(uart_log_fd >= 0);
+ }
+}
+
+static void
+uart_log_data(struct uart *u, int istx, uint8_t data)
+{
+ static struct {
+ struct uart *uart;
+ int istx;
+ uint32_t time;
+ int chars_in_line;
+ } state = {
+ .uart = NULL,
+ .istx = 0
+ };
+ uint32_t now;
+ char tmpbuf[32];
+ int len;
+
+ if (uart_log_fd < 0) {
+ return;
+ }
+ now = os_time_get();
+ if (state.uart) {
+ if (u != state.uart || now != state.time || istx != state.istx) {
+ /*
+ * End current printout.
+ */
+ if (write(uart_log_fd, "\n", 1) != 1) {
+ assert(0);
+ }
+ state.uart = NULL;
+ } else {
+ if (state.chars_in_line == 8) {
+ if (write(uart_log_fd, "\n\t", 2) != 2) {
+ assert(0);
+ }
+ state.chars_in_line = 0;
+ }
+ len = snprintf(tmpbuf, sizeof(tmpbuf), "%c (%02x) ",
+ isalnum(data) ? data : '?', data);
+ if (write(uart_log_fd, tmpbuf, len) != len) {
+ assert(0);
+ }
+ state.chars_in_line++;
+ }
+ }
+ if (u && state.uart == NULL) {
+ len = snprintf(tmpbuf, sizeof(tmpbuf), "%u:uart%d %s\n\t%c (%02x) ",
+ now, u - uarts, istx ? "tx" : "rx", isalnum(data) ? data : '?', data);
+ if (write(uart_log_fd, tmpbuf, len) != len) {
+ assert(0);
+ }
+ state.chars_in_line = 1;
+ state.uart = u;
+ state.istx = istx;
+ state.time = now;
+ }
+}
+
+static void
uart_poller(void *arg)
{
int i;
@@ -86,6 +157,7 @@ uart_poller(void *arg)
OS_EXIT_CRITICAL(sr);
break;
}
+ uart_log_data(uart, 1, ch);
OS_EXIT_CRITICAL(sr);
ch = rc;
rc = write(uart->u_fd, &ch, 1);
@@ -110,6 +182,7 @@ uart_poller(void *arg)
}
if (uart->u_rx_char >= 0) {
OS_ENTER_CRITICAL(sr);
+ uart_log_data(uart, 0, uart->u_rx_char);
rc = uart->u_rx_func(uart->u_func_arg, uart->u_rx_char);
/* Delivered */
if (rc >= 0) {
@@ -119,6 +192,7 @@ uart_poller(void *arg)
}
}
}
+ uart_log_data(NULL, 0, 0);
os_time_delay(10);
}
}
@@ -274,6 +348,7 @@ hal_uart_config(int port, int32_t baudrate, uint8_t databits, uint8_t stopbits,
}
set_nonblock(uart->u_fd);
+ uart_open_log();
uart->u_open = 1;
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/os/include/os/arch/sim/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/sim/os/os_arch.h b/libs/os/include/os/arch/sim/os/os_arch.h
index 3466727..3b0f212 100644
--- a/libs/os/include/os/arch/sim/os/os_arch.h
+++ b/libs/os/include/os/arch/sim/os/os_arch.h
@@ -58,6 +58,7 @@ void os_arch_ctx_sw_isr(struct os_task *);
os_sr_t os_arch_save_sr(void);
void os_arch_restore_sr(int);
os_error_t os_arch_os_init(void);
+void os_arch_os_stop(void);
os_error_t os_arch_os_start(void);
void os_bsp_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/os/include/os/os_mbuf.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_mbuf.h b/libs/os/include/os/os_mbuf.h
index 9eaee38..fd24c61 100644
--- a/libs/os/include/os/os_mbuf.h
+++ b/libs/os/include/os/os_mbuf.h
@@ -188,7 +188,8 @@ _os_mbuf_trailingspace(struct os_mbuf *om)
omp = om->om_omp;
- return (&om->om_databuf[0] + omp->omp_databuf_len) - om->om_data;
+ return (&om->om_databuf[0] + omp->omp_databuf_len) -
+ (om->om_data + om->om_len);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/os/src/arch/cortex_m4/os_fault.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/cortex_m4/os_fault.c b/libs/os/src/arch/cortex_m4/os_fault.c
index 2c7c6fb..63404ad 100644
--- a/libs/os/src/arch/cortex_m4/os_fault.c
+++ b/libs/os/src/arch/cortex_m4/os_fault.c
@@ -68,18 +68,18 @@ void
os_default_irq(struct trap_frame *tf)
{
console_blocking_mode();
- console_printf("Unhandled interrupt (%d), exception sp 0x%08x\n",
+ console_printf("Unhandled interrupt (%ld), exception sp 0x%08lx\n",
SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk, (uint32_t)tf->ef);
- console_printf(" r0:0x%08x r1:0x%08x r2:0x%08x r3:0x%08x\n",
+ console_printf(" r0:0x%08lx r1:0x%08lx r2:0x%08lx r3:0x%08lx\n",
tf->ef->r0, tf->ef->r1, tf->ef->r2, tf->ef->r3);
- console_printf(" r4:0x%08x r5:0x%08x r6:0x%08x r7:0x%08x\n",
+ console_printf(" r4:0x%08lx r5:0x%08lx r6:0x%08lx r7:0x%08lx\n",
tf->r4, tf->r5, tf->r6, tf->r7);
- console_printf(" r8:0x%08x r9:0x%08x r10:0x%08x r11:0x%08x\n",
+ console_printf(" r8:0x%08lx r9:0x%08lx r10:0x%08lx r11:0x%08lx\n",
tf->r8, tf->r9, tf->r10, tf->r11);
- console_printf("r12:0x%08x lr:0x%08x pc:0x%08x psr:0x%08x\n",
+ console_printf("r12:0x%08lx lr:0x%08lx pc:0x%08lx psr:0x%08lx\n",
tf->ef->r12, tf->ef->lr, tf->ef->pc, tf->ef->psr);
- console_printf("ICSR:0x%08x HFSR:0x%08x CFSR:0x%08x\n",
+ console_printf("ICSR:0x%08lx HFSR:0x%08lx CFSR:0x%08lx\n",
SCB->ICSR, SCB->HFSR, SCB->CFSR);
- console_printf("BFAR:0x%08x MMFAR:0x%08x\n", SCB->BFAR, SCB->MMFAR);
+ console_printf("BFAR:0x%08lx MMFAR:0x%08lx\n", SCB->BFAR, SCB->MMFAR);
system_reset();
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/os/src/arch/sim/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_sim.c b/libs/os/src/arch/sim/os_arch_sim.c
index 0c83487..25f3833 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -245,6 +245,17 @@ initialize_signals(void)
sigaction(SIGVTALRM, &sa, NULL);
}
+static void
+cancel_signals(void)
+{
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof sa);
+ sa.sa_handler = SIG_DFL;
+
+ sigaction(SIGALRM, &sa, NULL);
+ sigaction(SIGVTALRM, &sa, NULL);
+}
static void
timer_handler(int sig)
@@ -305,6 +316,24 @@ start_timer(void)
}
}
+static void
+stop_timer(void)
+{
+ struct itimerval it;
+ int rc;
+
+ memset(&it, 0, sizeof(it));
+
+ rc = setitimer(ITIMER_VIRTUAL, &it, NULL);
+ if (rc != 0) {
+ const char msg[] = "Cannot stop itimer";
+ write(2, msg, sizeof(msg));
+ _exit(1);
+ }
+
+ cancel_signals();
+}
+
os_error_t
os_arch_os_init(void)
{
@@ -340,3 +369,13 @@ os_arch_os_start(void)
return 0;
}
+/**
+ * Stops the tick timer and clears the "started" flag. This function is only
+ * implemented for sim.
+ */
+void
+os_arch_os_stop(void)
+{
+ stop_timer();
+ g_os_started = 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/os/src/os_info.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_info.c b/libs/os/src/os_info.c
index 2387cdd..7697824 100644
--- a/libs/os/src/os_info.c
+++ b/libs/os/src/os_info.c
@@ -94,12 +94,12 @@ shell_os_tasks_display(int argc, char **argv)
}
}
- console_printf(" %s (prio: %u, nw: %u, flags: 0x%x, "
- "ssize: %u, cswcnt: %lu, tot_run_time: %ums)\n",
- info[i].oti_name,
- info[i].oti_prio, info[i].oti_next_wakeup, info[i].oti_flags,
- info[i].oti_stack_size,
- info[i].oti_csw_cnt, info[i].oti_run_time);
+ console_printf(" %s (prio: %u, nw: %lu, flags: 0x%x, "
+ "ssize: %u, cswcnt: %lu, tot_run_time: %lums)\n",
+ info[i].oti_name, info[i].oti_prio,
+ (unsigned long)info[i].oti_next_wakeup, info[i].oti_flags,
+ info[i].oti_stack_size, (unsigned long)info[i].oti_csw_cnt,
+ (unsigned long)info[i].oti_run_time);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/os/src/os_mbuf.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_mbuf.c b/libs/os/src/os_mbuf.c
index f14466a..9453960 100644
--- a/libs/os/src/os_mbuf.c
+++ b/libs/os/src/os_mbuf.c
@@ -348,7 +348,6 @@ _os_mbuf_copypkthdr(struct os_mbuf *new_buf, struct os_mbuf *old_buf)
/**
* Append data onto a mbuf
*
- * @param omp The mbuf pool this mbuf was allocated out of
* @param om The mbuf to append the data onto
* @param data The data to append onto the mbuf
* @param len The length of the data to append
@@ -973,9 +972,9 @@ os_mbuf_pullup(struct os_mbuf *om, uint16_t len)
om2->om_len += count;
om->om_len -= count;
space -= count;
- if (om->om_len)
+ if (om->om_len) {
om->om_data += count;
- else {
+ } else {
next = SLIST_NEXT(om, om_next);
os_mbuf_free(om);
om = next;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/testutil/include/testutil/testutil.h
----------------------------------------------------------------------
diff --git a/libs/testutil/include/testutil/testutil.h b/libs/testutil/include/testutil/testutil.h
index 0aaade1..7bf1fef 100644
--- a/libs/testutil/include/testutil/testutil.h
+++ b/libs/testutil/include/testutil/testutil.h
@@ -31,6 +31,7 @@ typedef void tu_restart_fn_t(void *arg);
struct tu_config {
int tc_print_results;
+ int tc_system_assert;
tu_case_init_fn_t *tc_case_init_cb;
void *tc_case_init_arg;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/testutil/src/arch/sim/testutil_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/arch/sim/testutil_arch_sim.c b/libs/testutil/src/arch/sim/testutil_arch_sim.c
index 1b5ff49..3ab49bf 100644
--- a/libs/testutil/src/arch/sim/testutil_arch_sim.c
+++ b/libs/testutil/src/arch/sim/testutil_arch_sim.c
@@ -14,11 +14,14 @@
* limitations under the License.
*/
+#include "os/os.h"
+#include "os/os_arch.h"
#include "os/os_test.h"
#include "testutil_priv.h"
void
tu_arch_restart(void)
{
+ os_arch_os_stop();
tu_case_abort();
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/testutil/src/case.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/case.c b/libs/testutil/src/case.c
index 7b55629..e003f0b 100644
--- a/libs/testutil/src/case.c
+++ b/libs/testutil/src/case.c
@@ -177,6 +177,10 @@ tu_case_fail_assert(int fatal, const char *file, int line,
va_list ap;
int rc;
+ if (tu_config.tc_system_assert) {
+ assert(0);
+ }
+
tu_case_buf_len = 0;
tu_case_append_file_info(file, line);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/egg.yml
----------------------------------------------------------------------
diff --git a/libs/util/egg.yml b/libs/util/egg.yml
index 3faef1b..6018c58 100644
--- a/libs/util/egg.yml
+++ b/libs/util/egg.yml
@@ -4,10 +4,3 @@ egg.deps:
- hw/hal
- libs/os
- libs/testutil
-egg.deps.SHELL:
- - libs/console/full
- - libs/shell
-egg.cflags.SHELL: -DSHELL_PRESENT
-egg.deps.NFFS:
- - libs/nffs
-egg.cflags.NFFS: -DNFFS_PRESENT
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/include/util/flash_map.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/flash_map.h b/libs/util/include/util/flash_map.h
deleted file mode 100644
index 3b77c86..0000000
--- a/libs/util/include/util/flash_map.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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_UTIL_FLASH_MAP_
-#define H_UTIL_FLASH_MAP_
-
-/**
- *
- * Provides abstraction of flash regions for type of use.
- * I.e. dude where's my image?
- *
- * System will contain a map which contains flash areas. Every
- * region will contain flash identifier, offset within flash and length.
- *
- * 1. This system map could be in a file within filesystem (Initializer
- * must know/figure out where the filesystem is at).
- * 2. Map could be at fixed location for project (compiled to code)
- * 3. Map could be at specific place in flash (put in place at mfg time).
- *
- * Note that the map you use must be valid for BSP it's for,
- * match the linker scripts when platform executes from flash,
- * and match the target offset specified in download script.
- */
-#include <inttypes.h>
-
-struct flash_area {
- uint8_t fa_flash_id;
- uint8_t _pad[3];
- uint32_t fa_off;
- uint32_t fa_size;
-};
-
-/*
- * Flash area types
- */
-#define FLASH_AREA_BOOTLOADER 0
-#define FLASH_AREA_IMAGE_0 1
-#define FLASH_AREA_IMAGE_1 2
-#define FLASH_AREA_IMAGE_SCRATCH 3
-#define FLASH_AREA_NFFS 4
-
-/*
- * Initializes flash map. Memory will be referenced by flash_map code
- * from this on.
- */
-void flash_area_init(const struct flash_area *map, int map_entries);
-
-/*
- * Start using flash area.
- */
-int flash_area_open(int idx, const struct flash_area **);
-
-void flash_area_close(const struct flash_area *);
-
-/*
- * Read/write/erase. Offset is relative from beginning of flash area.
- */
-int flash_area_read(const struct flash_area *, uint32_t off, void *dst,
- uint32_t len);
-int flash_area_write(const struct flash_area *, uint32_t off, void *src,
- uint32_t len);
-int flash_area_erase(const struct flash_area *, uint32_t off, uint32_t len);
-
-/*
- * Given flash map index, return info about sectors within the area.
- */
-int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret);
-
-/*
- * Given flash map index, return sector info in NFFS area desc format.
- */
-struct nffs_area_desc;
-int flash_area_to_nffs_desc(int idx, int *cnt, struct nffs_area_desc *nad);
-
-#endif /* H_UTIL_FLASH_MAP_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/include/util/log.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/log.h b/libs/util/include/util/log.h
deleted file mode 100644
index b1b64d7..0000000
--- a/libs/util/include/util/log.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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 __UTIL_LOG_H__
-#define __UTIL_LOG_H__
-
-#include "util/cbmem.h"
-#include <os/queue.h>
-
-struct util_log;
-
-typedef int (*util_log_walk_func_t)(struct util_log *, void *arg, void *offset,
- uint16_t len);
-
-typedef int (*ulh_read_func_t)(struct util_log *, void *dptr, void *buf,
- uint16_t offset, uint16_t len);
-typedef int (*ulh_append_func_t)(struct util_log *, void *buf, int len);
-typedef int (*ulh_walk_func_t)(struct util_log *,
- util_log_walk_func_t walk_func, void *arg);
-typedef int (*ulh_flush_func_t)(struct util_log *);
-
-struct ul_handler {
- ulh_read_func_t ulh_read;
- ulh_append_func_t ulh_append;
- ulh_walk_func_t ulh_walk;
- ulh_flush_func_t ulh_flush;
- void *ulh_arg;
-};
-
-struct ul_entry_hdr {
- int64_t ue_ts;
-};
-
-struct util_log {
- char *ul_name;
- struct ul_handler *ul_ulh;
- STAILQ_ENTRY(util_log) ul_next;
-};
-
-int util_log_cbmem_handler_init(struct ul_handler *, struct cbmem *);
-int util_log_register(char *name, struct util_log *log, struct ul_handler *);
-int util_log_append(struct util_log *log, uint8_t *data, uint16_t len);
-int util_log_read(struct util_log *log, void *dptr, void *buf, uint16_t off,
- uint16_t len);
-int util_log_walk(struct util_log *log, util_log_walk_func_t walk_func,
- void *arg);
-int util_log_flush(struct util_log *log);
-
-#endif /* __UTIL_LOG_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/include/util/stats.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/stats.h b/libs/util/include/util/stats.h
deleted file mode 100644
index f35e0c0..0000000
--- a/libs/util/include/util/stats.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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 __UTIL_STATS_H__
-#define __UTIL_STATS_H__
-
-#include <os/queue.h>
-#include <stdint.h>
-
-struct stats_name_map {
- void *snm_off;
- char *snm_name;
-};
-
-struct stats_hdr {
- char *s_name;
- uint8_t s_size;
- uint8_t s_cnt;
- uint16_t s_pad1;
-#ifdef STATS_NAME_ENABLE
- struct stats_name_map *s_map;
- int s_map_cnt;
-#endif
- STAILQ_ENTRY(stats_hdr) s_next;
-};
-
-
-#define STATS_SECT_START(__name) \
-struct stats_ ## __name { \
- struct stats_hdr s_hdr;
-
-
-#define STATS_SECT_END(__name) \
-} g_stats_ ## __name;
-
-#define STATS_SECT_NAME(__name) \
- g_stats_ ## __name
-
-#define STATS_HDR(__name) ((struct stats_hdr *) &STATS_SECT_NAME(__name))
-
-#define STATS_SECT_VAR(__var) \
- s##__var
-
-#define STATS_SIZE_16 (sizeof(uint16_t))
-#define STATS_SIZE_32 (sizeof(uint32_t))
-#define STATS_SIZE_64 (sizeof(uint64_t))
-
-#define STATS_SECT_ENTRY(__var) uint32_t STATS_SECT_VAR(__var);
-#define STATS_SECT_ENTRY16(__var) uint16_t STATS_SECT_VAR(__var);
-#define STATS_SECT_ENTRY32(__var) uint32_t STATS_SECT_VAR(__var);
-#define STATS_SECT_ENTRY64(__var) uint64_t STATS_SECT_VAR(__var);
-
-#define STATS_SIZE_INIT_PARMS(__name, __size) \
- __size, \
- ((sizeof(STATS_SECT_NAME(__name)) - sizeof(struct stats_hdr)) / __size)
-
-
-#define STATS_INC(__name, __var) \
- (STATS_SECT_NAME(__name).STATS_SECT_VAR(__var)++)
-
-#define STATS_INCN(__name, __var, __n) \
- (STATS_SECT_NAME(__name).STATS_SECT_VAR(__var) += (__n))
-
-#ifdef STATS_NAME_ENABLE
-
-#define STATS_NAME_MAP_NAME(__name) g_stats_map_ ## __name
-
-#define STATS_NAME_START(__name) \
-struct stats_name_map STATS_NAME_MAP_NAME(__name)[] = {
-
-#define STATS_NAME(__name, __entry) \
- { &STATS_SECT_NAME(__name).STATS_SECT_VAR(__entry), #__entry },
-
-#define STATS_NAME_END(__name) \
-};
-
-#define STATS_NAME_INIT_PARMS(__name) \
- &(STATS_NAME_MAP_NAME(__name)[0]), \
- (sizeof(STATS_NAME_MAP_NAME(__name)) / sizeof(struct stats_name_map))
-
-#else /* STATS_NAME_ENABLE */
-
-#define STATS_NAME_START(__name)
-#define STATS_NAME(__name, __entry)
-#define STATS_NAME_END(__name)
-#define STATS_NAME_INIT_PARMS(__name) NULL, 0
-
-#endif /* STATS_NAME_ENABLE */
-
-int stats_module_init(void);
-int stats_init(struct stats_hdr *shdr, uint8_t size, uint8_t cnt,
- struct stats_name_map *map, uint8_t map_cnt);
-int stats_register(char *name, struct stats_hdr *shdr);
-struct stats_hdr *stats_find(char *name);
-
-#endif /* __UTIL_STATS_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/src/flash_map.c
----------------------------------------------------------------------
diff --git a/libs/util/src/flash_map.c b/libs/util/src/flash_map.c
deleted file mode 100644
index 81d0f22..0000000
--- a/libs/util/src/flash_map.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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 <string.h>
-
-#include <hal/hal_flash.h>
-#include <hal/hal_flash_int.h>
-#ifdef NFFS_PRESENT
-#include <nffs/nffs.h>
-#endif
-#include "util/flash_map.h"
-
-static const struct flash_area *flash_map;
-static int flash_map_entries;
-
-void
-flash_area_init(const struct flash_area *map, int map_entries)
-{
- flash_map = map;
- flash_map_entries = map_entries;
- /*
- * XXX should we validate this against current flashes?
- */
-}
-
-int
-flash_area_open(int idx, const struct flash_area **fap)
-{
- if (!flash_map || idx >= flash_map_entries) {
- return -1;
- }
- *fap = &flash_map[idx];
- return 0;
-}
-
-void
-flash_area_close(const struct flash_area *fa)
-{
- /* nothing to do for now */
-}
-
-int
-flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret)
-{
- int i;
- const struct hal_flash *hf;
- const struct flash_area *fa;
- uint32_t start, size;
-
- if (!flash_map || idx >= flash_map_entries) {
- return -1;
- }
- *cnt = 0;
- fa = &flash_map[idx];
-
- hf = bsp_flash_dev(fa->fa_flash_id);
- for (i = 0; i < hf->hf_sector_cnt; i++) {
- hf->hf_itf->hff_sector_info(i, &start, &size);
- if (start >= fa->fa_off && start < fa->fa_off + fa->fa_size) {
- if (ret) {
- ret->fa_flash_id = fa->fa_flash_id;
- ret->fa_off = start;
- ret->fa_size = size;
- ret++;
- }
- *cnt = *cnt + 1;
- }
- }
- return 0;
-}
-
-#ifdef NFFS_PRESENT
-/*
- * Turn flash region into a set of areas for NFFS use.
- *
- * Limit the number of regions we return to be less than *cnt.
- * If sector count within region exceeds that, collect multiple sectors
- * to a region.
- */
-int
-flash_area_to_nffs_desc(int idx, int *cnt, struct nffs_area_desc *nad)
-{
- int i, j;
- const struct hal_flash *hf;
- const struct flash_area *fa;
- int max_cnt, move_on;
- int first_idx, last_idx;
- uint32_t start, size;
- uint32_t min_size;
-
- if (!flash_map || idx >= flash_map_entries) {
- return -1;
- }
- first_idx = last_idx = -1;
- max_cnt = *cnt;
- *cnt = 0;
-
- fa = &flash_map[idx];
-
- hf = bsp_flash_dev(fa->fa_flash_id);
- for (i = 0; i < hf->hf_sector_cnt; i++) {
- hf->hf_itf->hff_sector_info(i, &start, &size);
- if (start >= fa->fa_off && start < fa->fa_off + fa->fa_size) {
- if (first_idx == -1) {
- first_idx = i;
- }
- last_idx = i;
- *cnt = *cnt + 1;
- }
- }
- if (*cnt > max_cnt) {
- min_size = fa->fa_size / max_cnt;
- } else {
- min_size = 0;
- }
- *cnt = 0;
-
- move_on = 1;
- for (i = first_idx, j = 0; i < last_idx + 1; i++) {
- hf->hf_itf->hff_sector_info(i, &start, &size);
- if (move_on) {
- nad[j].nad_flash_id = fa->fa_flash_id;
- nad[j].nad_offset = start;
- nad[j].nad_length = size;
- *cnt = *cnt + 1;
- move_on = 0;
- } else {
- nad[j].nad_length += size;
- }
- if (nad[j].nad_length >= min_size) {
- j++;
- move_on = 1;
- }
- }
- nad[*cnt].nad_length = 0;
- return 0;
-}
-#endif /* NFFS_PRESENT */
-
-int
-flash_area_read(const struct flash_area *fa, uint32_t off, void *dst,
- uint32_t len)
-{
- if (off > fa->fa_size || off + len > fa->fa_size) {
- return -1;
- }
- return hal_flash_read(fa->fa_flash_id, fa->fa_off + off, dst, len);
-}
-
-int
-flash_area_write(const struct flash_area *fa, uint32_t off, void *src,
- uint32_t len)
-{
- if (off > fa->fa_size || off + len > fa->fa_size) {
- return -1;
- }
- return hal_flash_write(fa->fa_flash_id, fa->fa_off + off, src, len);
-}
-
-int
-flash_area_erase(const struct flash_area *fa, uint32_t off, uint32_t len)
-{
- if (off > fa->fa_size || off + len > fa->fa_size) {
- return -1;
- }
- return hal_flash_erase(fa->fa_flash_id, fa->fa_off + off, len);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/src/log.c
----------------------------------------------------------------------
diff --git a/libs/util/src/log.c b/libs/util/src/log.c
deleted file mode 100644
index 5d16364..0000000
--- a/libs/util/src/log.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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 <os/os.h>
-
-#include <string.h>
-
-#include "util/log.h"
-#include "util/cbmem.h"
-
-#include <stdio.h>
-
-#ifdef SHELL_PRESENT
-
-#include <shell/shell.h>
-#include <console/console.h>
-
-struct shell_cmd shell_log_cmd;
-uint8_t shell_registered;
-
-#endif
-
-static STAILQ_HEAD(, util_log) g_util_log_list =
- STAILQ_HEAD_INITIALIZER(g_util_log_list);
-
-
-#ifdef SHELL_PRESENT
-
-static int
-shell_log_dump_entry(struct util_log *log, void *arg, void *dptr, uint16_t len)
-{
- struct ul_entry_hdr ueh;
- char data[128];
- int dlen;
- int rc;
-
- rc = util_log_read(log, dptr, &ueh, 0, sizeof(ueh));
- if (rc != sizeof(ueh)) {
- goto err;
- }
-
- dlen = min(len-sizeof(ueh), 128);
-
- rc = util_log_read(log, dptr, data, sizeof(ueh), dlen);
- if (rc < 0) {
- goto err;
- }
- data[rc] = 0;
-
- /* XXX: This is evil. newlib printf does not like 64-bit
- * values, and this causes memory to be overwritten. Cast to a
- * unsigned 32-bit value for now.
- */
- console_printf("[%d] %s\n", (uint32_t) ueh.ue_ts, data);
-
- return (0);
-err:
- return (rc);
-}
-
-static int
-shell_log_dump_all(int argc, char **argv)
-{
- struct util_log *log;
- int rc;
-
- STAILQ_FOREACH(log, &g_util_log_list, ul_next) {
- rc = util_log_walk(log, shell_log_dump_entry, NULL);
- if (rc != 0) {
- goto err;
- }
- }
-
- return (0);
-err:
- return (rc);
-}
-
-#endif
-
-static int
-ulh_cbmem_append(struct util_log *log, void *buf, int len)
-{
- struct cbmem *cbmem;
- int rc;
-
- cbmem = (struct cbmem *) log->ul_ulh->ulh_arg;
-
- rc = cbmem_append(cbmem, buf, len);
- if (rc != 0) {
- goto err;
- }
-
- return (0);
-err:
- return (rc);
-}
-
-static int
-ulh_cbmem_read(struct util_log *log, void *dptr, void *buf, uint16_t offset,
- uint16_t len)
-{
- struct cbmem *cbmem;
- struct cbmem_entry_hdr *hdr;
- int rc;
-
- cbmem = (struct cbmem *) log->ul_ulh->ulh_arg;
- hdr = (struct cbmem_entry_hdr *) dptr;
-
- rc = cbmem_read(cbmem, hdr, buf, offset, len);
-
- return (rc);
-}
-
-static int
-ulh_cbmem_walk(struct util_log *log, util_log_walk_func_t walk_func, void *arg)
-{
- struct cbmem *cbmem;
- struct cbmem_entry_hdr *hdr;
- struct cbmem_iter iter;
- int rc;
-
- cbmem = (struct cbmem *) log->ul_ulh->ulh_arg;
-
- rc = cbmem_lock_acquire(cbmem);
- if (rc != 0) {
- goto err;
- }
-
- cbmem_iter_start(cbmem, &iter);
- while (1) {
- hdr = cbmem_iter_next(cbmem, &iter);
- if (!hdr) {
- break;
- }
-
- rc = walk_func(log, arg, (void *) hdr, hdr->ceh_len);
- if (rc == 1) {
- break;
- }
- }
-
- rc = cbmem_lock_release(cbmem);
- if (rc != 0) {
- goto err;
- }
-
- return (0);
-err:
- return (rc);
-}
-
-static int
-ulh_cbmem_flush(struct util_log *log)
-{
- struct cbmem *cbmem;
- int rc;
-
- cbmem = (struct cbmem *) log->ul_ulh->ulh_arg;
-
- rc = cbmem_flush(cbmem);
- if (rc != 0) {
- goto err;
- }
-
- return (0);
-err:
- return (rc);
-}
-
-int
-util_log_cbmem_handler_init(struct ul_handler *handler, struct cbmem *cbmem)
-{
- handler->ulh_read = ulh_cbmem_read;
- handler->ulh_append = ulh_cbmem_append;
- handler->ulh_walk = ulh_cbmem_walk;
- handler->ulh_flush = ulh_cbmem_flush;
- handler->ulh_arg = (void *) cbmem;
-
- return (0);
-}
-
-int
-util_log_register(char *name, struct util_log *log, struct ul_handler *ulh)
-{
-#ifdef SHELL_PRESENT
- if (!shell_registered) {
- /* register the shell */
-
- shell_registered = 1;
- shell_cmd_register(&shell_log_cmd, "log", shell_log_dump_all);
- }
-#endif
-
- log->ul_name = name;
- log->ul_ulh = ulh;
-
- STAILQ_INSERT_TAIL(&g_util_log_list, log, ul_next);
-
- return (0);
-}
-
-int
-util_log_append(struct util_log *log, uint8_t *data, uint16_t len)
-{
- struct ul_entry_hdr *ue;
- int rc;
-
- ue = (struct ul_entry_hdr *) data;
- ue->ue_ts = (int64_t) os_time_get();
-
- rc = log->ul_ulh->ulh_append(log, data, len + sizeof(*ue));
- if (rc != 0) {
- goto err;
- }
-
- return (0);
-err:
- return (rc);
-}
-
-int
-util_log_walk(struct util_log *log, util_log_walk_func_t walk_func, void *arg)
-{
- int rc;
-
- rc = log->ul_ulh->ulh_walk(log, walk_func, arg);
- if (rc != 0) {
- goto err;
- }
-
- return (0);
-err:
- return (rc);
-}
-
-int
-util_log_read(struct util_log *log, void *dptr, void *buf, uint16_t off,
- uint16_t len)
-{
- int rc;
-
- rc = log->ul_ulh->ulh_read(log, dptr, buf, off, len);
-
- return (rc);
-}
-
-int
-util_log_flush(struct util_log *log)
-{
- int rc;
-
- rc = log->ul_ulh->ulh_flush(log);
- if (rc != 0) {
- goto err;
- }
-
- return (0);
-err:
- return (rc);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/src/stats.c
----------------------------------------------------------------------
diff --git a/libs/util/src/stats.c b/libs/util/src/stats.c
deleted file mode 100644
index e61d785..0000000
--- a/libs/util/src/stats.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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 <os/os.h>
-
-#include <string.h>
-
-#include "util/stats.h"
-
-#ifdef SHELL_PRESENT
-#include "shell/shell.h"
-#include "console/console.h"
-#endif
-
-#include <stdio.h>
-
-STATS_SECT_START(stats)
- STATS_SECT_ENTRY(num_registered)
-STATS_SECT_END(stats)
-
-STATS_NAME_START(stats)
- STATS_NAME(stats, num_registered)
-STATS_NAME_END(stats)
-
-STAILQ_HEAD(, stats_hdr) g_stats_registry =
- STAILQ_HEAD_INITIALIZER(g_stats_registry);
-
-#ifdef SHELL_PRESENT
-uint8_t stats_shell_registered;
-struct shell_cmd shell_stats_cmd;
-#endif
-
-
-#ifdef SHELL_PRESENT
-
-static void
-shell_stats_display_entry(struct stats_hdr *hdr, uint8_t *ptr)
-{
- char *name;
- char buf[12];
- int ent_n;
- int len;
-#ifdef STATS_NAME_ENABLE
- int i;
-#endif
-
- name = NULL;
-
-#ifdef STATS_NAME_ENABLE
- for (i = 0; i < hdr->s_map_cnt; i++) {
- if (hdr->s_map[i].snm_off == ptr) {
- name = hdr->s_map[i].snm_name;
- break;
- }
- }
-#endif
-
- if (name == NULL) {
- ent_n = (ptr - ((uint8_t *) hdr + sizeof(*hdr))) / hdr->s_size;
-
- len = snprintf(buf, sizeof(buf), "s%d", ent_n);
- buf[len] = 0;
- name = buf;
- }
-
- switch (hdr->s_size) {
- case sizeof(uint16_t):
- console_printf("%s: %u\n", name, *(uint16_t *) ptr);
- break;
- case sizeof(uint32_t):
- console_printf("%s: %u\n", name, *(uint32_t *) ptr);
- break;
- case sizeof(uint64_t):
- console_printf("%s: %llu\n", name, *(uint64_t *) ptr);
- break;
- default:
- console_printf("Unknown stat size for %s %u\n", name,
- hdr->s_size);
- break;
- }
-}
-
-static int
-shell_stats_display(int argc, char **argv)
-{
- struct stats_hdr *hdr;
- char *name;
- uint8_t *cur;
- uint8_t *end;
-
- name = argv[1];
- if (name == NULL || !strcmp(name, "")) {
- console_printf("Must specify a statistic name to dump, "
- "possible names are:\n");
- STAILQ_FOREACH(hdr, &g_stats_registry, s_next) {
- console_printf("\t%s\n", hdr->s_name);
- }
- goto done;
- }
-
-
- hdr = stats_find(name);
- if (!hdr) {
- console_printf("Could not find statistic %s\n", name);
- goto done;
- }
-
- cur = (uint8_t *) hdr + sizeof(*hdr);
- end = (uint8_t *) hdr + sizeof(*hdr) + (hdr->s_size * hdr->s_cnt);
- while (cur < end) {
- shell_stats_display_entry(hdr, (uint8_t *) cur);
- cur += hdr->s_size;
- }
-
-done:
- return (0);
-}
-
-#endif
-
-
-int
-stats_module_init(void)
-{
- int rc;
-#ifdef SHELL_PRESENT
- if (!stats_shell_registered) {
- stats_shell_registered = 1;
- shell_cmd_register(&shell_stats_cmd, "stat", shell_stats_display);
- }
-#endif
-
-
- rc = stats_init(STATS_HDR(stats), STATS_SIZE_INIT_PARMS(stats, STATS_SIZE_32),
- STATS_NAME_INIT_PARMS(stats));
- if (rc != 0) {
- goto err;
- }
-
- rc = stats_register("stat", STATS_HDR(stats));
- if (rc != 0) {
- goto err;
- }
-
- return (0);
-err:
- return (rc);
-}
-
-
-int
-stats_init(struct stats_hdr *shdr, uint8_t size, uint8_t cnt,
- struct stats_name_map *map, uint8_t map_cnt)
-{
- memset((uint8_t *) shdr, 0, sizeof(*shdr) + (size * cnt));
-
- shdr->s_size = size;
- shdr->s_cnt = cnt;
-#ifdef STATS_NAME_ENABLE
- shdr->s_map = map;
- shdr->s_map_cnt = map_cnt;
-#endif
-
- return (0);
-}
-
-int
-stats_register(char *name, struct stats_hdr *shdr)
-{
- struct stats_hdr *cur;
- int rc;
-
- /* Don't allow duplicate entries, return an error if this stat
- * is already registered.
- */
- STAILQ_FOREACH(cur, &g_stats_registry, s_next) {
- if (!strcmp(cur->s_name, name)) {
- rc = -1;
- goto err;
- }
- }
-
- shdr->s_name = name;
-
- STAILQ_INSERT_TAIL(&g_stats_registry, shdr, s_next);
-
- STATS_INC(stats, num_registered);
-
- return (0);
-err:
- return (rc);
-}
-
-struct stats_hdr *
-stats_find(char *name)
-{
- struct stats_hdr *cur;
-
- cur = NULL;
- STAILQ_FOREACH(cur, &g_stats_registry, s_next) {
- if (!strcmp(cur->s_name, name)) {
- break;
- }
- }
-
- return (cur);
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/src/test/flash_map_test.c
----------------------------------------------------------------------
diff --git a/libs/util/src/test/flash_map_test.c b/libs/util/src/test/flash_map_test.c
deleted file mode 100644
index 005139c..0000000
--- a/libs/util/src/test/flash_map_test.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Copyright (c) 2015 Runtime Inc.
- *
- * Licensed 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 "os/os.h"
-#include "testutil/testutil.h"
-#include "util/flash_map.h"
-
-#include "hal/hal_flash.h"
-#include "hal/hal_flash_int.h"
-
-/*
- * Test flash_area_to_sectors()
- */
-TEST_CASE(flash_map_test_case_1)
-{
- const struct flash_area *fa;
- int areas_checked = 0;
- int i, j, rc;
- const struct hal_flash *hf;
- struct flash_area my_secs[32];
- int my_sec_cnt;
- uint32_t end;
-
- os_init();
-
- for (i = 0; i < 8; i++) {
- rc = flash_area_open(i, &fa);
- if (rc) {
- continue;
- }
-
- hf = bsp_flash_dev(fa->fa_flash_id);
- TEST_ASSERT_FATAL(hf != NULL, "bsp_flash_dev");
-
- rc = flash_area_to_sectors(i, &my_sec_cnt, my_secs);
- TEST_ASSERT_FATAL(rc == 0, "flash_area_to_sectors failed");
-
- end = fa->fa_off;
- for (j = 0; j < my_sec_cnt; j++) {
- TEST_ASSERT_FATAL(end == my_secs[j].fa_off, "Non contiguous area");
- TEST_ASSERT_FATAL(my_secs[j].fa_flash_id == fa->fa_flash_id,
- "Sectors not in same flash?");
- end = my_secs[j].fa_off + my_secs[j].fa_size;
- }
- if (my_sec_cnt) {
- areas_checked++;
- TEST_ASSERT_FATAL(my_secs[my_sec_cnt - 1].fa_off +
- my_secs[my_sec_cnt - 1].fa_size == fa->fa_off + fa->fa_size,
- "Last sector not in the end");
- }
- }
- TEST_ASSERT_FATAL(areas_checked != 0, "No flash map areas to check!");
-}
-
-/*
- * Test flash_erase
- */
-TEST_CASE(flash_map_test_case_2)
-{
- const struct flash_area *fa;
- struct flash_area secs[32];
- int sec_cnt;
- int i;
- int rc;
- uint32_t off;
- uint8_t wd[256];
- uint8_t rd[256];
-
- os_init();
-
- rc = flash_area_open(FLASH_AREA_IMAGE_0, &fa);
- TEST_ASSERT_FATAL(rc == 0, "flash_area_open() fail");
-
- rc = flash_area_to_sectors(FLASH_AREA_IMAGE_0, &sec_cnt, secs);
- TEST_ASSERT_FATAL(rc == 0, "flash_area_to_sectors failed");
-
- /*
- * First erase the area so it's ready for use.
- */
- for (i = 0; i < sec_cnt; i++) {
- rc = hal_flash_erase_sector(secs[i].fa_flash_id, secs[i].fa_off);
- TEST_ASSERT_FATAL(rc == 0, "hal_flash_erase_sector() failed");
- }
- TEST_ASSERT_FATAL(rc == 0, "read data != write data");
-
- memset(wd, 0xa5, sizeof(wd));
-
- /* write stuff to beginning of every sector */
- off = 0;
- for (i = 0; i < sec_cnt; i++) {
- rc = flash_area_write(fa, off, wd, sizeof(wd));
- TEST_ASSERT_FATAL(rc == 0, "flash_area_write() fail");
-
- /* read it back via hal_flash_Read() */
- rc = hal_flash_read(fa->fa_flash_id, fa->fa_off + off, rd, sizeof(rd));
- TEST_ASSERT_FATAL(rc == 0, "hal_flash_read() fail");
-
- rc = memcmp(wd, rd, sizeof(wd));
- TEST_ASSERT_FATAL(rc == 0, "read data != write data");
-
- /* write stuff to end of area */
- rc = hal_flash_write(fa->fa_flash_id,
- fa->fa_off + off + secs[i].fa_size - sizeof(wd), wd, sizeof(wd));
- TEST_ASSERT_FATAL(rc == 0, "hal_flash_write() fail");
-
- /* and read it back */
- memset(rd, 0, sizeof(rd));
- rc = flash_area_read(fa, off + secs[i].fa_size - sizeof(rd),
- rd, sizeof(rd));
- TEST_ASSERT_FATAL(rc == 0, "hal_flash_read() fail");
-
- rc = memcmp(wd, rd, sizeof(rd));
- TEST_ASSERT_FATAL(rc == 0, "read data != write data");
-
- off += secs[i].fa_size;
- }
- /* erase it */
- rc = flash_area_erase(fa, 0, fa->fa_size);
- TEST_ASSERT_FATAL(rc == 0, "read data != write data");
-
- /* should read back ff all throughout*/
- memset(wd, 0xff, sizeof(wd));
- for (off = 0; off < fa->fa_size; off += sizeof(rd)) {
- rc = flash_area_read(fa, off, rd, sizeof(rd));
- TEST_ASSERT_FATAL(rc == 0, "hal_flash_read() fail");
-
- rc = memcmp(wd, rd, sizeof(rd));
- TEST_ASSERT_FATAL(rc == 0, "area not erased");
- }
-}
-
-TEST_SUITE(flash_map_test_suite)
-{
- flash_map_test_case_1();
- flash_map_test_case_2();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/src/test/util_test.c
----------------------------------------------------------------------
diff --git a/libs/util/src/test/util_test.c b/libs/util/src/test/util_test.c
index 9998fa7..f37a997 100644
--- a/libs/util/src/test/util_test.c
+++ b/libs/util/src/test/util_test.c
@@ -23,7 +23,6 @@ int
util_test_all(void)
{
cbmem_test_suite();
- flash_map_test_suite();
return tu_case_failed;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole/blob/86701063/libs/util/src/test/util_test_priv.h
----------------------------------------------------------------------
diff --git a/libs/util/src/test/util_test_priv.h b/libs/util/src/test/util_test_priv.h
index d6f8da4..873dded 100644
--- a/libs/util/src/test/util_test_priv.h
+++ b/libs/util/src/test/util_test_priv.h
@@ -18,6 +18,5 @@
#define __UTIL_TEST_PRIV_
int cbmem_test_suite(void);
-int flash_map_test_suite(void);
#endif