GithubHelp home page GithubHelp logo

infineon / mtb-example-xmc-flash-bmi Goto Github PK

View Code? Open in Web Editor NEW
0.0 14.0 0.0 381 KB

This example demonstrates how Boot Mode Index (BMI) can be used to configure a customized boot sequence on the XMC device.

Makefile 12.62% C 87.38%
kit-xmc47-relax-v1 peripherals kit-xmc-plt2go-xmc4200 kit-xmc-plt2go-xmc4400 kit-xmc43-relax-ecat-v1 kit-xmc45-relax-v1 kit-xmc48-relax-ecat-v1

mtb-example-xmc-flash-bmi's Introduction

XMC™ MCU: Flash BMI

This example demonstrates how boot mode index (BMI) can be used to configure a customized boot sequence on XMC4000 series of devices.

Warning: This code example involves programming the user configuration blocks (UCB), which can be programmed only a limited number of times. See the Design and implementation section before proceeding with this code example.

Requirements

Supported toolchains (make variable 'TOOLCHAIN')

  • GNU Arm® embedded compiler v10.3.1 (GCC_ARM) - Default value of TOOLCHAIN
  • Arm® compiler v6.16 (ARM)
  • IAR C/C++ compiler v9.30.1 (IAR)

Supported kits (make variable 'TARGET')

Hardware setup

This example uses the board's default configuration. See the kit user guide to ensure that the board is configured correctly.

Software setup

  • Install a terminal emulator if you don't have one. Instructions in this document use Tera Term.
In Eclipse IDE for ModusToolbox™ software
  1. Click the New Application link in the Quick Panel (or, use File > New > ModusToolbox™ Application). This launches the Project Creator tool.

  2. Pick a kit supported by the code example from the list shown in the Project Creator - Choose Board Support Package (BSP) dialog.

    When you select a supported kit, the example is reconfigured automatically to work with the kit. To work with a different supported kit later, use the Library Manager to choose the BSP for the supported kit. You can use the Library Manager to select or update the BSP and firmware libraries used in this application. To access the Library Manager, click the link from the Quick Panel.

    You can also just start the application creation process again and select a different kit.

    If you want to use the application for a kit not listed here, you may need to update the source files. If the kit does not have the required resources, the application may not work.

  3. In the Project Creator - Select Application dialog, choose the example by enabling the checkbox.

  4. (Optional) Change the suggested New Application Name.

  5. Enter the local path in the Application(s) Root Path field to indicate where the application needs to be created.

    Applications that can share libraries can be placed in the same root path.

  6. Click Create to complete the application creation process.

For more details, see the Eclipse IDE for ModusToolbox™ software user guide (locally available at {ModusToolbox™ software install directory}/ide_{version}/docs/mt_ide_user_guide.pdf).

In command-line interface (CLI)

ModusToolbox™ software provides the Project Creator as both a GUI tool and the command line tool, "project-creator-cli". The CLI tool can be used to create applications from a CLI terminal or from within batch files or shell scripts. This tool is available in the {ModusToolbox™ software install directory}/tools_{version}/project-creator/ directory.

Use a CLI terminal to invoke the "project-creator-cli" tool. On Windows, use the command line "modus-shell" program provided in the ModusToolbox™ software installation instead of a standard Windows command-line application. This shell provides access to all ModusToolbox™ software tools. You can access it by typing modus-shell in the search box in the Windows menu. In Linux and macOS, you can use any terminal application.

This tool has the following arguments:

Argument Description Required/optional
--board-id Defined in the <id> field of the BSP manifest Required
--app-id Defined in the <id> field of the CE manifest Required
--target-dir Specify the directory in which the application is to be created if you prefer not to use the default current working directory Optional
--user-app-name Specify the name of the application if you prefer to have a name other than the example's default name Optional

The following example clones the "Flash BMI" application with the desired name "MyFlashBMI" configured for the KIT_XMC_PLT2GO_XMC4200 BSP into the specified working directory, C:/mtb_projects:

project-creator-cli --board-id KIT_XMC_PLT2GO_XMC4200 --app-id mtb-example-xmc-flash-bmi --user-app-name MyFlashBMI --target-dir "C:/mtb_projects"

Note: The project-creator-cli tool uses the git clone and make getlibs commands to fetch the repository and import the required libraries. For details, see the "Project creator tools" section of the ModusToolbox™ software user guide (locally available at {ModusToolbox™ software install directory}/docs_{version}/mtb_user_guide.pdf).

In third-party IDEs

Use one of the following options:

  • Use the standalone Project Creator tool:

    1. Launch Project Creator from the Windows Start menu or from {ModusToolbox™ software install directory}/tools_{version}/project-creator/project-creator.exe.

    2. In the initial Choose Board Support Package screen, select the BSP, and click Next.

    3. In the Select Application screen, select the appropriate IDE from the Target IDE drop-down menu.

    4. Click Create and follow the instructions printed in the bottom pane to import or open the exported project in the respective IDE.


  • Use command-line interface (CLI):

    1. Follow the instructions from the In command-line interface (CLI) section to create the application, and then import the libraries using the make getlibs command.

    2. Export the application to a supported IDE using the make <ide> command.

    3. Follow the instructions displayed in the terminal to create or import the application as an IDE project.

For a list of supported IDEs and more details, see the "Exporting to IDEs" section of the ModusToolbox™ software user guide (locally available at {ModusToolbox™ software install directory}/docs_{version}/mtb_user_guide.pdf).

Operation

  1. Connect the board to your PC using a micro-USB cable through the debug USB connector.

  2. Open a terminal program and select the J-Link CDC UART COM port. Configure the terminal with baud rate of 115200, data bits of 8, stop bits of 1, and with parity and flow control set to none.

  3. Program the board using Eclipse IDE for ModusToolbox™ software:

    1. Select the application project in the Project Explorer.

    2. In the Quick Panel, scroll down, and click <Application Name> Program (JLink).

  4. Once programmed, open your serial terminal software. You should see the shell application displayed as shown follows:

    Figure 1. Shell application

  5. Do the following to install flash read protection using the shell application:

    1. Type status to get the status of the BMI installation and UCB program count:

      >> status
      

      Figure 2. BMI installation status

    2. Type install to install the BMI configuration into UCB2.

      The device will reset after this command for the changes to take effect.

      For example:

      >> install
      

      Figure 3. Install BMI configuration

    3. Check the status to see if the BMI installation was successful. The UCB program count will also be displayed.

      >> status
      

      Figure 4. BMI installation status

    4. Type usb to read the USB serial number loaded into DSRAM1:

      >> usb
      

      Figure 5. USB serial number

    5. Type mac to read the MAC address loaded into DSRAM1:

      >> mac
      

      Figure 6. MAC address

    6. Type ipv4 to read the IPv4 address (LSB) loaded into DSRAM1:

      >> ipv4
      

      Figure 7. IPV4 address (LSB)

Note: If the kit is reset or power cycled when running this example, the program will start in normal mode because of the state of the TMS/TCK pins even if the BMI has been installed previously. Therefore, the BMI installation status will be seen as invalid. Install the BMI string again if this happens.


Debugging

You can debug the example to step through the code. In the IDE, use the <Application name> Debug (JLink) configuration in the quick panel. For details, see the "Program and debug" section in the Eclipse IDE for ModusToolbox™ software user guide.

Design and implementation

XMC4000 family of devices supports several boot modes such as the following:

  • Normal boot mode
  • Alternative boot mode
  • Fallback ABM
  • PSRAM boot mode
  • ASC BSL boot mode
  • CAN BSL boot mode
  • Boot mode index (BMI)

BMI mode allows you to customize the boot sequence using a BMI string. The BMI string is written into the user configuration block 2 (UCB) Page1. This defines the set of activities to be performed on startup.

Upon reset, the startup software copies the BMI string into a 64-byte location in DSRAM1. These 64 bytes can be used to store the MAC address, USB serial number, and the IP address.

In this code example, UCB2 is programmed with a BMI string that copies the MAC address, USB serial number, and the IP address to DSRAM1 before going into normal boot Mode.

A custom linker script specifies the additional size required to store the BMI string in the DSRAM region. It is located in the CUSTOM_DESIGN_MODUS folder of the respective kits. The Makefile variable LINKER_SCRIPT specifies the custom linker script to be selected corresponding to the TARGET being used.

Figure 8. Firmware flow diagram

The code example uses a shell application to take input commands from the user to perform five different operations:

Command Description
install Installs the BMI string into UCB2
usb Retrieves USB serial number from DSRAM1
mac Retrieves the MAC address from DSRAM1
ipv4 Retrieves the IPv4 address from DSRAM1
status Displays the BMI installation status

Warning: The BMI String is modified by erasing and programming the UCB2. The erase and re-program of the UCBs can be performed up to four times. Exceeding this limit may make the device unusable.

Resources and settings

The code example uses a custom design.modus file because it uses the universal serial interface channel (USIC) block to implement the shell application. The following settings were modified in the default design.modus file.

Figure 9. USIC (UART) settings


Figure 10. UART Rx settings


Figure 11. UART Tx settings

Resources Links
Kit guides XMC4200 Platform2GO XTREME kit
XMC4300 relax EtherCAT kit
XMC4400 Platform2GO XTREME kit
XMC4500 relax kit
XMC4700/XMC4800 relax kit series-V1
Code examples on Github Using ModusToolbox™ software
Device documentation XMC4000 family datasheets
XMC4000 family technical reference manuals
Development kits XMC™ MCU eval boards
Libraries on GitHub mtb-xmclib-cat3 – XMC™ MCU peripheral library (XMCLib) and docs
Tools Eclipse IDE for ModusToolbox™ software – ModusToolbox™ software is a collection of easy-to-use software and tools enabling rapid development with Infineon MCUs, covering applications from embedded sense and control to wireless and cloud-connected systems using AIROC™ Wi-Fi and Bluetooth® connectivity devices.

Other resources

Infineon provides a wealth of data at www.infineon.com to help you select the right device, and quickly and effectively integrate it into your design.

For XMC™ MCU devices, see 32-bit XMC™ industrial microcontroller based on Arm® Cortex®-M.

Document history

Document title: CE232718 - XMC™ MCU: Flash BMI

Version Description of change
1.0.0 New code example
1.1.0 Added support for new kits
2.0.0 Updated to support ModusToolbox™ software v3.0.
This CE is not backward-compatible with previous versions of ModusToolbox™ software

All other trademarks or registered trademarks referenced herein are the property of their respective owners.

© 2023 Infineon Technologies AG

All Rights Reserved.

The information given in this document shall in no event be regarded as a guarantee of conditions or characteristics. With respect to any examples or hints given herein, any typical values stated herein and/or any information regarding the application of the device, Infineon Technologies hereby disclaims any and all warranties and liabilities of any kind, including without limitation, warranties of non-infringement of intellectual property rights of any third party.

Information

For further information on technology, delivery terms and conditions and prices, please contact the nearest Infineon Technologies Office (www.infineon.com).

Warnings

Due to technical requirements, components may contain dangerous substances. For information on the types in question, please contact the nearest Infineon Technologies Office.

Infineon Technologies components may be used in life-support devices or systems only with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may be endangered.


mtb-example-xmc-flash-bmi's People

Contributors

cy-msur avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.