.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Jun 06 10:45:20 2017 +0100
Parent:
10:0378ca4ea345
Child:
12:09cdcd74a245
Commit message:
Merge pull request #9 from 0xc0170/fix_config_update_file

Config used for update file path
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-bootloader

Changed in this revision

README.md Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- a/README.md	Thu May 25 15:30:17 2017 +0100
+++ b/README.md	Tue Jun 06 10:45:20 2017 +0100
@@ -76,10 +76,12 @@
 
 It creates two binary files. The original uncombined image is in the output directory, <project-name>_application.bin, and the bootloader image is <project-name>.bin.
 
-When the build succeeds, you have created a bootloader for your target. This bootloader defines the update file to be located at `/sd/mbed-os-example-bootloader-blinky_application.bin`. This is the binary bootloader flashes and then jumps to.
+When the build succeeds, you have created a bootloader for your target. This example defines the application file to be located at `/sd/mbed-os-example-blinky_application.bin` in the application config file ``mbed_app.json``. This is the application binary bootloader flashes and then jumps to.
 
 ## Set up application to use bootloader
 
+### Program bootloader and application
+
 The next step is to build an application you can combine with your bootloader to create a loadable image. 
 
 1. Update your board to use the newly created bootloader image. To do this, set the target (replace `<TARGET_NAME>` with your target name) value `bootloader_img` to the file path of the bootloader image.
@@ -99,16 +101,15 @@
     mbed compile -m <TARGET_NAME> -t ARM
     ```
 
-### Program bootloader and application
 
 1. Connect your mbed device to the computer over USB.
-1. Copy the application binary file to the mbed device.
+1. Copy the binary file (``<program name.bin>``) to the mbed device.
 1. Press the reset button to start the program.
 
 ### Program application using SD card
 
 1. Connect the SD card to your computer.
-1. Copy the application binary to the root of the SD card.
+1. Copy the application binary (``<program name>_application.bin``, we defined it earlier as ``mbed-os-example-blinky_application.bin``) to the root of the SD card.
 1. Remove the SD card from your PC, and plug it into the mbed board.
 1. Press the reset button to start the firmware update.
 
--- a/main.cpp	Thu May 25 15:30:17 2017 +0100
+++ b/main.cpp	Tue Jun 06 10:45:20 2017 +0100
@@ -2,8 +2,6 @@
 #include "SDBlockDevice.h"
 #include "FATFileSystem.h"
 
-#define UPDATE_FILE     "/sd/mbed-os-example-bootloader-blinky_application.bin"
-
 SDBlockDevice sd(D11, D12, D13, D10);
 FATFileSystem fs("sd");
 FlashIAP flash;
@@ -15,14 +13,14 @@
     sd.init();
     fs.mount(&sd);
 
-    FILE *file = fopen(UPDATE_FILE, "rb");
+    FILE *file = fopen(MBED_CONF_APP_UPDATE_FILE, "rb");
     if (file != NULL) {
         printf("Firmware update found\r\n");
 
         apply_update(file, POST_APPLICATION_ADDR);
 
         fclose(file);
-        remove(UPDATE_FILE);
+        remove(MBED_CONF_APP_UPDATE_FILE);
     } else {
         printf("No update found to apply\r\n");
     }
--- a/mbed_app.json	Thu May 25 15:30:17 2017 +0100
+++ b/mbed_app.json	Tue Jun 06 10:45:20 2017 +0100
@@ -9,5 +9,8 @@
         "UBLOX_EVK_ODIN_W2": {
             "target.restrict_size": "0x20000"
         }
+    },
+    "config": {
+        "update_file": "\"/sd/mbed-os-example-blinky_application.bin\""
     }
 }