[GitHub] [mynewt-core] vrahane commented on a change in pull request #1927: Add Dialog OTP driver and associated scripts

2019-08-15 Thread GitBox
vrahane commented on a change in pull request #1927: Add Dialog OTP driver and 
associated scripts
URL: https://github.com/apache/mynewt-core/pull/1927#discussion_r314520108
 
 

 ##
 File path: test/spiflash_stress_test/src/spiflash_stress_test.c
 ##
 @@ -0,0 +1,179 @@
+/*
+ * 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 
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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(SPIFLASH_STRESS_TEST_STACK_SIZE));
+};
+
+static struct runtest_task runtest_tasks[SPIFLASH_STRESS_TEST_TASK_COUNT];
+
+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[] = {
+{ MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x0, 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 
},
+};
+
+
+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 >= SPIFLASH_STRESS_TEST_TASK_COUNT) {
+assert("No more test tasks");
+return NULL;
+}
+
+task = _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, _args[runtest_next_task_idx],
+  prio, OS_WAIT_FOREVER, stack,
+  MYNEWT_VAL(SPIFLASH_STRESS_TEST_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.";
 
 Review comment:
   Our coding style suggests code size per line should be 79.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] vrahane commented on a change in pull request #1927: Add Dialog OTP driver and associated scripts

2019-08-15 Thread GitBox
vrahane commented on a change in pull request #1927: Add Dialog OTP driver and 
associated scripts
URL: https://github.com/apache/mynewt-core/pull/1927#discussion_r314520090
 
 

 ##
 File path: test/spiflash_stress_test/src/spiflash_stress_test.c
 ##
 @@ -0,0 +1,179 @@
+/*
+ * 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 
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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(SPIFLASH_STRESS_TEST_STACK_SIZE));
+};
+
+static struct runtest_task runtest_tasks[SPIFLASH_STRESS_TEST_TASK_COUNT];
+
+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[] = {
+{ MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x0, 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 
},
+};
+
+
+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 >= SPIFLASH_STRESS_TEST_TASK_COUNT) {
+assert("No more test tasks");
+return NULL;
+}
+
+task = _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, _args[runtest_next_task_idx],
+  prio, OS_WAIT_FOREVER, stack,
+  MYNEWT_VAL(SPIFLASH_STRESS_TEST_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, ))
+return;
+
+while (1) {
+os_sem_pend(, 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 finished and waits for next start\n",
+   os_sched_get_current_task()->t_taskid);
+}
+}
+
+static int spiflash_stress_test_cli_cmd(int argc, char 

[GitHub] [mynewt-core] vrahane commented on a change in pull request #1927: Add Dialog OTP driver and associated scripts

2019-08-15 Thread GitBox
vrahane commented on a change in pull request #1927: Add Dialog OTP driver and 
associated scripts
URL: https://github.com/apache/mynewt-core/pull/1927#discussion_r314520119
 
 

 ##
 File path: test/spiflash_stress_test/src/spiflash_stress_test.c
 ##
 @@ -0,0 +1,179 @@
+/*
+ * 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 
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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(SPIFLASH_STRESS_TEST_STACK_SIZE));
+};
+
+static struct runtest_task runtest_tasks[SPIFLASH_STRESS_TEST_TASK_COUNT];
+
+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[] = {
+{ MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x0, 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 
},
+};
+
+
+struct os_task *
+runtest_init_task(os_task_func_t task_func, uint8_t prio)
+{
+struct os_task *task = NULL;
+#if 1
 
 Review comment:
   Are you planning on removing this later ? Doesn't really serve a purpose if 
it's 1 :-)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] vrahane commented on a change in pull request #1927: Add Dialog OTP driver and associated scripts

2019-08-15 Thread GitBox
vrahane commented on a change in pull request #1927: Add Dialog OTP driver and 
associated scripts
URL: https://github.com/apache/mynewt-core/pull/1927#discussion_r314520081
 
 

 ##
 File path: test/spiflash_stress_test/src/spiflash_stress_test.c
 ##
 @@ -0,0 +1,179 @@
+/*
+ * 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 
+#include "os/mynewt.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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(SPIFLASH_STRESS_TEST_STACK_SIZE));
+};
+
+static struct runtest_task runtest_tasks[SPIFLASH_STRESS_TEST_TASK_COUNT];
+
+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[] = {
+{ MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x0, 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 
},
+};
+
+
+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 >= SPIFLASH_STRESS_TEST_TASK_COUNT) {
+assert("No more test tasks");
+return NULL;
+}
+
+task = _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, _args[runtest_next_task_idx],
+  prio, OS_WAIT_FOREVER, stack,
+  MYNEWT_VAL(SPIFLASH_STRESS_TEST_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, ))
+return;
+
+while (1) {
+os_sem_pend(, 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 finished and waits for next start\n",
+   os_sched_get_current_task()->t_taskid);
+}
+}
+
+static int spiflash_stress_test_cli_cmd(int argc, char