Read me file for secure CAN FD bootloader demo application, NXP LPC54618
by Embedded Systems Academy, www.esacademy.com, July 2017

Overview
========
The LPCXpresso54618 test application project is a demonstration program to test the function of the
secure CAN FD bootloader. The example uses LEDs and push buttons to control the LEDs and to force
the execution of the secure bootloader again through reset.

WARNING:
  THIS DEMO USES DEFAULT KEYS THAT ARE NOT SECURE! NEVER USE THESE KEYS IN PRODUCTION SOFTWARE!

Generating encrypted code update file
=====================================
The secure code update file is auto-generated with the build process. The process is described
further below.

If you only want to re-generate a secure update file using another key, proceed as follows:
a) unpack the zip archive
b) paste the key to use to file "key_mf.txt" 
c) execute Utilities/FirmwareEncrypt.cmd
This generates the secure update file at Release\lpcxpresso54618_test_app_sec.bin


Hardware requirements
=====================
- Micro USB cable
- LPCXpresso54618 board with CAN shield
- PEAK CAN FD interface
- Personal Computer

Board settings
==============
No special settings are required.

Running the demo
================
Close jumper J5 (DFU Link). Connect the Micro USB cable to the debug port on the board. With the
Flash Magic software, select "LPC54618J512" part with SWD interface, then download the secure
bootloader (with default keys) hex file to the board. Refer to the bootloader documentation for
further details.
Disconnect the Micro USB cable and open jumper J5 (DFU Link), then connect the cable again. Now the
secure bootloader will be active and communicating via the CAN0 (upper) port. Connect the CAN0
port to the PEAK CAN FD interface. Use either a terminated CAN cable, or an unterminated cable
with the termination on the CAN shield enabled. Don't use both termination options at the same time.
In the Flash Magic software, select "LPC54618J512 CAN" with default CANcrypt key ID and key. Via
ISP - Read Device Signature you should now test secure communication to the bootloader. If that
works, select the test application lpcxpresso54618_test_app_sec.bin file, check "erase all flash"
and hit "Start". After successful programming, after a reset the test application will start up.

- You will see a running light on LED1..LED3
- Pushing the button SW2 will speed up the running light, SW3 will slow it down and SW4 will
  toggle between a running light and an inverted running light.
- Pushing SW5 will generate a reset after setting a special flag in RAM to execute the secure
  bootloader again.

Building the Demo
=================
Import the project in lpcxpresso54618_test_app_mcuxpresso.zip into your MCUXpresso workspace:

Import - General - Existing Projects into Workspace - Next - Select archive file

Build the 'Release' target. Note the call of the 'hexsum' and 'FirmwareEncrypter' tools in the
post-build steps. The secure firmware update file is now at
lpcxpresso54618_test_app\Release\lpcxpresso54618_test_app_sec.bin.

The manufacturer key is taken from the lpcxpresso54618_test_app\key_mf.txt file.

