You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2019/01/08 12:09:14 UTC

[mynewt-core] branch master updated (59912fc -> fd48133)

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

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


    from 59912fc  Merge pull request #1540 from mlaz/update_nrfx140
     new 4e7b5eb  Add spiflash stress testing package
     new fd48133  spiflash_stress_test: Add syscfg

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


Summary of changes:
 test/{flash_test => spiflash_stress_test}/pkg.yml  |   9 +-
 .../src/spiflash_stress_test.c                     | 179 +++++++++++++++++++++
 .../spiflash_stress_test}/syscfg.yml               |  14 +-
 3 files changed, 191 insertions(+), 11 deletions(-)
 copy test/{flash_test => spiflash_stress_test}/pkg.yml (89%)
 create mode 100644 test/spiflash_stress_test/src/spiflash_stress_test.c
 copy {sys/coredump => test/spiflash_stress_test}/syscfg.yml (76%)


[mynewt-core] 01/02: Add spiflash stress testing package

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

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

commit 4e7b5eb2a1a16aeeac3ab60dabfd236a849b3dce
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Nov 30 12:42:39 2018 +0100

    Add spiflash stress testing package
    
    Spiflash was hal like flash and it did not provide thread
    safeness.
    To verify that thread safe changes to spiflash driver work
    correct this package adds 3 tasks that write and read flash
    concurrently.
---
 test/spiflash_stress_test/pkg.yml                  |  34 ++++
 .../src/spiflash_stress_test.c                     | 176 +++++++++++++++++++++
 2 files changed, 210 insertions(+)

diff --git a/test/spiflash_stress_test/pkg.yml b/test/spiflash_stress_test/pkg.yml
new file mode 100644
index 0000000..201236c
--- /dev/null
+++ b/test/spiflash_stress_test/pkg.yml
@@ -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.
+#
+
+pkg.name: test/spiflash_stress_test
+pkg.description: spiflash stress tester
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps:
+    - "@apache-mynewt-core/kernel/os"
+    - "@apache-mynewt-core/hw/hal"
+    - "@apache-mynewt-core/sys/shell"
+pkg.req_apis:
+    - console
+
+pkg.init:
+    spiflash_stress_test_init: 500
+
diff --git a/test/spiflash_stress_test/src/spiflash_stress_test.c b/test/spiflash_stress_test/src/spiflash_stress_test.c
new file mode 100644
index 0000000..b733d97
--- /dev/null
+++ b/test/spiflash_stress_test/src/spiflash_stress_test.c
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <inttypes.h>
+#include "os/mynewt.h"
+#include <console/console.h>
+#include <hal/hal_bsp.h>
+#include <hal/hal_flash.h>
+#include <hal/hal_flash_int.h>
+#include <shell/shell.h>
+#include <stdio.h>
+#include <string.h>
+
+struct runtest_task {
+    struct os_task task;
+    char name[sizeof "taskX"];
+    OS_TASK_STACK_DEFINE_NOSTATIC(stack, MYNEWT_VAL(RUNTEST_STACK_SIZE));
+};
+
+static struct runtest_task runtest_tasks[MYNEWT_VAL(RUNTEST_NUM_TASKS)];
+
+static int runtest_next_task_idx;
+
+struct task_cfg {
+    uint8_t flash_area_id;
+    uint32_t flash_area_offset;
+    uint32_t flash_area_size;
+    int increment;
+    int pin;
+} task_args[] = {
+    { FLASH_AREA_TEST_1, 0x00000, 0x01000, 1, 11 },
+    { FLASH_AREA_TEST_1, 0x02000, 0x06000, 7, 12 },
+    { FLASH_AREA_TEST_1, 0x08000, 0x08000, 13, 13 },
+};
+
+
+struct os_task *
+runtest_init_task(os_task_func_t task_func, uint8_t prio)
+{
+    struct os_task *task = NULL;
+#if 1
+    os_stack_t *stack;
+    char *name;
+    int rc;
+
+    if (runtest_next_task_idx >= MYNEWT_VAL(RUNTEST_NUM_TASKS)) {
+        assert("No more test tasks");
+        return NULL;
+    }
+
+    task = &runtest_tasks[runtest_next_task_idx].task;
+    stack = runtest_tasks[runtest_next_task_idx].stack;
+    name = runtest_tasks[runtest_next_task_idx].name;
+
+    strcpy(name, "task");
+    name[4] = '0' + runtest_next_task_idx;
+    name[5] = '\0';
+
+    rc = os_task_init(task, name, task_func, &task_args[runtest_next_task_idx],
+                      prio, OS_WAIT_FOREVER, stack,
+                      MYNEWT_VAL(RUNTEST_STACK_SIZE));
+    assert(rc == 0);
+
+#endif
+    runtest_next_task_idx++;
+    return task;
+}
+
+const uint8_t pattern[] = "1234567890 We choose to go to the moon in this decade and do the other things, not because they are easy, but because they are hard.";
+
+struct os_sem sem;
+
+void flash_test_task1(void *arg)
+{
+    const struct flash_area *fa;
+    struct task_cfg *cfg = arg;
+    int i;
+    int increment;
+    uint8_t pat_buf[sizeof(pattern)];
+
+    g_current_task->t_pad = cfg->pin;
+    if (flash_area_open(cfg->flash_area_id, &fa))
+        return;
+
+    while (1) {
+        os_sem_pend(&sem, OS_TIMEOUT_NEVER);
+        console_printf("Task %d starts\n", os_sched_get_current_task()->t_taskid);
+        flash_area_erase(fa, cfg->flash_area_offset, cfg->flash_area_size);
+        increment = cfg->increment;
+        int chunk = 0;
+        for (i = 0 ; i < cfg->flash_area_size; ) {
+            chunk += increment;
+            if (chunk < 0 || chunk > sizeof(pattern)) {
+                increment = -increment;
+                chunk += increment;
+            }
+            if (i + chunk > cfg->flash_area_size)
+                chunk = cfg->flash_area_size - i;
+            flash_area_write(fa, cfg->flash_area_offset + i, pattern, chunk);
+            i += chunk;
+            os_time_delay(1);
+        }
+
+        increment = cfg->increment;
+        chunk = 0;
+        for (i = 0 ; i < cfg->flash_area_size; ) {
+            chunk += increment;
+            if (chunk < 0 || chunk > sizeof(pattern)) {
+                increment = -increment;
+                chunk += increment;
+            }
+            memset(pat_buf, 0xDA, chunk);
+            if (i + chunk > cfg->flash_area_size)
+                chunk = cfg->flash_area_size - i;
+            flash_area_read(fa, cfg->flash_area_offset + i, pat_buf, chunk);
+            if (memcmp(pattern, pat_buf, chunk) != 0) {
+                console_printf("Flast write/read failed\n");
+            }
+            os_time_delay(1);
+            i += chunk;
+        }
+        console_printf("Task %d waits\n", os_sched_get_current_task()->t_taskid);
+    }
+}
+
+static int spiflash_stress_test_cli_cmd(int argc, char **argv);
+static struct shell_cmd spiflash_stress_cmd_struct = {
+    .sc_cmd = "flashstress",
+    .sc_cmd_func = spiflash_stress_test_cli_cmd
+};
+
+static int
+spiflash_stress_test_cli_cmd(int argc, char **argv)
+{
+    if (argc > 1 && (!strcmp(argv[1], "?") || !strcmp(argv[1], "help"))) {
+        console_printf("Commands Available\n");
+        console_printf("start\n");
+        return 0;
+    }
+
+    os_sem_release(&sem);
+    os_sem_release(&sem);
+    os_sem_release(&sem);
+
+    return 0;
+}
+
+/*
+ * Initialize the package. Only called from sysinit().
+ */
+void
+spiflash_stress_test_init(void)
+{
+    os_sem_init(&sem, 0);
+    runtest_init_task(flash_test_task1, MYNEWT_VAL(OS_MAIN_TASK_PRIO) + 1);
+    runtest_init_task(flash_test_task1, MYNEWT_VAL(OS_MAIN_TASK_PRIO) + 2);
+    runtest_init_task(flash_test_task1, MYNEWT_VAL(OS_MAIN_TASK_PRIO) + 3);
+
+    shell_cmd_register(&spiflash_stress_cmd_struct);
+}


[mynewt-core] 02/02: spiflash_stress_test: Add syscfg

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

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

commit fd48133c1bd2a139519c55e13b5d8a97fe6c906b
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Dec 14 16:25:56 2018 +0100

    spiflash_stress_test: Add syscfg
    
    syscfg allows to specify flash area to use for testing
    stack size can also be changed, default value works with ARM
    platforms but may not be enough for others.
---
 .../src/spiflash_stress_test.c                     | 19 +++++++++-------
 test/spiflash_stress_test/syscfg.yml               | 26 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/test/spiflash_stress_test/src/spiflash_stress_test.c b/test/spiflash_stress_test/src/spiflash_stress_test.c
index b733d97..6333133 100644
--- a/test/spiflash_stress_test/src/spiflash_stress_test.c
+++ b/test/spiflash_stress_test/src/spiflash_stress_test.c
@@ -27,13 +27,15 @@
 #include <stdio.h>
 #include <string.h>
 
+#define SPIFLASH_STRESS_TEST_TASK_COUNT 3
+
 struct runtest_task {
     struct os_task task;
     char name[sizeof "taskX"];
-    OS_TASK_STACK_DEFINE_NOSTATIC(stack, MYNEWT_VAL(RUNTEST_STACK_SIZE));
+    OS_TASK_STACK_DEFINE_NOSTATIC(stack, MYNEWT_VAL(SPIFLASH_STRESS_TEST_STACK_SIZE));
 };
 
-static struct runtest_task runtest_tasks[MYNEWT_VAL(RUNTEST_NUM_TASKS)];
+static struct runtest_task runtest_tasks[SPIFLASH_STRESS_TEST_TASK_COUNT];
 
 static int runtest_next_task_idx;
 
@@ -44,9 +46,9 @@ struct task_cfg {
     int increment;
     int pin;
 } task_args[] = {
-    { FLASH_AREA_TEST_1, 0x00000, 0x01000, 1, 11 },
-    { FLASH_AREA_TEST_1, 0x02000, 0x06000, 7, 12 },
-    { FLASH_AREA_TEST_1, 0x08000, 0x08000, 13, 13 },
+    { MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x00000, 0x01000, 1, 11 },
+    { MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x02000, 0x06000, 7, 12 },
+    { MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x08000, 0x08000, 13, 13 },
 };
 
 
@@ -59,7 +61,7 @@ runtest_init_task(os_task_func_t task_func, uint8_t prio)
     char *name;
     int rc;
 
-    if (runtest_next_task_idx >= MYNEWT_VAL(RUNTEST_NUM_TASKS)) {
+    if (runtest_next_task_idx >= SPIFLASH_STRESS_TEST_TASK_COUNT) {
         assert("No more test tasks");
         return NULL;
     }
@@ -74,7 +76,7 @@ runtest_init_task(os_task_func_t task_func, uint8_t prio)
 
     rc = os_task_init(task, name, task_func, &task_args[runtest_next_task_idx],
                       prio, OS_WAIT_FOREVER, stack,
-                      MYNEWT_VAL(RUNTEST_STACK_SIZE));
+                      MYNEWT_VAL(SPIFLASH_STRESS_TEST_STACK_SIZE));
     assert(rc == 0);
 
 #endif
@@ -135,7 +137,8 @@ void flash_test_task1(void *arg)
             os_time_delay(1);
             i += chunk;
         }
-        console_printf("Task %d waits\n", os_sched_get_current_task()->t_taskid);
+        console_printf("Task %d finished and waits for next start\n",
+                       os_sched_get_current_task()->t_taskid);
     }
 }
 
diff --git a/test/spiflash_stress_test/syscfg.yml b/test/spiflash_stress_test/syscfg.yml
new file mode 100644
index 0000000..c3ac7e6
--- /dev/null
+++ b/test/spiflash_stress_test/syscfg.yml
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+syscfg.defs:
+    SPIFLASH_STRESS_TEST_FLASH_AREA_ID:
+        description: 'Flash area ID to use for stress testing'
+        restriction: !null
+        value:
+    SPIFLASH_STRESS_TEST_STACK_SIZE:
+        description: 'Stack size for flash stressing tasks'
+        value: 150