Home

GU0108 Using the TSK165x Embedded Tools

image

Contents

1. exist test asm ccl65x test asm When the file test asm exists it yields exist test asm ccl65x test asm When the file test asm does not exist nothing is expanded nexist The nexist function is the opposite of the exist function It expands to its second argument if the first argument is not an existing file or directory Example nexist test obj ccl65x test asm Using the Utilities Conditional processing Lines containing ifdef ifndef else or endif are used for conditional processing of the makefile They are used in the following way ifdef macro name if lines else else lines endif The if lines and else lines may contain any number of lines or text of any kind even other ifdef ifndef else and endif lines or no lines at all The else line may be omitted along with the e se ines following it First the macro name after the if command is checked for definition If the macro is defined then the f lines are interpreted and the else lines are discarded if present Otherwise the if ines are discarded and if there is an else line the e se ines are interpreted but if there is no else line then no lines are interpreted When using the ifndef line instead of ifdef the macro is tested for not being defined These conditional lines can be nested up to 6 levels deep qo See also Defining Macros in section 2 4 Make Utility Options in Chapter Tools Options of the reference manual Comment lines A
2. Display invocation syntax Define preprocessor macro Show description of diagnostic s Specify a symbol as unresolved external Redirect diagnostic messages to a file with extension e1k Read options from file Scan libraries in given order Add dir to LSL include file search path Search only in L directories not in default path Import a binary file containing raw data Keep output files after errors Link only do not locate Check LSL file s and exit Do not generate ROM copy Locate all ROM sections in RAM Link incrementally Display version header only Verbose extra verbose information help item Dmacro def diag fmt all nr esymbol error file fi e f file first library first ldir ignore default library path import object file k link only Isl check N non romable r V v vv Table 3 3 Additional Linker options qo For a complete overview of all options with extensive description see section 2 2 Linker Options of the reference manual 3 6 Using the Linker 3 4 Linking with Libraries User library You can create your own libraries Section 4 4 Librarian in Chapter Using the Utilities describes how you can use the librarian to create your own library with object modules To link user libraries 1 From the Project menu select Add Existing to Project The Choose Documents to add to Project dialog box appears 2 Select the l
3. derivative name is arbitrary Specification of the derivative Written by Altium core cl65x always specify the core architecture cl165x bus data_bus data bus maps to data bus in cl 65x core internal memory processor procl processor name is arbitrary derivative X You can omit this part except if you use a multi core system memory ext_name external memory definition section layout procl cl65x data section layout 1 section placement statements sections are located in address space data of core cl 65x of processor procl 3 7 4 The Architecture Definition Although you will probably not need to program the architecture definition unless you are building your own processor core it helps to understand the Linker Script Language and how the definitions are interrelated Within an architecture definition the characteristics of a target processor core that are important for the linking process are defined These include e space definitions the logical address spaces and their properties e bus definitions the I O buses of the core architecture e mappings the address translations between logical address spaces the connections between logical address spaces and buses and the address translations between buses 3 11 Using the TSK165x Embedded Tools Address spaces A logical address space is a memory range for which the core has a separate wa
4. v 0 000000 Address O 1 2 3 4 5 6 7 8 9 A B C D E F Data pooo ooo 24 Z1 01 00 40 81 38 00 40 Ol 00 00 34 21 00 00 GD8 8 4 0000 0010 40 81 00 00 3C Ol O1 01 24 3D 82 80 3C 01 01 x 2 0000 0020 z4 3C 80 00 3C 04 00 O0 24 84 16 BC 8C 88 00 00 G amp 0000 0030 ac 89 00 04 8C S 00 08 8C 8B 00 OC 34 05 00 0000 0040 10 A8 00 06 24 84 00 10 34 05 O0 OZ 10 A8 00 0000 0050 oo 00 00 00 O8 00 00 25 00 00 00 00 81 45 00 0000 0060 Al 25 00 00 25 6B FF FF 25 4A 00 Ol 1D 60 FF 0000 0070 zs 29 o0 01 08 00 00 OB 00 00 O0 00 Al 20 00 0080 25 6B FF FF 1D 60 FF FD 25 29 00 01 08 00 00 0090 oo oo oo oo 3C 04 00 00 OC OO 00 63 3C 05 00 00A0 os 00 00 A3 00 40 20 25 01 00 00 CC Ol 00 00 OOBO oo oo oo oo oo GO OO 50 00 09 00 00 Ol 00 01 ooco o1 00 01 1C 00 00 00 O0 00 00 OO 50 OO OA OL oopo oo 00 oo oo GO GO OO O0 00 O0 OO OO FF FF FF In the edit field you can specify the address you want to start viewing from Using the TSK165x Embedded Tools 2 Using the Assembler Summ ary This chapter describes the assembly process and explains how to call the assembler 2 1 Introduction The assembler converts hand written or compiler generated assembly language programs into machine language resulting in object files in the IEEE 695 object format The assembler takes the following files for input and output assembly file assembly file asm SEG li i l hand coded L lis
5. 0 0 ce cece eect ttt eens 3 10 3 7 4 The Architecture Definition oqqa 2 6 0 0 ee ee eee ee 3 11 3 7 5 The Derivative Definition 22 ccce ce ule Ie ee eee eee eee es 3 14 3 7 6 The Processor Definition Using Multi Processor Systems 00 0c cence eee ee 3 15 3 7 7 The Memory Definition hn Rp Rd eda EL eio doen tede wd ahd 3 15 3 7 8 The Section Layout Definition Locating Sections 00 cece eee 3 16 3 8 Linker Labels EMIT 3 17 3 9 Generating a Map File i vseecl pere e RR ERR E eme rae R Re eee REN eR 3 19 3 10 Linker Error Messages exe Ibero pep Rer bh rete moenia zie snes qr eed 3 19 Using the TSK165x Embedded Tools Using the Utilities 4 1 4 1 INMODUCHON RM oth ee oii ie ean awe a aed a a en eee ee oe daa 4 1 4 2 Control Program sssr 2 een eee n 4 2 4 2 1 Calling the Control Program 1 RI n 4 2 4 2 2 Overview of Control Program Options 0 cece ects 4 3 4 3 Make Utility 1 eer peer Eze bain aide UPRERIDEE EJ ET WR ER awe AL EE 4 4 4 3 1 Calling the Make Utility 0 0 0 RII 4 5 4 3 2 Overview of Make Utility Options lsssssssseeeeese IH 4 5 4 9 8 Writing a MakeFile 2 cese ento ERR UL EE RR ERR RUE ERREUR ERE NE 4 6 4 4 CH oM 4 12 4 4 1 Calling the Librarian ace de EE IRR a RAS Dueh E A RUPEE eR 4 12 4 4 2 Overview of Librarian Options 0 cece cette nn 4 12 4 4 3 curse eT 4 13 Inde
6. The following control program options are available Show description of diagnostics Check the source but do not generate code Verbose output Verbose output and suppress execution Suppress all or specific warnings Treat warnings as errors Description Option Information Display invocation options help Display version header version V diag fmt all nr check verbose v dry run n no warnings num w warnings as errors Preprocessing Define preprocessor macro define macro def D Code generation Select target CPU Generate symbolic debug information cpu cpu debug info g Pass arguments Pass arguments directly to the Assembler pass assembler option Linker pass linker option Input files Specify linker script file Read options from file Add include directory Isl file file d option file file f include directory dir l Output files Redirect diagnostic messages to a file Select final output file relocatable output file object file s Specify linker output format IEEE ELF IHEX SREC Set the address size for linker IHEX SREC files Keep output file s after errors Generate assembler list files Do not generate linker map file Specify name of output file Do not delete intermediate temporary files error file create relocatable create object format type address size n
7. the assembler generates a call to a preliminary relocatable address usually 0000 while stating the symbol name e Debug information Other information about the object code that is used by a debugger The assembler optionally generates this information and can consist of line numbers C source code local symbols and descriptions of data structures The linker resolves the external references between the supplied relocatable object files and or libraries and combines the files into a single relocatable linker object file The linker starts its task by scanning all specified relocatable object files and libraries If the linker encounters an unresolved symbol it remembers its name and continues scanning The symbol may be defined elsewhere in the same file or in one of the other files or libraries that you specified to the linker If the symbol is defined in a library the linker extracts the object file with the symbol definition from the library This way the linker collects all definitions and references of all of the symbols Next the linker combines sections with the same section name and attributes into single sections The linker also substitutes external symbol references by relocatable numerical addresses where possible At the end of the linking phase the linker either writes the results to a file a single relocatable object file or keeps the results in memory for further processing during the locating phase The resulting file o
8. Linker Options You can set the following linker options in Altium Designer Menu entry Command line Build Options Library files path Ldir Linker Output Format Output format Absolute file for debuggers abs Library for TASKING linker lib Intel Hex records for EPROM programmers hex Motorola S records for EPROM programmers sre offile format addr_size c basename IHEX adar size c basename SREC adadr_size Linker Optimization Optimization level No optimization 00 Default optimization 01 Full optimization 02 Custom optimization Custom optimization Oflags Linker Map File Generate a memory map file map M Map file format mflags Linker Diagnostics Error reporting Report all warnings Suppress all warnings Suppress specific warnings Treat warnings as errors no option w W wnum num warnings as errors Linker Miscellaneous Include symbolic debug information Link case sensitive required for C language Dump processor and memory info from LSL file Use project specific LSL file Additional linker options S strips debug information case insensitive Isl dump file dfile options Table 3 2 Altium Designer Linker options 3 5 Using the TSK165x Embedded Tools The following linker options are only available on the command line Description Command line
9. Options ssssssssesse eI 2 3 2 4 How the Assembler Searches Include Files sseeeeeeeeeeeee eese 2 4 2 5 Assembler Optimizations sssseeeeslees eee hh 2 4 2 6 Generatingia List File srar conecte iiem ppp clan epe E REE E NEIGE un 2 5 2 7 Assembler Error Messages sssssessseeee e 2 5 Using the Linker 3 1 3 1 Introduction eru RIS E paniri PE ca each enw de ale ER eae Poa ed oad eed et ena 3 1 3 2 Linking Process 24 6 e ck reyes Dp nada pads HAGA GORA e eE Oy pr e oi Me dee ted 3 1 3 2 1 Phase TALLINKIN utn oi tr Be cies let cett t e e e o Rex ea ee Genie aan ah 3 2 3 2 2 Pliase 2 LoCallhg iux ec Estan ee rd Rue e won eel ene ele ara wi eed nos Qc d ecc 3 3 3 3 Calling the Linker xe bor te ED EE eR EI dr ied oed ee a a eee Rura fied cae 3 4 3 3 1 Overview of Linker Options 0 eect tte eee ane 3 5 3 4 Linking With Libraries sisi cert re cie tk eate urge dora Swan RW ER EO Rn e Ya a p 3 7 3 4 1 How the Linker Extracts Objects from Libraries 00 cece ees 3 7 3 5 Incremental LINKING oer eret Iph Ree eret etna od vA leder dom 3 8 3 6 Linker Optimizations sssseleeseses eee RR 3 8 3 7 Controlling the Linker with a Script 0 0 0 cece cee III 3 9 3 7 1 Purpose of the Linker Script Language sssssseeeee eens 3 9 3 7 2 Altium Designerand LSL seist icerisinde iaig eebbeeere e ote deb eode see 3 9 3 7 3 Structure of a Linker Script File
10. When the first fit decreasing optimization is enabled the linker will first place the largest sections in the smallest memory ranges that can contain the section Small sections are located last and can likely fit in the remaining gaps Copy table compression option Ot OT The startup code initializes the application s data areas The information about which memory addresses should be zeroed and which memory ranges should be copied from ROM to RAM is stored in the copy table When this optimization is enabled the linker will try to locate sections in such a way that the copy table is as small as possible thereby reducing the applications ROM image 3 8 Using the Linker Delete duplicate code option Ox OX Delete duplicate constant data option Oy OY These two optimizations remove code and constant data that is defined more than once from the resulting object file 3 7 Controlling the Linker with a Script With the options on the command line you can control the linker s behavior to a certain degree From Altium Designer it is also possible to determine where your sections will be located how much memory is available which sorts of memory are available and so on Altium Designer passes these locating directions to the linker via a script file If you want even more control over the locating process you can supply your own script The language for the script is called the Linker Script Language or shortly LSL You can speci
11. also reads the file tmk mk which contains predefined rules and macros See section 4 3 3 Writing a Makefile The makefile contains the relationships among your files called dependencies and the commands that are necessary to create each of the files called rules Typically the absolute object file abs is updated when one of its dependencies has changed The absolute file depends on obj files and libraries that must be linked together The obj files on their turn depend on asm files that must be assembled In the makefile makefile this looks like test obj test asm f dependency as165x test asm rule test abs test obj 1k165x test obj o test abs dl65x lsl M You can use any command that is valid on the command line as a rule in the makefile So rules are not restricted to invocation of the toolset Example To build the target test abs call tmk with one of the following lines tmk test abs tmk f mymake mak test abs By default the make utility reads makefile so you do not need to specify it on the command line If you want to use another name for the makefile use the option f my_makefile LN If you do not specify a target tmk uses the first target defined in the makefile In this example it would build test obj instead of test abs The make utility now tries to build test abs based on the makefile and peforms the following steps 1 From the makefile the make utility reads that test abs depends on test ob
12. board on which an application is executing A board contains at least one processor However a complex target may contain multiple processors and external memory and may be shared between processors A reference to a symbol for which the linker did not find a definition yet Table 3 1 Glossary of terms 3 2 1 Phase 1 Linking The linker takes one or more relocatable object files and or libraries as input A relocatable object file as generated by the assembler contains the following information e Header information Overall information about the file such as the code size name of the source file it was assembled from and creation date e Object code Binary code and data divided into various named sections Sections are contiguous chunks of code that have to be placed in specific parts of the memory The program addresses start at zero for each section in the object file e Symbols Some symbols are exported defined within the file for use in other files Other symbols are imported used in the file but not defined external symbols Generally these symbols are names of routines or names of data objects 3 2 Using the Linker e Relocation information A list of places with symbolic references that the linker has to replace with actual addresses When in the code an external symbol a symbol defined in another file or in a library is referenced the assembler does not know the symbol s size and address Instead
13. instructions Normally you do not need to clear this option Set To Installatio Getting Started with Embedded Software 2 Inthe left pane expand the Assembler entry This entry contains several pages where you can specify assembler settings 3 Inthe right pane set the options to the values you want Do this for all pages 4 Repeat steps 2 and 3 for the other tools like the linker 5 Click OK to confirm the new settings Based on the embedded project options Altium Designer creates a so called makefile which it uses to build your embedded application t On the Miscellaneous page of each tool entry the Command line options field shows how your settings are translated to command line options Setting options for an individual document 1 In the Projects panel right click on hello asm and select Document Options Alternatively select Project Document Options The Options for Document dialog appears Steps 2 to 5 are the same as the steps for setting project wide options The Files With Options tab in the Options for Embedded Project dialog shows which files have deviating settings If you right click on a file in this tab a menu provides you with functions to copy options quickly from and to other individual files 1 5 Building your Embedded Application You are now ready to build your embedded application 1 Select Project Compile Embedded Project GettingStarted PrjEmb or click on the LE button The TAS
14. keep output files k list files name no map file output file o keep temporary files t Table 4 1 Overview of control program options q For a complete list and description of all control program options see section 2 3 Control Program Options in Chapter Tool Options of the reference manual 4 3 Using the TSK165x Embedded Tools 433 Make Utility If you are working with large quantities of files or if you need to build several targets it is rather time consuming to call the individual tools to compile assemble link and locate all your files You save already a lot of typing if you use the control program cctarget and define an options file You can even create a batch file or script that invokes the control program for each target you want to create But with these methods all files are completely compiled assembled and linked to obtain the target file even if you changed just one C source This may demand a lot of CPU time on your host The make utility tmk is a tool to maintain update and reconstruct groups of programs The make utility looks which files are out of date and only recreates these files to obtain the updated target Make process In order to build a target the make utility needs the following input e the target it should build specified as argument on the command line e the rules to build the target stored in a file usually called makefile In addition the make utility
15. line is not defined in the makefile or has not rules in the makefile the make utility looks if there is an implicit rule to build the target Example This makefile says that prog abs depends on two files prog ob and sub obj and that they in turn depend on their corresponding source files prog asm and sub asm along with the common file gen inc LSL dl165x 1sl macro prog abs prog obj sub obj 1k165x prog obj sub obj LSL o prog abs prog obj prog asm gen inc as165x prog asm sub obj sub asm gen inc as165x sub asm The following makefile uses implicit rules from tmk mk to perform the same job LKFLAGS d165x 1sl macro used by implicit rules prog abs prog obj sub obj implicit rule used prog obj prog asm gen inc implicit rule used sub obj sub asm gen inc implicit rule used Macro definitions A macro is a symbol name that is replaced with its definition before the makefile is executed Although the macro name can consist of lower case or upper case characters upper case is an accepted convention The general form of a macro definition is 4 8 Using the Utilities MACRO text and more text Spaces around the equal sign are not significant To use a macro you must access its contents MACRO you can read this as MACRO the contents of macro MACRO If the macro name is a single character the parentheses are optional Note that the expansion is done recursively so the body of a
16. macro may contain other macros These macros are expanded when the macro is actually used not at the point of definition FOOD EAT and DRINK EAT meat and or vegetables DRINK water export FOOD The macro FOOD is expanded as meat and or vegetables and water atthe moment it is used in the export line line and the environment variable FOOD is set accordingly Predefined macros Macro Description MAKE Holds the value tmk Any line which uses MAKE temporarily overrides the option n Show commands without executing just for the duration of the one line This way you can test nested calls to MAKE with the option n MAKEFLAGS Holds the set of options provided to tmk except for the options f and d If this macro is exported to set the environment variable MAKEFLAGS the set of options is processed before any command line options You can pass this macro explicitly to nested tmk s but it is also available to these invocations as an environment variable PRODDIR Holds the name of the directory where tmk is installed You can use this macro to refer to files belonging to the product for example a library source file DOPRINT PRODDIR lib src doprint c When tmk is installed in the directory c Tasking bin this line expands to DOPRINT c Tasking lib src doprint c SHELLCMD Holds the default list of commands which are local to the SHELL If a rule is an invocation of one of these commands a SHELL is aut
17. optimization Using the Assembler To enable or disable optimizations 1 From the Project menu select Project Options The Project Options dialog box appears 2 Expand the Assembler entry and select Optimization You can enable or disable the optimizations described below The command line option for each optimization is given in brackets qo See also option optimize O in section 2 1 Assembler Options in Chapter Tool Options of the reference manual Allow generic instructions option Og OG When this option is enabled you can use generic instructions in your assembly source The assembler tries to replace instructions by faster or smaller instructions By default this option is enabled If you turn off this optimization generic instructions are not allowed In that case you have to use hardware instructions Optimize jump chains option Oj OJ When this option is enabled the assembler replaces chained jumps by a single jump instruction For example a jump from a to b immediately followed by a jump from b to c is replaced by a jump from a to c By default this option is disabled Optimize instruction size option Os OS When this option is enabled the assembler tries to find the shortest possible operand encoding for instructions By default this option is enabled 2 6 Generating a List File The list file is an additional output file that contains information about the generated code You can customiz
18. the Linker entry and select Optimization You can enable or disable the optimizations described below The command line option for each optimization is given in brackets qo See also option optimize O in section 2 2 Linker Options in Chapter Tool Options of the reference manual Delete unreferenced sections option Oc OC This optimization removes unused sections from the resulting object file Because debug information normally refers to all sections the optimization has no effect until you compile your project without debug information or use linker option strip debug to remove the debug information First fit decreasing option Ol OL When the physical memory is fragmented or when address spaces are nested it may be possible that a given application cannot be located although the size of the available physical memory is larger than the sum of the section sizes Enable the first fit decreasing optimization when this occurs and re link your application The linker s default behavior is to place sections in the order that is specified in the LSL file that is working from low to high memory addresses or vice versa This also applies to sections within an unrestricted group If a memory range is partially filled and a section must be located that is larger than the remainder of this range then the section and all subsequent sections are placed in a next memory range As a result of this gaps occur at the end of a memory range
19. to mark the begin of the stack or heap or copy table lc b name lc ue name End of section name Also used to mark the end of the stack or heap lc e name lc cb name Start address of an overlay section in ROM 3 17 Using the TSK165x Embedded Tools Label Description lc ce name End address of an overlay section in ROM lc gb name Begin of group name This label appears in the output file even if no reference to the label exists in the input file lc ge name End of group name This label appears in the output file even if no reference to the label exists in the input file Table 3 5 Linker labels The linker only allocates space for the stack and or heap when a reference to either of the section labels exists in one of the input object files Additionally the linker script file defines the following symbols Symbol Description init Start of initialization routine Same as 1c ub dinit qo See also section 5 9 4 Creating Symbols in Chapter 5 Linker Script Language of the reference manual Example refer to the stack Suppose in an LSL file you have defined a stack section with the name stack with the keyword stack You can refer to the end of the stack from your assembly source as follows extern _ lc ue stack end of stack Using the Linker 3 9 Generating a Map File The map file is an additional output
20. tools in the toolset and lets you quickly generate an absolute object file from C and or assembly source input files tmk A utility program to maintain update and reconstruct groups of programs The make utility looks whether files are out of date rebuilds them and determines which other files as a consequence also need to be rebuilt tlb A librarian With this utility you create and maintain library files with relocatable object modules obj generated by the assembler 4 1 Using the TSK165x Embedded Tools 4 2 Control Program The control program is a tool that invokes all tools in the toolset for you It provides a quick and easy way to generate the final absolute object file out of your C sources without the need to invoke the assembler and linker manually 4 2 1 Calling the Control Program You can only call the control program from the command line The invocation syntax is cctarget option file where target is the target you are building for Recognized input files The control program recognizes the following input files e Files with a asm suffix are interpreted as hand written assembly source files which have to be passed to the assembler e Files with a src suffix are interpreted as compiled assembly source files They are directly passed to the assembler e Files with a 1ib suffix are interpreted as library files and are passed to the linker e Files with a ob suffix are interpreted as ob
21. Designer creates and uses a makefile to build your entire project After you have build your project the output files of the linking step are available in your project directory unless you specified an alternative output directory in the Build Options page of the Project Options dialog To link your program Click the following button L3 Compile Active Project Builds your entire project but only updates files that are out of date or have been changed since the last build which saves time Or select Recompile Embedded Project from the Projects menu Builds your entire project unconditionally All steps necessary to obtain the final abs file are performed To access the linker options 1 From the Project menu select Project Options The Project Options dialog box appears 2 Expand the Linker entry 3 Select the sub entries and set the options in the various pages The command line variant is shown simultaneously Invocation syntax on the command line Windows Command Prompt The invocation syntax on the command line is 1k165x option file When you are linking multiple files either relocatable object files obj or libraries 1ib it is important to specify the files in the right order This is explained in Section 3 4 Linking with Libraries Example 1k165x d165x 1sl test obj This links and locates the file test ob and generates the file test abs 3 4 Using the Linker 3 3 1 Overview of
22. Designer menu entries and dialogs E Command line type your input on the command line d gt Reference follow this reference to find related topics vii Using the TSK165x Embedded Tools Related Publications C Standards e ISO IEC 9899 1999 E Programming languages C ISO IEC More information on the standards can be found at http www ansi org e DSP C An Extension to ISO IEC 9899 1999 E Programming languages C TASKING TK0071 14 MISRA C e Guidelines for the Use of the C Language in Vehicle Based Software MIRA limited 1998 See also http www misra org uk e MISRA C 2004 Guidelines for the use of the C Language in critical systems MIRA limited 2004 See also http www misra c com TASKING Tools e TSK165x Embedded Tools Reference Altium TRO106 e TSK165x RISC MCU Core Reference Altium CRO114 viii 1 Getting Started with Embedded Software Summ ary This tutorial shows how to create an embedded software project with Altium Designer 1 1 Introduction This tutorial presumes you are familiar with programming in C assembly and have basic knowledge of embedded programming It contains an overview of the TASKING tools available in Altium Designer It describes how you can add create and edit source files in an embedded project and how to build an embedded application An embedded software project is normally used as a subproject for an FPGA project and once they are built they are downlo
23. FT space bit mau 8 id 3 width 8 mau 1 256 id 1 mau 8 128 space code bus code bus 0 1 id 2 mau 12 mau 12 width 12 2k Figure 3 2 Scheme of the c165x architecture The figure shows three address spaces called data bit and code The address space bit is a subset of the address space data All address spaces have attributes like a number that identifies the logical space id a MAU and an alignment In LSL notation the definition of these address spaces look as follows Using the Linker space data id 1 mau 8 map src_offset 0x00 dest_offset 0x00 size 0x10 map src offset 0x10 dest offset 0x10 size 0x10 map src offset 0x20 dest offset 0x00 size 0x10 map src offset 0x30 dest offset 0x30 size 0x10 map src offset 0x40 dest offset 0x00 size 0x10 map src offset 0x50 dest offset 0x50 size 0x10 map src offset 0x60 dest offset 0x00 size 0x10 map src offset 0x70 dest offset 0x70 size 0x10 space bit id 2 3 mau 1 map size 0x100 dest space data space code id 2 mau 12 map size 2k dest bus code_bus dest bus dest bus dest bus dest bus dest bus dest bus dest bus dest bus The keyword map corresponds with the arrows in the drawing You can map address space gt address space address space gt bus memory gt bus not shown in the drawing bus gt bus not shown in the drawi
24. KING program builder compiles assembles links and locates the files in the embedded project that are out of date or that have been changed during a previous build The resulting file is the absolute object file GettingStarted abs in the IEEE 695 format 2 You can view the results of the build in the Output panel View Workspace Panels System Output TASKING program builder vl l63r0 Build 076 SN 00000000 Assembling hello asm asl65x Il45 hello asm 6 Hello World Linking and Locating 1 5 4 Compiling a single source file If you want to compile a single source file 1 Right click on the file he110 asm you want to compile and select Compile Document hello asm Alternatively you can open a file in the Text Editor and select Project Compile Document hello asm 2 Open the Messages panel to view any errors that may have occurred during compilation by selecting View Workspace Panels System Messages or selecting System Messages from the Panels tab 3 Correct any errors in your source files Save your project files 1 5 2 Rebuiling your entire application If you want to build your embedded application from scratch regardless of their date time stamp you can perform a recompile 1 Select Project Recompile Embedded Project GettingStarted PrjEmb 2 The TASKING program builder compiles assembles links and locates all files in the embedded project unconditionally Using the TSK165x Embedded Tools Yo
25. PCB the components on the FPGA become part of the board design and there is no need to distinguish between internal and external memory For this reason you probably do not need to work with derivative definitions at all There are however two situations where derivative definitions are useful 1 When you re use an FPGA design for several board designs it may be practical to write a derivative definition for the FPGA design and include it in the project LSL file 2 When you want to use multiple cores of the same type you must instantiate the cores in a derivative definition since the linker automatically instantiates only a single core for an unused architecture The processor definition The processor definition describes an instance of a derivative A processor definition is only needed in a multi processor embedded system It allows you to define multiple processors of the same type If for a derivative A no processor is defined in the LSL file the linker automatically creates a processor named A of derivative A This is why for single processor applications it is enough to specify the derivative in the LSL file The memory and bus definitions optional Memory and bus definitions are used within the context of a derivative definition to specify internal memory and on chip buses In the context of a board specification the memory and bus definitions are used to define external off chip memory and buses Given the above definiti
26. S record format 3 3 O Object code 3 2 Optimizations assembler 2 4 allow generic instructions 2 5 jump chains 2 5 optimize instruction size 2 5 copy table compression 3 8 delete duplicate code sections 3 9 delete duplicate constant data 3 9 delete unreferenced sections 3 8 first fit decreasing 3 8 linker 3 8 Output formats See Linker output formats P Physical address 3 2 Processor 3 2 class 2 2 selecting a core 2 2 Processor definition 3 10 3 15 Processors Selecting a device 1 5 Setting a target processor 1 5 Project Embedded 1 4 Projects Embedded projects 1 1 R Relocatable object file 3 1 3 2 debug information 3 3 header information 3 2 object code 3 2 relocation information 3 3 symbols 3 2 Relocation 3 2 Relocation expressions 3 3 Relocation information 3 2 Resolving symbols 3 7 S Section 3 2 Section attributes 3 2 Section layout definition 3 10 3 16 Sections locating 3 16 Setting Breakpoints 1 8 Space names 3 12 Index T Utilities Target 3 2 control program 4 2 Target processors in embedded projects 1 5 librarian 4 12 TASKING tools 1 1 make utility 4 4 U V Unresolved reference 3 2 Verbose option linker 3 7 Index 3 Using the TSK165x Embedded Tools Index 4
27. Using the TSK165x Embedded Tools GU0108 April 29 2008 Software hardware documentation and related materials Copyright 2008 Altium Limited All Rights Reserved The material provided with this notice is subject to various forms of national and international intellectual property protection including but not limited to copyright protection You have been granted a non exclusive license to use such material for the purposes stated in the end user license agreement governing its use In no event shall you reverse engineer decompile duplicate distribute create derivative works from or in any way exploit the material licensed to you except as expressly permitted by the governing agreement Failure to abide by such restrictions may result in severe civil and criminal penalties including but not limited to fines and imprisonment Provided however that you are permitted to make one archival copy of said materials for back up purposes only which archival copy may be accessed and used only in the event that the original copy of the materials is inoperable Altium Altium Designer Board Insight DXP Innovation Station LiveDesign NanoBoard NanoTalk OpenBus P CAD SimCode Situs TASKING and Topological Autorouting and their respective logos are trademarks or registered trademarks of Altium Limited or its subsidiaries All other registered or unregistered trademarks referenced herein are the property of their respective owners and no trademark rig
28. able IP cores loaded in an FPGA Each core may execute a different program and external memory may be shared by multiple cores The linker takes the following files for input and output relocatable object files obj m gt relocatable linker object file out relocatable object library Lib linker script file 1s1 gt linker map file map linker error messages elk L relocatable linker object file out ew memory definition file mdf Intel Hex IEEE 695 Motorola S record absolute object file absolute object file absolute object file hex abs sre Figure 3 1 Linker This chapter first describes the linking process Then it describes how to call the linker and how to use its options An extensive list of all options and their descriptions is included in section 2 2 Linker Options of the reference manual To control the link process you can write a script for the linker This chapter shortly describes the purpose and basic principles of the Linker Script Language LSL on the basis of an example A complete description of the LSL is included in Chapter 5 Linker Script Language of the reference manual 3 2 Linking Process The linker combines and transforms relocatable object files obj into a single absolute object file This process consists of two phases the linking phase and the locating phase In the first phase the linker combines the supplied relocatable
29. absolute object file hex abs sre debugger simulator or hardware Figure 1 1 Toolset overview Getting Started with Embedded Software The following table lists the file types used by the TASKING toolset Extension Description Source files asm Assembler source file hand coded Isl Linker script file Object files obj IEEE 695 relocatable object file generated by the assembler lib Archive with IEEE 695 object files out Relocatable linker output file abs IEEE 695 absolute object file generated by the locating part of the llinker hex Absolute Intel Hex object file sre Absolute Motorola S record object file List files Ast Assembler list file map Linker map file Error list files ers Assembler error messages file elk Linker error messages file Table 1 1 File extensions Using the TSK165x Embedded Tools 1 3 Creating an Embedded Project To start working with Altium Designer you first need a project A project makes managing your source documents and any generated outputs much easier For embedded software you need to create an Embedded Software project To create a new Embedded Software project 1 Select File New Project Embedded Project form the menu or click on Blank Project Embedded in the New section of the Files panel If this panel is not displayed click on the Files tab at the bottom of the Design Manager panel The Proje
30. aded and executed inside an FPGA device The example used in this tutorial is a sample program in assembly Other examples are supplied in the Examples NanoBoard Common Processor Examples folder relative to the installation path 1 2 Embedded Software Tools With the TASKING embedded software tools in Altium Designer you can write compile assemble and link applications for several targets such as the TSK51x TSK52x TSK80x TSK165x PowerPC TSK3000 MicroBlaze Nios II and ARM Figure 1 1 shows all components of the TASKING toolset with their input and output files The assembler linker and debugger are target dependent whereas the librarian is target independent The bold names in the figure are the executable names of the tools Substitute target with one of the supported target names for example as165x is the TSK165x assembler 1 1 Using the TSK165x Embedded Tools assembly file asm assembler m listfile lst astarget error messages ers librarian r relocatable object file tlb L obj relocatable object library lib m relocatable linker object file out Y linker script file linker m linker map file map lsl Iktarget error messages elk relocatable linker object file gt memory definition file mdf out i Intel Hex IEEE 695 Motorola S record absolute object file absolute object file
31. and their properties e Select View Workspace Panels Embedded Breakpoints 1 6 2 Evaluating and watching expressions While debugging you can examine the value of expressions in the Evaluate panel 1 Open the Evaluate panel by selecting View Workspace Panels Embedded Evaluate 2 Inthe edit field enter the expression you want to evaluate and click Evaluate The expression and its value appear below in the Evaluate panel Click on the Evaluate button every time the variable in the code is modified To watch an expression continuously you can set a watch 3 Select Add Watch The new expression and its value appear in the Watches panel The values in the Watches panel are updated continuously when the code is executing Alternatively Select Debug Add Watch enter an expression and click OK t The way an expression is evaluated depends strongly on the amount of debug information in the object file Also the optimization level influences the ease of debugging Getting Started with Embedded Software 1 6 3 Viewing memory It is possible to view the contents of the memory You can open several memory windows Remember you must be in debugging mode The type of memory windows you can open depends on the selected target processor To open for example the Main memory window 1 2 Select View Workspace Panels Embedded Main The Main memory window opens showing the contents of the memory A
32. arious pages The command line variant is shown simultaneously Invocation syntax on the command line Windows Command Prompt The invocation syntax on the command line is astarget option file The input file must be an assembly source file asm or src astarget can be one of the supported assemblers For example as165x for the TSK165x Using the Assembler Example asl65x test asm This assembles the file test asm and generates the file test ob which serves as input for the linker 2 3 1 Overview of Assembler Options You can set the following assembler options in Altium Designer Menu entry Command line Build Options Include files path ldir Processor Processor Definition Select processor C tsk165a tsk165b tsk165c Assembler Preprocessing User macro Dmacro value Include this file before source Hfile Assembler Optimization Generic instructions Og Jump chains Oj Instruction size Os Assembler Debug Information Symbolic Debug Generation Automatic HLL or assembly level debug information gs Custom debug information No debug information gAHLS Custom debug information gflags Assembler source line information ga Pass HLL debug information gh Assembler local symbols information gl Assembler List File Generate list file I Display section information tl List file format Lflags Assembler Diagnostic
33. as possible only the defined symbols of the library members are recorded in this area When the linker finds a symbol that matches an unresolved external the corresponding object file is extracted from the library and is processed After processing the object file the remaining library index is searched If after a complete search of the library unresolved externals are introduced the library index will be scanned again After all files and libraries are processed and there are still unresolved externals and you did not specify the linker option no rescan all libraries are rescanned again This way you do not have to worry about the library order on the command line and the order of the object files in the libraries The verbose option shows how libraries have been searched and which objects have been extracted Resolving symbols If you are linking from libraries only the objects that contain symbols to which you refer are extracted from the library This implies that if you invoke the linker like nothing is linked and no output file will be produced because there are no unresolved symbols when the linker searches through mylib lib It is possible to force a symbol as external unresolved symbol with the option extern e In this case the linker searches for the symbol main in the library and if found extracts the object that contains main If this module contains new unresolved symbols the linker looks again in mylib 1lib T
34. ation through the toolset As an example consider the following assembly part section non volatile data clear global _battery backup invok battery backup invok ds 2 This defines a section with the name non volatile of section type data carrying section attribute clear The section type and attributes tell the linker to locate the section in address space data and that the section content should be filled with zeros at startup Using the Linker Section placement The data of the example should be saved in non volatile battery back upped memory This is the memory my_nvram from the example in section 3 7 7 The Memory Definition To control the locating of sections you need to write one or more section definitions in the LSL file At least one for each address space where you want to change the default behavior of the linker In our example we need to locate sections in the address space data section_layout data Section placement statements To locate sections you must create a group in which you select sections from your program For the battery back up example we need to define one group which contains the section non volatile All other sections are located using the defaults specified in the architecture definition Section non_volatile should be placed in non volatile ram To achieve this the run address refers to our non volatile memory called my_nvram Furthermore the section should not be clear
35. bes several utilities and how you can use them to facilitate various tasks The following utilities are included control program make utility and librarian vi Manual Purpose and Structure Conventions Used in this Manual Notation for syntax The following notation is used to describe the syntax of command line input bold Type this part of the syntax literally italics Substitute the italic word by an instance For example filename Type the name of a file in place of the word filename Encloses a list from which you must choose an item Encloses items that are optional For example as165x Both as165x and as165x are valid commands Separates items in a list Read it as OR You can repeat the preceding item zero or more times Example as165x option filename You can read this line as follows enter the command as165x with or without an option follow this by zero or more options and specify a filename The following input lines are all valid asl65x test asm asl65x g test asm asl65x g l test asm Not valid is asl65x g According to the syntax description you have to specify a filename Icons The following illustrations are used in this manual AN Note notes give you extra information A Warning read the information carefully It prevents you from making serious mistakes or from loosing information Q This illustration indicates actions you can perform with the mouse Such as Altium
36. ct Save Project Your project now looks like Getting Started with Embedded Software Projects M C Embedded Software Development sj hello asm Workspace1 Dsriwrk X Section Text Code GettinaStarted PriEmb seer HA Monde nr Project GOTO MainProc File View O Structure Editor MainProc EE GettingStarted PriEmb d message I Hello World LG Source Documents a GN T 1 3 2 Adding an existing source file to the project If you want to add an exisiting source file to your project proceed as follows 1 In the Projects panel right click on GettingStarted PrjEmb and select Add Existing to Project The Choose Documents to Add to Project dialog appears 2 Navigate to the file you want to add to your project and click Open The source file is added to the project and listed in the Projects panel To edit or view the recently added file in the Text Editor 3 Double click on the filename Save your project 4 Inthe Projects panel right click on GettingStarted PrjEmb and select Save Project 1 4 Setting the Embedded Project Options An embedded project in Altium Designer has a set of embedded options associated with it After you have added files to your project and have written your application hello asmin our example the next steps in the process of building your embedded application are e selecting a device resulting in an associated toolset e specifying the options of the tools in the toolset suc
37. cts panel displays a new project file Embedded_Project1 PrjEmb Projects vex Workspacel Dsnwrk v Workspace Embedded_Project1 PriEmb Project adil File View Structure Editor ail Embedded Project1 PriEmb B Bl No Documents Added 2 Rename the new project file with a PrjEmb extension by selecting File Save Project As Navigate to the location where you want to save your project type the name GettingStarted PrjEmb in the File name field and click on Save 1 3 1 Adding a new source file to the project If you want to add a new source file assembly or text file to your project proceed as follows 1 In the Projects panel right click on GettingStarted PrjEmb and select Add New to Project Assembly File A new Assembly source file Source1 ASM is added to the Embedded Software project under the folder named Source Documents in the Projects panel The Text Editor opens ready for your input t For a new text file select Text Document instead of Assembly File 2 Enter the source code required For this tutorial enter the following code Section Text Code Start GOTO MainProc MainProc message I Hello World END 3 Save the source file by selecting File Save As Navigate to the location where you want to store the source type the name hello asmin the File name field and click on Save 4 Save your project by right clicking on GettingStarted PrjEmb in the Projects panel and sele
38. d locations in the following order 1 Ifthe INCLUDE directive contains a path name the assembler looks for this file If no path is specified the assembler looks in the same directory as the source file 2 When the assembler did not find the include file it looks in the directories that are specified in the Build Options page of the Project Options dialog equivalent to the I command line option 3 When the assembler did not find the include file because it is not in the specified include directory or because no directory is specified it looks in the path s specified in the environment variable AStargetINC for example AS165XINC for the TSK165x 4 When the assembler still did not find the include file it finally tries the default include directory relative to the installation directory Example Suppose that the assembly source file test asm contains the following lines INCLUDE myinc inc You can call the assembler as follows astarget Imyinclude test asm First the assembler looks for the file myinc inc in the directory where test asm is located If the file is not there the assembler searches in the directory myinclude If it was still not found the assembler searches in the environment variable and then in the default include directory 2 5 Assembler Optimizations The assembler performs various optimizations to reduce the size of assembled applications There are two options available to influence the degree of
39. e end of the module If the module already exists in the library it is replaced tlb r mylib lib mod3 obj Print a list of object modules in the library To inspect the contents of the library tlb t mylib lib The library has the following contents cstart obj calc obj mod3 obj Move an object module to another position To move mod3 obj to the beginning of the library position it just before cstart obj tlb mb cstart obj mylib lib mod3 obj Delete an object module from the library To delete the object module cstart obj from the library mylib lib tlb d mylib lib cstart obj Extract all modules from the library Extract all modules from the library mylib lib tlb x mylib lib 4 13 Using the TSK165x Embedded Tools Index Index A Absolute object file 3 2 Address 3 2 Address spaces 3 12 Architecture 3 2 Architecture definition 3 10 3 11 Assembler 2 1 error messages 2 5 invocation 2 2 optimizations 2 4 setting options 2 2 Assembler settings 1 7 Assembly process 2 1 Board specification 3 10 Breakpoints 1 8 Building an Embedded Application 1 7 Bus 3 14 Bus definition 3 10 C C prepocessor 3 9 C programming 1 1 C source files Adding a new source file to a project 1 4 Adding existing files to a project 1 5 ChromaCoding 3 9 Code modification 3 3 Compiling a single source file 1 7 Control program 4 2 invocation 4 2 options overview 4 3 Controlling the linke
40. e the amount and form of information If the assembler generates errors or warnings these are reported in the list file just below the source line that caused the error or warning To generate a list file 1 From the Project menu select Project Options The Project Options dialog box appears 2 Expand the Assembler entry and select List File 3 Select Generate list file 4 Optional Enable the options to include that information in the list file Example on the command line Windows Command Prompt The following command generates the list file test 1st astarget l test asm 2 7 Assembler Error Messages The assembler produces error messages of the following types F Fatal errors After a fatal error the assembler immediately aborts the assembly process 2 5 Using the TSK165x Embedded Tools E Errors Errors are reported but the assembler continues assembling No output files are produced unless you have set the assembler option keep output files the resulting output file may be incomplete W Warnings Warning messages do not result into an erroneous assembly output file They are meant to draw your attention to assumptions of the assembler for a situation which may not be correct You can control warnings in the Assembler Diagnostics page of the Project Project Options menu assembler option no warnings Display detailed information on diagnostics 1 From the View menu select Workspace Pan
41. ecified targets it continues with the rules following this target IGNORE Non zero error codes returned from commands are ignored Encountering this in a makefile is the same as specifying the option i on the command line INIT The rules following this target are executed before any other targets are built PRECIOUS Dependency files mentioned for this target are never removed Normally if a command in a rule returns an error or when the target construction is interrupted the make utility removes that target file SILENT Commands are not echoed before executing them Encountering this in a makefile is the same as specifying the option s on the command line SUFFIXES This target specifies a list of file extensions Instead of building a completely specified target you now can build a target that has a certain file extension Implicit rules to build files with a number of extensions are included in the system makefile tmk mk If you specify this target with dependencies these are added to the existing SUFFIXES target in tmk mk If you specify this target without dependencies the existing list is cleared Rules A line with leading white space tabs or spaces is considered as a rule and associated with the most recently preceding dependency line A rule is a line with commands that are executed to build the associated target A target dependency line can be followed by one or more rules final obj final a
42. ed and therefore the attribute s scratch is assigned to the group group ordered run_addr mem my_nvram attributes rws select non volatile Section placement from Altium Designer To specify the above settings using Altium Designer follow these steps 1 From the Project menu select Project Options The Project Options dialog box appears 2 Open the Sections Reserved Areas tab 3 Click Add Section The Section dialog box appears 4 Inthe Name field enter non_volatile 5 Inthe Space field select data 6 Inthe Location field enter mem my_nvram This completes the LSL file for the sample architecture and sample program You can now invoke the linker with this file and the sample program to obtain an application that works for this architecture qe For a complete description of the Linker Script Language refer to Chapter 5 Linker Script Language in the reference manual 3 8 Linker Labels The linker creates labels that you can use to refer to from within the application software Some of these labels are real labels at the beginning or the end of a section Other labels have a second function these labels are used to address generated data in the locating phase The data is only generated if the label is used Linker labels are labels starting with Ic The linker assigns addresses to the following labels when they are referenced Label Description lc ub name Begin of section name Also used
43. els System Messages The Messages panel appears 2 In the Messages panel right click on the message you want more information on A popup menu appears 3 Select More Info A Message Info box appears with additional information On the command line you can use the assembler option diag to see an explanation of a diagnostic message astarget diag format all number qo See assembler option diag in section 2 1 Assembler Options in Chapter Tool Options of the reference manual 2 6 3 Using the Linker Summary This chapter describes the linking process how to call the linker and how to control the linker with a script file 3 1 Introduction The TASKING linker is a combined linker locator The linker phase combines relocatable object files obj files generated by the assembler and libraries into a single relocatable linker object file out The locator phase assigns absolute addresses to the linker object file and creates an absolute object file which you can load into a target processor From this point the term inker is used for the combined linker locator The linker can simultaneously link and locate all programs for all cores available on a target board The target board may be of arbitrary complexity A simple target board may contain one standard processor with some external memory that executes one task A complex target board may contain multiple standard processors and DSPs combined with configur
44. f the linking phase is a single relocatable object file out If this file contains unresolved references you can link this file with other relocatable object files obj or libraries 1ib to resolve the remaining unresolved references With the linker command line option link only you can tell the linker to only perform this linking phase and skip the locating phase The linker complains if any unresolved references are left 3 2 2 Phase 2 Locating In the locating phase the linker assigns absolute addresses to the object code placing each section in a specific part of the target memory The linker also replaces references to symbols by the actual address of those symbols The resulting file is an absolute object file which you can actually load into a target memory Optionally when the resulting file should be loaded into a ROM device the linker creates a so called copy table section which is used by the startup code to initialize the data sections Code modification When the linker assigns absolute addresses to the object code it needs to modify this code according to certain rules or relocation expressions to reflect the new addresses These relocation expressions are stored in the relocatable object file Consider the following snippet of x86 code that moves the contents of variable a to variable b via the eax register Al 3412 0000 mov a eax a defined at 0x1234 byte reversed A3 0000 0000 mov eax b b is imported so the inst
45. file that contains information about the location of sections and symbols You can customize the type of information that should be included in the map file To generate a map file 1 From the Project menu select Project Options The Project Options dialog box appears 2 Expand the Linker entry and select Map File 3 Select Generate a memory map file map 4 Optional Enable the options to include that information in the map file Example on the command line Windows Command Prompt lktarget M test obj With this command the map file test map is created See section 3 2 Linker Map File Format in Chapter List File Formats of the reference manual for an explanation of the format of the map file Linker option map file M Generate task related map file Linker option map file format m Map file formatting 3 10 Linker Error Messages The linker produces error messages of the following types F Fatal errors After a fatal error the linker immediately aborts the link locate process E Errors Errors are reported but the linker continues linking and locating No output files are produced unless you have set the linker option keep output files W Warnings Warning messages do not result into an erroneous output file They are meant to draw your attention to assumptions of the linker for a situation which may not be correct You can control warnings in the Linker Diagnostics page of the Project Projec
46. fy the script file to the linker which reads it and locates your application exactly as defined in the script If you do not specify your own script file the linker always reads a standard script file which is supplied with the toolset 3 7 1 Purpose of the Linker Script Language The Linker Script Language LSL serves three purposes 1 It provides the linker with a definition of the target s core architecture This definition is supplied with the toolset 2 It provides the linker with a specification of the memory attached to the target processor 3 It provides the linker with information on how your application should be located in memory This gives you for example the possibility to create overlaying sections The linker accepts multiple LSL files You can use the specifications of the core architectures that Altium has supplied in the include 1s1 directory Do not change these files If you use a different memory layout than described in the LSL file supplied for the target core you must specify this in a separate LSL file and pass both the LSL file that describes the core architecture and your LSL file that contains the memory specification to the linker Next you may want to specify how sections should be located and overlaid You can do this in the same file or in another LSL file LSL has its own syntax In addition you can use the standard C preprocessor keywords such as include and define because the linker sends the scrip
47. h as the assembler and linker options Different toolset configurations may have different sets of options 1 4 1 Selecting a device For an embedded project you must specify the device for which you want to build your embedded project first 1 In the Projects panel right click on GettingStarted PrjEmb and select Project Options Alternatively select Project Project Options The Options for Embedded Project dialog appears Using the TSK165x Embedded Tools Options for Embedded Project GettingStarted PrjEmb Compiler Options Files With Options Parameters Configure Memory Sections Reserved Areas Device TSK30004 Build Options Device Selection i r Generic Processor Save project documents before compile Actel C Compiler Keep temporary files that are generated during a compil sy Assembler il Pera Stop build process on error Linker i i E Bam Use absolute path names in generated makefile 4i TSK51 Device Software Framework Use additional make options 4 TSK52 POSIX Configuration TsKe0 E Use user defined makefile TSK165 TSK3000 E Directories EE a Executable files path AMCC Include files path NXP Library files path Sharp Library source files path Xilinx Debug search path Output directory instead of project directory Description Set To Installation Defaults 2 Inthe Compiler Options tab select the Device You can make a selection based on manufacturer or you can
48. hen all subsequent lines are placed in a temporary file until the line LABEL is encountered Next lt lt LABEL is replaced by the name of the temporary file Example o f lt lt EOF separate Mn match obj separate Mn match lib LKFLAGS EOF The three lines between lt lt EOF and EOF are written to a temporary file for example mkce4c0a tmp and the rule is rewritten as o 80 f mkce4c0a tmp Suffix targets Instead of specifying a specific target you can also define a general target A general target specifies the rules to generate a file with extension ex1 to a file with extension ex2 For example SUFFIXES asm asm obj asl65x lt Read this as to build a file with extension ob out of a file with extension asm call the assembler with lt lt is a predefined macro that is replaced with the basename of the specified file The special target SUFFIXES is followed by a list of file extensions of the files that are required to build the target Implicit rules Implicit rules are stored in the system makefile tmk mk and are intimately tied to the SUFFIXES special target Each dependency that follows the SUFFIXES target defines an extension to a filename which must be used to build another file The implicit rules then define how to actually build one file from another These files share a common basename but have different extensions If the specified target on the command
49. his process repeats until no new unresolved symbols are found Using the TSK165x Embedded Tools 3 5 Incremental Linking With the TASKING linker it is possible to link incrementally Incremental linking means that you link some but not all obj modules to a relocatable object file out In this case the linker does not perform the locating phase With the second invocation you specify both new obj files as the out file you had created with the first invocation LN Incremental linking is only possible on the command line 1k165x d165x 1sl r testl obj otest out 1k165x d165x 1sl test2 obj test out This links the file test1 obj and generates the file test out This file is used again and linked together with test2 obj to create the file test abs the default name if no output filename is given in the default IEEE 695 format With incremental linking it is normal to have unresolved references in the output file until all ob files are linked and the final out or abs file has been reached The option incremental r for incremental linking also suppresses warnings and errors because of unresolved symbols 3 6 Linker Optimizations During the linking and locating phase the linker looks for opportunities to optimize the object code Both code size and execution speed can be optimized To enable or disable optimizations 1 From the Project menu select Project Options The Project Options dialog box appears 2 Expand
50. hts to the same are claimed v8 0 31 3 08 Table of Contents Table of Contents Getting Started with Embedded Software 1 1 1 1 IMO UCONN irera anaa eaa i aa ean eee Aina tune a heh ea E We Ro eae ade 1 1 1 2 Embedded Software Tools 000s cece een eens 1 1 1 3 Creating an Embedded Project 0 0 cece cece nnn 1 4 1 3 1 Adding a new source file to the project 0 eee I 1 4 1 3 2 Adding an existing source file to the project eee eee ees 1 5 1 4 Setting the Embedded Project Options 0 00 cece 1 5 1 4 1 Selecting a device issus nied eine Saw ea Rag dln UD RR aad EG Rew E E ee 1 5 1 4 2 Setting the tool options cette teeta 1 6 1 5 Building your Embedded Application 0 0 cee cece 1 7 1 5 1 Compiling a single source fil 1 teeta 1 7 1 5 2 Rebuiling your entire application 0 cette ene nes 1 7 1 6 Debugging your Embedded Application 0 cece eee 1 8 1 6 1 Setting breakpoints 3 4s eViee D e rep PROP ida coe eee aa bs 1 8 1 6 2 Evaluating and watching expressions 0 ccc eee eens 1 8 1 6 3 Viewing IMEMONY whos ceedetaese beer nia ia ai o a ioe Piigxres 1 9 Using the Assembler 2 1 2 1 IntrOQU EOD orense seimai canc s al nerd cage ERR Aa Oke or aed DOR ad aes 2 1 2 2 Assembly Process 2 ave Lara Oe vede bedi a elita e d orien UR Dueb eee eed 2 1 2 3 Calling the Assembler sslssessseeseeR eee nr 2 2 2 3 1 Overview of Assembler
51. ian takes the following files for input and output assembler librarian r relocatable object file tlb c 0bj relocatable object library lib linker Figure 4 1 Librarian The linker optionally includes object modules from a library if that module resolves an external symbol definition in one of the modules that are read before 4 4 1 Calling the Librarian You can only call the librarian from the command line The invocation syntax is tlb key option sub option library object file key option With a key option you specify the main task which the librarian should perform You must always specify a key option sub option Sub options specify into more detail how the librarian should perform the task that is specified with the key option It is not obligatory to specify sub options library The name of the library file on which the librarian performs the specified action You must always specify a library name except for the option and V When the library is not in the current directory specify the complete path either absolute or relative to the library object file The name of an object file You must always specify an object file name when you add extract replace or remove an object file from the library 4 4 2 Overview of Librarian Options The following librarian options are available Description Option Sub option Main functions
52. ibraries you want to add and click Open 3 Click OK to accept the new project settings When you want to link user libraries from the command line you must specify their filenames on the command line If the library resides in a sub directory specify that directory with the library name If you do not specify a directory the linker searches the library in the current directory only Library order The order in which libraries appear on the command line is important By default the linker processes object files and libraries in the order in which they appear at the command line With the option first library first you can tell the linker to scan the libraries from left to right and extract symbols from the first library where the linker finds it This can be useful when you want to use newer versions of a library routine If the file test ob calls a function which is both present in a 1ib and b lib normally the function in b 1ib would be extracted With this option the linker first tries to extract the symbol from the first library a Lib Note that routines in b 1ib that call other routines that are present in both a 1ib and b lib are now also resolved from a lib 3 4 1 How the Linker Extracts Objects from Libraries A library built with the TASKING librarian tlb always contains an index part at the beginning of the library The linker scans this index while searching for unresolved externals However to keep the index as small
53. ipt file 3 3 architecture definition 3 10 3 11 board specification 3 10 bus definition 3 10 Index 1 Using the TSK165x Embedded Tools derivative definition 3 10 3 14 memory definition 3 10 3 15 processor definition 3 10 3 15 section layout definition 3 10 3 16 structure 3 10 Linker script language LSL 3 3 3 9 internal memory 3 14 on chip memory 3 14 Linking process 3 1 incremental linking 3 8 linking 3 2 locating 3 3 optimizations 3 8 List file generating 2 5 Locating 3 3 Logical address 3 2 LSL 3 9 LSL file 3 2 M Make utility 4 4 DEFAULT target 4 7 DONE target 4 7 IGNORE target 4 7 INIT target 4 7 PRECIOUS target 4 7 SILENT target 4 7 SUFFIXES target 4 7 comment lines 4 11 conditional processing 4 11 dependency 4 6 drive letters 4 6 else 4 11 endif 4 11 exist function 4 10 export lines 4 11 functions 4 10 ifdef 4 11 ifndef 4 11 implicit rules 4 8 include lines 4 11 invocation 4 5 macro definition 4 5 macro definitions 4 8 macro MAKE 4 9 macro MAKEFLAGS 4 9 macro PRODDIR 4 9 macro SHELLCMD 4 9 makefile 4 4 4 6 match function 4 10 nexist function 4 10 options overview 4 5 predefined macros 4 9 protect function 4 10 rules in makefile 4 7 separate function 4 10 special targets 4 7 Index 2 Makefile 4 4 writing 4 6 Map file 3 19 MAU 3 2 Memory 3 14 Memory definition 3 10 3 15 Memory viewing 1 9 Motorola
54. ired In essence an architecture definition describes how the linker should convert logical addresses into physical addresses for a given type of core If the core supports multiple address spaces then for each space the linker must know how to perform this conversion In this context a physical address is an offset on a given internal or external bus Additionally the architecture definition contains information about items such as the hardware stack and the vector table This specification is normally written by Altium Altium supplies LSL files in the include 1s1 directory The architecture definition of the LSL file should not be changed by you unless you also modify the core s hardware architecture If the LSL file describes a multi core system an architecture definition must be available for each different type of core The linker uses the architecture name in the LSL file to identify the target For example the default library search path can be different for each core architecture The derivative definition The derivative definition describes the configuration of the internal on chip bus and memory system Basically it tells the linker how to convert offsets on the buses specified in the architecture definition into offsets in internal memory Microcontrollers and DSPs often have internal memory and I O sub systems apart from one or more cores The design of such a chip is called a derivative When you design an FPGA together with a
55. j 2 If test obj does not exist or is out of date the make utility first tries to build this file and reads from the makefile that test obj depends on test src 3 There are no other files necessary to create test abs so the make utility now can use test obj to create test abs by executing the rule test obj o test abs The make utility has now built test abs but it only used the assembler to update test ob and the linker to create test abs If you compare this to the control program ccl65x test asm 4 4 Using the Utilities This invocation has the same effect but now all files are recompiled assembled linked and located 4 3 1 Calling the Make Utility You can only call the make utility from the command line The invocation syntax is tmk option target macro def For example tmk test abs target You can specify any target that is defined in the makefile A target can also be one of the intermediate files specified in the makefile macro def Macro definition This definition remains fixed for the tmk invocation It overrides any regular definitions for the specified macro within the makefiles and from the environment It is inherited by subordinate tmk s but act as an environment variable for these That is depending on the e setting it may be overridden by a makefile definition Exit status tmk returns an exit status of 1 when it halts as a result of an error Otherwise it returns an exit s
56. ject files and are passed to the linker e Files with a out suffix are interpreted as linked object files and are passed to the locating phase of the linker The linker accepts only one out file in the invocation e An argument with a 1s1 suffix is interpreted as a linker script file and is passed to the linker Options The control program accepts several command line options If you specify an unknown option to the control program the control program looks if it is an option for a specific tool If so it passes the option directly to the tool However for directly passing an option to the assembler or linker it is recommended to use the control program options pass assembler pass linker Example with verbose output ccl65x v test asm The control program calls all tools in the toolset and generates the absolute object file test abs With option verbose v you can see how the control program calls the tools pathNasl65x o ccl692b obj test asm path 1k165x ccl1692b obj o test abs dl65x lsl M The control program produces unique filenames for intermediate steps in the compilation process such as cc1692b 0bj in the example above which are removed afterwards unless you specify command line option keep temporary files t Example with argument passing to a tool ccl65x Wa Ogs test asm The option Ogs is directly passed to the assembler 4 2 Using the Utilities 4 2 2 Overview of Control Program Options
57. key options Replace or add an object module r a b c u v Extract an object module from the library X V Delete object module from library d V Move object module to another position m a b v Print a table of contents of the library t s0 s1 Print object module to standard output p Sub options Append or move new modules after existing module name a name 4 12 Using the Utilities Description Option Sub option Append or move new modules before existing module name b name Create library without notification if library does not exist C Preserve last modified date from the library 0 Print symbols in library modules s 0 1 Replace only newer modules u Verbose V Miscellaneous Display options Display version header V Read options from file f file Suppress warnings above level n wn Table 4 3 Overview of librarian options and sub options qo For a complete list and description of all librarian options see section 2 5 Librarian Options in Chapter Tool Options of the reference manual 4 4 3 Examples Create a new library If you add modules to a library that does not yet exist the library is created To create a new library with the name mylib lib and add the object modules cstart ob j and calc obj to it tlb r mylib lib cstart obj calc obj Add a new module to an existing library If you add a new module to an existing library the module is added at th
58. macro name e g match argl arg2 arg3 All functions are built in and currently there are five of them match separate protect exist and nexist match The match function yields all arguments which match a certain suffix match obj prog obj sub obj mylib lib yields prog obj sub obj separate The separate function concatenates its arguments using the first argument as the separator If the first argument is enclosed in double quotes then n is interpreted as a newline character t is interpreted as a tab ooo is interpreted as an octal value where ooo is one to three octal digits and spaces are taken literally For example separate Mn prog obj sub obj results in prog obj sub obj Function arguments may be macros or functions themselves So separate Mn match obj yields all object files the current target depends on separated by a newline string protect The protect function adds one level of quoting This function has one argument which can contain white space If the argument contains any white space single quotes double quotes or backslashes it is enclosed in double quotes In addition any double quote or backslash is escaped with a backslash Example echo protect I ll show you the protect function yields echo I ll show you the protect function exist The exist function expands to its second argument if the first argument is an existing file or directory Example
59. ng Next the two internal buses named data_bus and code_bus must be defined in LSL bus data_bus mau 8 width 8 there are 8 data lines on the bus bus code_bus mau 12 width 12 data_bus data_bus data_bus data_bus data_bus data_bus data_bus data_bus This completes the LSL code in the architecture definition Note that all code above goes into the architecture definition thus between architecture cl165x All code above goes here 3 13 Using the TSK165x Embedded Tools 3 7 5 The Derivative Definition When you are building a personal ASIC using FPGAs you will probably not need to program the derivative definition unless you are using multiple cores but the description below helps to understand the Linker Script Language and how the definitions are interrelated A derivative is the design of a processor as implemented on an FPGA It comprises one or more cores and on chip memory The derivative definition includes e core definition an instance of a core architecture e bus definition the I O buses of the core architecture e memory definitions internal or on chip memory Core Each derivative must have at least one core and each core must have a specification of its core architecture This core architecture must be defined somewhere in the LSL file s core cl65x architecture cl65x Bus Each derivative can contain a bus definition for co
60. ng buttons E Compile Active Document Assembles the currently selected assembly file asm or src This results in a relocatable object file obj B Compile Active Project Builds your entire project but only updates files that are out of date or have been changed since the last build which saves time Or select Recompile Embedded Project from the Projects menu Builds your entire project unconditionally All steps necessary to obtain the final abs file are performed Select the right toolset First make sure you have selected the correct toolset for your target 1 From the Project menu select Project Options The Project Options dialog box appears 2 Select the correct Device Select a target processor core If you have selected a toolset that supports several processor cores by means of a Generic device you need to choose a processor type first To access the processor options 1 From the Project menu select Project Options The Project Options dialog box appears 2 Expand the Processor entry and select Processor Definition 3 In the Select Processor box select a processor type Processor options affect the invocation of all tools in the toolset In Altium Designer you only need to set them once To access the assembler options 1 From the Project menu select Project Options The Project Options dialog box appears 2 Expand the Assembler entry 3 Select the sub entries and set the options in the v
61. nnecting external memory In this example the bus data_bus maps to the bus data_bus defined in the architecture definition of core c165x bus data_bus mau 8 width 8 map dest bus cl65x data bus dest_offset 0 size 128 Memory Memory is usually described in a separate memory definition but you can specify on chip memory for a derivative For example memory internal code rom 1 type rom size 2k mau 8 map dest bus code_bus size 2k dest_offset 0x00 src_offset is zero by default This completes the LSL code in the derivative definition Note that all code above goes into the derivative definition thus between derivative X name of derivative All code above goes here If you create a derivative and you want to use Altium Designer to select sections the derivative must be called c165x for the TSK165x since Altium Designer uses this name in the generated LSL file If you want to specify memory in Altium Designer the custom derivative must contain the buses data bus and code bus for the same reasons 3 14 Using the Linker 3 7 6 The Processor Definition Using Multi Processor Systems The processor definition is only needed when you write an LSL file for a multi processor embedded system The processor definition explicitly instantiates a derivative allowing multiple processors of the same type processor proc_name derivative deriv_name If no
62. nything after a 7 is considered as a comment and is ignored If the 7 is inside a quoted string it is not treated as a comment Completely blank lines are ignored test obj test asm this is comment and is ccl65x test asm ignored by the make utility Include lines An include line is used to include the text of another makefile like including a h file in a C source Macros in the name of the included file are expanded before the file is included Include files may be nested include makefile2 Export lines An export line is used to export a macro definition to the environment of any command executed by the make utility GREETING Hello export GREETING This example creates the environment variable GREETING with the value Hello The macros is exported at the moment the export line is read so the macro definition has to proceed the export line 4 11 Using the TSK165x Embedded Tools 4 4 Librarian The librarian tlb is a program to build and maintain your own library files A library file is a file with extension 1ib and contains one or more object files obj that may be used by the linker The librarian has five main functionalities Deleting an object module from the library Moving an object module to another position in the library file Replacing an object module in the library or add a new object module Showing a table of contents of the library file Extracting an object module from the library The librar
63. object files and libraries into a single relocatable object file In the second phase the linker assigns absolute addresses to the object file so it can actually be loaded into a target 3 1 Using the TSK165x Embedded Tools Glossary of terms Term Definition Absolute object file Address Address space Architecture Copy table Core Derivative Library Logical address LSL file MAU Object code Physical address Processor Relocatable object file Relocation Relocation information Section Section attributes Target Unresolved reference Object code in which addresses have fixed absolute values ready to load into a target A specification of a location in an address space The set of possible addresses A core can support multiple spaces for example in a Harvard architecture the addresses that identify the location of an instruction refer to code space whereas addresses that identify the location of a data object refer to a data space A description of the characteristics of a core that are of interest for the linker This encompasses the address space s and the internal bus structure Given this information the linker can convert logical addresses into physical addresses A section created by the linker This section contains data that specifies how the startup code initializes the data sections For each section the copy table contains the following fields action defines whether a sec
64. omatically spawned to handle it This macro translates to a dollar sign Thus you can use in the makefile to represent a single Dynamically maintained macros There are several dynamically maintained macros that are useful as abbreviations within rules It is best not to define them explicitly Macro Description The basename of the current target The name of the current dependency file e The name of the current target The names of dependents which are younger than the target The names of all dependents The lt and macros are normally used for implicit rules They may be unreliable when used within explicit target command lines All macros may be suffixed with F to specify the Filename components e g F F Likewise the macros lt and may be suffixed by D to specify the Directory component The result of the macro is always without double quotes regardless of the original target having double quotes around it or not The result of using the suffix F Filename component or D Directory component is also always without double quotes regardless of the original contents having double quotes around it or not 4 9 Using the TSK165x Embedded Tools Makefile Functions A function not only expands but also performs a certain operation Functions syntactically look like macros but have embedded spaces in the
65. ons qo For a complete list and description of all make utility options see section 2 4 Make Utility Options in Chapter Tool Options of the reference manual 4 3 3 Writing a MakeFile In addition to the standard makefile makefile the make utility always reads the makefile tmk mk before other inputs This system makefile contains implicit rules and predefined macros that you can use in the makefile makefile With the option r Do not read the tmk mk file you can prevent the make utility from reading tmk mk The default name of the makefile is makefile in the current directory If you want to use other makefiles use the option f my makefile The makefile can contain a mixture of e targets and dependencies e rules e macro definitions or functions e comment lines include lines e export lines To continue a line on the next line terminate it with a backslash Y this comment line is continued on the next line If a line must end with a backslash add an empty macro this comment line ends with a backslash EMPTY f this is a new line Targets and dependencies The basis of the makefile is a set of targets dependencies and rules A target entry in the makefile has the following format target dependency rule rule Target lines must always start at the beginning of a line leading white spaces tabs or spaces are not allowed A target line consists of one or more targets a semicolon and a
66. ons the linker can convert a logical address into an offset into an on chip or off chip memory device The board specification The processor definition and memory and bus definitions together form a board specification LSL provides language constructs to easily describe single core and heterogeneous or homogeneous multi core systems The board specification describes all characteristics of your target board s system buses memory devices I O sub systems and cores that are of interest to the linker Based on the information provided in the board specification the linker can for each core e convert a logical address to an offset within a memory device e locate sections in physical memory e maintain an overall view of the used and free physical memory within the whole system while locating The section layout definition optional The optional section layout definition enables you to exactly control where input sections are located Features are provided such as the ability to place sections at a given address to place sections in a given order and to overlay code and or data sections Using the Linker Example Skeleton of a Linker Script File A linker script file that defines a derivative X based on the c165x architecture its external memory and how sections are located in memory may have the following skeleton architecture cl165x 1 Specification of the cl 65x core architecture Written by Altium derivative X
67. processor definition is available that instantiates a derivative a processor is created with the same name as the derivative 3 7 7 The Memory Definition Once the core architecture is defined in LSL you may want to extend the processor with memory You need to specify the location and size of the physical external memory devices in the target system The principle is the same as defining the core s architecture but now you need to fill the memory definition memory name memory definitions memory xram ap 0 mau 8 64 re 0 mau 8 tS 64 memory my_nvram memory xrom lag a 0 mau 12 2k Figure 3 3 Adding external memory to the c165x architecture Suppose your embedded system has 64 bytes of internal RAM named xram and 64 bytes of external NVRAM named my nvram and 2k of external ROM named xrom see figure above xram and my nvram are connected to the bus data bus and xromis connected to the bus code bus In LSL this looks like follows memory xram mau 8 type ram size 64 map dest bus X data bus src offset 0 dest offset 0 size 64 3 15 Using the TSK165x Embedded Tools memory my nvram mau 8 type ram size 64 map dest bus X data_bus src_offset 0 dest_offset 64 size 64 memory xrom mau 12 type rom size 2k map dest bus X code bus src offset 0 dest offset 0 size 2k LN If you u
68. r 3 3 Copy table 3 2 compression 3 8 Core 3 2 3 14 D Debugging an Embedded Application 1 8 Evaluating expressions 1 8 Setting breakpoints 1 8 Viewing memory 1 9 Watching expressions 1 8 Delete duplicate code sections 3 9 Delete duplicate constant data 3 9 Delete unreferenced sections 3 8 Derivative 3 2 Derivative definition 3 10 3 14 Device selection 1 5 E Embedded Applications Building 1 7 Debugging 1 8 Rebuilding 1 7 Embedded programming 1 1 Embedded Project Options 1 5 Tool options 1 6 Embedded projects 1 1 Adding a new source file 1 4 Adding existing files 1 5 Creating 1 4 Setting options 1 5 Embedded Software Getting started 1 1 Embedded Software Tools 1 1 Embedded tool options 1 6 Error messages assembler 2 5 linker 3 19 F File extensions 1 3 First fit decreasing 3 8 l IEEE 695 format 3 3 Include files default directory 2 4 search order 2 4 Incremental linking 3 8 Intel Hex format 3 3 L Labels linker 3 17 Librarian 3 7 4 12 invocation 4 12 options overview 4 12 Libraries extracting objects 3 7 linking 3 7 order on command line 3 7 user 3 7 Library 3 2 Library maintainer 4 12 Linker controlling from within Altium Designer 3 9 controlling with a script 3 9 error messages 3 19 invocation 3 4 labels 3 17 optimizations 3 8 Linker output formats IEEE 695 format 3 3 Intel Hex format 3 3 Motorola S record format 3 3 Linker scr
69. ruction refers to 0x0000 since its location is unknown Now assume that the linker links this code so that the section in which a is located is relocated by 0x10000 bytes and b turns out to be at 0x9A12 The linker modifies the code to be Al 3412 0100 mov a eax 0x10000 added to the address A3 129A 0000 mov eax b 0x9A12 patched in for b These adjustments affect instructions but keep in mind that any pointers in the data part of a relocatable object file have to be modified as well Output formats The linker can produce its output in different file formats The default IEEE 696 format abs contains an image of the executable code and data and can contain additional debug information The Intel Hex format hex and Motorola S record format sre only contain an image of the executable code and data You can specify a format with the options output 0 and chip output c Controlling the linker Via a so called linker script file you can gain complete control over the linker The script language is called the Linker Script Language LSL Using LSL you can define e The memory installed in the embedded target system 3 3 Using the TSK165x Embedded Tools To assign locations to code and data sections the linker must know what memory devices are actually installed in the embedded target system For each physical memory device the linker must know its start address its size and whether the memory is read write acce
70. s Warnings Report all warnings Suppress all warnings Suppress specific warnings Treat warnings as errors no option w W wnum num warnings as errors n Assembler Miscellaneous Assemble case sensitive required for C language Labels are by default local default global Additional assembler options c case insensitive il ig options Table 2 1 Altium Designer assembler options Using the TSK165x Embedded Tools The following assembler options are only available on the command line Description Command line Display invocation syntax help item Check source check syntax without generating code check Show description of diagnostic s diag frt all nr Emit local symbols emit locals Redirect diagnostic messages to a file error file fi e Read options from file f file Keep output file after errors k Select TASKING preprocessor or no preprocessor m t n Specify name of output file 0 file Verbose information V Display version header only V Table 2 2 Additional assembler options qo For a complete overview of all options with extensive descriptions see section 2 1 Assembler Options of Chapter Tool Options of the reference manual 2 4 How the Assembler Searches Include Files When you use include files with the INCLUDE directive you can specify their location in several ways The assembler searches the specifie
71. se a different memory layout than described in the LSL file supplied for the target core you can specify this in Altium Designer or you can specify this in a separate LSL file and pass both the LSL file that describes the core architecture and your LSL file that contains the memory specification to the linker In order to bypass the default memory setup your memory definition file must contain a define MEMORY and you must specify this file before the core architecture LSL file Adding memory using Altium Designer 1 From the Project menu select Project Options The Project Options dialog box appears 2 Open the Configure Memory tab 3 Disable the check box Automatically import when compiling FPGA project 4 Right click in the tab and select Add Memory The Processor Memory Definition dialog box appears 5 Specify a new physical memory device for example my_nvram 3 7 8 The Section Layout Definition Locating Sections Once you have defined the internal core architecture and optional memory you can actually define where your application must be located in the physical memory Sections have a name an indication section type in which address space it should be located and attributes like writable or read only In the section layout definition you can exactly define how input sections are placed in address spaces relative to each other and what their absolute run time and load time addresses will be Example section propag
72. select a generic device If you select a device from a manufacturer the correct processor type is selected automatically If you select a generic device you have to specify the target processor type manually To specify the target processor type manually only for a Generic device 3 Inthe left pane expand the Processor entry and select Processor Definition 4 Inthe right pane expand the General entry and set Select processor to the correct target processor 5 Click OK to accept the new device 1 4 2 Setting the tool options You can set embedded options commonly for all files in the project and you can set file specific options Setting project wide options 1 In the Projects panel right click on GettingStarted PrjEmb and select Project Options Alternatively select Project Project Options The Options for Embedded Project dialog appears Options for Embedded Project GettingStarted PrjEmb z Fux d ENSIS p E Compiler Options Files With Options Parameters Configure Memory Sections Reserved Areas Ell Device TSK155A Build Options Processor Assembler Jump chains Preprocessing Debug Information List File Diagnostics Miscellaneous Linker Instruction size Description Generic instructions are not part of the instruction set The assembler replaces generic instructions with the fastest or shortest combination of real instructions Clear this option to generate errors on generic
73. set of files which are required to build the target dependencies The target itself can be one or more filenames or symbolic names all demo abs final abs demo abs final abs test obj demo obj final obj You can now can specify the target you want to build to the make utility The following three invocations all have the same effect tmk tmk all tmk demo abs final abs If you do not specify a target the first target in the makefile in this example a11 is built The target a11 depends on demo abs and final abs so the second and third invocation have the same effect and the files demo abs and final abs are built You can normally use colons to denote drive letters The following works as intended c foo obj a foo c 4 6 Using the Utilities If a target is defined in more than one target line the dependencies are added to form the target s complete dependency list all demo abs These two lines are equivalent with all final abs all demo abs final abs For target lines macros and functions are expanded at the moment they are read by the make utility Normally macros are not expanded until the moment they are actually used Special targets There are a number of special targets Their names begin with a period Target Description DEFAULT If you call the make utility with a target that has no definition in the makefile this target is built DONE When the make utility has finished building the sp
74. sm f target and dependency move test asm final asm rulel as165x final asm rule2 You can precede a rule with one or more of the following characters does not echo the command line except if n is used the make utility ignores the exit code of the command ERRORLEVEL in MS DOS Normally the make utility stops if a non zero exit code is returned This is the same as specifying the option i on the command line or specifying the special IGNORE target The make utility uses a shell or COMMAND COM to execute the command If the is not followed by a shell line but the command is a DOS command or if redirection is used lt gt the shell line is passed to COMMAND COM anyway You can force tmk to execute multiple command lines in one shell environment This is accomplished with the token combination For example cd c Tasking bin tmk V Note that the must always directly be followed by the token Whitespace is not removed when it is at the end of the previous command line or when it is in front of the next command line The use of the as an operator for a command like a semicolon separated list with each item on one line and the Y as a layout tool is not supported unless they are separated with whitespace 4 7 Using the TSK165x Embedded Tools Inline temporary files The make utility can generate inline temporary files If a line contains lt lt LABEL no whitespaces t
75. ssible RAM or read only accessible ROM e How and where code and data should be placed in the physical memory Embedded systems can have complex memory systems If for example on chip and off chip memory devices are available the code and data located in internal memory is typically accessed faster and with dissipating less power To improve the performance of an application specific code and data sections should be located in on chip memory By writing your own LSL file you gain full control over the locating process e The underlying hardware architecture of the target processor To perform its task the linker must have a model of the underlying hardware architecture of the processor you are using For example the linker must know how to translate an address used within the object file a logical address into an offset in a particular memory device a physical address In most linkers this model is hard coded in the executable and can not be modified For the TASKING linker this hardware model is described in the linker script file This solution is chosen to support configurable cores that are used in system on chip designs When you want to write your own linker script file you can use the standard linker script files with architecture descriptions delivered with the product qo See also section 3 7 Controlling the Linker with a Script 3 3 Calling the Linker In Altium Designer you can set options specific for the linker Altium
76. t Options menu linker option no warnings I Information Verbose information messages do not indicate an error but tell something about a process or the state of the linker To see verbose information use the linker option verbose S System errors System errors occur when internal consistency checks fail and should never occur When you still receive the system error message S6 message please report the error number and as many details as possible about the context in which the error occurred Display detailed information on diagnostics 1 From the View menu select Workspace Panels System Messages The Messages panel appears 3 19 Using the TSK165x Embedded Tools 2 In the Messages panel right click on the message you want more information on A popup menu appears 3 Select More Info A Message Info box appears with additional information On the command line you can use the linker option diag you can see an explanation of a diagnostic message lktarget diag format all number qe See linker option diag in section 2 2 Linker Options in Chapter Tool Options of the reference manual 3 20 Altium 4 Using the Utilities Summary This chapter describes the utilities that are delivered with the product 4 1 Introduction The TASKING toolset comes with a number of utilities that are only available as command line tools cctarget A control program The control program invokes all
77. t file first to the C preprocessor before it starts interpreting the script qo The complete syntax is described in Chapter 5 Linker Script Language in the reference manual 3 7 2 Altium Designer and LSL In Altium Designer you can specify the size of the stack and heap the physical memory attached to the processor identify that particular address ranges are reserved and specify which sections are located where in memory Altium Designer translates your input into an LSL file that is stored in the project directory under the name project 1s1l and passes this file to the linker If you want to learn more about LSL you can inspect the generated file project 1s1l To change the LSL settings 1 From the Project menu select Project Options The Project Options dialog box appears 2 Open the Configure Memory tab 3 Make your changes to the memory layout 4 Openthe Sections Reserved Areas tab 5 Make your changes to the list of sections and or reserved areas Each time you close the Project Options dialog the file project 1s1 is updated and you can immediately see how your settings are encoded in LSL Note that Altium Designer supports ChromaCoding applying color coding to text and template expansion when you edit LSL files 3 9 Using the TSK165x Embedded Tools 3 7 3 Structure of a Linker Script File A script file consists of several definitions The definitions can appear in any order The architecture definition requ
78. tatus of 0 4 3 2 Overview of Make Utility Options The following make utility options are available Description Option Information Display invocation options Display version header only V Print makefile lines while being read D DD Display time comparisons which indicate a target is out of date d dd Verbose option show commands without executing dry run n Do not show commands before execution S Do not build only indicate whether target is up to date q Input files Use makefile instead of the standard makefile f makefile Change to directory before reading the makefile G path Read options from file m file Do not read the tmk mk file r Process Always rebuild target without checking whether it is out of date a Run as a child process C Environment variables override macro definitions e Do not remove temporary files K On error only stop rebuilding current target k Overrule the option k only stop building current target S Touch the target files instead of rebuilding them t Treat target as if it has just been reconstructed W target Error messages Redirect error messages and verbose messages to a file err file Ignore error codes returned by commands i Using the TSK165x Embedded Tools Description Option Redirect messages to standard out instead of standard error W Show extended error messages X Table 4 2 Overview of control program opti
79. tfie 1st assembler gt error messages ers relocatable object file obj Figure 2 1 Assembler The following information is described e The assembly process e How to call the assembler and how to use its options An extensive list of all options and their descriptions is included in the reference manual e The various assembler optimizations e How to generate a list file e Types of assmbler messages 2 2 Assembly Process The assembler generates relocatable output files with the extension ob j These files serve as input for the linker Phases of the assembly process 1 Parsing of the source file preprocessing of assembler directives and checking of the syntax of instructions 2 Optimization instruction size and generic instructions 3 Generation of the relocatable object file and optionally a list file The assembler integrates file inclusion and macro facilities See section 1 9 Macro Operations in Chapter Assembly Language for more information Using the TSK165x Embedded Tools 2 3 Calling the Assembler Altium Designer uses a makefile to build your entire project You can set options specific for the assembler After you have built your project the output files of the assembly step are available in your project directory unless you specified an alternative output directory in the Build Options page of the Project Options dialog To assemble your program Click either one of the followi
80. tion is copied or zeroed destination defines the section s address in RAM source defines the sections address in ROM length defines the size of the section in MAUs of the destination space An instance of an architecture The design of a processor A description of one or more cores including internal memory and any number of buses Collection of relocatable object files Usually each object file in a library contains one symbol definition for example a function An address as encoded in an instruction word an address generated by a core CPU The set of linker script files that are passed to the linker Minimum Addressable Unit For a given processor the number of bits between an address and the next address This is not necessarily a byte or a word The binary machine language representation of the C source An address generated by the memory system An instance of a derivative Usually implemented as a custom chip but can also be implemented in an FPGA in which case the derivative can be designed by the developer Object code in which addresses are represented by symbols and thus relocatable The process of assigning absolute addresses Information about how the linker must modify the machine code instructions when it relocates addresses A group of instructions and or data objects that occupy a contiguous range of addresses Attributes that define how the section should be linked or located The hardware
81. u can now debug the resulting absolute object file GettingStarted abs 1 6 Debugging your Embedded Application When you have built your embedded application you can start debugging the resulted absolute object file with the simulator To start debugging you have to execute one or more source lines e Select one of the source level or instruction level step options Debug Step Into Step Over to step through your source or select Debug Run to run the simulation A blue line indicates the current execution position To view more information about items such as registers locals memory or breakpoints open the various workspace panels e Select View Workspace Panels Embedded a panel To end a debug session e Select Debug Stop Debugging 1 6 1 Setting breakpoints You can set breakpoints when the embedded source file is opened Small blue points indicate where you can set breakpoints e Click on the left margin next to the source line to toggle a breakpoint on and off A red crossed circle and red line mark the breakpoint To change the breakpoint s properties e To change the breakpoint right click on the breakpoint and select Breakpoint Properties To disable or enable a breakpoint e Right click on the breakpoint and select Disable Breakpoint or Enable Breakpoint when it was disabled A disabled breakpoint is marked with green color The breakpoint panel gives an overview of all disabled breakpoint
82. x Manual Purpose and Structure Manual Purpose and Structure Windows Users The documentation explains and describes how to use the TASKING TSK165x toolset to program a TSK165x processor You can use the tools either with the graphical Altium Designer or from the command line in a command prompt window Structure The toolset documentation consists of a user s manual this manual which includes a Getting Started section and a separate reference manual TSK165x Embedded Tools Reference Start by reading the Getting Started in Chapter 1 The other chapters explain how to use the assembler linker and the various utilities Once you are familiar with these tools you can use the reference manual to lookup specific options and details to make full use of the TASKING toolset The reference manual describes the assembly language Using the TSK165x Embedded Tools Short Table of Contents Chapter 1 Getting Started Overview of the toolset and its individual elements Explains step by step how to write assemble and debug your application Teaches how you can use embedded projects to organize your files Chapter 2 Using the Assembler Describes how you can use the assembler An extensive overview of all options is included in the reference manual Chapter 3 Using the Linker Describes how you can use the linker An extensive overview of all options is included in the reference manual Chapter 4 Using the Utilities Descri
83. y to encode an address into instructions Most microcontrollers and DSPs support multiple address spaces For example separate spaces for code and data Normally the size of an address space is 2N with N the number of bits used to encode the addresses The relation of an address space with another address space can be one of the following e one space is a subset of the other These are often used for small absolute and relative addressing e the addresses in the two address spaces represent different locations so they do not overlap This means the core must have separate sets of address lines for the address spaces For example in Harvard architectures we can identify at least a code and a data memory space Address spaces even nested can have different minimal addressable units MAU alignment restrictions and page sizes All address spaces have a number that identifies the logical space id The following table lists the different address spaces Space Id MAU Description data 1 8 Data space 4 banks of 32 bytes code 2 12 Code address space bit 3 1 Bit addressable data data space Table 3 4 TSK165x address spaces The TSK165x architecture in LSL notation The best way to program the architecture definition is to start with a drawing The figure below shows a part of the TSK165x architecture c165x sizes are for the TSK165B space data bus data_bus J9 s

Download Pdf Manuals

image

Related Search

Related Contents

Manual SD-3642 DESK - technoprint  Samsung HT-P1200 User Manual  Sony VGN-FS500 Marketing Specifications  FluorAce™ Apopain Assay Kit Fluorometric Detection of - Bio-Rad    "user manual"  

Copyright © All rights reserved.
Failed to retrieve file