3.8.2 Live Update Application on SAM E54 Curiosity Ultra Development Board
Description
The Live update application uses the dual bank Flash feature available on the SAME54 Microcontrollers (MCUs).
The banks on SAME54 MCU are named as BANK-A and BANK-B. At any point in time, the application considers the bank on which it is currently executing as an active bank while the other bank is marked as an inactive bank. The dual bank Flash enables programming the inactive bank with a new version of the firmware while running the current version of the firmware from the active bank.
The application updates the new version of the firmware to the inactive bank while the current version of the firmware runs from the active bank.
The Application Task checks the NVM Control status register to identify the Flash bank which has the latest version of the firmware (active bank) and toggles a specific LED at a periodic rate. For example, when there is no Live update then the LED1 is toggled for every 500ms if the application running from BANK-A else 1000ms if it is running from BANK-B. When there is a Live update request from the Host PC, after receiving the firmware image, the LED1 stops toggling and LED2 starts toggling with the toggle rate same as LED1. After a successful Live update i.e., by pressing the SW2, the device swaps the banks and resets. Then the LED2 stops toggling and LED1 starts toggling. Here, the user can observe the change in the LED1 toggle rate after firmware upgrade. For example, the LED1 is toggled for every 500ms if the application running from BANK-A else 1000ms if it is running from BANK-B.
Modules/Technology Used
- Peripheral Modules:
- NVMCTRL
- DSU
- SYSTICK
- SERCOM
- Harmony Core
Hardware Used
Software/Tools Used
This project has been verified to work with the following versions of software tools:
Refer Project Manifest present in harmony-manifest-success.yml under the project folder firmware/src/config/sam_e54_cult.
- Refer the Release Notes to know the MPLAB X IDE and MCC Plugin version.
- Any Serial Terminal application, such as Tera Term terminal application.
- Windows command prompt.
- Python 3.8.0.
Because Microchip regularly updates tools, occasionally issue(s) could be discovered while using the newer versions of the tools. If the project does not seem to work and version incompatibility is suspected. It is recommended to double-check and use the same versions that the project was tested with. To download original version of MPLAB Harmony v3 packages, refer to document How to Use the MPLAB Harmony v3 Project Manifest Feature (DS90003305).
Programming/Debugging Application Project
- Open the project (same54_uart_live_update/firmware/sam_e54_cult.X) in MPLAB X IDE
- Ensure SAM E54 Curiosity Ultra is selected as hardware tool to program/debug the application
- Build the code and program the device by clicking on the Make and Program Device button in MPLAB X IDE tool bar
- Follow the steps in Running the Demo section below
Running the Bootloader Application
- Download the MPLAB Harmony Bootloader package.
- Download the MPLAB Harmony UART Bootloader Applications package.
- Connect a micro USB cable to the DEBUG port of the SAM E54 Curiosity Ultra Development Board.
- Open the UART Fail Safe Bootloader
which is in
using the MPLAB X IDE.<Your Harmony Framework download Path: folder>/bootloader_apps_uart/apps/uart_fail_safe_bootloader/bootloader/firmware/sam_e54_xpro.X
- The project needs to be reconfigured to
work on SAM E54 Curiosity Ultra Development Board. Launch the MCC and follow below steps
to reconfigure for SAM E54 Curiosity Ultra Development Board.
- Remove SERCOM2.
- Add SERCOM1 to Project Graph.
- Configure SERCOM1 peripheral.
- Launch Pin Configurations plugin under MCC->Tools->Pin
Configurations. Remove SERCOM2 Pin configurations.
- Configure SERCOM1 pins.Note:
- The SAM E54 Curiosity Ultra Development Board uses SERCOM1 peripheral for EDBG. Therefore, SERCOM peripheral and its pins need to be reconfigured from SAM E54 Xplained Pro to SAM E54 Curiosity Ultra Development Board.
- Do not close the MCC as the user has to build the project again.
- Remove SERCOM2.
- Regenerate the project. Build and program the UART Fail Safe Bootloader using the MPLAB X IDE.
- The following shows the steps to
rebuild the UART Fail Safe Bootloader using the MPLAB X IDE. This step is to create
Bootloader binary image which will be merged with Live Update application to create a
single binary image as shown in Step 10.
- Remove the Device Fuse
configurations from the custom linker script as the user will be updated by the UART
Fail Safe Bootloader project.
- Enable Execute this line After Build option in the MPLAB X Project properties->
Building option.
- Regenerate the project.
- Remove the Device Fuse
configurations from the custom linker script as the user will be updated by the UART
Fail Safe Bootloader project.
- Build the UART Fail Safe Bootloader
application again using the MPLAB X IDE but do not program.
- This is required to generate the binary file for Bootloader application.
- Build the Live update application
(path:
<Live Update application folder>/firmware/sam_e54_cult.X
) using the MPLAB X IDE but do not program. - Run the btl_app_merge_bin.py
script from command prompt to merge the generated Bootloader binary and Live update
application
binary.
python <Your Harmony Framework download folder>/bootloader/tools/btl_app_merge_bin.py -o 0x2000 -b <Your Harmony Framework download folder>/bootloader_apps_uart/apps/uart_fail_safe_bootloader/bootloader/firmware/sam_e54_xpro.X/dist/<Config Name>/production/<Project Name>.production.bin -a <Live Update application folder>/hex/sam_e54_cult.X.production.bin
Below output should be displayed on command prompt.
- Run the btl_host.py from command
prompt to program the merged binary to opposite panel. The merged binary
btl_app_merged.bin will be generated in the path from where the
btl_app_merge_bin.py was called
from.
python <Your Harmony Framework download folder>/bootloader/tools/btl_host.py -v -s -i <COM PORT> -d same5x -a 0x00080000 -f btl_app_merged.bin
Note: If the user needs to know more information on the bootloader host script, refer help for setting up the host script available at<Your Harmony Framework download folder>/bootloader/doc/help_bootloader.chm and <Your Harmony Framework download folder>/bootloader_apps_uart/docs/index.html
- Following screenshot shows successful
programming of the application binary.
The messages Swapping Bank And Rebooting and Reboot Done in before screenshot signifies that bootloading is successful.
Running the Live Update Application
- Perform Running the Bootloader application steps mentioned above, if not done already.
- If the above step is successful, then LED1 should start blinking on the SAM E54 Curiosity Ultra Development Board.
- Run the host script
live_update.py from command prompt available at
<Live Update application folder>/scripts
to program the new version of the firmware to an inactive panel while the current version of the application is being run from the active panel.python <Live Update application folder>/scripts/live_update.py -v -i <COM PORT> -d same5x -a <Address> -f btl_app_merged.bin
The merged binary btl_app_merged.bin will be generated in the path from where the btl_app_merge_bin.py was called from.
Note: If the user needs to know more information on the Live Update Script, open command prompt, go to<Live Update application folder>/scripts
then enterpython live_update.py --help
. The below output shows the Live Update Script help.Below output should be displayed on command prompt.
- LED1 stops blinking and LED2 starts
blinking which indicates the application programming is successful.
- LED1 stops blinking and LED2 toggles for every 500 ms then Application is running from BANK A
- LED1 stops blinking and LED2 toggles for every 1000 ms then Application is running from BANK B
- Press Switch SW2 to swap the
bank and reset the device for the programmed application firmware to run.
- LED2 stops blinking and LED1 toggles for every 500ms then Application is running from BANK A
- LED2 stops blinking and LED1 toggles for every 1000ms then Application is running from BANK B
- In case of any error during the Live update both LED1 and LED2 will be turned ON. Follow the below steps recover from the error.
Comments
- Reference Application Note: Live Update application on SAME54 MCUs using MPLAB Harmony v3
- This application demo builds and
works out of box by following the instructions above in Running the Demo
section. If the user needs to enhance/customize this application demo, should use the
MPLAB Harmony v3 Software framework. Refer links below to setup and build the
applications using MPLAB Harmony.
- How to Setup MPLAB Harmony v3 Software Development Framework (DS90003232).
- How to Build an Application by Adding a New PLIB, Driver, or Middleware to an Existing MPLAB Harmony v3 Project (DS90003253).
- Video - How to Set up the Tools Required to Get Started with MPLAB® Harmony v3 and MCC
- Create a new MPLAB Harmony v3 project using MCC
- Update and Configure an Existing MHC-based MPLAB Harmony v3 Project to MCC-based Project