MCUXpresso SDK Documentation

Hardware requirements#

  • FRDM-IMXRT1186

  • RJ45 Network cable

  • Mini/micro USB cable

  • Personal Computer on which the TwinCat3 has been installed(Windows 10 is recommended)

Board settings#

  • J12(2-3)/J13(2-3): eCAT0 Function Via J57A(Default).

  • J18(2-3)/J17(2-3): eCAT1 Function Via J57B(Default).

MCUBoot layout#

Region

From

To

Size

MCUboot code

0x04000000

0x0403FFFF

256kB

Primary slot

0x04040000

0x0423FFFF

2048kB

Secondary slot

0x04240000

0x0443FFFF

2048kB

  • MCUBoot header size is set to 1024 bytes

  • Signing algorithm is ECDSA-P256

  • Write alignment is 4 bytes

  • MCUBoot is configured to use SWAP_MOVE image handling strategy

Prepare the Demo#

  1. Generate the SSC source code

    • Download Slave Stack Code Tool(SSC Tool V5.13) from BECKHOFF official website and install it

    • Open Slave Stack Code Tool

    • Click ‘File’ -> ‘New’ -> ‘Import’ to import the Congfig file Select foe.xml under path ‘.\boards\frdmimxrt1186\ecat_examples\foe<core>\SSC’.

    • Click ‘Custom’ -> ‘NXP ECAT…’ -> ‘OK’ to select the subdevice description file

    • Click ‘Tool’ -> ‘Application’ -> ‘Import’ to import Application information Select foe.xlsx under path ‘.\boards\frdmimxrt1186\ecat_examples\foe<core>\SSC’.

    • Click ‘Project’ -> ‘Create new Slave Files’ ‘Source Folder’(default): ‘.\boards\frdmimxrt1186\ecat_examples\foe<core>\SSC\Src’. Click ‘Start’.

    • Remove foe.c under Src folder

  2. Connect EtherCAT Port0 with TwinCAT3

    • RJ45 interface labeled as J57A is the EtherCAT Port0 and RJ45 interface labeled as J57B is the EtherCAT Port1.

  3. Connect a USB cable between the host PC and the OpenSDA USB port on the target board

  4. Open a serial terminal with the following settings

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  5. Compile mcuboot_opensource and FoE example image

    • mcuboot_opensource example path: ‘boards\frdmimxrt1186\ota_examples\mcuboot_opensource\cm33’

    • FoE example path: ‘boards\frdmimxrt1186\ecat_examples\foe\cm33’

  6. Download mcuboot_opensource and signed FoE image to the target board using ‘MCUXpresso Secure Provisioning Tool’

    • Download ‘MCUXpresso Secure Provisioning Tool’ from NXP official website

    • Change J60(from left to right)[1,2,3] to ‘100’ to open Serial Download mode, reset board

    • Open ‘SPT’ and create a new workspace for the selected processor

    • Connect the board via UART

    • Verify the selected boot memory in ‘main menu’ > ‘Target’ > ‘Boot Memory’

    • On the Build image view, select the ‘mcuboot_opensource_cm33.elf’ image as ‘Source executable image’

    • Open ‘main menu’ > ‘Tools’ > ‘MCUboot’ > ‘Sign Image’ and configure the following

      • ‘ecat_foe.bin’ image to be signed

      • The signing key; it is located in the same folder that the prebuilt application or in MCUXpresso SDK, in folder ‘middleware\mcuboot_opensource\boot\nxp_mcux_sdk\keys\sign-ecdsa-p256-priv.pem’

      • The imgtool arguments by default should match the SDK example. It is not needed to change them

      • Click the ‘Sign’ button to sign the application; fix problems, if any

      • Set target address: ‘0x04040000’

      • Close the dialog by clicking the ‘Save & Close’ button

    • On the Build tab, double-check that the ‘Build script hooks’ section contains the pre-build script

    • Open ‘Additional Images’ and check that the signed application is properly configured as ‘Image 1’

    • Build and write the bootable image into the processor

    • Note: You can refer ‘MCUboot workflow’ chapter of ‘MCUXSPTUG.pdf’, which is from ‘SPT Documentation website page’

  7. Run FoE example

    • Change J60(from left to right)[1,2,3] to ‘001’, reset board

    • The serial port will output:

      hello sbl. Bootloader Version 1.9.0 Primary image: magic=good, swap_type=0x1, copy_done=0x3, image_ok=0x1 Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3 Boot source: primary slot Swap type: none Bootloader chainload address offset: 0x40000 Reset_Handler address offset: 0x40400 Jumping to the image

      Start the SSC FoE example… Image version: 2.3.0

  8. Update ESI file to EEPROM

    • Copy ESI file ‘ECAT-FOE.xml’ generated by SSC TOOL to <TwinCAT_installation_folder>/<twincat_version>/Config/io/EtherCAT/

    • Restart TwinCAT3 IDE

    • Scan device and Update EEPROM

  9. Scan and load this device and create a PLC project in TwinCat3

    The PLC Main code is as follows:

     PROGRAM MAIN
     VAR 
     	Delay : TON;
     	LedIn AT %I* : BOOL; 
     	LedOut AT %Q* : BOOL;
     END_VAR
     
     Delay(IN := TRUE, PT := T#1S);
     IF Delay.Q THEN
     	LedOut := NOT LedIn;
     	Delay(IN := FALSE);
     END_IF;
    
  10. Activate configuration

    • Click ‘TwinCAT’ -> ‘Restart TwinCAT(Config Mode)’ to activate configuration

  11. FoE image upgrade

    • Generate new version FoE example signed image ‘imgtool sign –key sign-ecdsa-p256-priv.pem –align 4 –header-size 0x400 –pad-header –slot-size 0x200000 –max-sectors 800 –version “2.4.0” ecat_foe_cm33.bin ecat_foe_2-4-0_SIGNED.bin’

    • Click ‘Device’ -> ‘Box1’ -> ‘Online’ -> ‘Bootstrap’

    • Click ‘Download’ -> ‘ecat_foe_2-4-0_SIGNED.bin’ -> ‘Password: 12369874’ -> ‘Ok’ to upgrade image

    • The serial port will output:

        Firmware upgrade in progress...
      
        FoE_StoreImage: processed 116 bytes
      
        FoE_StoreImage: processed 232 bytes
      
        ...
      
        FoE_StoreImage: upload complete (42028 bytes)
      
        write magic number offset = 0x43ff00
      
        Update image success
      
    • After download, click ‘Init’ to restart board

  12. FoE image download

    • Click ‘Upload’ -> ‘ecat_foe_2-4-0_SIGNED.bin’ -> ‘Ok’ to download upgraded image

Note:

-	For subsequent upgrades, new version number must be greater than the old version number, perform step 11 to generate the new version signed image
-	For more mcuboot information, please refer to mcuboot_opensource example