[1/2] incubator-mynewt-core git commit: spitest; also consider SPI_0_MASTER/SPI_0_SLAVE setting.
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 3758239db -> e85352c61 spitest; also consider SPI_0_MASTER/SPI_0_SLAVE setting. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e85352c6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e85352c6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e85352c6 Branch: refs/heads/develop Commit: e85352c61cb373fa27b6e526111f9971e94fc2c4 Parents: 3310a9a Author: Marko KiiskilaAuthored: Fri Oct 14 17:19:04 2016 -0700 Committer: Marko Kiiskila Committed: Fri Oct 14 17:23:22 2016 -0700 -- apps/spitest/src/main.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e85352c6/apps/spitest/src/main.c -- diff --git a/apps/spitest/src/main.c b/apps/spitest/src/main.c index b59cd2a..3388333 100755 --- a/apps/spitest/src/main.c +++ b/apps/spitest/src/main.c @@ -60,7 +60,13 @@ struct os_sem g_test_sem; /* For LED toggling */ int g_led_pin; -#if MYNEWT_VAL(SPI_MASTER) +#if MYNEWT_VAL(SPI_MASTER) || MYNEWT_VAL(SPI_0_MASTER) +#define SPI_MASTER 1 +#endif +#if MYNEWT_VAL(SPI_SLAVE) || MYNEWT_VAL(SPI_0_SLAVE) +#define SPI_SLAVE 1 +#endif +#ifdef SPI_MASTER uint8_t g_spi_tx_buf[32]; uint8_t g_spi_rx_buf[32]; uint32_t g_spi_xfr_num; @@ -124,7 +130,7 @@ sblinky_spi_cfg(int spi_num) } #endif -#if MYNEWT_VAL(SPI_SLAVE) +#ifdef SPI_SLAVE uint8_t g_spi_tx_buf[32]; uint8_t g_spi_rx_buf[32]; uint32_t g_spi_xfr_num; @@ -168,7 +174,7 @@ sblinky_spi_cfg(int spi_num) } #endif -#if MYNEWT_VAL(SPI_MASTER) +#ifdef SPI_MASTER void task1_handler(void *arg) { @@ -264,7 +270,7 @@ task1_handler(void *arg) } #endif -#if MYNEWT_VAL(SPI_SLAVE) +#ifdef SPI_SLAVE void task1_handler(void *arg) {
[2/2] incubator-mynewt-core git commit: STM32F4 hal spi; fix master support.
STM32F4 hal spi; fix master support. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3310a9a5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3310a9a5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3310a9a5 Branch: refs/heads/develop Commit: 3310a9a5123061d4651527cfda766637239adf2c Parents: 3758239 Author: Marko KiiskilaAuthored: Fri Oct 14 17:17:05 2016 -0700 Committer: Marko Kiiskila Committed: Fri Oct 14 17:23:22 2016 -0700 -- hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c | 66 +--- hw/bsp/olimex_stm32-e407_devboard/syscfg.yml| 15 +- .../include/mcu/stm32f4xx_mynewt_hal.h | 3 +- hw/mcu/stm/stm32f4xx/src/hal_spi.c | 313 +++ 4 files changed, 207 insertions(+), 190 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3310a9a5/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c -- diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c index 24ce48c..b2c4bd0 100644 --- a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c +++ b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c @@ -39,9 +39,9 @@ #include "stm32f4xx_hal_adc.h" #include #include -#if MYNEWT_VAL(SPI_MASTER)||MYNEWT_VAL(SPI_SLAVE) -#include "Mcu/stm32f4xx_mynewt_hal.h" -#include "hal/hal_spi.h" +#include +#if MYNEWT_VAL(SPI_0_MASTER) || MYNEWT_VAL(SPI_0_SLAVE) +#include #endif static struct uart_dev hal_uart0; @@ -266,42 +266,16 @@ static struct stm32f4_hal_i2c_cfg i2c_cfg0 = { }; #endif -#if MYNEWT_VAL(SPI_MASTER) -#define STM32F4_SPI_DEFAULT_INIT_TD \ -{\ -.Mode = SPI_MODE_MASTER,\ -.Direction = SPI_DIRECTION_2LINES,\ -.DataSize = SPI_DATASIZE_8BIT,\ -.CLKPolarity = SPI_POLARITY_LOW,\ -.CLKPhase = SPI_PHASE_1EDGE,\ -.NSS = SPI_NSS_HARD_INPUT,\ -.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8,\ -.FirstBit = SPI_FIRSTBIT_MSB,\ -.TIMode= SPI_TIMODE_DISABLE,\ -.CRCCalculation= SPI_CRCCALCULATION_DISABLE,\ -.CRCPolynomial = 0\ -} -#endif - - -#if MYNEWT_VAL(SPI_SLAVE) -#define STM32F4_SPI_DEFAULT_INIT_TD \ -{\ -.Mode = SPI_MODE_SLAVE,\ -.Direction = SPI_DIRECTION_2LINES,\ -.DataSize = SPI_DATASIZE_8BIT,\ -.CLKPolarity = SPI_POLARITY_LOW,\ -.CLKPhase = SPI_PHASE_1EDGE,\ -.NSS = SPI_NSS_HARD_INPUT,\ -.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8,\ -.FirstBit = SPI_FIRSTBIT_MSB,\ -.TIMode= SPI_TIMODE_DISABLE,\ -.CRCCalculation= SPI_CRCCALCULATION_DISABLE,\ -.CRCPolynomial = 0\ -} +#if MYNEWT_VAL(SPI_0_SLAVE) || MYNEWT_VAL(SPI_0_MASTER) +struct stm32f4_hal_spi_cfg spi0_cfg = { +.ss_pin = 4, +.sck_pin = 5, +.miso_pin = 6, +.mosi_pin = 21, +.irq_prio = 2 +}; #endif - void _close(int fd); void @@ -309,23 +283,13 @@ bsp_init(void) { int rc; -#if MYNEWT_VAL(SPI_SLAVE)||MYNEWT_VAL(SPI_MASTER) -SPI_InitTypeDef spi_init_td = STM32F4_SPI_DEFAULT_INIT_TD; -struct stm32f4_hal_spi_cfg spi_cfg = { -.sck_pin = 5, -.miso_pin = 6, -.mosi_pin = 21, -.spi_settings = _init_td -}; -#endif - -#if MYNEWT_VAL(SPI_MASTER) -rc = hal_spi_init(0, _cfg, HAL_SPI_TYPE_MASTER); +#if MYNEWT_VAL(SPI_0_MASTER) +rc = hal_spi_init(0, _cfg, HAL_SPI_TYPE_MASTER); assert(rc == 0); #endif -#if MYNEWT_VAL(SPI_SLAVE) -rc = hal_spi_init(0, _cfg, HAL_SPI_TYPE_SLAVE); +#if MYNEWT_VAL(SPI_0_SLAVE) +rc = hal_spi_init(0, _cfg, HAL_SPI_TYPE_SLAVE); assert(rc == 0); #endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3310a9a5/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml -- diff --git a/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml b/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml index 5323eb6..5f0cf16 100644 --- a/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml +++ b/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml @@ -25,12 +25,21 @@ syscfg.defs: description: 'I2C0' value: 0 -SPI_MASTER: +SPI_0: description: 'TBD' value: 0 -SPI_SLAVE: + +SPI_0_MASTER: description: 'TBD' -value: 1 +value: 0 +restrictions: +- SPI_0 + +SPI_0_SLAVE: +description: 'TBD' +value: 0 +restrictions: +- SPI_0 TIMER_0: description: 'TIMER_0'
[2/2] incubator-mynewt-core git commit: bootutil - Add unit tests for image revert.
bootutil - Add unit tests for image revert. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3758239d Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3758239d Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3758239d Branch: refs/heads/develop Commit: 3758239dba41f5dae47e481ef82b4f95edb59cf2 Parents: 4b1a5c1 Author: Christopher CollinsAuthored: Fri Oct 14 13:40:00 2016 -0700 Committer: Christopher Collins Committed: Fri Oct 14 16:39:48 2016 -0700 -- boot/bootutil/include/bootutil/bootutil_misc.h | 7 +- boot/bootutil/src/bootutil_misc.c | 85 ++- boot/bootutil/src/bootutil_priv.h | 4 - boot/bootutil/src/loader.c | 34 --- boot/bootutil/test/src/boot_test.c | 237 ++-- mgmt/imgmgr/src/imgmgr_state.c | 3 +- 6 files changed, 141 insertions(+), 229 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3758239d/boot/bootutil/include/bootutil/bootutil_misc.h -- diff --git a/boot/bootutil/include/bootutil/bootutil_misc.h b/boot/bootutil/include/bootutil/bootutil_misc.h index 1efe864..87b0b28 100644 --- a/boot/bootutil/include/bootutil/bootutil_misc.h +++ b/boot/bootutil/include/bootutil/bootutil_misc.h @@ -26,8 +26,11 @@ extern "C" { #endif -int boot_vect_read_test(int *slot); -int boot_vect_read_main(int *slot); +#define BOOT_SWAP_TYPE_NONE 0 +#define BOOT_SWAP_TYPE_TEMP 1 +#define BOOT_SWAP_TYPE_PERM 2 + +int boot_swap_type(void); int boot_vect_write_test(int slot); int boot_vect_write_main(void); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3758239d/boot/bootutil/src/bootutil_misc.c -- diff --git a/boot/bootutil/src/bootutil_misc.c b/boot/bootutil/src/bootutil_misc.c index bb7b2a3..0606215 100644 --- a/boot/bootutil/src/bootutil_misc.c +++ b/boot/bootutil/src/bootutil_misc.c @@ -65,11 +65,8 @@ boot_status_sz(void) return sizeof(struct boot_img_trailer) + 32 * sizeof(uint32_t); } -/* - * Read the image trailer from a given slot. - */ -static int -boot_vect_read_img_trailer(int slot, struct boot_img_trailer *bit) +int +boot_swap_type(void) { struct boot_img_trailer bit0; struct boot_img_trailer bit1; @@ -80,77 +77,25 @@ boot_vect_read_img_trailer(int slot, struct boot_img_trailer *bit) if (bit0.bit_copy_start == BOOT_MAGIC_SWAP_NONE && bit1.bit_copy_start == BOOT_MAGIC_SWAP_NONE) { -area_id = flash_area_id_from_image_slot(slot); -rc = flash_area_open(area_id, ); -if (rc) { -return rc; +return BOOT_SWAP_TYPE_NONE; } -off = fap->fa_size - sizeof(struct boot_img_trailer); -rc = flash_area_read(fap, off, bit, sizeof(*bit)); -flash_area_close(fap); - -return rc; -} -/** - * Retrieves from the slot number of the test image (i.e., - * the image that has not been proven stable, and which will only run once). - * - * @param slot On success, the slot number of image to boot. - * - * @return 0 if a test image was found; - * nonzero if there is no test image. - */ -int -boot_vect_read_test(int *slot) -{ -struct boot_img_trailer bit; -int i; -int rc; +if (bit1.bit_copy_start == BOOT_MAGIC_SWAP_TEMP) { +return BOOT_SWAP_TYPE_TEMP; +} -for (i = 0; i < 2; i++) { -if (i == boot_current_slot) { -continue; -} -rc = boot_vect_read_img_trailer(i, ); -if (rc) { -continue; -} -if (bit.bit_copy_start == BOOT_MAGIC_SWAP_TEMP) { -*slot = i; -return 0; +if (bit0.bit_copy_start == BOOT_MAGIC_SWAP_PERM) { +if (bit0.bit_img_ok != 0xff) { +return BOOT_SWAP_TYPE_NONE; +} else { +return BOOT_SWAP_TYPE_PERM; } } -return -1; -} - -/** - * Retrieves from the slot number of the main image. If this is - * different from test image slot, next restart will revert to main. - * - * @param out_ver On success, the main version gets written here. - * - * @return 0 on success; nonzero on failure. - */ -int -boot_vect_read_main(int *slot) -{ -int rc; -struct boot_img_trailer bit; - -rc = boot_vect_read_img_trailer(0, ); -assert(rc == 0); -if (bit.bit_copy_start != BOOT_MAGIC_SWAP_TEMP || bit.bit_img_ok != 0xff) { -/* - * If there never was copy that took place, or if the current - * image has been marked good, we'll keep
[1/2] incubator-mynewt-core git commit: Two-stage boot (test / confirm).
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop e7abb3c74 -> 3758239db Two-stage boot (test / confirm). Code cleanup to follow. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4b1a5c1d Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4b1a5c1d Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4b1a5c1d Branch: refs/heads/develop Commit: 4b1a5c1dacb83ca13df68460a752b3d6d94041ce Parents: e7abb3c Author: Christopher CollinsAuthored: Fri Oct 14 13:27:14 2016 -0700 Committer: Christopher Collins Committed: Fri Oct 14 16:39:43 2016 -0700 -- boot/bootutil/src/bootutil_misc.c | 65 -- boot/bootutil/src/bootutil_priv.h | 67 ++- boot/bootutil/src/loader.c | 175 --- boot/bootutil/test/src/boot_test.c | 207 ++-- mgmt/imgmgr/src/imgmgr_state.c | 28 +++-- 5 files changed, 352 insertions(+), 190 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4b1a5c1d/boot/bootutil/src/bootutil_misc.c -- diff --git a/boot/bootutil/src/bootutil_misc.c b/boot/bootutil/src/bootutil_misc.c index 0ee7ea9..bb7b2a3 100644 --- a/boot/bootutil/src/bootutil_misc.c +++ b/boot/bootutil/src/bootutil_misc.c @@ -39,7 +39,7 @@ int8_t boot_split_app_active; /* * Read the image trailer from a given slot. */ -static int +int boot_vect_read_img_trailer(int slot, struct boot_img_trailer *bit) { int rc; @@ -59,6 +59,39 @@ boot_vect_read_img_trailer(int slot, struct boot_img_trailer *bit) return rc; } +int +boot_status_sz(void) +{ +return sizeof(struct boot_img_trailer) + 32 * sizeof(uint32_t); +} + +/* + * Read the image trailer from a given slot. + */ +static int +boot_vect_read_img_trailer(int slot, struct boot_img_trailer *bit) +{ +struct boot_img_trailer bit0; +struct boot_img_trailer bit1; + +boot_vect_read_img_trailer(0, ); +boot_vect_read_img_trailer(1, ); + +if (bit0.bit_copy_start == BOOT_MAGIC_SWAP_NONE && +bit1.bit_copy_start == BOOT_MAGIC_SWAP_NONE) { + +area_id = flash_area_id_from_image_slot(slot); +rc = flash_area_open(area_id, ); +if (rc) { +return rc; +} +off = fap->fa_size - sizeof(struct boot_img_trailer); +rc = flash_area_read(fap, off, bit, sizeof(*bit)); +flash_area_close(fap); + +return rc; +} + /** * Retrieves from the slot number of the test image (i.e., * the image that has not been proven stable, and which will only run once). @@ -83,7 +116,7 @@ boot_vect_read_test(int *slot) if (rc) { continue; } -if (bit.bit_copy_start == BOOT_IMG_MAGIC) { +if (bit.bit_copy_start == BOOT_MAGIC_SWAP_TEMP) { *slot = i; return 0; } @@ -108,7 +141,7 @@ boot_vect_read_main(int *slot) rc = boot_vect_read_img_trailer(0, ); assert(rc == 0); -if (bit.bit_copy_start != BOOT_IMG_MAGIC || bit.bit_img_ok != 0xff) { +if (bit.bit_copy_start != BOOT_MAGIC_SWAP_TEMP || bit.bit_img_ok != 0xff) { /* * If there never was copy that took place, or if the current * image has been marked good, we'll keep booting it. @@ -144,7 +177,7 @@ boot_vect_write_test(int slot) } off = fap->fa_size - sizeof(struct boot_img_trailer); -magic = BOOT_IMG_MAGIC; +magic = BOOT_MAGIC_SWAP_TEMP; rc = flash_area_write(fap, off, , sizeof(magic)); flash_area_close(fap); @@ -256,21 +289,26 @@ boot_read_status(struct boot_status *bs) uint8_t flash_id; uint32_t off; -/* - * Check if boot_img_trailer is in scratch, or at the end of slot0. - */ +/* Check if boot_img_trailer is in scratch, or at the end of slot0. */ boot_slot_magic(0, ); -if (bit.bit_copy_start == BOOT_IMG_MAGIC && bit.bit_copy_done == 0xff) { +if (bit.bit_copy_start != BOOT_MAGIC_SWAP_NONE && +bit.bit_copy_done == 0xff) { + boot_magic_loc(0, _id, ); boot_read_status_bytes(bs, flash_id, off); return 1; } + boot_scratch_magic(); -if (bit.bit_copy_start == BOOT_IMG_MAGIC && bit.bit_copy_done == 0xff) { +if (bit.bit_copy_start != BOOT_MAGIC_SWAP_NONE && +bit.bit_copy_done == 0xff) { + boot_scratch_loc(_id, ); boot_read_status_bytes(bs, flash_id, off); return 1; } + + return 0; } @@ -316,10 +354,10 @@ boot_write_status(struct boot_status *bs) * progress. */ void -boot_clear_status(void) +boot_set_copy_done(void) { +struct boot_img_trailer bit; uint32_t off; -uint8_t val = 0;
incubator-mynewt-core git commit: hal_spi.h; add comment saying that baudrate unit is kHz.
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop f9bf3836c -> e7abb3c74 hal_spi.h; add comment saying that baudrate unit is kHz. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e7abb3c7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e7abb3c7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e7abb3c7 Branch: refs/heads/develop Commit: e7abb3c749d534c4cdaddc900cb7e94daa3d5a0b Parents: f9bf383 Author: Marko KiiskilaAuthored: Fri Oct 14 12:49:28 2016 -0700 Committer: Marko Kiiskila Committed: Fri Oct 14 12:49:28 2016 -0700 -- hw/hal/include/hal/hal_spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e7abb3c7/hw/hal/include/hal/hal_spi.h -- diff --git a/hw/hal/include/hal/hal_spi.h b/hw/hal/include/hal/hal_spi.h index c542123..38a51b2 100644 --- a/hw/hal/include/hal/hal_spi.h +++ b/hw/hal/include/hal/hal_spi.h @@ -54,7 +54,7 @@ struct hal_spi_settings { uint8_t data_mode; uint8_t data_order; uint8_t word_size; -uint32_tbaudrate; +uint32_tbaudrate; /* baudrate in kHz */ }; /**
incubator-mynewt-core git commit: fix echo command type and cleanup attribute array
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 7bedd6c51 -> f9bf3836c fix echo command type and cleanup attribute array Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f9bf3836 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f9bf3836 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f9bf3836 Branch: refs/heads/develop Commit: f9bf3836c9fedd62ab98d60192cbe61d426003a4 Parents: 7bedd6c Author: Paul DietrichAuthored: Fri Oct 14 12:17:02 2016 -0700 Committer: Paul Dietrich Committed: Fri Oct 14 12:17:46 2016 -0700 -- mgmt/newtmgr/nmgr_os/src/newtmgr_os.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f9bf3836/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c -- diff --git a/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c b/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c index 9fbc294..d0d70e8 100644 --- a/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c +++ b/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c @@ -111,17 +111,14 @@ nmgr_def_console_echo(struct mgmt_cbuf *cb) { long long int echo_on = 1; int rc; -struct cbor_attr_t attrs[3] = { +struct cbor_attr_t attrs[2] = { [0] = { .attribute = "echo", -.type = CborAttrTextStringType, +.type = CborAttrIntegerType, .addr.integer = _on, .nodefault = 1 }, -[1] = { -.attribute = NULL -}, -[2] = { 0 }, +[1] = { 0 }, }; rc = cbor_read_object(>it, attrs);