IAR Embedded Workbench®

Total Page:16

File Type:pdf, Size:1020Kb

IAR Embedded Workbench® IAR Embedded Workbench® IAR C/C++ Development Guide Compiling and Linking for Advanced RISC Machines Ltd’s ARM® Cores DARM-16b COPYRIGHT NOTICE © 1999–2015 IAR Systems AB. No part of this document may be reproduced without the prior written consent of IAR Systems AB. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. TRADEMARKS IAR Systems, IAR Embedded Workbench, C-SPY, C-RUN, C-STAT, visualSTATE, Focus on Your Code, IAR KickStart Kit, IAR Experiment!, I-jet, I-jet Trace, I-scope, IAR Academy, IAR, and the logotype of IAR Systems are trademarks or registered trademarks owned by IAR Systems AB. Microsoft and Windows are registered trademarks of Microsoft Corporation. ARM, Thumb, and Cortex are registered trademarks of Advanced RISC Machines Ltd. Adobe and Acrobat Reader are registered trademarks of Adobe Systems Incorporated. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE Sixteenth edition: December 2015 Part number: DARM-16b This guide applies to version 7.50.x of IAR Embedded Workbench® for ARM. Internal reference: M18, csrct2010.1, V_110411, IMAE. IAR C/C++ Development Guide 2 Compiling and Linking for ARM AFE1_AFE2-1:1 Brief contents Tables ...................................................................................................................... 27 Preface .................................................................................................................... 29 Part 1. Using the build tools ................................................... 37 Introduction to the IAR build tools ........................................................ 39 Developing embedded applications ......................................................... 45 Data storage ...................................................................................................... 59 Functions ............................................................................................................... 63 Linking using ILINK ........................................................................................ 75 Linking your application ................................................................................ 93 The DLIB runtime environment ............................................................ 107 Assembler language interface ................................................................. 151 Using C ................................................................................................................ 175 Using C++ .......................................................................................................... 185 Application-related considerations ....................................................... 197 Efficient coding for embedded applications ...................................... 213 Part 2. Reference information ........................................... 233 External interface details ............................................................................ 235 Compiler options ........................................................................................... 245 Linker options .................................................................................................. 289 Data representation ...................................................................................... 319 Extended keywords ....................................................................................... 333 3 AFE1_AFE2-1:1 Pragma directives ............................................................................................ 347 Intrinsic functions ........................................................................................... 371 The preprocessor ........................................................................................... 407 C/C++ standard library functions .......................................................... 415 The linker configuration file ...................................................................... 425 Section reference ............................................................................................ 451 The stack usage control file ...................................................................... 457 IAR utilities ........................................................................................................ 465 Implementation-defined behavior for Standard C ......................... 501 Implementation-defined behavior for C89 ........................................ 517 Index ..................................................................................................................... 529 4 AFE1_AFE2-1:1 Contents Tables ...................................................................................................................... 27 Preface .................................................................................................................... 29 Who should read this guide ............................................................... 29 How to use this guide .......................................................................... 29 What this guide contains ................................................................... 30 Other documentation ........................................................................... 31 Document conventions ........................................................................ 34 Part 1. Using the build tools ................................................... 37 Introduction to the IAR build tools ........................................................ 39 The IAR build tools—an overview ................................................... 39 IAR language overview ......................................................................... 41 Device support ......................................................................................... 41 Special support for embedded systems ........................................ 43 Developing embedded applications ......................................................... 45 Developing embedded software using IAR build tools .......... 45 The build process—an overview ...................................................... 47 Application execution—an overview ............................................. 50 Building applications—an overview ................................................ 54 Basic project configuration ................................................................. 55 Processor configuration ...................................................................... 55 Data storage ...................................................................................................... 59 Introduction ............................................................................................. 59 Storage of auto variables and parameters .................................. 60 Dynamic memory on the heap ........................................................ 61 Functions ............................................................................................................... 63 Function-related extensions .............................................................. 63 ARM and Thumb code ......................................................................... 63 5 AFE1_AFE2-1:1 Execution in RAM ................................................................................... 64 Interrupt functions for Cortex-M devices .................................... 65 Interrupt functions for ARM7/9/11, Cortex-A, and Cortex-R devices ......................................................................................................... 66 Inlining functions ..................................................................................... 71 Linking using ILINK ........................................................................................ 75 Linking—an overview ............................................................................ 75 Modules and sections ............................................................................ 76 The linking process in detail .............................................................. 77 Placing code and data—the linker configuration file .............. 79 Initialization at system startup ......................................................... 82 Stack usage analysis ............................................................................... 85 Introduction to stack usage analysis ................................................... 85 Performing a stack usage analysis ..................................................... 86 Linking your application ................................................................................ 93 Linking considerations .......................................................................... 93 Hints for troubleshooting ................................................................ 103 Checking
Recommended publications
  • Bill Baggs Cape Florida State Park
    Haw Creek Preserve State Park Approved Plan Unit Management Plan STATE OF FLORIDA DEPARTMENT OF ENVIRONMENTAL PROTECTION Division of Recreation and Parks December 16, 2016 TABLE OF CONTENTS INTRODUCTION ...................................................................................1 PURPOSE AND SIGNIFICANCE OF THE PARK ....................................... 1 Park Significance ................................................................................1 PURPOSE AND SCOPE OF THE PLAN..................................................... 2 MANAGEMENT PROGRAM OVERVIEW ................................................... 7 Management Authority and Responsibility .............................................. 7 Park Management Goals ...................................................................... 8 Management Coordination ................................................................... 8 Public Participation ..............................................................................9 Other Designations .............................................................................9 RESOURCE MANAGEMENT COMPONENT INTRODUCTION ................................................................................. 11 RESOURCE DESCRIPTION AND ASSESSMENT..................................... 12 Natural Resources ............................................................................. 12 Topography .................................................................................. 12 Geology ......................................................................................
    [Show full text]
  • Introduction to Computer Systems 15-213/18-243, Spring 2009 1St
    M4-L3: Executables CSE351, Winter 2021 Executables CSE 351 Winter 2021 Instructor: Teaching Assistants: Mark Wyse Kyrie Dowling Catherine Guevara Ian Hsiao Jim Limprasert Armin Magness Allie Pfleger Cosmo Wang Ronald Widjaja http://xkcd.com/1790/ M4-L3: Executables CSE351, Winter 2021 Administrivia ❖ Lab 2 due Monday (2/8) ❖ hw12 due Friday ❖ hw13 due next Wednesday (2/10) ▪ Based on the next two lectures, longer than normal ❖ Remember: HW and readings due before lecture, at 11am PST on due date 2 M4-L3: Executables CSE351, Winter 2021 Roadmap C: Java: Memory & data car *c = malloc(sizeof(car)); Car c = new Car(); Integers & floats c->miles = 100; c.setMiles(100); x86 assembly c->gals = 17; c.setGals(17); Procedures & stacks float mpg = get_mpg(c); float mpg = Executables free(c); c.getMPG(); Arrays & structs Memory & caches Assembly get_mpg: Processes pushq %rbp language: movq %rsp, %rbp Virtual memory ... Memory allocation popq %rbp Java vs. C ret OS: Machine 0111010000011000 100011010000010000000010 code: 1000100111000010 110000011111101000011111 Computer system: 3 M4-L3: Executables CSE351, Winter 2021 Reading Review ❖ Terminology: ▪ CALL: compiler, assembler, linker, loader ▪ Object file: symbol table, relocation table ▪ Disassembly ▪ Multidimensional arrays, row-major ordering ▪ Multilevel arrays ❖ Questions from the Reading? ▪ also post to Ed post! 4 M4-L3: Executables CSE351, Winter 2021 Building an Executable from a C File ❖ Code in files p1.c p2.c ❖ Compile with command: gcc -Og p1.c p2.c -o p ▪ Put resulting machine code in
    [Show full text]
  • CERES Software Bulletin 95-12
    CERES Software Bulletin 95-12 Fortran 90 Linking Experiences, September 5, 1995 1.0 Purpose: To disseminate experience gained in the process of linking Fortran 90 software with library routines compiled under Fortran 77 compiler. 2.0 Originator: Lyle Ziegelmiller ([email protected]) 3.0 Description: One of the summer students, Julia Barsie, was working with a plot program which was written in f77. This program called routines from a graphics package known as NCAR, which is also written in f77. Everything was fine. The plot program was converted to f90, and a new version of the NCAR graphical package was released, which was written in f77. A problem arose when trying to link the new f90 version of the plot program with the new f77 release of NCAR; many undefined references were reported by the linker. This bulletin is intended to convey what was learned in the effort to accomplish this linking. The first step I took was to issue the "-dryrun" directive to the f77 compiler when using it to compile the original f77 plot program and the original NCAR graphics library. "- dryrun" causes the linker to produce an output detailing all the various libraries that it links with. Note that these libaries are in addition to the libaries you would select on the command line. For example, you might compile a program with erbelib, but the linker would have to link with librarie(s) that contain the definitions of sine or cosine. Anyway, it was my hypothesis that if everything compiled and linked with f77, then all the libraries must be contained in the output from the f77's "-dryrun" command.
    [Show full text]
  • Introduction to Embedded C
    INTRODUCTION TO EMBEDDED C by Peter J. Vidler Introduction The aim of this course is to teach software development skills, using the C programming language. C is an old language, but one that is still widely used, especially in embedded systems, where it is valued as a high- level language that provides simple access to hardware. Learning C also helps us to learn general software development, as many of the newer languages have borrowed from its concepts and syntax in their design. Course Structure and Materials This document is intended to form the basis of a self-study course that provides a simple introduction to C as it is used in embedded systems. It introduces some of the key features of the C language, before moving on to some more advanced features such as pointers and memory allocation. Throughout this document we will also look at exercises of varying length and difficulty, which you should attempt before continuing. To help with this we will be using the free RapidiTTy® Lite IDE and targeting the TTE®32 microprocessor core, primarily using a cycle-accurate simulator. If you have access to an FPGA development board, such as the Altera® DE2-70, then you will be able to try your code out in hardware. In addition to this document, you may wish to use a textbook, such as “C in a Nutshell”. Note that these books — while useful and well written — will rarely cover C as it is used in embedded systems, and so will differ from this course in some areas. Copyright © 2010, TTE Systems Limited 1 Getting Started with RapidiTTy Lite RapidiTTy Lite is a professional IDE capable of assisting in the development of high- reliability embedded systems.
    [Show full text]
  • Embedded C Programming I (Ecprogrami)
    To our customers, Old Company Name in Catalogs and Other Documents On April 1st, 2010, NEC Electronics Corporation merged with Renesas Technology Corporation, and Renesas Electronics Corporation took over all the business of both companies. Therefore, although the old company name remains in this document, it is a valid Renesas Electronics document. We appreciate your understanding. Renesas Electronics website: http://www.renesas.com April 1st, 2010 Renesas Electronics Corporation Issued by: Renesas Electronics Corporation (http://www.renesas.com) Send any inquiries to http://www.renesas.com/inquiry. Notice 1. All information included in this document is current as of the date this document is issued. Such information, however, is subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website. 2. Renesas Electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or others. 3. You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. 4. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples.
    [Show full text]
  • Equipment For' River Measurements
    .. UNITED STATES DEPARTMENT OF THE INTERIOR GEOLOGICAL SURVEY WATER RESOURCES BRANCH EQUIPMENT FOR' RIVER MEASUREMENTS " PLANS AND SPECIFICATIONS FOR REINFORCED CONCRETE HOUSE AND WELL FOR WATER-STAGE RECORDERS ARRANGED BY LASLEY LEE DISTRICT ENGINEER, COLUMBUS, OHIO • 1933 DlI'I\IITMDlT 0' THI INnIUOII' UNITEO STATES GEOl.OGICAL SURVEY WATER RESOURCES BRANCH EQUIPMENT FOR RIVER MEASUREMENTS CABLE TOWER AND CAR WATER-STAGE RECORDER HOUSE AND WELL CABLE TOWER AND CAR Chelan River, Chelan. Wash. Alle8heny River. Franklin, Pa. Columbia River, Rock Island. wash. MEASUREMENT BY WADING MEASUREMENT FROM CABLE MEASUREMENT FROM BRIDGE MEASUREMENT THROUGH ICE Merced River, Yosemite Valley. calif. Scioto River, Columbus, Ohio Scioto River. Dublin. Ohio Wisconsin River, Muscoda. Wis. OONTENTS Introduct1on •••••••••••••••••• ~ ••••••••••••••••••••••••• ••• 1 Construction cqllipmont •.•• " •••••••••••.•••••••••••••••••••• 4 .. Excavation •••••••••••• , .•• , •••••••••••••••••• ~.~ ••••••• ~.~ • 4 Blasting •••••••••••••• ~ •••••••••• , ••••••••••••• ~.~.~ •• 6 Concrete ••••••••••••••. .•• ~ ••••••••••••••••••• , ••• ~ •• ~.~ •• 7 Ccm811 t ................. ~ ••.•••••••• ~ •••••• ~ ••••• , •••••• 7 Fine aggregate •••••••••••••••• , ••••••••••••••••••••••• 7 Coarse aggrogate ••••••••••••••••• !' •••••••• !' •••••••••• ~ 7 ?report ions •••.• ~ • ~ .... ~ •• ~ .... .,." •. ~ •• , ••• ~. 0 •• ~. ~ ~ ~ • '•• 7 Quality of water ••••••••••••••••••• , ••••••• , •• ~, •••••• 8 Mixillg ••• ~ ••••••• '8 ••• ~ .................. , ••••••••• , •••• 8 Qua~tity of water
    [Show full text]
  • Linking + Libraries
    LinkingLinking ● Last stage in building a program PRE- COMPILATION ASSEMBLY LINKING PROCESSING ● Combining separate code into one executable ● Linking done by the Linker ● ld in Unix ● a.k.a. “link-editor” or “loader” ● Often transparent (gcc can do it all for you) 1 LinkingLinking involves...involves... ● Combining several object modules (the .o files corresponding to .c files) into one file ● Resolving external references to variables and functions ● Producing an executable file (if no errors) file1.c file1.o file2.c gcc file2.o Linker Executable fileN.c fileN.o Header files External references 2 LinkingLinking withwith ExternalExternal ReferencesReferences file1.c file2.c int count; #include <stdio.h> void display(void); Compiler extern int count; int main(void) void display(void) { file1.o file2.o { count = 10; with placeholders printf(“%d”,count); display(); } return 0; Linker } ● file1.o has placeholder for display() ● file2.o has placeholder for count ● object modules are relocatable ● addresses are relative offsets from top of file 3 LibrariesLibraries ● Definition: ● a file containing functions that can be referenced externally by a C program ● Purpose: ● easy access to functions used repeatedly ● promote code modularity and re-use ● reduce source and executable file size 4 LibrariesLibraries ● Static (Archive) ● libname.a on Unix; name.lib on DOS/Windows ● Only modules with referenced code linked when compiling ● unlike .o files ● Linker copies function from library into executable file ● Update to library requires recompiling program 5 LibrariesLibraries ● Dynamic (Shared Object or Dynamic Link Library) ● libname.so on Unix; name.dll on DOS/Windows ● Referenced code not copied into executable ● Loaded in memory at run time ● Smaller executable size ● Can update library without recompiling program ● Drawback: slightly slower program startup 6 LibrariesLibraries ● Linking a static library libpepsi.a /* crave source file */ … gcc ..
    [Show full text]
  • Build a Plane That Cuts Smooth and Crisp Raised Panels With, Against Or Across the Grain – the Magic Is in the Spring and Skew
    Fixed-width PanelBY WILLARD Raiser ANDERSON Build a plane that cuts smooth and crisp raised panels with, against or across the grain – the magic is in the spring and skew. anel-raising planes are used Mass., from 1790 to 1823 (Smith may to shape the raised panels in have apprenticed with Joseph Fuller doors, paneling and lids. The who was one of the most prolific of the profile has a fillet that defines early planemakers), and another similar Pthe field of the panel, a sloped bevel example that has no maker’s mark. to act as a frame for the field and a flat Both are single-iron planes with tongue that fits into the groove of the almost identical dimensions, profiles door or lid frame. and handles. They differ only in the I’ve studied panel-raising planes spring angles (the tilt of the plane off made circa the late 18th and early 19th vertical) and skew of the iron (which centuries, including one made by Aaron creates a slicing cut across the grain to Smith, who was active in Rehoboth, reduce tear-out). The bed angle of the Smith plane is 46º, and the iron is skewed at 32º. Combined, these improve the quality of cut without changing the tool’s cutting angle – which is what happens if you skew Gauges & guides. It’s best to make each of these gauges before you start your plane build. In the long run, they save you time and keep you on track. Shaping tools. The tools required to build this plane are few, but a couple of them – the firmer chisel and floats – are modified to fit this design.
    [Show full text]
  • IAR Systems Brings Functional Safety Tools to RISC-V with Certification for IEC 61508 and ISO 26262
    Press release Date: October 20, 2020 IAR Systems brings functional safety tools to RISC-V with certification for IEC 61508 and ISO 26262 Stockholm, Sweden—October 20, 2020— IAR Systems®, the future-proof supplier of software tools and services for embedded development, further extends its strong tools offering for RISC-V by announcing a certified version of its development tools. The functional safety edition of IAR Embedded Workbench® for RISC-V will be certified by TÜV SÜD according to the requirements of IEC 61508, the international umbrella standard for functional safety, as well as ISO 26262, which is used for automotive safety-related systems. In addition, the certification covers the international standard IEC 62304, which specifies life cycle requirements for the development of medical software and software within medical devices, and the European railway standards EN 50128 and EN 50657. “We are seeing RISC-V becoming an important architecture not only in broad designs, but specifically in automotive applications,” said Stefan Skarin, CEO, IAR Systems. “By providing our development tools with certification according to ISO 26262, we enable the RISC-V community to further expand and more rapidly bring functional safety designs to the market. As a commercial tools vendor, we are able to provide global technical support as well as invest in keeping our products robust, maintained and qualified. Our certified tools will enable our customers to speed up the path to using RISC-V in safety-critical applications within automotive and other areas.” “We see a strong demand for RISC-V with safety among our customers, and the certification of IAR Embedded Workbench for RISC-V aligns perfectly with that demand,” said Frankwell Lin, President, Andes Technology.
    [Show full text]
  • IAR Systems Supports New Amazon Web Services Iot Microcontroller Operating System Amazon Freertos at Launch
    Press release Date: November 30, 2017 IAR Systems supports new Amazon Web Services IoT Microcontroller Operating System Amazon FreeRTOS at Launch Amazon FreeRTOS will be supported by the leading embedded development toolchain IAR Embedded Workbench Uppsala, Sweden—November 30, 2017—IAR Systems®, a leading supplier of software tools and services for embedded development, announces support for newly launched Internet of Things (IoT) Microcontroller Operating System, Amazon FreeRTOS. Together with Amazon Web Services (AWS), IAR Systems provides developers with easy access to high-performance, pre-integrated development tools for developing and debugging embedded and IoT-connected applications based on Amazon FreeRTOS. Amazon FreeRTOS provides tools that developers need to quickly and easily deploy a microcontroller- based connected device and develop an embedded or IoT application without having to worry about the complexity of scaling across millions of devices. Based on the FreeRTOS kernel, Amazon FreeRTOS includes software libraries which make it easy to securely connect devices locally to AWS Greengrass, directly to the cloud, and update them remotely. For new devices, developers can choose to build their embedded and IoT application on a variety of qualified microcontrollers from companies collaborating with AWS and IAR Systems, including Microchip, NXP, STMicroelectronics and Texas Instruments. Since 1983, IAR Systems’ solutions have ensured quality, reliability and efficiency in the development of over one million embedded applications. Now available for Amazon FreeRTOS users, development tools from IAR Systems deliver leading code optimizations and extensive debugging functionality. The technology is coupled with professional technical support offered globally. “AWS is pleased to be teamed with IAR Systems to provide developers with access to a high performance, pre-integrated set of development tools for developing and debugging connected applications,” says Richard Barry, Principal Engineer, Amazon Web Services, Inc.
    [Show full text]
  • Porting Musl to the M3 Microkernel TU Dresden
    Porting Musl to the M3 microkernel TU Dresden Sherif Abdalazim, Nils Asmussen May 8, 2018 Contents 1 Abstract 2 2 Introduction 3 2.1 Background.............................. 3 2.2 M3................................... 4 3 Picking a C library 5 3.1 C libraries design factors . 5 3.2 Alternative C libraries . 5 4 Porting Musl 7 4.1 M3andMuslbuildsystems ..................... 7 4.1.1 Scons ............................. 7 4.1.2 GNUAutotools........................ 7 4.1.3 Integrating Autotools with Scons . 8 4.2 Repositoryconfiguration. 8 4.3 Compilation.............................. 8 4.4 Testing ................................ 9 4.4.1 Syscalls ............................ 9 5 Evaluation 10 5.1 PortingBusyboxcoreutils . 10 6 Conclusion 12 1 Chapter 1 Abstract Today’s processing workloads require the usage of heterogeneous multiproces- sors to utilize the benefits of specialized processors and accelerators. This has, in turn, motivated new Operating System (OS) designs to manage these het- erogeneous processors and accelerators systematically. M3 [9] is an OS following the microkernel approach. M3 uses a hardware/- software co-design to exploit the heterogeneous systems in a seamless and effi- cient form. It achieves that by abstracting the heterogeneity of the cores via a Data Transfer Unit (DTU). The DTU abstracts the heterogeneity of the cores and accelerators so that they can communicate systematically. I have been working to enhance the programming environment in M3 by porting a C library to M3. I have evaluated different C library implementations like the GNU C Library (glibc), Musl, and uClibc. I decided to port Musl as it has a relatively small code base with fewer configurations. It is simpler to port, and it started to gain more ground in embedded systems which are also a perfect match for M3 applications.
    [Show full text]
  • Fletcher Business Group Acquires Atlas Saw & Tool
    FOR IMMEDIATE RELEASE Media Contact: Sarah Archambault • 917.923.9838 • [email protected] FLETCHER BUSINESS GROUP ACQUIRES ATLAS SAW & TOOL Global Solution Provider Expands Product Line and Services through Acquisition of Leading Provider of Saw Blades, Cutting Tools and Sharpening Services [East Berlin, CT – January 23, 2017] Today, Fletcher Business Group (FBG) – a leading provider of solution-driven technologies for a wide range of industries – including custom and OEM picture framing; sign and digital graphics; hardware; woodworking; and float and glass fabrication industries – is announcing the acquisition of Atlas Saw & Tool and Tem-Tech. With locations in Illinois, Florida and Arizona, Atlas provides high quality saw blades, cutting tools and sharpening services. Tem-Tech carries a high capacity saw line, along with repair/refurbish services for all saw types. Atlas Saw & Tool joins FBG’s roster of globally recognized brands as a wholly owned subsidiary and will continue the day-to-day operations of its key brands. Atlas serves a variety of markets including picture framing, cabinet making, flooring, millwork and the plastic industry. Using precise German CNC grinders and associated robotics, Atlas Saw sharpens blades and tools to OEM specifications and serves customers nationwide from its three regional tech centers. Atlas will continue to provide custom saw blade design services, fabrication and re-sharpening programs utilizing its premier selection of American and Japanese made core blades. The Tem-Tech brand offerings will remain, including the large capacity saw, CNC moulding profile template machine, saw service, repair and preventative maintenance programs. This will include service, refurbishment and parts support of Pistorius brand saws.
    [Show full text]