You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/10/13 21:36:42 UTC
incubator-mynewt-core git commit: imgmgmt - Replace obsolete cmds
with image state.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop e550b59ed -> dd68ace87
imgmgmt - Replace obsolete cmds with image state.
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/dd68ace8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/dd68ace8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/dd68ace8
Branch: refs/heads/develop
Commit: dd68ace878404d45007eb2f27c889e144f705c97
Parents: e550b59
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Oct 13 14:35:31 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Oct 13 14:36:37 2016 -0700
----------------------------------------------------------------------
boot/boot_serial/src/boot_serial.c | 2 +-
boot/boot_serial/src/boot_serial_priv.h | 2 +-
mgmt/imgmgr/include/imgmgr/imgmgr.h | 12 +--
mgmt/imgmgr/src/imgmgr.c | 67 +------------
mgmt/imgmgr/src/imgmgr_boot.c | 144 ---------------------------
5 files changed, 9 insertions(+), 218 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd68ace8/boot/boot_serial/src/boot_serial.c
----------------------------------------------------------------------
diff --git a/boot/boot_serial/src/boot_serial.c b/boot/boot_serial/src/boot_serial.c
index ef7ffc0..564fb41 100644
--- a/boot/boot_serial/src/boot_serial.c
+++ b/boot/boot_serial/src/boot_serial.c
@@ -278,7 +278,7 @@ boot_serial_input(char *buf, int len)
*/
if (hdr->nh_group == NMGR_GROUP_ID_IMAGE) {
switch (hdr->nh_id) {
- case IMGMGR_NMGR_OP_LIST:
+ case IMGMGR_NMGR_OP_STATE:
bs_list(buf, len);
break;
case IMGMGR_NMGR_OP_UPLOAD:
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd68ace8/boot/boot_serial/src/boot_serial_priv.h
----------------------------------------------------------------------
diff --git a/boot/boot_serial/src/boot_serial_priv.h b/boot/boot_serial/src/boot_serial_priv.h
index d2eddb6..b350173 100644
--- a/boot/boot_serial/src/boot_serial_priv.h
+++ b/boot/boot_serial/src/boot_serial_priv.h
@@ -59,7 +59,7 @@ struct nmgr_hdr {
/*
* From imgmgr.h
*/
-#define IMGMGR_NMGR_OP_LIST 0
+#define IMGMGR_NMGR_OP_STATE 0
#define IMGMGR_NMGR_OP_UPLOAD 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd68ace8/mgmt/imgmgr/include/imgmgr/imgmgr.h
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/include/imgmgr/imgmgr.h b/mgmt/imgmgr/include/imgmgr/imgmgr.h
index d040a7b..d06da61 100644
--- a/mgmt/imgmgr/include/imgmgr/imgmgr.h
+++ b/mgmt/imgmgr/include/imgmgr/imgmgr.h
@@ -26,15 +26,11 @@
extern "C" {
#endif
-#define IMGMGR_NMGR_OP_LIST 0
+#define IMGMGR_NMGR_OP_STATE 0
#define IMGMGR_NMGR_OP_UPLOAD 1
-#define IMGMGR_NMGR_OP_BOOT 2
-#define IMGMGR_NMGR_OP_FILE 3
-#define IMGMGR_NMGR_OP_LIST2 4
-#define IMGMGR_NMGR_OP_BOOT2 5
-#define IMGMGR_NMGR_OP_CORELIST 6
-#define IMGMGR_NMGR_OP_CORELOAD 7
-#define IMGMGR_NMGR_OP_STATE 8
+#define IMGMGR_NMGR_OP_FILE 2
+#define IMGMGR_NMGR_OP_CORELIST 3
+#define IMGMGR_NMGR_OP_CORELOAD 4
#define IMGMGR_NMGR_MAX_MSG 400
#define IMGMGR_NMGR_MAX_NAME 64
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd68ace8/mgmt/imgmgr/src/imgmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr.c b/mgmt/imgmgr/src/imgmgr.c
index 52ff282..7afd840 100644
--- a/mgmt/imgmgr/src/imgmgr.c
+++ b/mgmt/imgmgr/src/imgmgr.c
@@ -34,22 +34,17 @@
#include "imgmgr/imgmgr.h"
#include "imgmgr_priv.h"
-static int imgr_list2(struct mgmt_cbuf *);
static int imgr_upload(struct mgmt_cbuf *);
static const struct mgmt_handler imgr_nmgr_handlers[] = {
- [IMGMGR_NMGR_OP_LIST] = {
- .mh_read = NULL,
- .mh_write = NULL
+ [IMGMGR_NMGR_OP_STATE] = {
+ .mh_read = imgmgr_state_read,
+ .mh_write = imgmgr_state_write,
},
[IMGMGR_NMGR_OP_UPLOAD] = {
.mh_read = NULL,
.mh_write = imgr_upload
},
- [IMGMGR_NMGR_OP_BOOT] = {
- .mh_read = NULL,
- .mh_write = NULL
- },
[IMGMGR_NMGR_OP_FILE] = {
#if MYNEWT_VAL(IMGMGR_FS)
.mh_read = imgr_file_download,
@@ -59,14 +54,6 @@ static const struct mgmt_handler imgr_nmgr_handlers[] = {
.mh_write = NULL
#endif
},
- [IMGMGR_NMGR_OP_LIST2] = {
- .mh_read = imgr_list2,
- .mh_write = NULL
- },
- [IMGMGR_NMGR_OP_BOOT2] = {
- .mh_read = imgr_boot2_read,
- .mh_write = imgr_boot2_write
- },
[IMGMGR_NMGR_OP_CORELIST] = {
#if MYNEWT_VAL(IMGMGR_COREDUMP)
.mh_read = imgr_core_list,
@@ -85,10 +72,6 @@ static const struct mgmt_handler imgr_nmgr_handlers[] = {
.mh_write = NULL
#endif
},
- [IMGMGR_NMGR_OP_STATE] = {
- .mh_read = imgmgr_state_read,
- .mh_write = imgmgr_state_write,
- },
};
#define IMGR_HANDLER_CNT \
@@ -249,47 +232,6 @@ imgr_find_by_hash(uint8_t *find, struct image_version *ver)
}
static int
-imgr_list2(struct mgmt_cbuf *cb)
-{
- int i;
- int rc;
- uint32_t flags;
- struct image_version ver;
- uint8_t hash[IMGMGR_HASH_LEN]; /* SHA256 hash */
- char vers_str[IMGMGR_NMGR_MAX_VER];
- int ver_len;
- CborEncoder *penc = &cb->encoder;
- CborError g_err = CborNoError;
- CborEncoder rsp, images, image;
-
- g_err |= cbor_encoder_create_map(penc, &rsp, CborIndefiniteLength);
- g_err |= cbor_encode_text_stringz(&rsp, "images");
- g_err |= cbor_encoder_create_array(&rsp, &images, CborIndefiniteLength);
-
- for (i = 0; i < 2; i++) {
- rc = imgr_read_info(i, &ver, hash, &flags);
- if (rc != 0) {
- continue;
- }
- g_err |= cbor_encoder_create_map(&images, &image, CborIndefiniteLength);
- g_err |= cbor_encode_text_stringz(&image, "slot");
- g_err |= cbor_encode_int(&image, i);
- g_err |= cbor_encode_text_stringz(&image, "version");
- ver_len = imgr_ver_str(&ver, vers_str);
- g_err |= cbor_encode_text_string(&image, vers_str, ver_len);
- g_err |= cbor_encode_text_stringz(&image, "hash");
- g_err |= cbor_encode_byte_string(&image, hash, IMGMGR_HASH_LEN);
- g_err |= cbor_encode_text_stringz(&image, "bootable");
- g_err |= cbor_encode_boolean(&image, !(flags & IMAGE_F_NON_BOOTABLE));
- g_err |= cbor_encoder_close_container(&images, &image);
- }
- g_err |= cbor_encoder_close_container(&rsp, &images);
- g_err |= cbor_encoder_close_container(penc, &rsp);
-
- return g_err;
-}
-
-static int
imgr_upload(struct mgmt_cbuf *cb)
{
uint8_t img_data[IMGMGR_NMGR_MAX_MSG];
@@ -461,7 +403,4 @@ imgmgr_module_init(void)
rc = imgr_cli_register();
SYSINIT_PANIC_ASSERT(rc == 0);
#endif
-
- /* XXX: Confirm image under test; this needs to be removed. */
- boot_vect_write_main();
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd68ace8/mgmt/imgmgr/src/imgmgr_boot.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr_boot.c b/mgmt/imgmgr/src/imgmgr_boot.c
deleted file mode 100644
index 34c3bb2..0000000
--- a/mgmt/imgmgr/src/imgmgr_boot.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * 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 <os/os.h>
-#include <os/endian.h>
-
-#include <limits.h>
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <mgmt/mgmt.h>
-#include <bootutil/image.h>
-#include <bootutil/bootutil_misc.h>
-#include <cborattr/cborattr.h>
-#include <hal/hal_bsp.h>
-
-#include "split/split.h"
-#include "imgmgr/imgmgr.h"
-#include "imgmgr_priv.h"
-
-
-int
-imgr_boot2_read(struct mgmt_cbuf *cb)
-{
- int rc;
- struct image_version ver;
- uint8_t hash[IMGMGR_HASH_LEN];
- int test_slot;
- int main_slot;
- int active_slot;
- CborEncoder *penc = &cb->encoder;
- CborError g_err = CborNoError;
- CborEncoder rsp;
-
- g_err |= cbor_encoder_create_map(penc, &rsp, CborIndefiniteLength);
-
- test_slot = -1;
- main_slot = -1;
- active_slot = -1;
-
- /* Temporary hack to preserve old behavior. */
- if (boot_split_app_active_get()) {
- if (split_mode_get() == SPLIT_MODE_TEST_APP) {
- test_slot = 0;
- }
- main_slot = 0;
- active_slot = 1;
- } else {
- boot_vect_read_test(&test_slot);
- boot_vect_read_main(&main_slot);
- active_slot = boot_current_slot;
- }
-
- if (test_slot != -1) {
- rc = imgr_read_info(test_slot, &ver, hash, NULL);
- if (rc >= 0) {
- g_err |= cbor_encode_text_stringz(&rsp, "test");
- g_err |= cbor_encode_byte_string(&rsp, hash, IMGMGR_HASH_LEN);
- }
- }
-
- if (main_slot != -1) {
- rc = imgr_read_info(main_slot, &ver, hash, NULL);
- if (rc >= 0) {
- g_err |= cbor_encode_text_stringz(&rsp, "main");
- g_err |= cbor_encode_byte_string(&rsp, hash, IMGMGR_HASH_LEN);
- }
- }
-
- if (active_slot != -1) {
- rc = imgr_read_info(active_slot, &ver, hash, NULL);
- if (rc >= 0) {
- g_err |= cbor_encode_text_stringz(&rsp, "active");
- g_err |= cbor_encode_byte_string(&rsp, hash, IMGMGR_HASH_LEN);
- }
- }
-
- g_err |= cbor_encode_text_stringz(&rsp, "rc");
- g_err |= cbor_encode_int(&rsp, MGMT_ERR_EOK);
- g_err |= cbor_encoder_close_container(penc, &rsp);
-
- return 0;
-}
-
-int
-imgr_boot2_write(struct mgmt_cbuf *cb)
-{
- int rc;
- uint8_t hash[IMGMGR_HASH_LEN];
- const struct cbor_attr_t boot_write_attr[2] = {
- [0] = {
- .attribute = "test",
- .type = CborAttrByteStringType,
- .addr.bytestring.data = hash,
- .len = sizeof(hash),
- },
- [1] = {
- .attribute = NULL
- }
- };
- struct image_version ver;
-
- rc = cbor_read_object(&cb->it, boot_write_attr);
- if (rc) {
- rc = MGMT_ERR_EINVAL;
- goto err;
- }
-
- rc = imgr_find_by_hash(hash, &ver);
- if (rc >= 0) {
- rc = boot_vect_write_test(rc);
- if (rc) {
- rc = MGMT_ERR_EUNKNOWN;
- goto err;
- }
- rc = 0;
- } else {
- rc = MGMT_ERR_EINVAL;
- goto err;
- }
-
- rc = MGMT_ERR_EOK;
-
-err:
- mgmt_cbuf_setoerr(cb, rc);
-
- return 0;
-}