You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/01/29 12:46:06 UTC

[GitHub] [incubator-nuttx-apps] pkarashchenko commented on a change in pull request #934: examples: Add mcuboot Swap Test example

pkarashchenko commented on a change in pull request #934:
URL: https://github.com/apache/incubator-nuttx-apps/pull/934#discussion_r795048628



##########
File path: examples/mcuboot/swap_test/version_main.c
##########
@@ -0,0 +1,125 @@
+/****************************************************************************
+ * apps/examples/mcuboot/swap_test/version_main.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <endian.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <bootutil/bootutil_public.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define BOOT_HEADER_MAGIC_V1 0x96f3b83d
+#define BOOT_HEADER_SIZE_V1  32
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct mcuboot_raw_header_v1
+{
+  uint32_t header_magic;
+  uint32_t image_load_address;
+  uint16_t header_size;
+  uint16_t pad;
+  uint32_t image_size;
+  uint32_t image_flags;
+  struct
+  {
+    uint8_t  major;
+    uint8_t  minor;
+    uint16_t revision;
+    uint32_t build_num;
+  } version;
+  uint32_t pad2;
+} __packed;

Review comment:
       Please use definitions from `compiler.h`

##########
File path: examples/mcuboot/swap_test/set_img_main.c
##########
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * apps/examples/mcuboot/swap_test/set_img_main.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/boardctl.h>
+
+#include <bootutil/bootutil_public.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * mcuboot_set_img_main
+ ****************************************************************************/
+
+int main(int argc, FAR char *argv[])
+{
+  boot_set_pending_multi(0, 0);
+
+  printf("Requested update for next boot. Restarting...\n");
+
+  fflush(stdout);
+  fflush(stderr);
+
+  usleep(1000);
+
+  boardctl(BOARDIOC_RESET, EXIT_SUCCESS);

Review comment:
       ```suggestion
     boardctl(BOARDIOC_RESET, 0);
   ```
   




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org