アプリケーションノート 5393

Getting Started with DeepCover Secure Microcontroller (MAXQ1050) Evaluation (EV) Kit and the Rowley CrossStudio Compiler for the MAXQ30


要約: This application note describes how to create, build, and debug applications targeted for the DeepCover® Secure Microcontroller (MAXQ1050) with RISC architecture. The example presented in this article uses the Rowley CrossStudio for the MAXQ30 compiler to demonstrate how the MAXQ1050 can read a smart card.

Introduction

The DeepCover® Secure Microcontroller (MAXQ1050) is a low-power microcontroller, designed for USB secure token and smart card reader applications that require certificate-based or other public key cryptographic schemes. The device uses the 32-bit, pipelined, MAXQ30 microcontroller CPU. The MAXQ1050 has 128KB flash memory, 12KB of volatile SRAM, 4KB of battery-backed NV SRAM, and 256B of battery-backed secure zeroization NV SRAM.
The microcontroller is powered either from the USB bus or by a separate 3.3V supply. A battery connection is provided for applications that need to maintain data in the NV SRAMs. In battery-backed mode, the NV SRAM and security sensors consume less than 240nA (typ).
The MAXQ1050 has a number of important features, including:
  • High-performance, low-power, 32-bit MAXQ30 RISC core
  • Operates from USB power or a single 3.3V supply
  • Runs from 20MHz (typ) internal oscillator
  • Supports external 12MHz/24MHz crystal oscillator for microcontroller and USB operation
  • On-chip 2x/4x clock multiplier
  • 16-bit instruction word, 32-bit internal data bus
  • 16 x 32-bit accumulators
  • 16 x 32-bit general-purpose working registers
  • Up to 20 general-purpose I/O pins
  • 5V tolerant I/O
  • Memory:
    • 128KB flash memory
    • 256B of secure NV SRAM
    • 4KB battery-backed NV SRAM
    • 12KB SRAM
  • Security:
    • Unique 64-bit serial number
    • Tamper detection with rapid key/data destruction
    • Secret key destruction on tamper events
    • Permanent loader lockout option
    • Hardware accelerators for AES, RSA, DSA, ECDSA, DES, 3DES, SHA-1, SHA-224, SHA-256
    • True hardware random-number generator
    • Temperature and voltage sensors to detect attacks
    • Two self-destruct input pins
  • Additional peripherals
    • Power-fail warning
    • Power-on-reset/brownout reset
    • JTAG I/F for system programming and accessing on-chip debugger
    • Full-speed USB device with six endpoint buffers and integrated transceiver
    • ISO 7816 smart card UART with FIFO
    • 16-bit programmable timers/counters with prescaler, capture/compare, and PWM
    • SPI master/slave hardware
    • Programmable watchdog timer
    • Up to 20 general-purpose I/O pins with eight external interrupts
The MAXQ1050 evaluation (EV) kit provides a proven, reliable platform for developing low-power applications for the MAXQ1050 processor. The kit includes a RS-232 serial port, a native USB port, 4 pushbuttons for user input, 4 LEDs for application usage, and headers for accessing all the MAXQ1050's I/O pins. Jumpers are provided that allow configuration of the smart card interface. A separate MAXQ622 is also included and provides the JTAG interface to the MAXQ1050 and the host loader/debugger.

Setting Up the MAXQ1050 EV Kit

A photograph of the MAXQ1050 EV kit board is provided in Figure 1. The following hardware components are contained in the EV kit. These components are used for implementing and verifying the demonstration program in this application note:
  1. MAXQ1050 EV kit board
  2. USB cable (Type A to Mini-B)
  3. Regulated power supply (5V, ±5%, 300mA, center positive)
  4. RS-232 serial cable (9-pin male to 9-pin female)
  5. Smart card
The MAXQ1050 has a number of jumpers to configure. The jumpers should be configured as shown in Table 1. See Figure 2 for jumper locations.
Figure 1. The MAXQ1050 EV kit.
More detailed image.
(PDF, 5.9MB)
Figure 1. The MAXQ1050 EV kit.
Table 1. Jumper Configurations for the MAXQ1050 EV Kit Board
Jumper(s) State Purpose if Jumper is Present
JH1 Present Smart card V50 power - from V50
JH2 Present VDD LED on
JH3 Removed CLKDIV1 (pull up/down)
JH4 Removed CLKDIV2 (pull up/down)
JH5 Removed 5V_3V (pull up/down)
JH6 Removed 1.8V (pull up/down)
JH7 Present VDD power
JH8 Present JTAG reset
JH9 Present Smart card VDD power - from VDD
JH10 VBAT+VDDIO Connects VBAT to VDDIO
JH11 Present TDO - JTAG
JH12 Present TMS - JTAG
JH13 Present TDI - JTAG
JH14 Present TCK -JTAG
JH15 Present CLKDIV1 - P1.7 - smart card
JH16 Present DUT_VDD
JH17 Present SC_IO - P1.3 - smart card
JH18 Present RXD - P1.0
JH19 Present SC_CLK - P1.2 - smart card
JH20 Present TXD - P1.1
JH21 Present CLKDIV2 - P0.7 - smart card
JH22 Present 5V_3V - P0.6 - smart card
JH23 Present RS 232 PWR
JH24 Present 1_8V - P0.5 - smart card
JH25 Present AUX2IN - P0.4 - smart card
JH26 Present VBUS/V45
JH27 Present AUX 1 IN - P0.3 - smart card
JH28 Present SC_OFF - P0.2 - smart card
JH29 Present SC_RST - P0.1 - smart card
JH30 Present P0.0 LED enable
JH31 Present P0.1 LED enable
JH32 Present P0.2 LED enable
JH33 Present P0.3 LED enable
JH34 Removed SDI1 closed
JH35 Removed SDI2 closed
JH36 Present CMDVCC - P0.0 - smart card
Figure 2. Location of jumpers on the MAXQ1050 EV kit.
Figure 2. Location of jumpers on the MAXQ1050 EV kit.

Setting Up the Serial-to-USB Driver

The MAXQ1050 evaluation kit is designed to interface to the host PC over a USB interface, which allows software running on the host to communicate with the JTAG loader/debuger on the MAXQ1050 microcontroller.
Connecting the USB cable between the PC and the EV kit will cause Windows 7 to start the driver installation. The USB cable is plugged into "CN1 JTAG USB" on the EV kit. The driver creates a virtual COM port on the PC. In the event that the PC does not detect your driver, you can manually browse and select the driver in the resource library package \install folder.
To determine the virtual COM port connected to the USB cable, click on the Windows Start menu, then Control Panel, and then Device Manager. In the Device Manager window, open the section of the tree display labeled Ports (COM & LPT). You should see a listing for MAXQ USB Serial Port (COMX), where X is the number of the COM port that has been assigned. Figure 3 has an image of the Device Manger window showing the COM9 serial port.
This COM port number may vary depending on previously installed devices and previous USB-to-serial drivers that have been installed. Make note of the virtual COM port that is connected to the MAXQ1050 USB so that you can reference it later if and when you use the Rowley CrossWorks Compiler for development.
Figure 3. Example showing COM9 as the MAXQ® USB Serial Port.
Figure 3. Example showing COM9 as the MAXQ® USB Serial Port.

Installing and Using the Microcontroller Tool Kit (MTK2)

The code in this application note outputs data through the RS-232 connector. To view the data, we need a terminal or a terminal emulator. One option for the terminal emulator is to use the Maxim-provided Microcontroller Tool Kit (MTK2) utility. If you have not already installed MTK2, you can do so by following the link provided in the resource library package.
After installing MTK2, run it from the Start menu. In the initial Select device dialog box, select Dumb Terminal and click OK (Figure 4). This opens MTK2 in a simple text terminal emulator mode (as opposed to a mode designed to communicate directly with the loader of a specific device).
Figure 4. Initial device selection in MTK2.
Figure 4. Initial device selection in MTK2.
Next, you will need to configure and open the serial port. From the MTK2 menu, select Options > Configure Serial Port. In the dialog box that appears, select the physical COM port to which your serial cable is connected (or the virtual COM port if you are using a USB-to-serial adapter) and select 115200 for the Speed setting (Figure 5). (Note: if the COM port number you want to use is not shown in the drop-down list, you can enter it directly in the Port field).
Figure 5. Configuring the Serial Port in MTK2.
Figure 5. Configuring the Serial Port in MTK2.
Finally, select Target > Open COMx at 115200 baud from the menu. The main section of the MTK2 window will turn white to indicate that the port has been opened.

Getting and Installing the Rowley Compiler

Go to www.rowley.co.uk/maxq30/index.htm in your browser (Figure 6). The page that appears may look different than the one displayed in Figure 6, due to browser compatibility and future Rowley page updates.
Figure 6. Rowley's MAXQ download page.
More detailed image.
(PDF, 2.4MB)
Figure 6. Rowley's MAXQ download page.
Click on Version 2.2.0 for Windows or the latest version that is available. The browser will ask you where to save this file. Select a directory and save the file (Figure 7 and Figure 8).
Figure 7. Request by browser to save compiler installation program.
Figure 7. Request by browser to save compiler installation program.
Figure 8. Saving the Rowley setup program to a temporary directory.
More detailed image.
(PDF, 597KB)
Figure 8. Saving the Rowley setup program to a temporary directory.
Using Windows Explorer, go to the directory to which you downloaded the install file and double-click on the file name. Your screen will dim under Windows 7 and you will be asked Do you want to allow the following program to make changes to your computer? Click Yes. The software will begin extracting files and you will see a Welcome window (Figure 9). Click on Next>.
Figure 9. Starting the compiler installation.
Figure 9. Starting the compiler installation.
A License Agreement window will be displayed (Figure 10). Accept the agreement and click Next>.
Figure 10. Accepting the license agreement.
Figure 10. Accepting the license agreement.
A new window will ask for a place to install the compiler (Figure 11). Select a directory and click Next>.
Figure 11. Installing the compiler to the default directory.
Figure 11. Installing the compiler to the default directory.
The next window asks for the program folder name to be used in the Start menu (Figure 12). Select a name and click Next>.
Figure 12. Selecting the default program folder.
Figure 12. Selecting the default program folder.
The Associate Files window will follow (Figure 13). Click Next>.
Figure 13. Accepting the file associations.
Figure 13. Accepting the file associations.
Now we get the Start Installation window (Figure 14). Click Install.
Figure 14. Starting the actual compiler install.
Figure 14. Starting the actual compiler install.
The last window to come up is the Installation Complete. Click Finish.
Click the Windows 7 Start icon and then All Programs > Rowley Associates > CrossWorks for MAXQ30 2.2 > CrossStudio for MAXQ30 2.2 (Figure 15).
Figure 15. Searching through the All Programs list to find the compiler.
Figure 15. Searching through the All Programs list to find the compiler.
The compiler is up, but not licensed (Figure 16). Notice in the Update pane that there are updates to install. After activating the compiler, install the update.
Figure 16. The opening CrossStudio window.
More detailed image.
(PDF, 1.7MB)
Figure 16. The opening CrossStudio window.
Under the Tools button, click License Manager (Figure 17).
Figure 17. License Manger.
Figure 17. License Manger.
We intend to 'evaluate' the compiler. After selecting this option, the request shown in Figure 18 appears. Click Send e-mail to use your built-in email program. You can also select and copy the data in the Activation Request window, paste it into a different email program, and then send it off to .
Figure 18. Activation request.
Figure 18. Activation request.
An activation key will be returned to you in a few hours. Copy the activation key from the email and paste it into the indicated window of the Activate CrossWorks window (Figure 19). These keys are unique to your hardware. Click on Install License.
Figure 19. An activation key pasted into the Activate CrossWorks window.
Figure 19. An activation key pasted into the Activate CrossWorks window.
The evaluation license will now appear, along with the days remaining that you can use it (Figure 20).
Figure 20. Thirty-day activation for the compiler.
Figure 20. Thirty-day activation for the compiler.
Close this window and exit the compiler.

Getting Started with the Rowley Compiler

This demonstration program is a simple application that will open the serial port and display a request to insert the smart card. Once the card is detected, it is powered and the answer-to-reset (ATR) data is printed. The ATR has information about communication parameters and the cards nature and state. It must conform to the ISO/IEC 7816 standard.
From the MAXQ1050 EV Kit resource library package, copy the directory from \Sample Code\C\isouart to the CrossWorks projects directory. On Windows 7, this directory is located under \Users\<username>\My Documents\CrossWorks Projects. (This user guide is using <username> as a generic name.)
Start the Rowley CrossStudio for MAXQ30 compiler (Figure 21). Notice that this CrossStudio window has the time left on the evaluation and update status.
Figure 21. A licensed compiler with an update to be installed.
More detailed image.
(PDF, 1.7MB)
Figure 21. A licensed compiler with an update to be installed.
In the Updates pane, click Install. The Package Manger will bring up the Summary window (Figure 22).
Figure 22. A sample update that needs to be installed.
More detailed image.
(PDF, 361KB)
Figure 22. A sample update that needs to be installed.
Click on the Next button to install the update (Figure 23).
Figure 23. Finished loading the update.
Figure 23. Finished loading the update.
Click on the Finish button and start a new project.
Under File, select New Project (Figure 24). In the New Project window, under Project Templates, select A C executable. Enter ISOUart into the Name field. Append isouart to the location path in the Location field. Click Next.
Figure 24. New Project window.
Figure 24. New Project window.
Under Code Generation Options (Figure 25), find Target Processor, and select MAXQ1050 from the pull-down list. Leave all the other options with the default value. Click Next.
Figure 25. Selecting the MAXQ1050 and other code generation options.
Figure 25. Selecting the MAXQ1050 and other code generation options.
The next window (Figure 26) has some of the files to compile. The file main.c is already in the source directory, so just press the Next button.
Figure 26. New project files.
Figure 26. New project files.
The next window (Figure 27) lets us create directories for both a debug version and a release version of our project. Both should be selected. Click Finish.
Figure 27. Selecting the debug and release directories.
Figure 27. Selecting the debug and release directories.
The project now requests to create a new main.c (Figure 28). Use the existing one, so click No.
Figure 28. Compiler request to create a new main.c.
Figure 28. Compiler request to create a new main.c.
On right-hand side of the window and a few lines down, you will find the Project Explorer (Figure 29). Click the + symbol in front of Project 'ISOUart'. Click the + symbol in front of Source Files to reveal main.c.
Highlight and right-click on Source Files. Click Add Existing File.... Highlight delay.c, MAXQ30_7816_LIB.C, and serial.c, and press Open. If you hold the Ctrl key, you can select all three files at once. Repeat the process, and select delayasm.asm. Click Open.
It is now time to power up your MAXQ1050 EV KIT. Plug in the JTAG USB cable to CN1 and your computer. Connect the 9-pin serial cable to the 9-pin connector on the EV kit and to the computer's serial port. This application note assumes that the 9-pin serial cable is connected to COM1, and the serial JTAG USB connection is on COM9.
Go further down to the Target list and click Maxim Serial JTAG Adapter. This will open the Connection entries. Set the COM port to which you are connected. In this example, we are connecting to COM9. Now go to the middle section titled Targets, then connect to the JTAG port. This can be done in three different ways: 1) Double-click on Maxim Serial JTAG Adapter; 2) Right-click on Maxim Serial JTAG Adapter and select Connect; or 3) Press the most left icon below Targets. The status bar at the bottom of the window will go from Disconnected to Maxim Serial JTAG Adapter (Figure 29).
Figure 29. CrossWorks is connected to the Maxim Serial JTAG Adapter on COM9.
More detailed image.
(PDF, 1.9MB)
Figure 29. CrossWorks is connected to the Maxim Serial JTAG Adapter on COM9.
Now highlight Project 'ISOUart' and right-click. Select Build. In the Output pane, you will see the project building.
Note: Make sure the Microcontroller Tool Kit (MTK2) is running and connected to the MAXQ1050 EV kit at 115200 baud via the 9-pin serial connector.
Go to the top buttons and click Project and Start Without Debugging. In the output pane, you can watch as the compiler checks the configuration, erases the MAXQ1050 flash, downloads the program, and verifies the program (Figure 30).
Figure 30. Loading of ISOUart to MAXQ1050.
Figure 30. Loading of ISOUart to MAXQ1050.
Once the program is loaded, it will start running. You will see a banner and a request to Insert Card Now. Put the supplied smart card in to the card reader, and watch as the card is found and powered up, and the ATR message is printed (Figure 31). Pressing the RST_N (SW7) button on the EV kit will make the program run again.
Figure 31. Output from ISOUart.
Figure 31. Output from ISOUart.

The ISOUart Program

This demonstration program comprises several source files. The files delay.c and delayasm.asm demonstrate how to call assembly code from 'c.' These particular routines implement a callable microsecond delay in the assembly file, and a callable millisecond delay in the c source.
Serial.c implements the int __putchar(int ch) and char __getchar(void) routines. Once these two routines are written, the higher-level stdin and stdout routines can be used with the RS-232 serial port. Serial.c also implements the void serial_init(void) routine, which initializes the serial port to operate at 115200 baud.
MAXQ30_7816_LIB.C implements the ISOUART functions.
The main program is listed in Figure 32.
/**
 * ISO uart example.  Retrieve and Display ATR on LCD
 *  This example only uses Slot 1.  The SIM Card slot is not used.
 */
#include "MAXQ30.h"
#include "MAXQ30_7816_LIB.H"
#include "delay.h"
#include "serial.h"
#include <stdio.h>


void main(void)
{  
  int status, i;
  uint8_t buff[128];

  serial_init() ;

  printf("\nMAXQ1050 ISOUART Ex.\n");

  // Initialize the Smart Card interface
  dssc_init();

  dssc_selectcard(0);

  if (!dssc_checkpresence())
  {
    printf("Insert Card Now\n");

    // Wait forever until card is present
    while (!dssc_checkpresence());
  }

  // Wait for user to see output
  delay_ms(1000);

  printf("\nCard found. Power up\n");
        
  // Set up for transaction and get an Answer To Reset
  status = dssc_powerup(POWERUP_5V);

  if ( status == ERR_DO_WARM_RESET )
  {
    printf("Warm Reset\n");
    status = dssc_warmreset();
  }

  // Wait for user to see output
  delay_ms(1000);

  if (status != STATUS_SUCCESS)
  {
    printf("\nPower up Error: %d\n", status);
  }
  else
  {
    status = dssc_getATRbuffer(buff, 128);

    printf("\nATR Recived\n");

    // Wait for user to see output
    delay_ms(1000);
    

    for(i=0;i<status;i++)
    {
      printf("%02X", buff[i]);
      if ((i % 20) == 19)
        printf("\n"); // Need to shift to next line
      else printf(" ") ;
    }
        printf("\n");

  }

  // Power down card interface
  dssc_powerdown();

  while (1){};
}   
Figure 32. Listing of ISOUart's main.c.

For More Information

The source code for this application and many others is available in the resource library package distributed with the MAXQ1050 EV kit. All the Rowley project files are also included in the distribution.
Maxim has software libraries, application notes, and reference designs available for further design assistance. Search Maxim's microcontroller product line pages or contact Technical Support for the latest information on available libraries and tools.