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 2015/11/14 02:32:51 UTC
[1/4] incubator-mynewt-larva git commit: Fix off-by-one issue with
sector size.
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master d478f7bce -> c1478e24d
Fix off-by-one issue with sector size.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/96f4fdf7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/96f4fdf7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/96f4fdf7
Branch: refs/heads/master
Commit: 96f4fdf72701088de6fcaeb96cc60fd920589b34
Parents: c6ccb0e
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Nov 13 17:25:05 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Nov 13 17:25:05 2015 -0800
----------------------------------------------------------------------
hw/hal/src/hal_flash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/96f4fdf7/hw/hal/src/hal_flash.c
----------------------------------------------------------------------
diff --git a/hw/hal/src/hal_flash.c b/hw/hal/src/hal_flash.c
index 5def317..a921fb6 100644
--- a/hw/hal/src/hal_flash.c
+++ b/hw/hal/src/hal_flash.c
@@ -43,7 +43,7 @@ hal_flash_sector_size(struct hal_flash *hf, int sec_idx)
{
uint32_t end;
- if (sec_idx < hf->hf_sector_cnt) {
+ if (sec_idx < hf->hf_sector_cnt - 1) {
end = hf->hf_sectors[sec_idx + 1];
} else {
end = hf->hf_sectors[0] + hf->hf_size;
[3/4] incubator-mynewt-larva git commit: Add few tests for flash
map/hal_flash..
Posted by ma...@apache.org.
Add few tests for flash map/hal_flash..
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/12f52004
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/12f52004
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/12f52004
Branch: refs/heads/master
Commit: 12f52004b47df7448897743f388e420011ae4656
Parents: 8554d6a
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Nov 13 17:29:39 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Nov 13 17:29:39 2015 -0800
----------------------------------------------------------------------
libs/util/src/test/flash_map_test.c | 142 +++++++++++++++++++++++++++++++
libs/util/src/test/util_test.c | 3 +-
libs/util/src/test/util_test_priv.h | 1 +
3 files changed, 145 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/12f52004/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
new file mode 100644
index 0000000..0d255d5
--- /dev/null
+++ b/libs/util/src/test/flash_map_test.c
@@ -0,0 +1,142 @@
+/**
+ * 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;
+ 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");
+
+ 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-larva/blob/12f52004/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 93d4125..9998fa7 100644
--- a/libs/util/src/test/util_test.c
+++ b/libs/util/src/test/util_test.c
@@ -17,12 +17,13 @@
#include <assert.h>
#include <stddef.h>
#include "testutil/testutil.h"
-#include "util_test_priv.h"
+#include "util_test_priv.h"
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-larva/blob/12f52004/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 873dded..d6f8da4 100644
--- a/libs/util/src/test/util_test_priv.h
+++ b/libs/util/src/test/util_test_priv.h
@@ -18,5 +18,6 @@
#define __UTIL_TEST_PRIV_
int cbmem_test_suite(void);
+int flash_map_test_suite(void);
#endif
[4/4] incubator-mynewt-larva git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
Posted by ma...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/c1478e24
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/c1478e24
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/c1478e24
Branch: refs/heads/master
Commit: c1478e24d6e77e358283538b9cbb8c66ebfe5dce
Parents: 12f5200 d478f7b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Nov 13 17:30:29 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Nov 13 17:30:29 2015 -0800
----------------------------------------------------------------------
.../controller/include/controller/ble_ll.h | 13 +-
.../controller/include/controller/ble_ll_adv.h | 3 +
.../controller/include/controller/ble_ll_conn.h | 16 +
.../controller/include/controller/ble_ll_scan.h | 45 +-
net/nimble/controller/src/ble_ll.c | 53 +-
net/nimble/controller/src/ble_ll_adv.c | 175 ++++--
net/nimble/controller/src/ble_ll_conn.c | 604 +++++++++++++++++--
net/nimble/controller/src/ble_ll_hci.c | 1 +
net/nimble/controller/src/ble_ll_scan.c | 81 ++-
net/nimble/drivers/nrf52/src/ble_phy.c | 5 +
10 files changed, 829 insertions(+), 167 deletions(-)
----------------------------------------------------------------------
[2/4] incubator-mynewt-larva git commit: Add flash map for native.
Posted by ma...@apache.org.
Add flash map for native.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/8554d6a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/8554d6a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/8554d6a7
Branch: refs/heads/master
Commit: 8554d6a7d8d1cc17e7b4f3a2bac21c9d803ec99c
Parents: 96f4fdf
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Nov 13 17:27:14 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Nov 13 17:27:14 2015 -0800
----------------------------------------------------------------------
hw/bsp/native/src/os_bsp.c | 47 +++++++++++++++++++++++++++
libs/os/include/os/arch/sim/os/os_arch.h | 2 ++
libs/os/src/arch/sim/os_arch_sim.c | 5 ++-
3 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/8554d6a7/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
new file mode 100644
index 0000000..a632c86
--- /dev/null
+++ b/hw/bsp/native/src/os_bsp.c
@@ -0,0 +1,47 @@
+/**
+ * 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 <util/flash_map.h>
+
+static struct flash_area bsp_flash_areas[] = {
+ [FLASH_AREA_BOOTLOADER] = {
+ .fa_flash_id = 0, /* internal flash */
+ .fa_off = 0x00000000, /* beginning */
+ .fa_size = (32 * 1024)
+ },
+ /* 2 * 16K and 1*64K sectors here */
+ [FLASH_AREA_IMAGE_0] = {
+ .fa_flash_id = 0,
+ .fa_off = 0x00020000,
+ .fa_size = (384 * 1024)
+ },
+ [FLASH_AREA_IMAGE_1] = {
+ .fa_flash_id = 0,
+ .fa_off = 0x00080000,
+ .fa_size = (384 * 1024)
+ },
+ [FLASH_AREA_IMAGE_SCRATCH] = {
+ .fa_flash_id = 0,
+ .fa_off = 0x000e0000,
+ .fa_size = (128 * 1024)
+ }
+};
+
+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-larva/blob/8554d6a7/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 7144a44..3466727 100644
--- a/libs/os/include/os/arch/sim/os/os_arch.h
+++ b/libs/os/include/os/arch/sim/os/os_arch.h
@@ -60,4 +60,6 @@ void os_arch_restore_sr(int);
os_error_t os_arch_os_init(void);
os_error_t os_arch_os_start(void);
+void os_bsp_init(void);
+
#endif /* _OS_ARCH_SIM_H */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/8554d6a7/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 5d2bfe6..f2d57e3 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -308,7 +308,10 @@ os_arch_os_init(void)
TAILQ_INIT(&g_os_sleep_list);
os_init_idle_task();
- os_sanity_task_init();
+ os_sanity_task_init();
+
+ os_bsp_init();
+
return OS_OK;
}