[GitHub] jacobrosenthal commented on a change in pull request #281: imgmgr: add erase command, remove erase from upload command

2017-05-30 Thread git
jacobrosenthal commented on a change in pull request #281: imgmgr: add erase 
command, remove erase from upload command
URL: 
https://github.com/apache/incubator-mynewt-core/pull/281#discussion_r119246771
 
 

 ##
 File path: mgmt/imgmgr/src/imgmgr.c
 ##
 @@ -223,6 +228,70 @@ imgr_find_by_hash(uint8_t *find, struct image_version 
*ver)
 }
 
 static int
+imgr_erase(struct mgmt_cbuf *cb)
+{
+struct image_version ver;
+int area_id;
+int best = -1;
+int rc;
+int i;
+CborError g_err = CborNoError;
+
+for (i = 0; i < 2; i++) {
+rc = imgr_read_info(i, , NULL, NULL);
+if (rc < 0) {
+continue;
+}
+if (rc == 0) {
+/* Image in slot is ok. */
+if (imgmgr_state_slot_in_use(i)) {
+/* Slot is in use; can't erase to this. */
+continue;
+} else {
+/*
+ * Not active slot, but image is ok. Use it if there are
+ * no better candidates.
+ */
+best = i;
+}
+continue;
+}
+best = i;
+break;
+}
+if (best >= 0) {
+area_id = flash_area_id_from_image_slot(best);
+if (imgr_state.upload.fa) {
+flash_area_close(imgr_state.upload.fa);
+imgr_state.upload.fa = NULL;
+}
+rc = flash_area_open(area_id, _state.upload.fa);
+if (rc) {
+return MGMT_ERR_EINVAL;
+}
+rc = flash_area_erase(imgr_state.upload.fa, 0,
+  imgr_state.upload.fa->fa_size);
 
 Review comment:
   Done
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on 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] jacobrosenthal commented on a change in pull request #281: imgmgr: add erase command, remove erase from upload command

2017-05-30 Thread git
jacobrosenthal commented on a change in pull request #281: imgmgr: add erase 
command, remove erase from upload command
URL: 
https://github.com/apache/incubator-mynewt-core/pull/281#discussion_r119246721
 
 

 ##
 File path: sys/flash_map/include/flash_map/flash_map.h
 ##
 @@ -41,6 +41,7 @@ extern "C" {
  * match the linker scripts when platform executes from flash,
  * and match the target offset specified in download script.
  */
+#include 
 
 Review comment:
   Ah yes. Roger
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on 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] jacobrosenthal commented on a change in pull request #281: imgmgr: add erase command, remove erase from upload command

2017-05-30 Thread git
jacobrosenthal commented on a change in pull request #281: imgmgr: add erase 
command, remove erase from upload command
URL: 
https://github.com/apache/incubator-mynewt-core/pull/281#discussion_r119244439
 
 

 ##
 File path: sys/flash_map/include/flash_map/flash_map.h
 ##
 @@ -41,6 +41,7 @@ extern "C" {
  * match the linker scripts when platform executes from flash,
  * and match the target offset specified in download script.
  */
+#include 
 
 Review comment:
   Yes for bool
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on 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] jacobrosenthal commented on a change in pull request #281: imgmgr: add erase command, remove erase from upload command

2017-05-30 Thread git
jacobrosenthal commented on a change in pull request #281: imgmgr: add erase 
command, remove erase from upload command
URL: 
https://github.com/apache/incubator-mynewt-core/pull/281#discussion_r119244347
 
 

 ##
 File path: sys/flash_map/src/flash_map.c
 ##
 @@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include 
 
 Review comment:
   yes for min, though that could be duplicated so os isnt needed, or put 
somewhere else
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on 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