Repository: incubator-mynewt-larva Updated Branches: refs/heads/master 1570110d0 -> 810036811
Add shell, nffs and nmgr to bletest project 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/81003681 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/81003681 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/81003681 Branch: refs/heads/master Commit: 810036811d7887c9532546f0395fd50eebd09125 Parents: 1570110 Author: wes3 <w...@micosa.io> Authored: Thu Feb 4 21:32:00 2016 -0800 Committer: wes3 <w...@micosa.io> Committed: Thu Feb 4 21:32:08 2016 -0800 ---------------------------------------------------------------------- project/bletest/bletest.yml | 8 ++++- project/bletest/src/main.c | 63 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/81003681/project/bletest/bletest.yml ---------------------------------------------------------------------- diff --git a/project/bletest/bletest.yml b/project/bletest/bletest.yml index f4aafc5..6f9f167 100644 --- a/project/bletest/bletest.yml +++ b/project/bletest/bletest.yml @@ -1,8 +1,14 @@ project.name: bletest project.eggs: - - libs/os - net/nimble/controller - net/nimble/host + - libs/os - libs/console/full - libs/baselibc + - libs/shell + - libs/imgmgr + - libs/newtmgr + - sys/config + - sys/log + - sys/stats project.cflags: -DBLETEST http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/81003681/project/bletest/src/main.c ---------------------------------------------------------------------- diff --git a/project/bletest/src/main.c b/project/bletest/src/main.c index 76a00d7..3b90791 100755 --- a/project/bletest/src/main.c +++ b/project/bletest/src/main.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Runtime Inc. + * Copyright (c) 2015, 2016 Runtime Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,15 @@ #include "bsp/bsp.h" #include "hal/hal_gpio.h" #include "hal/hal_cputime.h" +#include "hal/hal_flash.h" #include "console/console.h" +#include "shell/shell.h" +#include "stats/stats.h" +#include "hal/flash_map.h" +#include "fs/fs.h" +#include "nffs/nffs.h" +#include "newtmgr/newtmgr.h" +#include "imgmgr/imgmgr.h" /* BLE */ #include "nimble/ble.h" @@ -34,8 +42,23 @@ #include "controller/ble_ll_scan.h" #include "controller/ble_ll_adv.h" -/* Task 1 */ -#define HOST_TASK_PRIO (1) +/* Task priorities */ +/* NOTE: highest priority task (0) reserved for controller LL task */ +#define HOST_TASK_PRIO (OS_TASK_PRI_HIGHEST + 1) +#define BLETEST_TASK_PRIO (HOST_TASK_PRIO + 1) +#define SHELL_TASK_PRIO (BLETEST_TASK_PRIO + 1) +#define NEWTMGR_TASK_PRIO (SHELL_TASK_PRIO + 1) + +/* Shell task stack */ +#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(256)) +os_stack_t shell_stack[SHELL_TASK_STACK_SIZE]; + +/* Newt manager task stack */ +#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(448)) +os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE]; + +/* Flash file system sector size */ +#define NFFS_AREA_MAX (8) /* For LED toggling */ int g_led_pin; @@ -89,7 +112,6 @@ os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE]; #undef BLETEST_ADV_PKT_NUM #define BLETEST_PKT_SIZE (128) #define BLETEST_STACK_SIZE (256) -#define BLETEST_TASK_PRIO (HOST_TASK_PRIO + 1) uint32_t g_next_os_time; int g_bletest_state; struct os_eventq g_bletest_evq; @@ -779,7 +801,9 @@ main(void) { int i; int rc; + int cnt; uint32_t seed; + struct nffs_area_desc descs[NFFS_AREA_MAX]; /* Initialize OS */ os_init(); @@ -796,6 +820,9 @@ main(void) MBUF_NUM_MBUFS); assert(rc == 0); + rc = os_msys_register(&g_mbuf_pool); + assert(rc == 0); + /* Dummy device address */ #if BLETEST_CFG_ROLE == BLETEST_ROLE_ADVERTISER g_dev_addr[0] = 0x00; @@ -843,8 +870,34 @@ main(void) gpio_init_out(g_led_pin, 1); /* Init the console */ - rc = console_init(NULL); + rc = console_init(shell_console_rx_cb); + assert(rc == 0); + + rc = hal_flash_init(); + assert(rc == 0); + + nffs_config.nc_num_inodes = 32; + nffs_config.nc_num_blocks = 64; + nffs_config.nc_num_files = 2; + nffs_config.nc_num_dirs = 2; + rc = nffs_init(); + assert(rc == 0); + + cnt = NFFS_AREA_MAX; + rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs); assert(rc == 0); + if (nffs_detect(descs) == FS_ECORRUPT) { + rc = nffs_format(descs); + assert(rc == 0); + } + + shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE); + + nmgr_task_init(NEWTMGR_TASK_PRIO, newtmgr_stack, NEWTMGR_TASK_STACK_SIZE); + imgmgr_module_init(); + + /* Init statistics module */ + stats_module_init(); /* Init tasks */ init_tasks();