Home

ST200 Micro Toolset User Manual

image

Contents

1. 24 LIST CONFIG variable 36 39 libraries naa ha na PG PAA AG 93 LMI RAM memory 41 memory allocation 22 load program OS21 aware debugging 22 memory location 41 profiler 22 2 0 MUA WA 15 See also st200xrun STWorkbench and profiling c eee ee 167 st200insight real time kernel 22 low level I O 16 real time kernel library 16 Ix eli32 14 16 19 20 46 84 86 scheduler 178 source code eee 92 M stack traces 183 tick duration 196 make eee 15 0S21Trace 98 malloG ia ht e Rein 177 binaryfiles 115 WA ia 19 GDB commands 117 managing memory 175 GDB commands example 122 manualpages 19 GDB control commands 123 memory user APIS ii mes 98 allocation 22 161 user defined events 98 change location 41 OS21 Trace binary files LMI RAM 2 2 eee 41 os2itasktrace bin 117 management 24 93 os21trace bin 116 memory managers 177 os21trace bin ticks
2. 66 7 8 Debugging a program 67 74 Changing the target 68 7 5 Configuring breakpoints 69 7 5 1 The Breakpoints window 70 7 6 Using the Nelp uasa RR RERUM ERR NN Ea EGRE ROG E E Rage 70 7 7 Using the Stack window 71 7 8 Using the Registers window 72 7 9 Using the Memory window 73 7 9 1 Displaying multiple Memory windows 74 7 10 Using the Watch window 75 7 11 Using the Local Variables window 76 7 12 Using the Console Window 77 7 13 Using the Function Browser window 78 7 14 Using the Processes window 79 7 15 Using the ST200 Statistics window 80 7 16 Using the Performance Monitoring window 81 7 17 Using the Debug Support Unit Window 82 7 17 1 Editing a DSU register 82 4 246 8063762 Rev 9 ky ST200 Contents 8 ST200 SIImulatOF i 5 x aoro aci CR JA 83 8 1 Simulator pack 84 8 1 1 Customi
3. 11 Acknowledgements 00 ccc eee eee ns 12 1 Toolset overview XXX ce cu RERER RERO RE E nan eee REAR ee 13 1 1 Toolset features ocra dre Rede ex doe IA n s 13 1 2 Distribution content 14 1 2 1 uq 14 1 2 2 Libraries ISA ac RC A Ier ahd BOR OR IC dedos m KANG 15 1 2 3 Configuration scripts 16 1 2 4 SOURCES Haha EE Aa eden eid de a AA 16 1 2 5 Examples csse a so RE IRR EC EG RARUS Rue e RU x eae Re 16 1 3 Libraries delivered 000 eee 17 1 3 1 The C library newlib 17 1 3 2 The C library libstdc 18 1 3 3 The libdtf library III eee 18 1 3 4 The syscalls low level I O interface 18 1 4 Release directories 19 1 4 1 The documents directory 00 cece eee ee 19 1 4 2 GDB command scripts directory 20 1 5 The examples directory cece eee ee eee 20 2 Introducing 0521 xda xen dx wae creeds n a QR C ences 22 2 1 OS21 features au aces qd ed died oe dco de solde aodio AA an i 24 3 Code developmenttools 25 3 1 Toolset overview 25 3 2 st200cc command line 26 2 246 8063762 Rev 9 KI ST200 Contents 4
4. ST200 Cross development tools Table 9 st200gdb command quick reference continued Command Description set trace commands Sets trace commands on off Enables the tracing of GDB commands on off The default is off show trace commands Displays the current state of GDB CLI command tracing toreak function tine Sets a temporary one time only breakpoint on the specified function ile line line or address address watch exp Sets a watchpoint for the expression exp where n full This is identical to the backtrace command 5 3 6 ST200 GDB commands There are several additional features in the supplied st200gdb that are not found in the standard version of GDB from the Free Software Foundation FSF These are not specific to the ST200 configuration but are generic features that have been added in order to provide better support for the implementation of the GDB scripts used for connecting to STMicroelectronics simulators and silicon parts The commands become available only after the connection to an ST200 target To get online help about these commands from the GDB command prompt type gdb help STM Table 10 lists the additional st200gdb non specific GDB commands Table 10 8 ST200 st200gdb non specific commands Command Description callplugin Calls an installed target interface plugin compare sections Compares section data on target to the exec file console Enables or disables the target
5. show user api group group class class Display the status of all the APIs within the class c1ass of the user trace group group enable user api code disable_user_api code Enable or disable the logging of the user API specified by code All APIs are enabled by default The command show user api group a11 lists all the valid code parameters see Section 11 9 11 Type and event enables on page 121 For an event to be logged both the API code and the type user API in this case must be enabled Disabling the type prevents logging of all the events that belong to that type although it does not disable them show user api code Display the logging status of the user API specified by code enable_user_api_global disable_user_api_global Enable or disable the logging of user API types User API trace is disabled by default show_user_api_global Display the logging status of user API types Miscellaneous commands The following GDB command is also created by os21usertrace show_user_decode_trace Show the location of the associated os21decodetrace control file that is the argument passed to its user option d These commands are not qualified by class or group since the API must have global scope and therefore be unique 8063762 Rev 9 125 246 OS21 Trace ST200 11 11 Trace library API The OS21 Trace library is provided in 1ibos21trace a and its associated header file is os21trace h The function
6. 37 OS21 aware 22 with Insight 67 with OS21 eee 183 defines mkf 36 39 device plug ins 0 eee eee 89 DEVICE PLUGIN MODULES 89 directory structure 19 disabling timeslicing 181 disassembling code 49 discard symbols 15 documentation set 19 DSU window 82 DSU DEFAULT MODULE ENABLED 89 DSU ROM IMAGE 89 DUMP CONFIG FILE 86 E Eclipse Ludus be eek ewe E Na 58 ELF format files 15 embedded applications developing 2 cece eee 13 environment setup 55 Ethernet 14 event flags 0 0 0 cee eee 24 examples applications aw 16 debugging with Insight 67 OS21 iini tis eee eet es oe 21 SIZOOXIUN 12v S kasa denas na 56 exception handlers 24 exceptions 0 cee ee eee 184 execute program memory location 41 exit paths serseri ncrv aadete niiae s 186 EXTERNAL MEMORY BASE 87 EXTERNAL MEMORY PATTERN 89 EXTERNAL MEMORY SIZE 87 ST200 Index F ICACHE MODEL 86 FIFO message queues 24 index lo archive MAAN 15 FIFO scheduler 24 178 initialization hook
7. 43 PA bre ior e i 161 inlined list manipulation functions 93 Mi ses Me aa e Ea i eight AA 15 16 43 46 64 82 fixed block allocator 24 177 Preakpoini tne ii ea so Flash ROM Breakpoints window 70 exampl s 44 Console Window 64 77 Pree ee age MS Wa Aa Debug support unit window 82 Function Browser window 78 G Global menu 70 GCC Help menu cee eee eee 70 M AA AA 15 Local Variables window 76 GDB LLL LLL 13 43 184 Memory Preferences window 73 branch trace 224 Memory window 2 aaa ana 73 command line interface 43 Performance monitoring window 81 command line reference 48 49 51 54 77 Processes window AKA UA AA E 79 82 command reference 117 Registers window PVP ma 72 Insight 22s erem temm eae a 64 Source Window 65 OS21 aware debugging 22 toolbar AA 65 profiler 227 ST2x0 Statistics window 80 LIPS oo eee cee arara 186 Stack window 71 GDI Target Selection window 68 commands 80 Watch window 75 GNU instruction set accurate mode 83 assembler a 14 integrity checks 93 binutils 14 intern
8. ST200 Board target configuration Table 6 Board contribution continued Item DEFAULT BOOT ADDRESS Definition is needed at linking time m only if the boot and boot reset are linked Parameter location tools dir target board my board board 1d DEFAULT TEXT BASE Definition is mandatory lt tools dir gt target board lt my_board gt board 1d DEFAULT RAMEND Definition is mandatory tools dir target board my board board 1d STACK_POINTER Definition is mandatory lt tools dir gt target board lt my_board gt board 1d 4 2 2 Configuration matrix Table 7 lists the interaction between the mcore msoc mboard options and the different level of contribution in the lt tools dir gt target directory Table 7 Configuration matrix Item Default mcore msoc mboard Location Core include path lt tools dir gt target core st231 X Compiler driver SoC include path lt tools dir gt target soc default X Compiler driver Board include path tools dir target board default X Compiler driver Macros ST231 SE23L peou X Compiler driver crti o ST231 X Compiler driver crti o ST231 X Compiler driver crtn o ST231 X Compiler driver crtbegin o ST231 X Compiler driver crtend o ST231 X Compiler driver
9. 8063762 Rev 9 227 246 Profiler plugin ST200 Table 59 Profiler subcommands continued Subcommand type Option none trace range Description Set the type of profiler to be used none indicates that no profiler is to be used this is the default trace enables the trace profiler where each sample is time sampled see Section D 2 Trace profile output format on page 229 range enables the sampling profiler which increments a counter for an address range each time a sample is taken see Section D 3 Range profile output format on page 230 trace size Set the maximum number of samples to store on the STMC If insufficient space is available on the STMC to store the specified number of samples profiling is effectively disabled When the sample buffer is full the oldest samples are discarded therefore only size most recent samples are returned The trace subcommand is mandatory when the type of the profiler is set to trace range size startaddr endaddr Set the size in number of instructions of the slice of the application s address range to associate with a counter If insufficient space is available on the STMC to store the counters required for the specified address range profiling is effectively disabled The default address range for an application is determined by the stext and etext symbols placed by the linker but this may be overridden by specify
10. Launching Insight To launch the Insight GUI on the command line enter either st200gdb w or st200insight Alternately under Windows click the Start button and select Programs 5 STM Tools ST200 Micro Toolset R6 0 5 Insight When Insight launches for the first time the Source Window opens see Section 7 2 8063762 Rev 9 ky ST200 Using Insight 7 2 Using the Source Window The Source Window is the main window that opens when Insight launches see Figure 9 Section 7 2 1 describes the toolbar buttons Figure 9 Source Window ai File Run View Control Preferences Help 3o90 0 9e ztasoe zE n gee m Y source Program not running Click on run icon to start 7 2 1 Source Window toolbar Table 14 lists the buttons on the Source Window toolbar Table 14 The Source Window buttons Button Name Description 3 Run R Start the program executing Mm Step S Step into the next statement P Next N Step over the next statement P Finish F Step out of the current function n Continue C Continue the program after a breakpoint Hi Step Asm Inst S Step one instruction ar Next Asm Inst N Step over the next instruction 8063762 Rev 9 65 246 Using Insight ST200 Table 14 The Source Window buttons continued Button Name Registers Ctrl R Description Display the Registers window Memory Ctrl M Display the Memor
11. disable os21 api class all Disable logging of all OS21 APIs in all classes show os21 api class all Display logging status of all OS21 APIs in all classes 8063762 Rev 9 119 246 OS21 Trace ST200 enable os21 api class class Enable logging of the OS21 API in the class c1ass where class is one of classes reported by show os21 api classes disable os21 api class class Disable logging of the OS21 API in the class c1ass show os21 api class class Display the logging status of the OS21 API in the class class enable os21 api code Enable the logging of the OS21 API specified by code All APIs are enabled by default The command show os21 api class a11 provides the list of valid code parameters see Section 11 9 11 Type and event enables on page 121 For an event to be logged both the API code and the type OS21 API in this case must be enabled Disabling the type prevents logging of all the events that belong to that type although it does not disable them disable os21 api code Disable the logging of the OS21 API specified by code show os21 api code Display the logging status of the OS21 API specified by code 11 9 8 Enable task information logging enable os21 task trace Enable logging of task information Take care to ensure that logging is enabled when tasks are created otherwise os21decodetrace and STWorkbench are not able to associate task names with trace data Logging of task inf
12. 42 5 2 5 Initialization hook RII 43 5 3 The GNU debugger 43 5 3 1 Using GDB iia pase ROG een ae oaa SERS Had aot 43 5 3 2 The Ixgdbinitfile llle 46 5 3 3 Connecting to a running target 0 00 c eee eee 46 5 3 4 GDB command line reference 000 cece eee 48 5 3 5 GDB command quick reference 0c cee eee ee 49 5 3 6 ST200 GDB commands 51 5 4 Using st200xrun 55 5 4 1 Setting the environment 55 5 4 2 st200xrun command line reference 55 5 4 3 st200xrun command line examples 000 c eee eee eee 56 ky 8063762 Rev 9 3 246 Contents ST200 6 Using STWorkbench 58 6 1 Getting started with STWorkbench 58 6 1 1 The STWorkbench workbench 59 6 2 STWorkbench tutorials 62 6 3 ST200 System Analysis tutorials and reference pages 63 7 Using Insight iain ad asc Fac cad daa dri ke a dac a ac 64 7 1 Launching INSIQN ces eae gh coats BER E ERA EA Ue 64 7 2 Using the Source Window 65 7 2 1 Source Window toolbar 65 7 2 2 Context sensitive menus
13. 8063762 Rev 9 145 246 Relocatable loader library ST200 12 2 146 246 Table 33 Run time models comparison Supported features R Absolute R Relocatable R PIC XT TE 8 1 main program 1 main program Application partitioning 1 single program N load modules N load modules Static symbol binding Yes Yes Yes Startup time No Startup time Yes i E NG Run time Yes Run time Yes Dynamic symbol No Main program No Main program Yes binding Load modules Yes Load modules Yes Explicit module N A No Mag dependencies Dynamic symbol lookup N A Bottom up from loaded Unrestricted order to loader Symbol preemption N A No Yes Segment sharing N A Na Yes across processes Performance impact N A Minimal Yes Code size impact N A Minimal Yes Application writer N A Need explicit loading No change by default impact 3 Compiler options Compiler options Build systermimpact NYA Load modules build Load modules build Relocatable run time model The R Relocatable run time model as implemented by rl lib has the following features one main module loaded at application startup by the system several load modules that can load at run time and unload after use several modules can be resident at the same time a loaded module can load and unload other load modules as for the main module load modules can be loaded anywhere access to symbols in loaded modules from the loade
14. 6 1 Getting started with STWorkbench Under Linux start STWorkbench from the shell by entering stworkbench Under Windows start STWorkbench by selecting the appropriate option from the Start menu Programs STM Tools STWorkbench Rn n n STWorkbench where n n n is the STWorkbench version number Note The precise menu options displayed are dependant upon the version of STWorkbench you are using and the choices made when STWorkbench was installed When STWorkbench is launched the Workspace Launcher dialog is displayed see Figure 5 Use this dialog to enter or select the location of the workspace The workspace is the directory where the project data files and directories are stored Figure 5 Workspace Launcher Workspace Launcher Select a workspace STWorkbench stores your projects in a Folder called a workspace Choose a workspace Folder to use For this session Workspace CASTMYworkspace Use this as the default and do not ask again If the workspace directory does not already exist STWorkbench creates it for you Note 1 Donotuse spaces in the workspace path and name as it causes problems with the tools 2 The workspace can be changed at any time by selecting Switch Workspace from the File menu 58 246 8063762 Rev 9 ky ST200 Using STWorkbench When STWorkbench is launched for the first time the C C Projects perspective is displayed with only the Welcome to STWorkben
15. Declare the management data we use to control the partition a f ky 8063762 Rev 9 175 246 Toolset tips ST200 176 246 typedef struct f unsigned char base unsigned char limit unsigned char free ptr my state t Allocation routine really simple mf static void my alloc my state t state size t size f void ptr NULL if size amp amp state free ptr size lt state gt limit ptr state gt free_ptr state gt free_ptr state gt free_ptr size return ptr Partition status routine Note that status gt partition_status_used is not filled in here partition_status sets this field automatically static int my_status my_state_t state partition status t status partition status flags t flag f status partition status state partition status state valid status partition status type partition status type user status partition status size state gt limit state gt base status partition status free state gt limit state free ptr status partition status free largest state gt limit state free ptr Initialization routine called when a partition is created 7 static void my initialize partition t pp unsigned char base size t size f my state t state partition private state pp state free ptr base state gt base base state gt limit base size int main void parti
16. e Alternatives are separated by vertical bars Optional sequences are enclosed in square brackets and e Items which may be repeated appear in braces and Mathematical notation A range of values can be shown using square braces and round braces Square braces mean the nearest value is included and round braces mean the nearest value is not included For example EE 839 is the values 1 2 3 1 2 3 is the values 1 2 CE wa 3 is the values 2 3 1 3 is the value 2 only Acknowledgements 12 246 Microsoft MS DOS and Windows are registered trademarks of Microsoft Corporation in the United States and or other countries Linux is a registered trademark of Linus Torvalds MIM jM Red Hai is a registered trademark and RP Software Inc and Insight are trademarks of Red Hat Cygwin and InsightTM are trademarks of Red Hat Software Inc UNIX is a registered trademark of The Open Group 8063762 Rev 9 ky ST200 Toolset overview 1 1 Toolset overview The ST200 Micro Toolset is a cross development system for developing and debugging C and C embedded applications on STMicroelectronics range of products integrating the ST200 family of cores All ST200 devices include the debug support unit DSU available through the JTAG port of the device for on chip debugging capabilities such as code and data breakpoints watchpoints and memor
17. handle const char name handle The handle for the loaded module name The symbol in the loaded module The pointer reference to the symbol The r1 sym function returns a pointer reference to the symbol named name in the loaded module specified by handle It searches the dynamic symbol table of the loaded module and returns a pointer to the symbol The handle parameter can be the handle of any currently loaded module or the handle of the main module If the symbol is not defined in the loaded module NULL is returned It is not generally an error for this function to return NULL For example the user may conditionally call a specific function only if it is defined in the module In this function as well as in the r1 sym rec function the name parameter must be the mangled symbol name For instance on some targets C names are mangled by prefixing the name with an underscore For example to return a reference to the printf function the symbol name passed to r1 sym will be _printf Also to access C symbols the fully mangled name must be passed The C mangling scheme is dependent on the processor specific C ABI implemented Return a pointer reference to the symbol in the loaded module or one of its ancestors void rl sym rec rl handle t handle const char name handle The handle for the loaded module name The symbol in the loaded module The pointer reference to the symbol The r1 sym
18. i 1 rl errarg returns the symbo rl load stream name rl set file name The symbol is not defined in the module RL ERR SYM 1 turns the symbol EL EE rl errarg returns the symbo rl sym rec name RI ERR FOPEN The file cannot be opened by si load file rl fopen RL ERR FREAD Error while reading the file in rl load file rl fread RL ERR STREAM Error while loading the file from a si Joad streamt stream rl_load_file 114 ff RL ERR LINKED Module handle is already linked ru load uber i rl load stream rl handle delete rl unload rl sym RL ERR NLINKED Module handle is not linked rl sym rec rl foreach segment RL ERR SEGMENTF Error in segment function callback rl foreach segment rl load file RL ERR ACTIONF Error in action function callback rl load buffer rl load stream 8063762 Rev 9 159 246 Relocatable loader library ST200 rl errarg Definition Arguments Returns Description rl errstr Definition Arguments Returns Description 160 246 Return the name of the symbol that could not be resolved const char rl errarg rl handle t handle handle The handle for the module The name of the symbol that could not be resolved If x1 errno returns either R1 ERR RELSYM Or RL ERR SYM the r1 errarg function returns the name of the symbol that could not be resolved
19. China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 246 246 8063762 Rev 9 ky
20. Counting semaphores can be initialized to any count can be signalled from interrupts for FIFO semaphores the longest waiting task gets the semaphore for priority semaphores the highest priority task gets the semaphore Mutexes can create critical sections between tasks be recursively acquired by the owning task without deadlock for FIFO mutexes the longest waiting task gets the mutex for priority mutexes the highest priority task gets the mutex supports priority inheritance to avoid priority inversion Event flags where tasks can poll or wait for all or any event flag within a group events can be posted from a task or interrupt There is inter task communication that uses simple FIFO message queues There are user installable interrupt handlers There are user installable exception handlers It has extensive cache API The memory management has heaps afixed block allocator asimple non freeable allocator user definable allocators system heap managed by OS21 or C run time There is task aware profiling The OS21 profiler enables profiling of a single task a single interrupt level or the system as a whole The Board support package BSP libraries enable customization for new boards OS21 is based on the GNU toolset using newlib C run time library 8063762 Rev 9 ky ST200 Code development tools 3 1 Code development tools This is a b
21. Using Cygwin The Windows toolset requires Windows XP or Windows 7 However if a Unix like environment is required use the toolset in conjunction with Cygwin www cygwin net Cygwin adds a number of Unix like features to its own applications but cannot extend this support to other applications such as the ST200 Micro Toolset To improve interoperability and to use Cygwin as a build environment the ST200 Micro Toolset has a limited amount of Cygwin like behavior Many of the tools accept Cygwin pathnames according to the ST CYGPATH MODE environment variable see Table 38 Table 38 ST CYGPATH MODE settings Environment variable setting Description ST CYGPATH MODE off No pathname translation is attempted ST CYGPATH MODE normal or B i X nverts to X ST CYGPATH MODE is not set Sygdr vena Converts ROUES cygdrive X is converted as above and any other Cygwin ST CYGPATH MODE full mount points such as usr are also converted There are a few limitations e paths must be specified in canonical form that is cygdrive c will not work e relative pathnames cannot pass through these paths that is cygdrive c Will not work e Cygwin symbolic links short cuts are not understood The make utility is one of the ST200 Micro Toolset tools that does not have any Cygwin support The make utility is one of the tools in mingw32 make exe To use the Cygwin make utility place the Cygwin bin
22. are shown only if the stack frame belongs to a task not if the stack frame belongs to an interrupt handler The stack trace shows the state of the CPU at the time the exception occurred It should be possible to ascertain the cause of the exception from the description of the exception reported faulting addresses and the register dump For example the following program creates a task that contains a deliberate misaligned write to memory include lt os21 h gt void my_task void ptr unsigned int ptr OxBA49 int main void kernel_initialize NULL kernel start void task create my task void 0x12344321 32768 OS21 MAX USER PRIORITY bang 0 task delay time ticks per sec return 0 8063762 Rev 9 183 246 Toolset tips ST200 Building this program with the compiler options g and mruntime os21 and running it gives the following output OS21 z2222z22 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 222 2 22 22 2 2 22 22 2 2222 22 22 2 2 2 2 2 2 2 2 OS21 Stack trace 1 of 1 OS21 Fatal exception detected 0x00000200 OS21 misaligned access to 0x12344321 OS21 Active Task ID 0xC0034B38 OS21 Active Task Stackp 0xC003CB1C OS21 Active Task name bang OS21 PC 0xc000041C SP 0xC003CC38 LINK 0xC0002D5C PSW 0x0000000E OS21 R14 Ox00000000 R15 0x00000000 R16 0x12344321 R17 0x12344321 OS21 R18 0x00000000 R19 0x00000000 R20 0x00000000 R21 0x00000000 OS21 R
23. ci UM1294 YI User manual ST200 Micro Toolset Introducing the ST200 Micro Toolset The ST200 Micro Toolset is a cross development system for developing and debugging C and C embedded applications on STMicroelectronics range of products integrating the ST200 cores All ST200 devices include the debug support unit DSU available through the JTAG port of the device which provides access to on chip debugging capabilities such as code and data breakpoints watchpoints and memory peeking and poking The ST200 Micro Toolset provides an integrated set of tools to support the development of embedded applications This user manual provides detailed information to e enable users to run and debug code built for the ST200 family of processors on silicon and simulated targets e enable users to customize and extend the support of the ST200 Micro Toolset for new hardware platforms that use ST200 processors October 201 1 8063762 Rev 9 1 246 www st com Contents ST200 Contents Introducing the ST200 Micro Toolset cece eee eee eee 1 al n oes dead aa k a a AP eee abe es een 10 Document identification and control 10 License information 10 ST200 documentation suite 10 Terminology 2465263560 she NEGA LAKARAN KA eeoun esx RUCA KAL Roe Rab 11 Conventions used in this guide
24. INTERNAL INTERRUPTS EXTERNAL INTERRUPTS Returns Returns the error condition Description This function enables a specific interrupt bsp itc interrupt enable is kept for backward compatibility and it is equivalent to call bsp interrupt enable using type EXTERNAL INTERRUPTS ky 8063762 Rev 9 207 246 ST200 board support package BSP ST200 bsp interrupt install Install an interrupt handler Definition include lt platform h gt int bsp interrupt install int interrupt number int handler function void param ptr int old handler function void param ptr void stack base int stack size int type Arguments interrupt number The interrupt to which the handler is to be linked handler function The interrupt handler to be installed old handler function The interrupt handler previously installed stack base The pointer to the location in memory to be used as stack base If NULL the default system stack pointer is used instead stack size The stack size to be allocated for the handler not used if stack base is NULL type Flag to select between eternal and internal interrupts Values accepted NTERNAL INTERRUPTS EXTERNAL INTERRUPTS Returns Returns the error condition Description This function installs a new interrupt handler returning the handler installed previously bsp itc interrupt install is kept for backward compatibility and it is equivalent to call bsp interrup
25. and run the program as usual An example provided in lt tools dir gt examples hello shows how they are modified See the README file for more information Board configuration is flexible so that it is possible to add a custom board with different memory and run time settings see Section 4 3 Customizing board targets on page 34 Figure 3 ST200 address space usage Memory Space Comments 0x08000000 TEXT BASE Section loaded pia It contains the start entry point of the program Section loaded Initialized C global variables are data directly mapped at these addresses Not loaded Initialized to Oat___start execution bss as per ANSI C standard During the execution the stack grows towards the default area where sections are loaded and the heap for malloc grows from the end of the bss section towards the stack stack pt gt kstack pt 5 0x08800000 ramend Oxffffffff scratch area kernel stack Scratch area RAMEND 16 bytes aligned area to setup the stack 16 bytes reserved for the kernel stack 16 bytes aligned are to setup the kernel stack This base address is configurable through the board 1d script link dedicated to the target During normal execution the stack pointer points to the top of the stack and a 16 byte scratch area is required by the ABI for the initial context saving between function calls Simil
26. bool true 1 Ifrequired to model additional blocks of memory use EXTERNAL MEMORY SIZE and EXTERNAL MEMORY BASE 2 The st200xrun and st200gdb tools are insensitive to these options These options are only meaningful for co simulation environments ky 8063762 Rev 9 89 246 ST200 simulator ST200 3 The gmon format employs 16 bit numbers to represent time intervals Because this gives insufficient dynamic range for typical simulations time values have had to be scaled As a result the column headers produced by gprof specifying the underlying unit of time are incorrect We recommend that analysis of execution profiles is restricted to consideration of relative times see the gprof documentation for information on the interpretation of the output files 8 3 90 246 Table 18 lists the default values for the architecture dependent options Table 18 Architecture specific target options cache models Default value Target option MODE FAST MODE ISS MODE REFERENCE REF ICACHE MODEL See ICACHE MODEL BASIC ICACHE MODEL DETAILED DCACHE MODEL See 1 DCACHE MODEL BASIC DCACHE MODEL DETAILED 1 The FAST mode of simulation does not model the caches but accesses the memory directly If the configuration is dumped to file the cache model options correspond to those used in reference mode The sample dev
27. e critical sections can nest Disadvantages critical sections broken if the running task explicitly blocks 8063762 Rev 9 179 246 Toolset tips ST200 Mutexes Mutexes in OS21 provide robust critical sections The critical section remains in place even if the task in the critical section blocks Exactly one task is able to own a mutex at any one time OS21 has two forms of mutex FIFO and priority FIFO mutexes have the simplest semantics When tasks try to acquire a busy FIFO mutex they are queued in request order When a task releases a FIFO mutex ownership is passed to the task at the head of the waiting queue and it is unblocked Priority mutexes are more complex When tasks try to acquire a busy priority mutex they are queued on the mutex in order of descending task priority In this way the task at the head of the wait queue is always the one with the highest priority regardless of when it attempted to acquire the mutex Priority mutexes also implement what is known as priority inheritance This mechanism temporarily boosts the priority of the task that owns a mutex to be the same as the priority of the task at the head of the wait queue When the owning task releases the mutex its priority is returned to its original level This behavior prevents priority inversion where a low priority task can effectively prevent a high priority task from running This can happen if a low priority task owns a mutex which a high priorit
28. function may be implemented using the x1 1oad stream function User implementation of the callback function that read from a file static int rl stream read FILE file char buffer int length f int nbytes nbytes fread buffer 1 length file return nbytes Loads the module from a file FILE file int status file fopen f name rb if file NULL error status rl load stream handle rl stream func t rl stream read file if status 1 error fclose file Unload a previously loaded relocatable module int rl unload rl handle t handle handle The handle for the module Returns 0 for success 1 for failure The r1 unload function unloads a previously loaded relocatable module It finalizes unlinks and frees allocated memory for the loaded module This function calls the action callback functions for RL ACTION UNLOAD before unloading and after having executed finalization code in the module The return value is 0 if the unloading is successful otherwise the return value is 1 and the error code returned by x1 errno is set accordingly 8063762 Rev 9 ST200 Relocatable loader library rl sym Definition Arguments Returns Description rl sym rec Definition Arguments Returns Description Return a pointer reference to the symbol in the loaded module void ri sym rl handle t
29. rl action t cookie const char file name handle file name handle if file name NULL amp amp info seg flags amp RL SEG EXEC if action RL ACTION LOAD Call profiling interface for adding a code region profiler add region file name info seg addr info seg size if action RL ACTION UNLOAD Call profiling interface for removing a code region profiler remove region file name info seg addr info seg size return 0 Static int module_profile rl_handle_t handle rl_action_t action void cookie rl foreach segment handle segment profile void amp action return 0 int main if rl add action callback RL ACTION ALL module profile NULL 1 fprintf stderr rl add Action callback failed n exit 1 status rl load file handle file name return 0 8063762 Rev 9 165 246 Relocatable loader library ST200 12 8 12 9 166 246 Memory protection support When a new library segment has loaded into memory or is on the point of being unloaded from memory a system library or the user can use the user action callback interface to install a memory protection scheme To set user protection support use the user action callback see Section 12 7 Profiling support Load time decompression The loader does not perform load time decompression It is possible that this will change in a future extension and the loader may lo
30. some overhead occurs in the generated code to access functions and data objects Compiler options and C language extensions can be used to reduce this overhead Relocatable libraries are not subject to symbol preemption therefore when generating position independent code the fvisibility protected option can be used in addition to fpic The fvisibility protected option enables the inlining of global functions and can be used as a default option for compiling relocatable libraries For example st200cc o a o fpic fvisibility protected a c In addition to this option fine grain visibility can be specified with the attribute visibility GNU C extension at the source code level For example if the external interface of a load module is well defined in a header file the attribute visibility protected can be attached to each function of the external interface To specify that all other defined functions are internal to the load module on the command line use the visibility hidden option This combination of options optimize references from the same file to global objects that are not part of the interface To specify the visibility of each symbol externally with the given lt file gt use the mvisibility decl file option In the case where the external services required by a module default visibility and the external services provided by the module protected visibility are known all other functions or data
31. task trace initialize has been called Note os21 task trace initialize data can be used to clear the task information buffer if data refers to the existing task information buffer 128 246 8063762 Rev 9 ky ST200 OS21 Trace os21 task trace overflow User defined task information overflow function Definition void os21 task trace overflow void data unsigned int size Arguments data The current task information buffer size The size in bytes of data in the buffer Returns Void Description A function with this name is called when the task information buffer overflows in stop mode or before wraparound occurs in wrap mode The data and size parameters are the current buffer and the size of the data saved in the buffer The default implementation of this function is a no op that the user can override with their own implementation os21 task trace set mode Set the action on task information buffer full Definition typedef enum os21 trace mode e os21 trace mode stop 1 os21 trace mode wrap 2 os21 trace mode e os21 task trace mode e os21 task trace set mode os21 trace mode e mode Arguments mode Buffer full action stop or wrap Returns The previous trace mode Description Set the action to be performed when the task trace buffer is full The options are stop or wrap os21 trace set enable Enable trace logging Definition int os21 trace set enable int mode
32. use the gdb x i pc command To inspect the memory use the x examine command for example gdb x 0xC0000000 For other formats use the modifier For example strings gdb x s 0x08001234 To view by name any variable currently in scope use with the print or p command It can also be used with expressions for example gdb p footbar 2 To format the displayed information use the print command for example gdb printf Ss d d n 0x8001234 foo footbar 2 Changing the state of the program To alter memory locations registers and variables use the set command gdb set variable i 0 The expression syntax is similar to C or C depending what is being debugged but there are some extensions see the GNU Debugging with GDB manual Exiting GDB When the debug session is complete use the quit or q command to exit GDB 8063762 Rev 9 45 246 Cross development tools ST200 5 3 2 5 3 3 46 246 The Ixgdbinit file On startup GDB searches for the 1xgdbinit file first in the home directory and then in the current working directory If either of these files exist GDB sources their contents The GDB nx option prevents GDB from sourcing these files In addition if the st200gdb or st200insight tools launch GDB a default 1xgdbinit file is sourced before any other file This file enables support for the ST200 simulator and silicon targets The nx option has no effect on this file Any comman
33. 0 1 rwx rwx 4MB 0x08000000 0x08000000 WAY0 3 CACHED 210 246 8063762 Rev 9 ky ST200 ST200 board support package BSP bsp mmu memory map Create a memory mapping and return a virtual address range Definition include lt platform h gt void bsp mmu memory map void address size t length int prot int flags void phaddr Arguments address The virtual address length The length of region in bytes prot The combination of supervisor and user mode accesses permitted for the address being mapped flags Other information about the handling of the mapped data phaddr The physical address of the region to map Returns On successful completion the bsp mmu memory map function returns the virtual address at which the mapping was placed otherwise it returns a value of BSP FAILURE and sets bsp errno to indicate the error If bsp mmu memory map fails for reasons other than BSP EINVAL some of the mappings in the address range starting at address and continuing for length bytes may be unmapped Description The bsp mmu memory map function establishes a mapping between a range of virtual addresses accessed by the program and a range of physical address of the same size Protection attributes can be set for the access to this range of address The format of the call is as follows va bsp mmu memory map addr length prot flags phaddr In this example bsp mmu memory map establishes a m
34. 1 0 console installplugin Installs a plugin to drive the target interface layer directly msglevel Sets the target debug interface message level ondisconnect none reset restart Set the action to perform on disconnecting from the target The default is none none does nothing when disconnecting reset this option resets the target before disconnecting this is not compatible with the ST Micro Connect 2 restart this option restarts the target from where it was last stopped rtos Enables or disables RTOS awareness 8063762 Rev 9 51 246 Cross development tools ST200 st200gdb extended features st200gdb offers also commands for the ST200 simulator and ST200 specific devices that is the performance monitor block and the DSU interface Table 11 lists the simulator and DSU commands Table 11 Simulator and DSU commands Command Simulator commands Description bus trace off Turn off bus traffic tracing bus trace on Turn on bus traffic tracing flush Flush the trace output stream get config config item Give the value of a specified configuration item profile off Turn profiling off profile on Turn profiling on reset statistics set bus trace file Reset the simulator statistics counter to zero Set the current bus tracing file set trace file Set the current tracing file start statistics Start
35. 116 partitions E AA AA AA ESSE 175 0s21 time logging IUE 235 protection settings 35 os21decodetrace 98 99 109 111 MEMSYSTEM LATENCY 86 control file 112 MODE 86 example VIDENDUM 114 multi tasking eee eee 22 24 os2lusertrace 98 99 mutexes 24 180 definition file 100 example tt ak krr Eiee 113 N os21usertracegen 98 OUTPUT LOG FILE 88 newlib 17 24 177 OUTPUT TRACE FILE ENDE 88 features IIIA 17 NONCACHEABLE MEM SIZE 87 P O partition manager 177 path names 0c e eee eee 186 object files DOCK MORE 13 COPY Ge KA AAA 19 PERIPHERAL BASE 88 information X BOGCWOKCE ee cee AA ORC 15 PERIPHERAL LATENCY AT 87 list symbols siei IIIA 15 Ped a ecb Ch S bok ski er Exc 92 95 translate AA AA AN 15 platforms 000 eee eee 13 on chip emulation 13 plugin OS21 KAA AAA AAA AAA 13 AA lt lt cnn dnc oe ec cccutnsebanwcwwas 89 applications MIELE 17 plugins board support libraries 16 94 profiler 226 configurable options 92 ST TargetPack 233 critical sections 178 aim PDT 13 debugg
36. 191 po ai maana ANA pd RS di ed p3 KAT PEP NEP parles NADA Bor Naso d 192 B 2 1 Managingthecaches 192 B 2 2 Cache header file machine bsp cache h 192 B 2 3 L72 CANG ue RE ee xn uem xax dede x e IE ar ens 193 B 3 Memorymanagement 194 B 3 1 Initial memory map RII 194 B 3 2 Managing the MMU 194 B 3 3 MMU header file machine bsp MMmu h 0 eae 194 B 3 4 Speculative control unit SCU 195 BA TViMeSescuceusav RYE tunn raa Roe es KG P ERRENREE REF RRREE RES 196 B 4 1 Input clock frequency EH AA 196 B 4 2 Tick duration ua a NG nen eue ee ck nk e n eren 196 B 4 3 Reading the current time 196 B 4 4 ST200 timer assignmentis 196 B 4 5 Timer header file machine bsp timer h eee 197 B 5 Performance monitor PM 198 B 5 1 Hardware abstraction layer for the PM module 198 B 6 Erceptionhandling 198 B 6 1 Exceptions typeS 0 ee cee eee 198 B 6 2 Exceptions header file machine bsp core h 199 8 246 8063762 Rev 9 ky ST200 Contents Bas IMEE scone sda eee RES fiot BN WD PG KANPEPERANA SA hcc HA CR d 200 B 7 1 Interrupt handlerinstallation 20
37. 2 st200nm st2000bjcopy st2000bjdump st200ranlib st200readelf st200size st200strings st200strip List symbols from object files Copy and translate object files Display information from object files Generate index to archive contents Display the contents of ELF format files List file section sizes and total size List printable strings from files Discard symbols From the GNU make package mingw32 make GNU make only on MS Windows From the GCC GNU package gcov gcov dump GNU test coverage tool GNU tool to print coverage files content From the GDB Insight GNU package st200gdb st200insight Others st200c st200cc st200xrun os21decodetrace os21prof st200 rebase st200rltool st200version st200symbolise st240symbolise Libraries GNU target debugger Graphical User Interface for the debugger GCC compatible optimizing C compiler GCC compatible optimizing C compiler ST200 target loader Decode tool for OS21 Trace OS21 profiler implemented as a Perl script Enables the application s memory layout to be changed after linking Relocatable library tool implemented as a Perl script Display of the ST200 toolset version Augment the simulator STISS trace information There are libraries for each of the possible target configurations supported by st200cc one version for each permutation of the ST200 specific compiler options that affect code generation and for the Application Binary Interface
38. 46 memory allocation 161 connecting toa target See somes RA 43 44 relocatable run time model 146 DOWeI UP ca nagba ana ib avemeedi encase 187 RESET ADDRESS 87 profiling 226 232 RESET DELAY CYCLES 87 selecting target for Insight 68 rl add action callback 157 ST Micro Connection Package DIN 16 37 44 rl delete action callback 158 ST TargetPack See TargetPack n errarg ssoi tna manida iar epy A iena 160 st200addr2line 185 MOEN o AA 158 st200as 26 Hz et Ste ee hen oe eee ee NEA 160 st200C La 15 25 n file name 00 e eee eee 150 st200cc 15 29 37 84 94 rl foreach segment 156 building relocatable library 161 163 rl handle delete 149 command line 27 n handle new 149 examples 23 26 40 rl lib EC E EE E EE 145 interfaces 26 rn load addr 150 introduction 25 n load buffer WI aa 151 selectingOS 93 rl load file perc cas Tae PACO PC CEN M 152 st200gcov DEMEURE TEE 16 n load size AA 150 st200gdb 15 16 26 42 43 46 49 50 64 84 89 n load stream AA 186 231 fl
39. 9 209 246 ST200 board support package BSP ST200 bsp interrupt uninstall Uninstalls an interrupt handler Definition include lt platform h gt int bsp interrupt unistall int interrupt number int type Arguments interrupt number The interrupt to uninstall type Flag to select between eternal and internal interrupts Values accepted NTERNAL INTERRUPTS EXTERNAL INTERRUPTS Returns Returns the error condition Description This function uninstalls a previously installed interrupt handle bsp itc interrupt unistall is kept for backward compatibility and it is equivalent to call bsp interrupt unistall using type EXTERNAL INTERRUPTS bsp mmu dump TLB Settings Write TLB s settings on the stdio Definition include lt platform h gt int bsp mmu dump TLB Settings void Arguments None Returns Returns BSP OK Description The bsp mmu dump TLB Settings function writes the TLB s settings on the stdio The following example shows the output of the bsp mmu dump TLB Settings function for an ST231 or ST240 simulation Index Asid Shared Sup Usr Size Vaddr Paddr Partition Policy 58 0 1 r x 8KB 0x1F004000 Ox1F004000 WAYO 3 UNCACHED 59 0 1 rw 8KB 0x1F002000 Ox1F002000 WAYO 3 UNCACHED 60 0 1 rw 8KB 0x1F000000 Ox1F000000 WAYO 3 UNCACHED 61 0 1 rwx rwx 8KB 0x00000000 0x00000000 WAYO 3 UNCACHED 62 0 1 rwx rwx 4MB 0x08400000 0x08400000 WAY0 3 CACHED 63
40. ABI such as floating point and endianness Therefore whatever permutation a user program is compiled against a library 8063762 Rev 9 15 246 Toolset overview ST200 with the same permutation except for optimizations exists and is automatically selected by the compiler driver Compiler run time libraries An ISO ANSI C run time library libc and libm and header files The run time libraries also provide support for low level I O and additional math functions The low level I O is implemented by the libdtf library libdtf see Section 1 3 3 on page 18 and a run time library libgprof is also provided to support profiling with st200gprof An ISO ANSI C run time library libstdc and header files supporting I O streams and the standard templates library the STL Compiler support libraries Compiler intrinsic libraries libgcc and variants and a run time library libgcov to support code coverage with st200gcov are also provided Others e The OS21 real time kernel library and header files and OS21 board support libraries for the various supported platforms e Therelocatable loader library and header files 1 2 3 Configuration scripts st200gdb st200insight and st200xrun need a set of GDB command scripts to establish connections to e hardware targets supported by ST TargetPacks supplied with the ST Micro Connection Package e hardware targets not supported by a TargetPack in this case the configuration scr
41. APIs When used with the wrap source command line option the os21usertrace tool creates source code that includes a set of APIs that can be called by the application to control the generation of user trace records Note The initial element user in the names of the APIs listed in the following sections can be changed with the option user prefix of the os21usertrace tool 11 13 1 User activity control APIs The following APIs are created by os21usertrace for controlling the generation of trace records for custom user activity events Note If no user activities are defined then none of these APIs are defined user activity set group enable Enable tracing for an activity group Definition void user activity set group enable user activity group e code int mode Arguments code Activity group to enable or disable mode Enable 1 or disable 0 Returns Void Description Enable or disable the logging of all the activities for all classes of the user trace group specified by code The enumeration user activity group e is defined in the header file generated by os21usertrace user activity set group group class enable Enable tracing for an activity class Definition void user activity set group group class enable user activity group group class e code int mode Arguments code Activity class to enable or disable mode Enable 1 or disable 0 Returns Void Description os21usertrace generates a set of APIs for enabling o
42. APIs are defined then none of these APIs are defined user api set group enable Enable tracing for an API group Definition void user api set group enable user api group e code int mode Arguments code API group to enable or disable mode Enable 1 or disable 0 Returns Void Description Enable or disable the logging of all the APIs for all classes of the user trace group specified by code The enumeration user api group e is defined in the header file generated by os21usertrace 140 246 8063762 Rev 9 ky ST200 OS21 Trace user api set group group class enable Enable tracing for an API class Definition void user api set group group class enable user api group group class e code int mode Arguments code API class to enable or disable mode Enable 1 or disable 0 Returns Void Description os21usertrace generates a set of APIs for enabling or disabling the logging of classes of user defined APIs within each of the user defined trace groups There is one API for each group For example if there is a group of user defined APIs called libc then the API to enable or disable the logging of any given class of API within the 1ibc group is user api set group libc class enable An enumeration with the name user api group group class e where group is the name of an API group is defined for each API group in the header file generated by os21usertrace user api set enable Enable tracing for an API
43. BASE 87 bsp timer ticks per sec 221 BOOT ROM SIZE 88 bsp timer user 222 branch trace on ST240 223 224 bsp user end handle 202 breakpoints 13 49 65 69 184 bsp user start handle 201 BOP EET 24 BUNDLE CHECKING ON 88 bsp cache invalidate instruction 204 BUNDLE CHECKING RE ON 88 bsp cache invalidate instruction all 204 BUS BYTES PER CYCLE 87 bsp cache purge data 204 BUS BYTES PER TRANSACTION 87 bsp cache purge data all 205 BUS LATENCY 87 bsp core interrupt install 205 BUS MHZ 86 ky 8063762 Rev 9 240 246 Index BUS TRAFFIC OUTPUT TRACE FILE 88 BUS TRAFFIC TRACE END CYCLE 88 BUS TRAFFIC TRACE START CYCLE 88 BUS TRAFFIC TRACING ON 88 C op LEX 25 libraty cies eie f Ried 17 library header files 19 run time libraries 16 17 22 e APA 25 libraty aaa 18 library header files 19 run time libraries 16 17 symbols WA 14 Cache API aeaaaee eO HE Od 24 CLEAR MEMORY 89 clock frequencies aan 93 command line GDB commands 48 54 56 77 SI20060 ike ham pa we PAGE DAGA 26 st200
44. Definition int user api set enable user api e code int mode Arguments code API to enable or disable mode Enable 1 or disable 0 Returns O for success Description Enable or disable the logging of the user defined API specified by code The enumeration user api e is defined in the header file generated by os21usertrace user api set global enable Enable global tracing for APIs Definition int user api set global enable int mode Arguments mode Enable 1 or disable 0 Returns 0 for success Description Enable or disable the logging of user API types initially set to O ky 8063762 Rev 9 141 246 OS21 Trace ST200 11 13 3 User activity APIs The os21usertrace tool creates a set of APIs for generating the user defined events specified in the definition file These are all named USER ACTIVITY where ACTIVITY is the name in upper case letters of the activity given by the USER ACTIVITY specification in the definition file see Section 11 1 2 User definition file on page 100 The parameters of the API are determined by the specification given in the definition file Note The preferred version of the API is USER ACTIVITY as this enables the application to be linked successfully even if it is not linked with the OS21 Trace libraries There is an alternative form of the API with the name in lower case letter
45. OS21 configurable options continued Symbol name Description CONF INLINE FUNCTIONS Inline certain functions CONF NO FPU SUPPORT OS21 does not save restore FPU registers on context switch Note To alter the options listed in Table 19 edit the file makesT200 inc located in the at the top level of the OS21 source code directory By default none of the configuration options are enabled in this file 9 1 1 Configurable options in the standard OS21 libraries The standard OS21 libraries selected by st200cc mruntime os21 are built with CONF NO WRITE LATENCY WORKAROUND defined The debug OS21 libraries selected during build with mruntime 0s21 d are built with CONF DEBUG defined CONF DEBUG To produce a debug OS21 kernel define the CONF DEBUG preprocessor symbol This kernel contains many self checks to ensure internal integrity and to check that user calls into the kernel are correct CONF DEBUG ALLOC To produce an OS21 kernel with special checks added to the memory management code including the detection of heap scribbles and the freeing of bad pointers define the CONF DEBUG ALLOC preprocessor symbol CONF DEBUG CHECK SEM CONF DEBUG CHECK MTX and CONF DEBUG CHECK EVT To produce an OS21 with extra integrity checks enabled for semaphores mutexes and event flags respectively define these preprocessor symbols Every time one of these objects is referenced OS21 performs extra checks to ensure that its
46. Return a string for an error code const char rl errstr rl handle t handle handle The handle for the module A string for the error code The r1 errstr function returns a readable string for the error code reported by rl errno For example void sym rl sym handle symbol if sym NULL fprintf stderr failed s n rl_errstr handle If symbol is not defined in the module referenced by hand 1e then the following message is displayed failed symbol not found symbol 8063762 Rev 9 ky ST200 Relocatable loader library 12 4 12 4 1 Note 12 4 2 Note 12 5 Customization The relocatable loader library defines a number of functions that it uses internally for providing services such as heap memory management and file access To provide custom implementation of these functions the application in the main module can override these functions Memory allocation void rl malloc int size void rl memalign int align int size void r1 free void ptr These functions allocate free space for the load module image and for the handle objects The default behavior for these functions is to call the standard C library functions malloc memalign and free respectively If providing a custom implementation override all three functions File management void r1 fopen const char f name const char mode int rl fclose void file int rl fread char buffer int eltsize in
47. ST200 Micro Toolset 8063762 Rev 9 25 246 Code development tools ST200 3 2 26 246 Figure 2 Components of the ST200 Micro Toolset interfaces c source files cxx source files ST200 C C Compiler ST200 assembler files s ST200 assembler st200as ST200 libraries ST200 object file ST200 object file target board boot and sysconf files ST200 linker st2001d ST200 binary e1 ST200 load run tool ST200 debugger st200xrun st200gdb Figure 2 does not include the binary optimizer tool instruction cache placement dead code and dead data elimination or the profiling feedback optimization PFO or the interprocedural analysis optimization IAO st200cc command line The st200cc compiler driver tool has a large number of command line options although a minimal set of them is required to identify and configure the binaries with the desired run time libraries for a specific target A minimal command line for st200cc which generates the executable he110o out from the hello c source file has the following form S5 st200cc mcore core msoc soc mboard board o hello out hello c Where core soc and board are the system configuration parameters that specify the core variant ST231 or ST240 the system on chip SoC and the board for which the program is been built These options are used by the
48. The shtdi GDB target provides OS21 task aware debugging The shtdi GDB target installs a service that runs on the host and has knowledge of the data structures used in OS21 A dependency exists between the version of OS21 in use and the version of the shtdi service OS21 has static data tables that expose the layout of certain critical data structures to the shtdi service Each data table has a cyclic redundancy check CRC calculated for it that is stored statically These data tables are auto generated as part of the OS21 build process At the same time a header file is auto generated and imported into the build of the shtdi service This header file contains the same CRC values and some key type definitions The data tables are offset size pairs that identify particular fields within OS21 data structures The tables are indexed by enumerated types which are the types imported by the shtdi service There is one data table per OS21 data structure type that the shtdi service has to be aware The CRC value for each table is calculated using the field nam The order of the fields relative to each other is important because it is a CRC If a field changes name between releases or fields alter position within a data structure relative to each other then the CRC for the data table also changes When the shtdi service examines a target system to determine if it can debug it in OS21 aware mode it examines the data table CRCs in memory and checks to se
49. This option can be specified more than once group name Specify name as the definition group name for the following function names until the next group or output option or to the end of the command line whichever is the sooner g name The default is group default This option can be specified more than once in order to define multiple group names class name Specify name as the definition class name for the following function names until the next class or output option or to the end of the command line whichever is the sooner TC Hane The default is class default This option can be specified more than once in order to define multiple class names include file Specify the name of a C include file to add to the definitions file The set of C include files specified by this option is cleared by the next output option I file file can also be specified as file or lt file gt This option can be specified more than once os21usertracegen output file format os21usertracegen generates an annotated version of the definition file format see Section 11 1 2 User definition file on page 100 where the annotations provide the following additional information e the version of the os21usertracegen tool e the name of the ELF format input file from which the definitions file is derived e foreach contributing compilation unit the locations of the compiled source file compile unit annotation and the co
50. a robust critical section in a similar fashion to mutexes but with some major differences e Semaphores cannot be taken recursively any attempt to do this results in deadlocking the calling task e Like mutexes there are both FIFO and priority queuing models but unlike priority mutexes priority semaphores do not implement priority inheritance e Tasks are not automatically made immortal when they acquire a semaphore e Semaphores can be used with care from interrupt handlers Advantages e Robust critical section FIFO and priority queuing models are available but no priority inheritance No difference in cost between a FIFO and a priority semaphore Due to simpler semantics there is slightly lower execution cost compared to mutexes If TIMEOUT IMMEDIATE is used when trying to acquire and the interrupt handler is written to cope with not acquiring the semaphore semaphores can be used in an interrupt handler Disadvantages e Semaphores have to be created before they can be used More costly than task 1ock and task unlock Cannot be taken recursively because the system deadlocks No immortality while holding killing an owning task would be dangerous Disabling timeslicing When running with timeslicing enabled and a very light weight task task critical section is required which does not involve accessing a synchronization object it is possible to temporarily disable timeslicing For exam
51. and linked into the application e asingle linker script file containing the linker options for wrapping the user APIs e asingle control file describing the user APIs and activities being traced for use by the os21decodetrace tool The structure of the definition files is described in Section 11 1 2 User definition file on page 100 The command line for os21usertrace is os21usertrace option definition file The command line options are described in Table 21 There is a long form and short form alternative for each option Table 21 8 os21usertrace command line options Option Description help Display help h decode script file Create the os21decodetrace control file passed to the d file user option of os21decodetrace gdb script file Create the GDB command script file g file link script file Create the linker script file 1 file wrap source file Create the C source file s file user prefix name User control name space prefix Default is user up name user code base code User activity and API trace code base Default is 0 ucb code user code script FUNCTIONGFUNCTIONGEILE This option is reserved for STMicroelectronics use only ucs FUNCTIONGFUNCTIONGFILE 8063762 Rev 9 99 246 OS21 Trace ST200 Note 11 1 2 100 246 The wrap source option creates both a C source file and its corresponding header file The hea
52. anunsigned int with the value of the calculated CRC for the above array given the name struct descs crc GDB F ELD enum prefix field Declares that a field in the current structure is to be exposed to the shtdi server An enum called enum prefix fieldis generated and stored in the export header file to correspond to this fields index in the array of descriptors GDB ARRAY FIELD enum prefix field field index enum suffix Declares that a particular field in the structure array is to be exposed to the shtdi server An enum called enum prefix field enum suffixis generated and stored in the export header file to correspond to this field s index in the array of descriptors GDB B EGIN EXPORT GDB END EXPORT These two markers are used to identify a section of header file which is to be copied verbatim into the export header file 8063762 Rev 9 95 246 Booting OS21 from Flash ROM ST200 10 10 1 Note Note 96 246 Booting OS21 from Flash ROM Examples of booting from Flash ROM are located in the examples os21 subdirectory of the release installation directory Full details are in the readme txt files in these directories Table 20 lists some examples Table 20 Examples of booting from Flash ROM Example name Description rombootram Before running the ROM bootstrap copies the application to RAM rombootrom The application runs directl
53. args save caller address Of save frame address disable os21 trace control control Disable the saving of information indicated by control show os21 trace control control Shows whether control is enabled or disabled enable os21 trace control all Enable all controls as a single operation disable os21 trace control all Disable all controls as a single operation show os21 trace control all Display the controls that are enabled or disabled Enable OS21 activity enable os21 activity global Enable the logging of OS21 activity types which is disabled by default disable os21 activity global Disable the logging of OS21 activity types show os21 activity global Display the logging status of the OS21 activity types Enable OS21 API enable os21 api global Enable the logging of OS21 API types which is disabled by default disable os21 api global Disable the logging of OS21 API types show os21 api global Display the logging status of the OS21 API types 8063762 Rev 9 ky ST200 OS21 Trace 11 9 6 11 9 7 Enable OS21 activity event show os21 activity classes Display the OS21 activity event classes The supported classes are task interrupt and exception enable os21 activity class all Enable the logging of all OS21 activity events in all classes disable os21 activity class all Disable the logging of all OS21 activity events in all classes show os21 activity clas
54. board support package BSP Appendix B ST200 board support package BSP This appendix describes the board support package of the bare machine run time software for the STMicroelectronics ST200 family of processors The BSP has a set of function calls that enable you to command low level functionalities available on ST200 powered systems such as cache management timers programming performance monitoring and interrupts installation This bare machine run time software provides very low level control of the resources of the ST200 CPU core Most users are expected to use the OS21 run time kernel which manages the machine s low level resources and so do not need to use this low level API B 1 Error handling All BSP functions not directly returning a value return an error condition that assumes one of the following values BSP OK if there are no errors BSP FAILURE if an error occurred When an error is detected the global variable unsigned int bsp errno is set to the appropriate value at the exit of each BSP call If there are no errors bsp errno is set to BSP OK otherwise it is set to the appropriate error code see Table 40 Table 40 BSP errors Error Description BSP OK No errors BSP FAILURE General error condition BSP EINVAL An invalid argument is given BSP EINTR An error occurred installing an interrupt BSP EBUSY The resource is not available BSP EMAPFAIL Ther
55. case the option is used to specify to st200xrun that the first argument in the list following is the name of the executable To run hello out on the mb424sim simulator a profile of the ST231 simulator that simulates the IPBR1100 enter the following command st200xrun c st200sp t mb424sim e hello out To run hello out using a script file enter the following command st200xrun i load rc Where the contents of the script file Load rc could be file hello out st200tp IP address mb424 ST231 load c To run hello out With target program arguments enter the following command st200xrun c st200tp t IP address mb424 st231 e hello out a argl arg2 arg3 arg4 8063762 Rev 9 57 246 Using STWorkbench ST200 6 Using STWorkbench This chapter describes how to use the STWorkbench Integrated Development Environment IDE for the ST200 Micro Toolset STWorkbench is available on all supported host platforms The STWorkbench is delivered with CDT C C Development Tooling included CDT provides a fully functional C and C IDE for the STWorkbench platform and enables the user to develop execute and debug applications interactively The STWorkbench is built on the Eclipse IDE The Eclipse development environment and related information can be found at the Eclipse website www eclipse org Information on CDT can be found at www eclipse org cdt Note STWorkbench is a separate release to the ST200 Micro Toolset
56. endianness combination chosen by the toolset corresponds to st 231 default default LE When the linker is invoked the selected core 1d soc 1d and board 1d are automatically combined through a general plat form 1d file to provide an entire and consistent linker script For example the command tools dir bin st200cc o hello out mcore st231 msoc sti7200 mboard zmb519 audio0 hello c is equivalent to tools dir bin st200cc o hello out N EL nostdlib L lt tools dir gt target core st231 le bare L lt tools dir gt target soc sti7200 st231 le bare L lt tools dir gt target board mb519_audio0 st231 le bare L lt tools dir gt lib st231 le bare lt tools dir gt lib st231 le bare crtl o lt tools dir gt lib st231 le bare crti o lt tools dir gt lib st231 le bare crtbegin o lt tools dir gt target core st231 le bare bootcore o I tools dir target core st231 I tools dir target soc sti7200 I tools dir target board mb519 audio0 hello c lc ldtf lboard 1soc lcore lgcc tools dir lib st231 1e bare crtend o lt tools dir gt lib st231 le bare crtn o T tools dir target platform ld 8063762 Rev 9 29 246 Board target configuration ST200 4 2 4 2 1 30 246 Understanding target dependent settings This section describes the target dependent contribution to the toolset that is core SoC and board contribu
57. expression from the list Dump Memory at Displays the selected variable in the Memory window Help Displays the online help window Close Close the Local Variables window To expand the structure of a variable click on the plus sign To collapse the structure click the minus sign 8063762 Rev 9 ky ST200 Using Insight 7 12 Note Note a Using the Console Window The Console Window is the underlying GDB console and enables the user to issue commands directly to GDB To open the Console Window either click the button or from the View menu in the Source Window select Console Figure 21 Console Window Console Window The target endianness is set automatically currently little endian The target architecture is set automatically currently st231 mb424 connect start parameters TCK frequency set to 125080008 Hz Device id 0xdh2a851 tapnux connect boot mode single core setup tapmux setup to bypass to core st231 channel 1 mb424 initialization start Setup Clock Generator for STb53601 STb53801 Clock Generator Successfully setup tapnux complete connect single core setup mb424 initialization complete 6x 666680608 in section text size 0x22800 lma 6xc6000060 section init size 60x38 lma 6xc 6022866 section fini size 6x38 lma 0409022838 section rodata size 0x20e8 lna 0200022879 section eh frame size 6x4 lma xcg25958 section ctors size 6x8 Ima 6xc802495c section d
58. file for later use specify the name of the file with file 8063762 Rev 9 233 246 ST TargetPack plugin ST200 234 246 For example when connected to a target the following command sets up the memory mapped user commands and convenience variables targetpack export This command also displays further information on how to list the available memory mapped register names The following examples for a STi5301 SoC show how to use the memory mapped user commands and convenience variables List all register groups user commands help mmrs component List all registers help mmrs register Decode and display register contents mmrs SysServ MODE CONTROL v List all register convenience variables help mmrs convenience The targetpack command is available only when connected to a target However it is not necessary to connect to a target using an ST TargetPack in order to to use the targetpack command nor is it necessary to import or export the same targetstring used for the original target connection The following example illustrates this After connecting to a simulated MB424 target use the targetpack command to export the ST TargetPack register set to a GDB script file called mb424regs cmd st200sp mb424sim enable_targetpack targetpack import stmc mb424 st231 targetpack export mb424regs cmd 8063762 Rev 9 ST200 GDB os21 time logging user command Appendix F GDB os21 time
59. following binary files are created os21trace bin This file contains the contents of the trace buffer os21trace bin ticks OS21 time information time ticks per sec value for the trace timestamps and the absolute time of the last event saved in the trace buffer os21tasktrace bin This file contains the contents of the task information buffer Section 11 8 Structure of trace binary files on page 115 provides a description of the format for each of these files Analyzing the results After the OS21 Trace and the task information buffers have been saved on the host use the decoder tool os21decodetrace to convert this data into various output formats for viewing and analysis The command line for os21decodetrace is os21decodetrace option trace file The command line options for os21decodetrace are described in Table 25 Table 25 os21decodetrace command line options Option Description Optional name of target executable file Required to obtain the B fil 3 see We symbolic names of interrupt handlers Optional name of the task information data file for example n task trace file os21tasktrace bin This file provides the name and other useful information for each task 8063762 Rev 9 109 246 OS21 Trace ST200 Table 25 os21decodetrace command line options continued Option Description Optional output file name The default is to output to the console Trace data files must be gi
60. hello out D Debug verbose information The maximum time for executing on the target timeout is expressed in T timeout seconds V Display the version of st200xrun Specify that the remainder of the command line arguments are to be passed as arguments to the target application This option can only be specified as the final option in the command line a arguments arguments 1 Ifthe e option is omitted and the i option is not used then st200xrun assumes that the first argument in the argument list is the name of the executable file 2 This option can be issued multiple times The GDB commands are executed in the order specified in the command line Options passed using c are handled in the order specified by the sequence of c calls st200xrun command line examples To run hello out ona silicon IPBR1100 target mb424 with an ST TargetPack enter the following command st200xrun c st200tp t IP address mb424 st231 e hello out a argl arg2 The default configuration procedure is st200tp so in the previous example the c st200tp could be omitted to give the following command line st200xrun t IP address mb424 st231 e hello out a argl arg2 8063762 Rev 9 ST200 Cross development tools It is also possible to omit the e by specifying the following command line st200xrun t IP address mb424 st231 hello out a argi arg2 In this
61. int bsp timer user int timer unsigned int const unsigned int reload int interrupt handle void param int old handle void param timer The user timer to set TIMER1 or TIMER2 const The value to load to initialize the timer reload The value to be reloaded when reaching zero interrupt handle The handle of the interrupt old handle The interrupt handle previously associated with the timer Returns BSP OK on success on failure it returns BSP FAILURE and sets bsp errno to indicate the error This function set a user timer attaches an interrupt handle and enables the corresponding interrupt 8063762 Rev 9 ky ST200 Branch trace buffer Appendix C Branch trace buffer C 1 The branch trace buffer is an ST240 hardware feature intended to aid debugging showing the flow of control during execution of a program by recording the non sequential updates of the program counter PC The ST240 branch trace buffer is an eight level deep FIFO buffer which stores the source and destination addresses for the last eight branches The branch trace buffer can be configured for all branches a class of branches or a combination of branch classes The branch classes defined are general subroutine and traps see Section C 1 Branch trace buffer modes for further details The branch trace buffer features are accessible though the GDB branchtrace command Branch trace buffer modes The b
62. is set on Disable or enable all of the breakpoints Delete all of the breakpoints Save the breakpoints to a file Restore breakpoints from a file 8063762 Rev 9 ST200 Using Insight 7 7 Using the Stack window The Stack window shows a list of all the frames currently on the stack To open the Stack window either click the a button or from the View menu in the Source Window select Stack Figure 15 Stack window libc_lock_acquire_recursive libc lock init complete recursiu 0521 is active task context To select a frame click on the appropriate frame line The line is highlighted in yellow and the Registers and Local Variables windows show the associated data The Source Window shows the associated source line see Figure 16 on page 72 Figure 20 on page 76 and Figure 9 on page 65 ky 8063762 Rev 9 71 246 Using Insight ST200 7 8 Note 72 246 Using the Registers window The Registers window shows the content of all the registers To open the Registers window either click the al button or from the View menu in the Source Window select Registers Figure 16 Registers window Registers Oxc 6022838 OxctFF7Fd8 Oxc 0022020 Oxc 6622026 Oxc 0025334 Oxc 602c 808 Bx8F 041809 Oxc 092 4c18 Oxc 662 hee 6 Oxc 992 4ed8 Oxc1FF7FcB Oxc 6623066 xffFFd FfF 6x525268 6x593668 0x593600 xc 1b5eit xffffhecd To edit a register s va
63. loader library API 148 12 3 1 rl handle ttype 2 4 sisse sess e e ee mmi 148 12 4 Customization 161 12 4 1 Memory allocation 161 12 4 2 File management eren 161 12 5 Building a relocatable library or main module 161 12 5 1 Importinganderportingsymbols 162 12 5 2 Optimization options 163 12 6 Debugging support 164 12 7 Profiling support 165 12 8 Memory protection support 166 12 9 Load time decompression cece eee eee 166 13 Dynamic OS21 profiling 167 19 QVetVIBW cis ek EIA RES URENIO CER P AO RO PORA RES 167 13 2 Building an application for dynamic OS21 profiling 168 13 3 Running the application aana ee 168 194 GDB SOMMANGS esed ee e ERR HPG ce HE BAGA NAE o eee bine 168 13 5 Analyzing the results eee ee 172 135 IEXUmplg x5o35 0x0 IGUREEA TERRA RA ERA de Ud hoger waned ene 172 13 7 Profiler library API 172 13 7 1 Function definitions 172 13 72 Overrides l S MEV Oa LABI LAAN C EAE ERN RR 173 Appendix A Toolsett
64. local_sem task unlock if library sem local sem semaphore_delete local_sem When the code completes if necessary the library semaphore has been created The first check which occurs unlocked is to see if the semaphore already exists If it does then there is nothing more to do If it does not then the code allocates a new semaphore with the address of the semaphore in a local variable If the task is descheduled while creating the semaphore it is possible for another task to enter this routine It too would see that no library semaphore exists and would similarly attempt to create a new one When the task returns from creating the semaphore it locks the scheduler to prevent pre emption Under this lock it again checks the library semaphore If it still does not exist the library semaphore is assigned the address of the semaphore just created The scheduler is now unlocked The lock ensured that precisely one of the competing tasks assigned a non zero value to the library semaphore pointer When out of the lock the library semaphore is checked against the local one If they are identical then it is known that the local semaphore was used and nothing more needs to be done If they are different then another task assigned the library semaphore pointer In this case the local semaphore must be discarded it is not needed as the library semaphore already exists 8063762 Rev 9 ky ST200 Toolset tips A 10
65. logging user command OS21 records the elapsed time that a task has been run on the CPU This value is available to an application by using the OS21 task status API As a convenience the GDB command os21 time logging is provided to display the task list with the elapsed time for each task This command is defined in the GDB script file os21timelog cmd and displays the information with the following format task number task name time usus time ticks ticks where task number is the OS21 task number task name is the OS21 task name time us is the elapsed time in microseconds time ticks is the elapsed time in clock ticks indicates the current task For example gdb source os21timelog cmd gdb os21 time logging 1 Root Task 14607us 22824 ticks 2 Idle Task 9985us 15602 ticks 3 task0 19995us 31243 ticks 4 5 ma task1 39994us 62491 ticks task2 59992us 93738 ticks 6 task3 79993us 124990 ticks Note As the CPU clock is still running when the target is under the control of GDB this time will be accumulated against the current task indicated by a when the target is restarted Using the same example as above but having previously already hit a breakpoint in Root Task 1 Root Task 204545us 319602 ticks 2 Idle Task 9985us 15602 ticks 3 task0 19994us 31242 ticks 4 task1 39985us 62478 ticks 5 task2 59993us 93740 ticks 6 task3 79992us 1249
66. main gdb break 21 gdb break 0xc0000408 Download the program set any arguments if required and start the program on the target by invoking the cont inue command gdb load gdb set args argumenti argument2 argument3 gdb continue 8063762 Rev 9 ky ST200 Cross development tools The program runs until it completes hits a breakpoint is interrupted by the user with a Ctrl C or encounters an error When the program stops a short explanatory message is displayed and the GDB prompt returns To resume execution invoke the continue command again The following commands step execution a line or a machine instruction at a time step Moves on to the next source line even if it is in a different function Abbreviated to s stepi Moves on a single machine instruction before pausing the program again Abbreviated to si next This is the same as step but moves to the next line in the current function rather than the next line in the program and steps over any function calls Abbreviated to n nexti The machine code equivalent of next it moves to the next instruction in the sequence even if the current one is a call Examining the target All the GDB commands for interrogating targets are available To view the register set use the info registers command For a more compact display use the regs command To disassemble the current function use the disassemble command To disassemble the current instruction
67. parent euo WG ewe KPA eS DANG 150 command line 48 54 rl set file name apo ip Dux ius wacom ARNAN NAKA apk d a 151 connecting to target aga nA ako SERERE 44 n sym nn nnn 155 BALER AG KING KAPAGKA ee ee bea dd d 45 n Sym rec 2 1 n nnn 155 st200gprof 16 226 MANIS ia AA 149 st200insight See Insight n unload ia AAA aa 154 st2001d 26 run time libraries 16 17 19 st200objdump 185 run time model 0c eee eee ee 145 ST200TOOLS DIR 35 38 st200xrun 13 15 16 26 28 37 42 89 S command line reference 55 examples 23 56 scheduler CA 24 loading target 40 scheduler behavior 178 ky 8063762 Rev 9 244 246 Index ST200 running simulator 84 89 TargetPack 16 20 28 31 37 40 SQUID aces Sta hg ade eR RE RENTUR a d Go AG AG 44 55 56 233 234 ST2x0 Statistics window 80 targetpack command 233 stacktraces 183 185 TargetString 40 44 56 84 standard templates library 16 task interrupt critical sections 178 start parameter initialization 42 task task critical sections 179 statistics command
68. rec function returns a pointer reference to the symbol named name in the loaded module specified by handle or one of its ancestors This function searches the dynamic symbol table of the loaded module and returns a pointer to the symbol if found If the symbol is not found the function iteratively searches in the dynamic symbol table of the parent module until the symbol is found The handle parameter can be the handle of any currently loaded module or the handle of the main module If the symbol is not defined in the loaded module or one of its ancestors NULL is the returned It is not generally an error for this function to return NULL The name parameter must be the mangled symbol name as for the r1 sym function 8063762 Rev 9 155 246 Relocatable loader library ST200 rl foreach segment Iterate over all the segments of loaded module and Definition Arguments Returns Description 156 246 call the supplied function typedef rl segment info t rl segment info t typedef int rl segment func t rl handle t handle rl segment info t seg info void cookie int rl foreach segment rl handle t handle rl segment func t callback fn void callback cookie handle The handle for the module callback fn The user specified callback function callback cookie The argument to pass to the function Returns 0 for success 1 for failure The r1 foreach segment functi
69. resources When MAP FIXED is setin the 1ags argument the system is informed that the value of va must be addr exactly If MAP FIXED is set bsp mmu memory map may return MAP FAILED and set bsp errno to BSP_EINVAL If a MAP FIXED request is successful the mapping established by bsp mmu memory map 8063762 Rev 9 ky ST200 ST200 board support package BSP See also replaces any previous mappings for the program s pages in the range va va length When MAP FIXED is set and the requested address is the same as previous mapping the previous address is unmapped and the new mapping is created on top of the old one T When MAP_FIXED is not set the system uses addr to arrive at va The va is an area of the address space that the system deems suitable for a mapping of 1ength bytes to the physical address phaddr The value of addr is taken to be a suggestion of a program address near which the mapping should be placed When the system selects a value for va and MAP OVERRIDE is not set existing mappings are not overridden This includes the mapping set at program initialization time in BSP like code When MAP SPARE RESOURCES is set the hardware resources are spared so that a reasonable amount of hardware resources remain available for further bsp mmu memory map usage The implementation of this flag is ST200 architecture de
70. run time environment are in the single header file machine bsp mmap h see Table 44 Table 44 Functions defined in bsp mmap h Function Description bsp scu read Read the settings of the region bsp scu write Write the start and end address of a region bsp scu disable Disable a region bep scu dump scu Settings ae n a list of SCU regions with their The functions bsp scu read and bsp scu write use a struct to define start and end addresses typedef struct void start address void end address bsp scu entry t The two addresses are rounded to be aligned to the smallest TLB page size ky 8063762 Rev 9 195 246 ST200 board support package BSP ST200 B 4 B 4 1 B 4 2 B 4 3 B 4 4 196 246 Timers The ST200 has three independent timers each capable of running as a free running auto reload 32 bit counter with interrupt on underflow Each can be programmed to count some fraction of the input clock Time is represented in clock ticks with the bsp clock t type This is defined to be a signed 64 bit integer Input clock frequency The precise speed of the input clock is determined by the end user it is a function of the board design and boot software Tick duration ST200 BSP establishes the period of one tick when it boots Based on the input clock frequency it selects an appropriate divisor to yield a tick that is approximately 1 microsecond Reading the current
71. set architecture manual 8059133 To simplify the user settings there are two bare run time functions bsp mmu memory map and bsp mmu memory unmap see Section B 10 BSP function definitions on page 204 Note For ST231 onward any address area unknown to the core and outside the program RAM usage from text start to ramend requires an explicit mapping For example before accessing the 0x08900000 device address use the following C code int device control 0x08900000 include lt machine mmu h gt bsp mmu memory map 0x08900000 0x100 PROT SUPERVISOR WRITE PROT SUPERVISOR READ 0 0x08900000 device control 0 4 3 3 Defining a custom board target and compiling a program The following procedure describes how to define a board target and to keep the changes during an update 1 Create a new target directory outside the lt tools dir gt directory for example new target dir containing a board directory with a subdirectory for each board target for example my board The new target tree is new target dir board my board 2 Copy the file too1s dir target defines mkf into the new target directory new target dir and edit the file changing the value of the variable ST200TOOLS DIR With the path of the toolset lt tools dir gt 3 Recursively copy the files from the lt tools dir gt target board template directory to the newly created subdirectory for example my board Alternatively instead of u
72. st200xrun c st200sp t st231simle C DEVICE PLUGIN MODULES c plugins devl dll1 c plugins dev2 d11 prog exe If an external SDI device also has memory mapped registers it can be modelled by a single plugin This plugin supports both SDI and device plugin interfaces and is specified against both the SDI PLUGIN MODULE and DEVICE PLUGIN MODULES configuration items The sample device plugin is described in Section 8 3 on page 90 The source of a sample device plugin can be found in the standard release under lt tools dir gt host st200sim src Plugins SampleDevice Device plugins which simulate existing target boards are described Section 8 3 2 Building and running the plugin on page 91 on DSU DEFAULT By default the debug support handler code is compiled into the memory is cleared MODULE ENABLED simulator This option ensures that this code is loaded into true bool memory at the beginning of a simulation DSU ROM IMAGE Allows the user to specify their own debug support code module filename thus overriding the default one paie eM rS Path of pin stimulation data file psa lt filename gt EXTERNAL MEMORY If set this option initializes the whole of memory to the 4 byte cea PATTERN lt number gt pattern specified If set to 1 and EXTERNAL_MEMORY_PATTERN is set to zero then CLEAR MEMORY
73. structure is not corrupt and that it has not been previously deleted CONF DISPLAY CLOCK FREQS To produce an OS21 kernel that reports certain key ST200 clock frequencies when the kernel is initialized define the CONF DISPLAY CLOCK FREQS preprocessor symbol CONF INLINE FUNCTIONS To produce an OS21 with inlined list manipulation functions define the CONF INLINE FUNCTIONS preprocessor symbol This can yield a slight performance improvement 8063762 Rev 9 93 246 OS21 source guide ST200 9 2 Note 9 2 1 9 3 Note 94 246 Building the OS21 board support libraries Instructions on building the OS21 board support libraries are in the src os21 README file which can also be used on Linux also as a shell script Building the OS21 board support libraries overwrites the original libraries To restore the original libraries perform a new installation of the ST200 toolset Adding support for new boards To add OS21 board support to a custom target board refer to Chapter 4 Board target configuration on page 27 and follow the src os21 README guidelines for the OS21 specific information When a new board support has been set up for example mbXYZ_cpu1 with core type st231 and SoC named stxABCD the compiler driver selects the OS21 support for the board st200cc mcore st231 msoc stxABCD mboard mbXYZ cpul mruntime os21 o hello out hello c GDB OS21 awareness support
74. supervisor mode I PROT USER EXECUTE The address can be executed in user mode PROT SUPERVISOR EXECUTE The address can be executed in supervisor mode PROT NONE The data cannot be accessed POLICY CACHEABLE Memory accesses are cached POLICY CACHEABLE replaces PROT CACHEABLE which is kept for backward compatibility POLICY UNCACHEABLE Memory accesses are uncached POLICY WCUNCACHEABLE Memory accesses are uncached write combined PART REPLACE Place as specified by replacement counter and increment the counter PART WAY1 Place in way 1 only PART WAY2 Place in way 2 only PART WAY3 Place in way 3 only PAGE DIRTY Page is dirty write accesses to this page will cause a TLB WRITE TO CLEAN exception PAGE VALID Writes to this page are allowed If an implementation of bsp mmu memory map for a specific platform cannot support the combination of access types specified by prot the call to bsp mmu memory map fails The 1ags argument provides other information about the handling of the mapped data The value of 1ags is the bitwise inclusive OR of the following options defined in machine bsp mmu h MAP FIXED Interpret addr exactly MAP LOCKED Protect this TLB by random TLB replacement MAP OVERRIDE Override any existing mapping MAP SPARE RESOURCES Spare mapping
75. the event being monitored by a PM counter include lt platform h gt int bsp pm event set int counter unsigned int event counter The counter to set event The event to assign to the counter Returns the error condition This function sets the PM counter specified in counter to monitor the event specified in event bsp pm event get Reset all counters include lt platform h gt int bsp pm reset void None Returns BSP OK This function resets all of the PM counters Start all the event counters include lt platform h gt int bsp pm start void None Returns BSP OK This function starts all of the event counters bsp pm stop 8063762 Rev 9 ky ST200 ST200 board support package BSP bsp pm stop Stop all the event counters Definition include lt platform h gt int bsp pm stop void Arguments None Returns Returns BSP OK Description This function stops all of the event counters See also bsp pm start bsp rtrecord get Returns the run time configuration data Definition include lt platform h gt void bsp rtrecord get int data Arguments data The data field that is required to be returned from the run time configuration data Returns Returns the associated data The return value must be cast in the correct field format see Table 56 on page 203 Description This function reads from the run time configuration record the field specified by data and returns the relate
76. the name of the include file which defines a type referenced by a type spec The os21usertrace tool preserves the style of the header spec used ina USER INCLUDE definition when generating the C source file except when the form filename is used which is transformed into the i 1ename style of header spec USER API specifies the API within the application to be traced and consists of two parts The group class name provides the name of the API and the type spec list specifies the prototype for the API The order of elements in the type spec list is important The return type for the API is the first type spec specified in the type spec 1ist The types of the parameters of the API are specified by the second and subsequent elements in the type spec list For example USER API libc heap _malloc_r void p struct _reent p size_t d indicates that the _malloc_r API returns an object pointer of type void and accepts two parameters the first being a pointer to a_reent structure and the second being a size t If the return type is void or if the API takes no parameters use the form of type spec with no format that is type For example USER API libcGheapG free r void struct reent p void p USER ACTIVITY specifies the name of the custom activity API to be created by the os21usertrace tool The specification of type spec list is the same as for USER API except that it only specifies the type
77. to select the required threads The breakpoint is shown as a pink square 1 In optimized code this may not work as expected due to the compiler reordering code 7 2 2 Context sensitive menus Continue to Here Jump to Here Set Breakpoint Set Breakpoint on Thread s 66 246 8063762 Rev 9 ST200 Using Insight 7 3 Debugging a program The following procedure demonstrates debugging a program using the getting started example see Section 1 5 The examples directory on page 20 1 Launch Insight see Section 7 1 on page 64 2 Click the button The Load New Executable dialog box opens 3 Select the executable file and click the Open button The Target Selection window opens 4 Complete the Target Selection window see Section 7 4 Changing the target The program launches and stops at the breakpoint set at the main function see Figure 10 Figure 10 hello c stopped at breakpoint hello c Source Window File Run View Control Preferences Help 0000 me aasaomzErmw tea nello c M nain bes source ha 1 include lt stdio h gt 2 3 int main void 4 i return 8 Program stopped at line 5 888819c6 5 5 Debug the program using the menu and toolbar options To toggle breakpoints on and off click on the hyphen symbols to the left of the code Breakpoints are shown as red squares 8063762 Rev 9 67 246 Using Insight ST200 7 4 Changing the target 1 From the Fil
78. to the setup of GDB see Section 1 2 3 Configuration scripts on page 16 5 4 2 st200xrun command line reference To display the help invoke st200xrun with the n option Usage st200xrun c procedure d directory e file f g gdbpath h i filename t target u gdbname v x filename A gdb command B gdb command C target opt D T timeout V a arguments Note The command order is important a or must always be the last option as this indicates a that all the following arguments are to be passed to the target application Table 13 st200xrun command line options Option Description Specifies the target configuration procedure GDB command to be invoked The two supported configuration procedures are st200tp the ST200 TargetPack used for silicon targets this is the default used if a procedure is not specified st200sp the ST200 simulator pack used for simulator targets The configuration procedure must be compatible with the target being used c procedure Add a directory to GDB s search path The command dir directoryis d directory issued to GDB This option can be specified more than once e file Specify the executable file to be loaded onto the target f Ignored by st200xrun included for backward compatibility Specify the full path to the GDB executable to be used This should be a g gdbpath version compatible with the version of GDB supplied by STMic
79. type Q format type group class name identifier identifier identifier where e filename is the name of a header file e identifierisaC identifier typeisa C type specification which is either a C basic type such as unsigned int or a typedef defined in an included header file format is the format specification for type and is one of the format codes listed in Table 22 on page 102 commentis a comment all text in bold is literal and are not part of the modified BNF syntax e the and symbols are literal and not part of the modified BNF syntax 8063762 Rev 9 ST200 OS21 Trace In addition a spec definition is terminated by the end of a line and so cannot be split across multiple lines group class name describes the hierarchy of the API or activity and always consists of three components group c1ass and name The group and c1ass components are reflected in the GDB control commands see Section 11 10 User GDB control commands on page 123 and runtime control APIs see Section 11 13 User trace runtime APIs on page 139 The final component name is either the name of the user function being traced or is a name used to derive the name of a custom activity API see Section 11 13 1 User activity control APIs on page 139 A typical example of a group class name specification is libc heap malloc r which names the malloc r API from the class heap in the group libc USER INCLUDE specifies
80. user trace group group enable user activity group group class class disable user activity group group class class Enable or disable the logging of all the activities within the class class of the user trace group group where class is one of the classes listed by show user activity group group classes show user activity group group class class Display the logging status of all the activities within the class c1ass of the user trace group group 8063762 Rev 9 123 246 OS21 Trace ST200 enable user activity code disable user activity code Enable or disable the logging of the user activity code All activities are enabled by default The command show user activity group all lists all the valid code parameters see Section 11 9 11 Type and event enables on page 121 For an event to be logged both the activity code and the type user activity in this case must be enabled Disabling the type prevents logging of all the events that belong to that type although it does not disable them c show user activity code Display the logging status of the user activity code enable_user_activity_global disable_user_activity_global Enable or disable the logging of user activity types User activity trace is disabled by default show_user_activity_global Display the logging status of user activity types 11 10 2 User API control commands os21usertrace creates the following commands for controlling the generati
81. uses the program counter as the address to use disconnect Release the target from GDB control file file Uses file as the program to be debugged finish Completes the current function help GDB commands assistance info all registers Prints the contents of all the registers 8063762 Rev 9 49 246 Cross development tools ST200 50 246 Table 9 st200gdb command quick reference continued Command info breakpoints Description Lists all breakpoints info registers Prints the contents of the registers This provides more information than regs list Lists the next ten source lines list Lists the previous ten source lines list function line ile line address ile function Lists specific source code Any two arguments separated by a comma are required to specify a range load file LMA VMA offset next n Downloads the file to the target If no file is given the executable from the GDB command line or the file or exec file command is used LMA Load Memory Address or VMA Virtual Memory Address specify the area of memory file is copied to If unspecified LMA is assumed offset specifies the offset to add to each section loaded into memory The default is 0 Continues execution to next source line stepping over functions If n is specified do this n times nexti n Executes exactly one instruction stepping over subroutine cal
82. 0 B 7 2 Interrupts header file machine bsp interrupt h 200 B 8 User handles sz RE Den NG ERE ERROR uen e ees 201 B 9 Retrieving internal run time data 203 B 10 BSP function definitions 204 Appendix C Branchtracebuffer 223 C 1 Branch trace buffer modes 223 C 2 Thebranchtracecommand 224 CS Output format 225 Appendix D Profilerplugin 226 D 1 Profiler plugin reference 2c e eee eee 227 D2 Trace profile outputformat 229 D 3 Range profile outputformat 230 D4 ST Micro Connect configuration options 231 D5 ExXOM Cores sons a IT LE T DEI WA 232 Appendix E ST TargetPack plugin 233 E 1 Thetargetpackcommand 233 Appendix F GDB os21 time loggingusercommand 235 REVISION history uiuusak kae BABA KAKA NG Kr R8 errean RE RA dei dead an 236 INDEX pM rrr 240 ky 8063762 Rev 9 9 246 Preface ST200 Preface Comments on this manual should be made by contacting your local STMicroelectronics sales office or distributor Document identification and control Each book carr
83. 00000 In Figure 26 the registers are displayed on the left and their values on the right A register highlighted in blue indicates it is the currently selected register Each time the program stops the Debug Support Unit window automatically updates the register contents in the display Registers that have changed since the last stop are highlighted in black Editing a DSU register To edit a register 1 Click on the register with the left mouse button to select it 2 Type in the new value 3 Press Return on the keyboard Currently only hex numbers can be entered It is also possible to edit single bits of the selected register using the same editing method Press the Escape key on the keyboard to cancel an edit 8063762 Rev 9 ky ST200 ST200 simulator ST200 simulator The ST200 simulator has three modes of simulation of the ST200 CPU cores They reflect the trade off in simulation accuracy against simulation speed Reference or cycle accurate mode This mode executes code in a similar manner to the hardware that is it behaves as expected in all exceptional circumstances This includes the modelling of all types of bus errors interrupts debug interrupts and exceptions As a result it has the lowest performance of the three modes The following are modelled faithfully e the pipeline and the caches by default are configured to be at the highest level of detail e the mem
84. 00000 pclock 1000000 ramsize rambase Generating code for a board target To address an application for a given board target a specific option must be given at link time when generating the application mcore core target Enables the selection of a core target a specified core type This option automatically adds the bootcore o and libcore a files to the list of object files to link together and automatically selects the core specific core 1d linker file If the mcore option is missing the compiler driver assumes ST231 settings 8063762 Rev 9 ky ST200 Board target configuration a msoc soc target Enables the selection of a SoC target This option automatically adds the 1ibsoc a file located in the target core core target endianness run time directory to the list of object files to link together and automatically selects the core specific soc 1d linker file If the msoc option is missing the compiler driver assumes default settings mboard board target Enables the selection of a board target This option automatically adds the 1ibboard a file located in the target board board target core endianness gt lt run time gt directory to the list of object files to link together and automatically selects the board specific board la linker file If the mboard option is missing the compiler driver assumes default settings The default core soc board
85. 03 11 1 4 os21usertracegen example 106 11 2 Printa string to the OS21 Trace buffer 107 11 3 Building an application for OS21 Trace 107 11 4 Running the application 0 ee 108 1141 Trace buffer iesus ence eee etc pie eene sien 109 11 5 Analyzing the results 0 0 00 eee ee 109 11 5 1 Usage of the m mode option 111 11 5 2 os21decodetrace control file 112 ky 8063762 Rev 9 5 246 Contents ST200 11 6 Exampl8S 5 rama Pte ER RR Facio d d Haha hn 113 11 6 1 OS21 activity and OS21 APItrace 113 11 6 2 User API and user activity trace 000 eee 113 11 7 Trace overhead ele 115 11 8 Structure of trace binary files 115 TAB os21traceDIm oes KG KA JA KING EG RR EEUU KG 116 11 8 2 os21trace bin ticks nna aaan 116 11 8 3 os2itasktrace bin 117 11 9 GDB COMMAND esse des eR I d PCR Soe sane a CR ga e 117 11 9 1 Buffer full action ee 117 11 9 2 Enable OS21 Trace 117 11 9 3 Enable trace control commands 118 11 9 4 Enable OS21 activity 0 0 0 0 ee 118 11 9 5 EnabeOS21API 118 11 9 6 Enable OS21 activity
86. 22 0x00000000 R23 0x00000000 R24 0x00000000 R25 0x00000000 OS21 R26 0x00000000 R27 0x00000000 0821 B0 700000000 OS21 R1 0x00000000 R2 0x00000000 R3 0x00000000 R4 Ox00000000 OS21 R5 Ox00000000 R6 0x00000000 R7 0x00000000 R8 0x12344321 OS21 R9 Ox0000BA49 R10 0x00000000 R11 0x00000000 R13 0x00000000 OS21 R28 0x00000000 R29 0x00000000 R30 0x00000000 R31 0x00000000 OS21 R32 0x00000000 R33 0x00000000 R34 0x00000000 R35 0x00000000 OS21 R36 0x00000000 R37 0x00000000 R38 Ox00000000 R39 Ox00000000 OS21 R40 Ox00000000 R41 0x00000000 R42 0x00000000 R43 0x00000000 OS21 R44 0x00000000 R45 Ox00000000 R46 0x00000000 R47 0x00000000 OS21 R48 0x00000000 R49 0x00000000 R50 0x00000000 R51 0x00000000 OS21 R52 0x00000000 R53 0x00000000 R54 0x00000000 R55 0x00000000 OS21 R56 0x00000000 R57 0x00000000 R58 Ox00000000 R59 0x00000000 OS21 R60 Ox00000000 R61 0x00000000 R62 Ox00000000 R63 0xC0002D5C OS21 Aborted A 6 2 184 246 The exception has been decoded as a misaligned write to memory and the bad address is 0x12344321 Identifying a function that causes an exception It is not possible to directly identify the function that causes an exception from an OS21 stack trace However there are several ways to indirectly establish the function Using GDB To catch the exception in GDB place a breakpoint on OS21 s unexpected exception handler for example gdb b os21 exception handler Breakpoint 1 at 0xc0009cb4 file src os21 ex
87. 3762 Rev 9 ky ST200 Toolset overview OS21 examples The examples os21 subdirectory contains some examples of programs using the features of OS21 os21 os21 os21 os21 os21 os21 os21 os21 os21 os21 autostart dynamic failsafe mandelbrot profilingos21 romdynamic rombootram rombootrom soaktest timer os21 0s21 trace os21 walklight Illustrates extending the init section of an application to automatically initialize and start OS21 before main How to build a simple application that loads a dynamic library from the host file system Illustrates the use of a fail safe application in the flash layout A multi tasking example that generates a Mandelbrot pattern How to use the profiling feature of OS21 How to use the Relocatable Loader Library to load a dynamic library from Flash ROM from an application that is boots out of Flash ROM Demonstrates how a simple boot from ROM execute from RAM application may be created and written to Flash memory Demonstrates how a simple boot from ROM execute from ROM application may be created and written to Flash memory A simple stress test program designed to act as a confidence test for OS21 running on the target platform How the OS21 API can implement a simple timer Tasks are able to create timer objects which have a programmable duration and can run in one shot or periodic mode When a timer fires a
88. 6x6b266775 6x656e7265 8x2a2a286c 8x8888882a ug kernel xxx 8x88088808088192b8 6x61746144 Ox74656626 6x542 06863 6x7026424c Data fetch TLB p 8x888888888088192c8 6x65746F72 6x6F697463 6x6976266e Ox74616c6f rotection violat 6x 66666606086192d0 60x286e6f69 8x61286e6f 8x65726h6h 8x38287373 ion on address 8 8x00080008080192e0 0480782578 6x61746144 8x75656628 0954206863 x x Data fetch T 8x800808068088192F8 Bx6d26424c 8x20737369 8x61286e6f 6x65726464 LB miss on addre 8x0008000808019300 9438287373 6x 66782578 x26555 646 8x6173696h ss 6x x FPU disa 8x8888888008819318 6x64656c62 6x 666060666 6x61746144 6x69727726 bled Data wri 6x 6666666668619320 Bx74266574 8x696d206f 8x696c6173 8x6h656e67 te to misaligned 0x80000008008019330 6x64646126 6x73736572 6x25783626 6x 66606678 address 8xZx 8x8888880808819348 6x74736e49 8x75637572 8x286e6f69 6x63746566 Instruction fetc 4 Click on a memory location to edit the contents To customize the display use the Addresses menu Addresses menu Auto Update If the state of the target changes the memory information updates automatically default Update Now Manually override the auto update to show the memory state at that instant Preferences Opens the Memory Preferences window the options are size e format e number of bytes e miscellaneous Right click on a memory location to open the following context sensitive menu op
89. 80 task aware debugging 94 stepping through source code 50 65 task lock 179 STIMULATION FILE 89 task unlock 179 Sna pna eR LO LE 16 timeslicing AA cee eee 24 STWorkbench 58 63 110 disabling IIIA eee 181 GGltOr AA EE TEE TE TETEE 59 61 TLB scarse 37 38 191 194 195 199 210 214 perspective 59 61 tools directory 19 VON AA AA 59 61 toolset configuration 30 SuperH simulator 14 toolset introduction 13 14 support for new boards 94 trace on ST240 223 224 symbols TRACE END CYCLE 88 GISCANG zn eas ra RR E EGRE 15 TRACE START CYCLE 88 encoded scs crore sess 14 tracing an application 98 CEDE 15 TRACING ON 88 synchronization 24 TRANSACTION SETUP CYCLES 87 sysconf code module 28 translate object files 15 system heap eee 24 U T user debug interface 13 target changing with Insight 68 W configuration for compilation 27 30 connection 44 46 186 watch expressions 75 debugger 15 watc
90. 88 ticks The time in each task is comparable except for Root Task which now includes the time accumulated while the target was under the control of GDB ma ky 8063762 Rev 9 235 246 Revision history ST200 Revision history Table 62 Document revision history Date Revision 10 Oct 2011 9 Changes Supports the ST200 R7 2 Updated Section 5 1 Loading and executing a target program on page 40 Updated o output ile in Section 11 5 Analyzing the results on page 109 Added Section B 2 3 L2 cache on page 193 Added RUNTIME L2 CACHE SYSTEM ADDRESS to Table 56 on page 203 12 Oct 2010 H Supports the ST200 R7 1 Updated the list of supported hosts in Section 1 1 Toolset features on page 13 and Section 3 1 Toolset overview on page 25 Removed redundant reference to stm8010 files in Section 1 5 The examples directory on page 20 and in Section 10 Booting OS21 from Flash ROM on page 96 Update introduction to Chapter 4 Board target configuration on page 27 Corrected Section 4 1 2 Generating code for a board target on page 28 default settings for mboard Updated Section 4 3 1 Overriding the memory layout of an existing board target on page 34 to add alternative source of custom values Updated step 7 on page 36 in Section 4 3 3 Defining a custom board target and compiling a program on page 35 Updated the introduction to Chapter 11 OS21 Trace on page 98 Updated the B
91. Arguments mode Enable 1 or disable 0 Returns The previous mode Description Enable or disable OS21 Trace logging Initially set to 1 ky 8063762 Rev 9 129 246 OS21 Trace ST200 os21 activity set global enable Enable OS21 activity logging Definition int os21 activity set global enable int mode Arguments mode Enable 1 or disable 0 Returns The previous mode Description Enable or disable OS21 activity logging Initially set to O os21 activity set class enable Enable OS21 activity logging for class Definition typedef enum os21 activity class e os21 activity class exception os21 activity class interrupt os21 activity class task os21 activity class general os21 activity class EOF os21 activity class e void os21 activity set class enable os21 activity class e code int mode Arguments code OSe21 activity event class mode Enable 1 or disable 0 Returns Void Description Enable or disable logging for the specified OS21 activity event class 130 246 8063762 Rev 9 ky ST200 OS21 Trace os21 activity set enable Enable OS21 activity logging for activity Definition typedef enum os21 activity e os21 activity task switch os21 activity task create os21 activity task delete os21 activity task exit os21 activity intr install os21 activity intr uninstall os21 activity intr enter os21 activity intr exit os21 activity excp install os21 activity excp uninst
92. BASE 0xC0000000 EXTERNAL MEMORY SIZE 0x2000000 EXTERNAL MEMORY BASE 0x20 00000 EXTERNAL MEMORY SIZE1 0x1FFF EXTERNAL MEMORY BASE2 0x7 801000 EXTERNAL MEMORY SIZE2 Oxc0 BOOT ROM BASE Ox7FFFFFO00 BOOT ROM SIZE 0x10 8063762 Rev 9 ky ST200 ST200 simulator 4 Change the CORE MHZ value and save the file CORE MHZ 200 PERIPHERAL BASE 0x30000000 EXTERNAL MEMORY BASE 0xC0000000 EXTERNAL MEMORY SIZE 0x2000000 EXTERNAL MEMORY BASE 0x20 00000 EXTERNAL MEMORY SIZE1 0x1FFF EXTERNAL MEMORY BASE2 0x7 801000 EXTERNAL MEMORY SIZE2 0xc0 BOOT ROM BASE Ox7FFFFFO00 BOOT ROM SIZE 0x10 xj 8 1 2 Simulated boards naming convention In the lt tools dir gt 1x el1f 32 stdcmd subdirectory any command file starting with the prefix st200targets contains the hardware definition of the board through the target configuration options and some standard commands see Table 15 Table 15 Simulator pack GDB command Description board sim The simulated version of the board board The same as board sim With the additional capability to get the path board passedsim T of the simulator dynamic library as argument board profsim The same as board sim With profiling enabled 8 1 3 Simulator targets The st200targets stsim cmd command file
93. Board target configuration eee eee 27 4 1 Configuring the run time code for a target 27 41 1 The sysconf code module 28 4 1 2 Generating code for a board target 28 4 2 Understanding target dependent settings 30 4 2 1 Toolset configuration 30 4 2 2 Configuration matrix 33 4 3 Customizing board targets 34 4 3 1 Overriding the memory layout of an existing board target 34 4 3 2 Modifying the memory protection settings 35 4 3 8 Defining a custom board target and compiling a program 35 4 3 4 Building and debugging a program on a custom board target 37 44 Customizing SoC targets eese 37 4 4 1 Defining a custom SoC target 38 5 Cross development tools 40 5 1 Loading and executing a target program 40 5 2 Target code structure and initialization 41 5 2 1 Target address space usage 41 5 2 2 Initialization sequence 42 5 2 3 Start parameters 42 5 2 4 Other initializations
94. Core initialization library N A X libcore a Core library search path N A X Compiler driver SoC initialization library N A libsoc a SoC library search path N A X Compiler driver Board initialization library N A X libboard a Board library search path N A Compiler driver dise SEIS N A X board 1d AA N A X board ld DEFAULT TEXT BASE N A X board 1ld DEFAULT_RAMEND N A board 1d STACK_POINTER N A board 1d ky 8063762 Rev 9 33 246 Board target configuration ST200 4 3 Note 4 3 1 34 246 Customizing board targets This section describes different ways to create and debug custom board targets By default the 1ibboard a and board 1d files are taken from the tools dir target board default directory according to the core type and the run time During a toolset update the entire lt tools dir gt target directory is overwritten and if any changes have been made in this location they are lost Target dependent libraries as well as memory and run time settings in the board 1d file are no longer available Overriding the memory layout of an existing board target The memory layout for a given board is defined in the linker script file tools dir target board targetboard board ld by the following linker variables rambase ramsize e e X rombase X romnsize 9 Stack The default values of these variables can be overridden for a particular application build by using the following st200c
95. DDRESS Linker script Linker Run time DEFAULT BOOT ADDRESS Linker script Linker Run time DEFAULT TEXT BASE Linker script Linker Run time STACK POINTER CPU clock Linker script Run time simulator Linker Run time Run time 8063762 Rev 9 ST200 Board target configuration Table 3 ST200 toolset parameters continued Item Set up by Used by Bus clock Run time simulator Run time bootreset section address DEFAULT RESET ADDRESS Linker boot section address DEFAULT BOOT ADDRESS Linker Program sections address text rodata data bss PERAULT TERT BAS Linker bootcore o Compiler driver Linker Hardware memory map Linker script Linker Loader Early hardware initialization TargetPack Loader 1 See ST TargetPack user manual 8020851 The following sections describe the toolset target dependent settings and how and where to configure them Note bare or os21 and my core is the core name Core contribution In Table 4 Table 5 and Table 6 endianness is either le or be run time is either The mcore my core option controls the core contribution Only cores delivered in the toolset can be referenced using the mcore option Table 4 Core contribution Item Include search path Value I tools dir tar
96. Description Write the contents of the trace buffer to the file name The second parameter reset is the buffer reset argument If 1 then the buffer is cleared otherwise it is not reset and remains intact 194 246 8063762 Rev 9 ky ST200 OS21 Trace os21 trace status Get trace status Definition typedef struct os21 trace status s int version unsigned int codesize unsigned int size osclock t tickrate osclock t lasttime os21 trace status t void os21 trace status os21 trace status t status Arguments A structure status with the following fields to be filled in by the function version The version number for the trace buffer format codesize The size of the trace code field in the trace buffer Valid sizes are 1 2 or 4 bytes see Section 11 8 1 os21trace bin on page 116 size The current size of the data in the trace buffer tickrate The time ticks per sec value lasttime The time when the last record was logged to the trace buffer Returns Void Description Get the trace buffer status os21 trace write buffer Write trace data to memory Definition int os21 trace write buffer void data int reset Arguments data Destination buffer reset Clear 1 or keep 0 buffer Returns 0 if OK 1 if an error occurred Description Write the contents of the trace buffer to the buffer specified by data Use os21 task status to obtain the size needed for the destination buffer The second parameter reset is the buf
97. MER1 and TIMER2 however TIMER2 should only be used if the profiler is not enabled Do not use this function with TIMER SYSTEM bsp timer interrupt clear Clear the timer interrupt Definition include lt platform h gt int bsp timer interrupt clear int timer Arguments timer The timer interrupt to clean see Table 45 ST200 timer assignments on page 196 Returns Returns the error condition Description This function clears the interrupt of a given timer It should only be used with TIMER1 and TIMER2 however TIMER2 should only be used if the profiler is not enabled Do not use this function with TIMER SYSTEM bsp timer interrupt enable Enable the timer interrupt Definition include lt platform h gt int bsp timer interrupt enable int timer Arguments timer The timer interrupt to enable see Table 45 ST200 timer assignments on page 196 Returns Returns the error condition Description This function enables the interrupt for the given timer It should only be used with H IMER1 and TIMER2 however TIMER2 should only be used if the profiler is not enabled Do not use this function with TTMER SYSTEM 8063762 Rev 9 219 246 ST200 board support package BSP ST200 bsp timer now Return the current time Definition include lt platform h gt bspclock t bsp timer now void Arguments None Returns Returns the number of ticks since the system started Description bsp time
98. NF description in Section 11 1 2 User definition file on page 100 and introduced os21usertracegen Added Section 11 1 3 os21usertracegen host tool on page 103 and Section 11 1 4 os21usertracegen example on page 106 Removed Section 11 6 3 Tips for creating an os21usertrace definition file on page 115 which is redundant with the introduction of os21usertracegen 09 Feb 2010 G Supports the ST200 R7 0 Re ordered the sections in 4 Board target configuration on page 27 Updated Section 4 3 Customizing board targets on page 34 throughout Added 4 4 Customizing SoC targets on page 37 Minor syntax correction to Section 11 1 2 User definition file on page 100 236 246 a 8063762 Rev 9 ST200 Revision history Table 62 Document revision history continued Date 01 Dec 2009 Revision Changes Supports the ST200 R6 5 Updated Section 1 1 Toolset features on page 13to add ST TargetPacks Updated OS21 examples on page 21 Updated mboard in Section 4 1 2 Generating code for a board target on page 28 Section 5 3 6 ST200 GDB commands Table 11 updated enable dsu command and removed dsu version command Table 12 updated enable pmblock command Updated Chapter 6 Using STWorkbench on page 58 throughout Added details of OS21 Trace user record throughout Chapter 11 OS21 Trace on page 98 Updated Section 11 4 Running the application on page 108 Updated Section C 2 The b
99. NTIME SOC ID Device identifier unsigned int RUNTIME SOCNAME SoC name char RUNTIME STACK Stack pointer address unsigned int RUNTIME TEXTADDRESS text section address unsigned int RUNTIME VERSION ST200 toolchain version char 8063762 Rev 9 203 246 ST200 board support package BSP ST200 B 10 BSP function definitions bsp cache invalidate instruction Invalidate addresses within the specified range from the instruction cache Definition include lt platform h gt int bsp cache invalidate instruction void base address size t length Arguments base address The start address of the range to invalidate length The length of the range in bytes Returns Returns the error condition Description This function invalidates any valid instruction cache lines that fall within the address range specified If it is not possible to flush individual cache lines then the entire instruction cache is invalidated See also bsp cache invalidate instruction all bsp cache invalidate instruction all Invalidate the entire instruction cache Definition include lt platform h gt int bsp cache invalidate instruction all void Arguments None Returns Returns the error condition Description This function invalidates the entire instruction cache See also bsp cache invalidate instruction bsp cache purge data Purge addr
100. O THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2011 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada
101. OS21 profile data to file The OS21 profiler does not stop if it is currently running After invoking any of the commands listed above restart the target to perform the requested action The os21 profiler dump command has immediate effect and therefore the target does not have to be restarted in this case OS21 profiler cancel Use the following command to cancel a previous command os21 profiler cancel Cancel a previous command if that command is still pending that is the dynamic OS21 profiler is not in the BUSY state as reported by the show os21 profiler monitor status command All the commands listed above automatically cancel a previous command if it is still pending except for os21 profiler dump which has immediate effect 8063762 Rev 9 ky ST200 Dynamic OS21 profiling OS21 profiler status reporting The reporting of the status of a OS21 profiler request is achieved by placing breakpoints on the signal function called by the application when an action has been completed see os21 profiler signaled on page 173 The effect of these breakpoints is controlled by the following commands which enable or disable the reporting the result of the request and control the restart mode of the target enable os21 profiler report signaled Enable OS21 profiler request reporting The target is automatically restarted after reporting the result of the request disable_os21_profiler_report_signaled Disable OS21 profiler r
102. ST200 Board target configuration bsp memory map t STIxxxx maps void amp STIxxxx PERIPHERAL BASE PMA amp STIXxxxx PERIPHERAL SIZE PAGE 256MB LXTLB ENTRYO POLICY UNCACHED LXTLB PROT READ LXTLB PROT WRIT LXTLB PROT READ LXTLB PROT WRIT E E ml dni NO_MAP hi bsp memory map t bsp map init void f return STIxxxx maps j Edit the makefile changing the value of the variable LIST CONFIG with the required configuration and modify the path to include the defines mkf file in toolset dir target defines mkf The valid values for LIST CONFIG have the following format lt core gt lt endianess gt lt runtime gt For example LIST_CONFIG st231 le bare Build the board library running make in the board directory for example a Navigate to new_target_dir soc my_soc b gt make A new directory tree is created to contain the libraries and linker scripts for the selected configurations For example if the only selected configuration is st231 1e bare see step 5 the following directory is created new target dir soc my soc st231 le bare This directory contains 1ibsoc a and the linker script that are used when building an application for this SoC 8063762 Rev 9 39 246 Cross development tools ST200 5 5 1 Note 40 246 Cross development tools The cross development tools enabl
103. ST200 Profiler plugin D 4 ST Micro Connect configuration options The profiling data is collected by the ST Micro Connect The profiler can also be controlled by issuing ST Micro Connect configuration options to st200gdb Table 60 lists the ST Micro Connect configuration options that are equivalent to the profiler sub commands listed in Table 59 on page 227 Table 60 ST Micro Connect configuration options Configuration option Equivalent to stmcconfigure profiler on profiler enable stmcconfigure profiler off profiler disable stmcconfigure profiler reset profiler reset stmcconfigure profiler mode mode profiler mode mode stmcconfigure profiler period delay profiler period delay stmcconfigure profiler type type profiler type type stmcconfigure profiler type trace size profiler trace size stmcconfigure rofiler range size startaddr endaddr profiler type range startaddr endaddr bytes p d 1 Unless overridden startaddr is the address ofthe stext symbol and endaddr is the address of the ecext symbol bytes is the size in bytes of the number of instructions specified by size startaddr endaddr bytes must have the hex form 0x lt hexvalue gt 0x lt hexvalue gt 0x lt hexvalue gt 8063762 Rev 9 231 246 Profiler plugin ST200 D 5 Examples The following GDB command script shows how to configure the ST Micro Connect to use the trace profiler in non intrusive mod
104. ST200 toolset the debugger implements the required mechanism for the automatic debugging of loaded modules To find the file that contains the debug information the loader must know the path to the load module This is automatic in the case of r1 load file as the filename is specified in the interface For the x1 load buffer andr1 load stream functions the user must set the filename with a call to the x1 set file name function For example the following code enables automatic debugging of a load module loaded with rl load buffer f int status rl handle t handle rl handle new rl this 0 if handle NULL error ifdef DEBUG ENABLED rl set filename handle path to the file for the module endif status rl load buffer handle module image if status 1 error 8063762 Rev 9 ky ST200 Relocatable loader library 12 7 a Profiling support The action callbacks may be used with a profiling support library or alternatively a user defined package can be informed that a segment has just been loaded or is on the point of being unloaded by using the user action callback interface Below is an example that iterates over the segment list and declares the executable segments to a profiling support library on the loading unloading of a module static int segment profile rl handle t handle rl segment info t info void cookie rl action t action
105. SU unit of the target device which is used to control and communicate with the device during development ST TargetPacks ST TargetPacks are a method of describing target systems based on SoC devices ST TargetPacks provide a single definitive description of a target system for use by various tools within the development environment such as st200xrun Profiler support Performance data can be obtained when running an application on an ST200 simulator and used to generate statistical and trace information Performance data can also be acquired from an application running on a target board connected to an ST Micro Connect The data can be analyzed using STWorkbench or a tool such as st200gprof The targets supported by the ST200 toolset are STMicroelectronics development boards These boards provide development platforms for the STMicroelectronics system on chip devices which use the ST200 cores ST200 simulator GDB command scripts for simulator targets can be found in the directory 1x e1f32 Distribution content The ST200 Micro Toolset distribution includes tools libraries configuration scripts and examples Tools From the binutils GNU package st200as GNU assembler st200ld GNU linker st200addr2line Convert addresses into file names and line numbers st200ar Create modify and extract from archives st200 filt Demangle encoded C symbols st200gprof GNU profiler 8063762 Rev 9 ky ST200 Toolset overview 1 2
106. The command line to invoke the os21prof tool is as follows os21prof executable file profile file Information on the os21prof tool can be found in the 0521 user manual 7358306 13 6 Example The example examples os21 profiling os21 contains the source code of a simple OS21 multitasking application and the GDB script for a GDB dynamic profiling session 13 7 Profiler library API The dynamic OS21 profiler library is provided as 1ibos21profiler a and its associated header file is os21profiler h 13 7 1 Function definitions This sections lists the function definitions for the dynamic OS21 profiler library os21 profiler initialize Initialize profiling Definition typedef struct os21 profiler init s size t instrs per bucket int hz os21 profiler init t int os21 profiler initialize const os21 profiler init t init Arguments A structure init with the following fields instrs per bucket The number of instructions included in each bucket hz The sampling frequency in hertz Returns OS21 SUCCESS for success or 0521 FAILURE if called with invalid parameters or if out of memory Description Use this function to initialize the dynamic OS21 profiler If init is not NULL then this function calls the OS21 API profile init using the contents of the os21 profiler init t structure If init is NULL then profile init is not called The dynamic OS21 profiler constructor invokes this function with a default initialization parameter of NULL The user
107. _soc gt Parameter location SoC library search path L lt tools dir gt target soc lt my_soc gt lt my_core gt lt endianness gt lt run time gt SoC initialization library lsoc libsoc a lt tools dir gt target soc lt my_soc gt lt my_core gt lt endianness gt lt run time gt SoC initialization init soc function tools dir target soc my soc my core endianness run time libsoc a Board contribution The mboard my board option controls the board contribution Table 6 Board contribution Item Include search path Value I tools dir target board my board Parameter location Board library search path L lt tools dir gt target board lt my_board gt lt my_core gt lt endianness gt lt run time gt Board initialization library Board initialization lboard libboard a init board function tools dir target board my board my core endianness run time tools dir target board my board my core endianness run time libboard a Memory map definitions FLASH RAM area definition tools dir target board my board board 1d DDRESS DEFAULT RESET A Definition is needed at linking time only if the boot and boot reset are linked tools dir target board my board board 1d 32 246 8063762 Rev 9
108. a8 Ox 68007 8c Ox 08007 094 Ox 68067 a90 Ox 68007 094 6x 68 6679c4 000088888 Bx17d78466 4 74 246 8063762 Rev 9 ky ST200 Using Insight 7 10 Note Note Using the Watch window Use the Watch window to set and edit user specified expressions Each time the program halts the expressions are reevaluated and shows the program state Watch expressions are not the same as watchpoints Watchpoints must be set through the console window To open the Watch window either click the 4 button or from the View menu in the Source Window select Watch Expressions Figure 19 Watch window r3 int 117317857 r9 int 559838737 Sr1b1 int 8 tiles int 559638737 Add Watch There are two ways to add expressions to the Watch window e Type an expression into the field at the bottom of the window and click the Add Watch button e Inthe Source Window or Registers window right click on the expression to open the context sensitive menu and select Add to Watch The expression must use the same syntax as the language being debugged For example to watch for red being assigned the value 42 when debugging a C application enter fred 42 Using assignment operators by mistake for example red 42 changes the value of the variable in the program Right click on a watch expression to open the following context sensitive menu options Format Change the format to Hex Decimal Binary Octa
109. action callback rl action t action mask rl action func t callback fn void callback cookie action mask The set of actions for which the callback function must be called callback fn The user specified callback function callback cookie The argument to pass to the function Returns 0 for success 1 for failure The rl add action callback function adds a user action callback function to the user action callback list It can be called multiple times with different callback functions The same callback function cannot be added more than once For each defined action each callback function is called in the order it was added into the callback list The callback functions are not attached to a particular module and are called for any further loaded unloaded modules This function returns 0 on success and 1 on failure It does not set any error codes This function can fail if a callback function is already in the callback list or if the program goes out of memory The r1 action t type defines the action flags for module loading unloading and is passed to the action function callback The action flags can be OR ed to create an action mask that can be passed to the function x1 add action callback The action defined are RL ACTION LOAD The callback is called just after the module has been loaded in memory and cache has been synchronized No module code has been executed RL ACTION UNLOAD The callback is
110. ad compressed or uncompressed code without change to the interface For loading a compressed image of a load module into memory use the r1 load stream interface In this case the user must implement the decompression of the stream in the callback function 8063762 Rev 9 ky ST200 Dynamic OS21 profiling 13 13 1 Dynamic OS21 profiling The ST200 Micro Toolset supports profiling using the OS21 profiler under the control of GDB For this an application is linked with the dynamic OS21 profiler library This library enables GDB to control all aspects of the OS21 profiler by sending requests to the application to configure start and stop the OS21 profiler using standard OS21 APIs Also GDB can write the data gathered by the OS21 profiler directly to a file on the host without sending a request to the application The profile data obtained by GDB can be analyzed using the os21prof tool For more information about OS21 profiling see the OS21 user manual 7358306 For details of the GDB commands available to control the OS21 profiler see Section 13 4 GDB commands on page 169 Overview The dynamic OS21 profiler adds a monitor task to the application The purpose of the monitor task is to call OS21 profiler APIs on behalf of GDB When GDB needs to call an OS21 profiler API it writes an action request to a structure in target memory and then raises the OS21 interrupt 0921 INTERRUPT DEBUGGER reserved for exclusive use b
111. ailable in bare run time environment are in the single header file machine bsp mmu h see Table 43 8063762 Rev 9 ky ST200 ST200 board support package BSP Table 43 Functions defined in bsp mmu h Function Description bsp mmu reset Reset TLB settings Map pages of program address space into ST200 bsp mmu memory map physical addresses and set protections bsp mmu memory unmap Unmap pages of memory Write on the st dio a list of TLBs with their bsp mmu dump TLB Settings attributes B 3 4 Speculative control unit SCU To ensure that speculative bus requests are not sent out to peripherals and unmapped memory regions the SCU filters physical speculative load addresses both cached and uncached and prefetches that miss the cache The SCU supports four regions of memory aligned to the smallest TLB page size 8 Kbytes If the physical address of the speculative load prefetch address falls within one of the four supported regions it is allowed otherwise the SCU aborts the speculative load prefetch and either returns zero or the cancels the prefetch To configure the memory regions use the SCU BASEx and SCU LIMITx control registers The SCU resets so that each of the four regions cover the whole of memory This enables speculative loads to be issued before the SCU has been initialized SCU header file machine bsp mmap h All the definitions related to the SCU available in bare
112. al C run time initialization 42 C compiler 13 interrupt handlers 24 Cx compiler 15 interrupt mask 178 debugger See GDB interrupt mask allf 178 Tro a Pt 15 interrupt unmask 178 linker ln 14 inter task communication 24 HEEL 15 ISS mode AI aa 83 profiler IIIA 14 226 targetdebugger 15 K test coverage 15 kernel toolchain cens 24 GU aaa 64 bu RICE EAE 13 configuration files 19 Ba INDIAN es cuts eds de 16 KERNEL STACK SIZE 87 keyboard input 187 H HAZARD CHECKING ON 88 L Mu E PS Lcd x p L2 cache ss st anc cae ere lE a exin 193 help xL E DLE ibe PA MEER 16 Insight zc mr Rear RES PEE 70 ie ee GO Se b SIZGDXIUIT eg sd abc ea S Int dA Ha i 95 IBQCOV cies Reha ees 16 libgprof UA EA AA 16 l MDT ect 8 ee AA An AGA NA E 16 V Ostreams 16 librarian 13 libraryfiles 19 ky 8063762 Rev 9 242 246 Index ST200 libstdet iso im Re em 16 18 examples selessesss 21 AKE aussehen hee me ER ox 13 14 introduction 0 2 2 0 eee eee 22 Oplloris Ka pama aa See eee mde Nha 107 kernel 122iiiamue e et Rn bee RS 93 ELA 13 25 key features
113. all os21 activity excp enter os21 activity excp exit os21 activity general print os21 activity EOF os21 activity e int os21 activity set enable os21 activity e code int mode Arguments code OS21 activity event type mode Enable 1 or disable 0 Returns The previous mode Description Enable or disable logging of the specified OS21 activity event type os21 activity set task trace enable Enable OS21 task information logging Definition int os21 activity set task trace enable int mode Arguments mode Enable 1 or disable 0 Returns The previous mode Description Enable or disable logging of task information by OS21 activity events task create or task switch os21 api set global enable Enable OS21 API logging Definition int os21 api set global enable int mode Arguments mode Enable 1 or disable 0 Returns The previous mode Description Enable or disable OS21 API logging Initially set to O ky 8063762 Rev 9 131 246 OS21 Trace ST200 os21 api set class enable Definition Arguments Returns Description 132 246 typedef enum os21 api class e os21 api class cache os21 api class callback os21 api class event os21 api class exception os21 api class interrupt os21 api class kernel os21 api class memory os21 api class message os21 api class mmap os21 api class mutex os21 api class partition os21 api class power os21 api class profile
114. alls an interrupt handler bsp interrupt poll Polls an interrupt bsp interrupt raise Raises an interrupt bsp interrupt uninstall Uninstalls an interrupt handler For backward compatibility Table 53 list the old style functions defined in machine bsp interupt h 8063762 Rev 9 ky ST200 ST200 board support package BSP Table 53 Functions defined in machine bsp interrupt h Function Description bsp itc interrupt clear Clears an interrupt bsp itc interrupt disable Disable an interrupt bsp itc interrupt enable Enable an interrupt bsp itc interrupt install Installs an interrupt handler bsp itc interrupt poll Polls an interrupt bsp itc interrupt raise Raises an interrupt bsp itc interrupt uninstall Uninstalls an interrupt handler B 8 User handles User handles are an optional way to modify the BSP initialization behavior If standard behavior is in line with user expectations do not use user handles Table 54 lists the user handles Table 54 User handles User handle Description hin user start handle User handle called at the start of the BSP initialization Pep user Sodan die User handle called at the end of the BSP initialization bsp_user_start_handle User handle called at the start of the BSP initialization Definition int bsp_user_start_handle void Arguments None Returns RESUME The execution continues in the standar
115. an override with their own implementation ky 8063762 Rev 9 127 246 OS21 Trace ST200 os21 task trace initialize Create a task information buffer Definition void os21 task trace initialize void data unsigned int size os21 task trace mode e mode Arguments data The buffer to use size The size in bytes of the buffer to create mode Buffer full action stop or wrap Returns Void Description This function allocates and initializes a task information buffer specified by the size parameter If data is NULL the API returns the current buffer to the heap and allocates a new buffer specified by size On startup of OS21 Trace the default constructor invokes this function to create a buffer of size 64 Kbytes enough for 2k records in os21 trace mode wrap mode This default size can be overridden by the user See Section 11 12 Variables and APIs that can be overridden on page 138 os21 task trace initialize data Replace an existing task information buffer Definition void os21 task trace initialize data void data unsigned int size Arguments data The buffer to use size The size in bytes of the buffer to create Returns Void Description Replace the existing task information buffer with the buffer specified by the data and size parameters If data is NULL the API returns the current buffer to the heap and allocates a new buffer of the specified size This function must not be used before os21
116. apping between the address space of the program at an address va for 1ength bytes to the physical address phaddr for 1ength bytes The value of va is exactly where the access at addr starts and is a function of the addr argument and the value of 1ags further described below A successful bsp mmu memory map call returns va as its result As the result of bsp mmu memory map a block of program address space including the range va va length is mapped The limits of this block are rounded according to the hardware constraints such as the page size The mapping established by bsp mmu memory map replaces any previous mappings for those whole pages containing any part of the address space of the program starting at va and continuing for Length bytes The prot argument determines all the attributes of the mapping access rights for supervisor and user mode policy related to the cache and partition attributes ky 8063762 Rev 9 211 246 ST200 board support package BSP ST200 212 246 The prot argument should be either PROT NONE or the bitwise inclusive OR of one or more of the following attributes defined in the header file target core include bsp mmu h PROT USER READ The address can be read in user mode PROT SUPERVISOR READ The address can be read in supervisor mode PROT USER WRITE The address can be written in user mode PROT SUPERVISOR WRITE The address can be written in
117. arly the kernel stack identifies the stack used during trap handling and a 16 byte corresponding scratch space is necessary Refer to ST200 Run time architecture manual 7521848 for details 8063762 Rev 9 41 246 Cross development tools ST200 5 2 2 5 2 3 5 2 4 42 246 Initialization sequence Core registers are initialized after the program loads and before the program execution starts Software initialization parameters main arguments and environment variables are passed to the host by the __ start entry point function This configuration is done according to st200xrun options or st200gdb commands After the program starts and before the main function is called the program executes the internal real time run time initialization Start parameters int argc char argv These are the arguments passed to the ST200 program from the st200xrun command line st200xrun a ARGUMENTS or st200gdb commands set args They are passed through a syscall during the execution of the start function Other initializations Internal C run time initialization At the execution of the start function before the BSP initialization the kernel stack is set up The C run time initialization sequence is located in the crti o module linked with the program The C run time initialization invokes the BSP initialization calling the three hooks init core init board and init soc before calling mai
118. as reached a specified point in its execution It is also possible to print a string to the OS21 Trace buffer with the 0521 TRACE PRINT API See os21 trace status on page 135 for more information Building an application for OS21 Trace To enable tracing for an application link it with the appropriate command line options trace or trace trace api Enabling OS21 API tracing also requires OS21 activity tracing to be enabled Therefore to enable OS21 API tracing the trace linker command line option must always precede trace api Table 24 lists the st200cc linker options required to enable the OS21 Trace features 8063762 Rev 9 107 246 OS21 Trace ST200 11 4 Note 108 246 Table 24 st200cc linker options to enable OS21 Trace trace st200cc options Description Initialize OS21 Trace support Install OS21 callbacks to monitor kernel events See the Callbacks chapter in the OS21 User Manual for more details This option uses the default 1a linker script file os2ltrace 1d located at lt toolset dir target os21 trace api Use in conjunction with trace to initialize OS21 API tracing for all functions in the OS21 API When this option is used all public OS21 functions are wrapped using the GNU linker wrap option The wrapper functions record the parameters and return values of the OS21 APIs into the trace buffer This option uses the special linker script files os21w
119. as the effect that a module containing a symbol definition can be sure that it will use this definition For example this enables inlining in load modules e Weak references are treated the same way as undefined references in load modules Therefore when traversing the module tree bottom up the first definition found is taken Relocatable loader library API The relocatable loader library supports loading and unloading a module and for accessing a symbol address in a module by name The relocatable loader library is provided as a library librl a and its associated header file x1 1ib h The functions defined in this API are explained in the following sections rl handle t type All the functions manipulating a load module use a pointer to the r1 handle t type This is an abstract type for a load module handle A load module handle is allocated by the x1 handle new function and deallocated by the r1 handle delete function The main module handle is statically allocated and initialized in the startup code of the main module A module handle references one loaded module at a time To load another module from the same handle the previous module must first be unloaded 8063762 Rev 9 ky ST200 Relocatable loader library rl handle new Allocate and initialize a new handle Definition rl handle t rl handle new const rl handle t parent int mode Arguments parent The handle of the parent module mode Reserved f
120. atus 136 246 8063762 Rev 9 ky ST200 OS21 Trace os21 task trace write buffer Write task information data to a buffer Definition int os21 task trace write buffer void data int reset Arguments data Destination buffer reset Clear 1 or keep 0 buffer Returns 0 if OK 1 if an error occurred Description Write the contents of the task information buffer to the buffer specified by data Use os21 task trace status to obtain the size needed for the destination buffer The second parameter reset is the buffer reset argument If 1 then the buffer is cleared otherwise it is not reset and remains intact Use this API in conjunction with os21 task trace status To ensure that the information returned by os21 task trace status remains valid for the call to os21 task trace write buffer these API calls must be encapsulated within calls to os21 task trace set enable 1 and os21 task trace set enable 0 8063762 Rev 9 137 246 OS21 Trace ST200 11 12 Variables and APIs that can be overridden OS21 Trace provides default constructors for the trace buffer and the task information buffer The user may customize the constructors for both buffers by overriding the functions and variables listed in this section The following variables may be overridden by the user extern void os21 trace constructor data Defaults to NULL in which case the initial trace buffer is allocated by os21 trace ini
121. board to adjust the memory initialization for hardware and simulator targets this is mandatory for ST200 program execution TargetPacks are provided with the ST Micro Connection Package They are described in the ST TargetPack user manual 8020851 together with instructions about how to customize them Simulator packs are described in Section 8 1 Simulator pack on page 84 Building and debugging a program on a custom board target For a simulated target a generated program can be executed without having to carry out additional steps For a hardware board define the new custom board my board see Section 4 3 3 Defining a custom board target and compiling a program and define its new TargetPack see ST TargetPack user manual 8020851 To build and run the hello c application the st200cc option mtargetdir is used to specify an alternative directory where new SoC and board directories are searched first Use the following commands tools dir bin st200cc mcore core mboard my board msoc my soc mtargetdir full path new target dir o hello out hello c To run the application use the commands tools dir bin st200xrun c st200tp t IPaddress my boardtype my targetcore e hello out a arguments Customizing SoC targets In the majority of cases a new SoC can be targeted by simply building with the default SoC definition tools dir bin st200cc mcore core mboard my board mso
122. bsp scu entry t sect Arguments regno The SCU region number to be written sect A pointer to an allocated structure of type bsp scu entry t containing the start and end addresses Returns Returns the error condition BSP OK or BSP FAILURE Description The bsp scu write function sets the start and stop address of the SCU region specified by regno to the addresses specified in the structure sect bsp timer count get Get the initial value of the counter of the specific timer Definition include lt platform h gt unsigned int bsp timer count get int timer Arguments timer The timer for which to get the initial counter value see Table 45 ST200 timer assignments on page 196 Returns The value of the counter of the required timer Description This function returns the counter of the given timer See also bsp timer count set 218 246 8063762 Rev 9 ky ST200 ST200 board support package BSP bsp timer count set Setthe initial value of the counter of the specific timer Definition include lt platform h gt int bsp timer count set int timer unsiged int value Arguments timer The timer to initialize see Table 45 ST200 timer assignments on page 196 value The value to be used for counter initialization Returns Returns the error condition Description This function initializes the counter of a given timer It should only be used with TI
123. c default mtargetdir lt full path new target dir o hello out hello c The only case where a new SoC definition must be created is when specific SoC translation look aside buffer TLB entries are required for the SoC In this case a custom SoC may be build using a similar procedure to that used to create a custom board definition See Appendix B ST200 board support package BSP on page 191 for more information about TLBs 8063762 Rev 9 37 246 Board target configuration ST200 4 4 1 38 246 Defining a custom SoC target The following procedure describes how to define a custom SoC target and to keep the changes during an update 1 Create a new target directory outside the lt tools dir gt directory for example new target dir containing a SoC directory with a subdirectory for each SoC target for example my soc The new target tree is new target dir soc my soc Copy the file lt tools dir gt target defines mkf into the new target directory new target dir and edit the file changing the value of the variable ST200TOOLS DIR With the path of the toolset lt tools dir gt Recursively copy the files from the lt tools dir gt target soc template directory to the newly created subdirectory for example my soc Modify the file src init c to create TLB entries in the initialization of the memory areas which are defined in the table of SoCs The memory map table is defined as an array of s
124. c option Wz defsym variable new value This option passes the new value to the link phase It is also necessary to use an alternate linker script called platform nomem 1d using the st200cc T option For example To change the default memory layout of an MB424 board to start the RAM at 0xD0000000 and make the RAM size 0x100000 use the following command st200cc mcore st231 msoc sti5301 mboard mb424 Wz defysm __ rambase 0xD0000000 Wz defysm __ramsize 0x100000 T tools target platform nomem ld o hello c hello c Alternatively define custom board 1d and companion board nomem 14d files using the custom values in the directory tools dir target board targetboard configuration directory For example lt tools dir gt target board targetboard st231 le bare 8063762 Rev 9 ky ST200 Board target configuration 4 3 2 Modifying the memory protection settings It is possible to override the default setting of the memory protection so that it is set before the main function execution Use the startup initialization hook mechanism see Section 5 2 4 Other initializations on page 42 The default memory protection setting is found in tools dir target core core src mmu c The memory translation and protection unit implements the memory protection settings see the ST231 Core and instruction set architecture manual 7645929 and ST240 Core and instruction
125. called just before the module is unloaded from memory No module code will be executed after this point RL ACTION ALL The callback will be called for any action 8063762 Rev 9 157 246 Relocatable loader library ST200 The type for the user action callback function is x1 action func t The parameters passed to the callback function when it is called are handle The handle that performed the action action The action performed cookie The callback cookie parameter passed to rl add action callback The callback function returns 0 on success and 1 on failure In the case of failure the loading or unloading of the module is undone and the error code returned by rl errno is set to RL ERR ACTIONF rl delete action callback Remove the given function from the action Definition Arguments Returns Description rl errno Definition Arguments Returns Description 158 246 callback list int rl delete action callback rl action func t callback fn callback fn The user specified callback function Returns 0 for success 1 if the callback was not present in the callback list The r1 delete action callback function removes the specified callback function from the action callback list This function returns 0 if the callback was removed or 1 if it was not present in the callback list No error code is set Return the error code for the last failed function int r
126. can override this default See Section 13 7 2 Overrides 172 246 8063762 Rev 9 ky ST200 Dynamic OS21 profiling os21 profiler deinitialize Deinitialize profiling Definition int os21 profiler deinitialize void Arguments None Returns 0821 SUCCESS for success or 0821 FAILURE if the dynamic OS21 profiler cannot be deinitialized Definition Use this function to deinitialize the dynamic OS21 profiler This function stops the OS21 profiler if it is running releases all memory and resources allocated by os21 profiler initialize os21 profiler signaled User defined signal function Definition void os21 profiler signaled void Arguments None Returns None Definition The dynamic OS21 profiler calls a function with this name when it completes an action requested by the user from GDB The default implementation of this function is a stub that the user can override with their own implementation 13 7 2 Overrides Customizing the constructor The dynamic OS21 profiler provides constructor and destructor functions The user may customize the constructor by overriding the os21 profiler constructor init variable os21 profiler init t os21 profiler constructor init The init argument passed to os21 profiler initialize lfthis is not defined NULL is passed to this function Configuration of the dynamic OS21 profiler monitor task The dynamic OS21 profiler uses a dedicated task to monitor for us
127. ce for a clearer understanding of OS21 s behavior refer to the OS21 source to aid debugging rebuild OS21 with different compiler options enable configurable options within OS21 that are not enabled in the shipped binaries build your own board support libraries To build OS21 GNU make and Perl version 5 6 1 must be available on your system Configurable options OS21 supports a number of configurable options These options are selectively enabled at build time by defining preprocessor symbols Table 19 lists the preprocessor symbols that are available for configuring OS21 for the ST200 Table 19 OS21 configurable options Symbol name Description CONF DEBUG Enable debug checking within the OS21 kernel CONF DEBUG ALLOC Enable additional debug checking for memory allocators CONF DEBUG CHECK EVT Perform extra validation checks on events CONF DEBUG CHECK MTX Perform extra validation checks on mutexes CONF DEBUG CHECK SEM Perform extra validation checks on semaphores CONF DISPLAY CLOCK FREQS OS21 reports certain ST200 clock settings on kernel boot Program the system clock to operate at as high a frequency as CONF FINE GRAIN CLOCK dom possible hence yielding greater accuracy Restrict FPU save and restore to the bank of FPU registers used CONF FPU SINGLE BANK 3 m by GCC 8063762 Rev 9 ky ST200 OS21 source guide Table 19
128. ception exception c line 114 gdb c Continuing Switching to Thread 2147483647 Breakpoint 1 os21 exception handler at src os21 exception exception c 114 114 for lnp os21 list give node front amp excpHandList gdb info threads 4 Thread 3 bang active amp interrupted 0xc0034b38 0xc000041c in my task ptr 0x12344321 at u spilotro work samples OS21 Exceptions OS21 test c 5 3 Thread 2 Idle Task active 0xc0031630 os21 task launch at 8063762 Rev 9 ST200 Toolset tips Src os21 task task c 1626 2 Thread 1 Root Task active 0xc0024c08 Oxc0006db0 in md kernel syscall 1 Thread 2147483647 OS21 System Task active amp running 0 PSEUDO Note os21 exception handler at src os21 exception exception c 114 In this example the thread that hits the breakpoint is a pseudo thread called 0821 System Task This is fabricated by GDB to enable it to present the state of the system When the exception occurred thread 4 is indicated as being interrupted as it was running To examine the state of this thread change context to that thread gdb thread 4 Switching to thread 4 Thread 3 40 0x880017d4 in my task ptr 0x12344321 at test c 5 5 unsigned int ptr OxBA49 gdb print x ptr 1 0x12344321 gdb Using st2000bjdump From the OS21 stack trace see Section A 6 1 Understanding OS21 stack traces on page 183 note the value o
129. ch of the regexp and noregexp options are in force see below for details regexp Specifies that the function names following this option contain a regular expression This is the default For example specifying x t1 will match functions with the names t1 t10 and test1 This option can be specified more than once noregexp Specifies that the function names following this option do not contain a regular expression For example specifying x t1 will only match the function with the name t1 This option can be specified more than once file regexp Specifies that only functions with a source file name that f regexp matches regexp are included in the definitions file The default is to match all source file names dir regexp Specifies that only functions with a compilation directory d regexp name that matches regexp are included in the definitions file The default is to match all compilation directories 8063762 Rev 9 ky ST200 OS21 Trace Table 23 8 os21usertracegen command line options continued Option Description Output grouping options output file Output the generated definitions to file The default is to send the output to the console This option resets the group and class options to their 26 FILE default values and clears the set of C include files specified by the include option see below for details
130. ch uses the same approach as the STMC sample profiler but provides a sequential view of the application s activities over a period of time OS21 Profiler These pages describe the OS21 Profiler view in the debugger perspective This view shows the OS21 Profiler data in a graphical form The OS21 Profiler is described in Chapter 11 OS21 Trace on page 98 8063762 Rev 9 63 246 Using Insight ST200 7 7 1 Note 64 246 Using Insight Insight is a Graphical User Interface for GDB that is available on all supported host platforms It enables the user to execute and debug applications interactively The command line interface for GDB is described in Section 5 3 The GNU debugger on page 43 Insight can display several windows that contain source and assembly level code together with a range of system information In addition Insight has a Console Window for entering GDB commands on the command line Insight has several features e For many parts of a window click the right hand mouse button to open a context sensitive menu see Section 7 2 2 Context sensitive menus on page 66 e When the mouse pointer hovers over a button tooltips are displayed e When Insight launches it restores the configuration and open windows from the state saved in the user s home directory specified by the HOME environment variable in a file named gdbtk200init on Unix or gdbtk200 ini on Windows This state is saved each time Insight closes
131. ch view visible See Figure 6 Welcome view F C C STWorkbench C STM workspace File Edit Refactor Navigate Search Project Run Window Help F SN D eU Welcome to STWorkbench eclipse Hg ahs The icons on this screen allow you to access documentation about STWorkbench tutorials and sample code If you are a first time user then you should take some time to explore the documentation to learn more about STWorkbench Proceed from the Welcome view to the Workbench by clicking on the curved arrow icon in the top right corner of the Welcome screen circled in red in You can return to the Welcome view at any time by selecting Help Welcome A Workbench provides one or more perspectives A perspective contains editors and views such as the Navigator Multiple Workbenches can be opened simultaneously 6 1 1 The STWorkbench workbench Before using STWorkbench it is important to become familiar with the various elements of the workbench A workbench consists of perspectives e views e editors A perspective is a predefined group of views and editors in the Workbench A perspective is designed to include all the views necessary for carrying out a specific task For example 8063762 Rev 9 59 246 Using STWorkbench ST200 the C C perspective contains views required for C C development including the C C Projects view and the Outline view and the Debug perspective contains views required when debugging
132. contains the definitions for some standard simulator configurations see Table 16 Table 16 Simulator targets GDB command Description st2XYsimle The simulated st2XY board in little endian mode st2XYfastsimle The same as st2xYsimle with the target option MODE FAST st2XYpassedsimle The same as s t2XYs imle with the capability to get the path of the simulator dynamic library as an argument st2XYprofsimle The same as st2XYsimle with profiling enabled st2XYsimbe The simulated st2XY board in big endian mode st2XYfastsimbe The same as st2XYsimbe with the target option MODE FAST sek passedsimbe The same as st2XYsimbe with the capability to get the path of the simulator dynamic library as an argument st2XYprofsimbe The same as st2XYsimbe with profiling enabled a 8063762 Rev 9 85 246 ST200 simulator ST200 8 2 Target configuration options Table 17 lists the simulator options To customize the simulator options use the ST200 toolset simulator target command files in the lt tools dir gt 1x el 32 stdcmd directory as examples Table 17 Target configuration options Option Description Default value CONFIG FILE Read options from the specified CONFIG FILE see filename DUMP CONFIG FILE ENE FILE Du
133. controlling targets that have been added in the ST200 configuration see Section 5 3 6 ST200 GDB commands on page 51 The GNU Debugging with GDB manual provides further details on GDB commands and the GNU debugger At the start of every user defined GDB command an argc GDB convenience variable is automatically defined specifying the number of arguments to the command This enables a command to test how many parameters are passed to it Table 9 st200gdb command quick reference Command Description Prints a backtrace of all the stack frames function calls If n is specified and is positive then give the top n frames If n is specified and backtrace n full is negative then give the bottom n frames If the word u11 is given then it also prints the values of the local variables The bt command may be used as an alias for backtrace break function line file line Sets a breakpoint on the specified function line or address address clear function line file line Clears a breakpoint on the specified function line or address address continue Continues execution of the program delete number Deletes the numbered breakpoint or all breakpoints disable number Disables the numbered breakpoint or all breakpoints Disassembles the machine code between the addresses addi and disassemble addi ada2 If one address is omitted then the code around the one given is add2 disassembled If both are omitted then it
134. ctly mkimage pl is called automatically to convert them into component image files Use the flasher tool to program the complete binary ROM image to Flash ROM You cannot update complete ROM images you must create a new image from all constituent ELF files and or component image files The examples provide sample boot vector and bootstrap code for the ST200 that locates and starts the ST200 application in the Flash ROM The following list shows the flow of execution on booting 1 The host processor boot vector code runs jumping to its bootstrap code 2 The host core bootstrap code configures the clocks EMI and LMI interfaces locates the ST200 boot application or a fail safe application if there is one present moves any sections to RAM which require moving zeros any sections in RAM which require zeroing transfers control to the ST200 fail safe or main application ky 8063762 Rev 9 97 246 OS21 Trace ST200 11 OS21 Trace The ST200 Micro Toolset supports tracing of the OS21 kernel activity and APIs and also user defined APIs and activities To trace the OS21 kernel activity and APIs an application is linked with instrumented versions of the supplied libraries this instrumentation writes events to a memory buffer allocated on the target To assist with tracing the user s application and any user supplied libraries the ST200 Micro Toolset provides the tools os21usertrace and os21usertracegen The t
135. d BSP initialization OVERWRITE bsp user start handle handles all of the BSP initialization and the standard initialization is skipped Description If this function is user defined it is invoked at the start of the BSP initialization At this stage this function is in supervisor mode and nothing of the BSP has been initialized no memory management and timer initialization Example int bsp user start handle void kprintf At the start of user defined bsp user start handle in Dosomething return RESUME Continue with standard BSP init ky 8063762 Rev 9 201 246 ST200 board support package BSP ST200 bsp user end handle User handle called at the end of the BSP initialization Definition void bsp user end handle void Arguments None Returns None Description If this function is user defined it is invoked at the end of the BSP initialization At this stage this function is in the mode requested the default is supervisor and the BSP has been initialized This function is called before main Note This function is only invoked in the standard flow of BSP initialization If the user defined bsp user start handle has returned OVERWRITE bsp user end handle is not called Example void bsp user end handle void f kprintf At the end of BSP init rn Dosomething j 202 246 8063762 Rev 9 ky ST200 ST200 board support package BSP B 9 Table 55 Retrieving in
136. d information as void bsp scu disable Disable an SCU region Definition include platform h unsigned int bsp scu disable unsigned int regno Arguments regno The SCU region number to be disabled Returns Returns the error condition BSP OK or BSP FAILURE Description This function disables the specified SCU region bsp scu dump SCU Settings Dump on the I O a list of the SCU regions Definition include lt platform h gt int bsp scu dump SCU Settings void Arguments None Returns Returns BSP OK Description This function writes the SCU region s settings on the stdio ky 8063762 Rev 9 217 246 ST200 board support package BSP ST200 bsp scu read Read the start and stop address of an SCU region Definition include lt platform h gt unsigned int bsp scu read unsigned int regno bsp scu entry t sect Arguments regno The SCU region number to read sect A pointer to an allocated structure of type bsp scu entry t Returns Returns the error condition BSP OK or BSP FAILURE In case of success the structure sect contains the start and end addresses of the region Description The bsp scu read function reads the start and stop address of the SCU region specified by regno The addresses are returned in the structure sect bsp scu write Set the start and stop address of an SCU region Definition include lt platform h gt unsigned int bsp scu write unsigned int regno
137. dependent tasks that co ordinate their use of shared system resources such as memory and CPU time External events arriving from peripheral devices are made known to the system through interrupts The OS21 real time kernel provides comprehensive multi tasking services Tasks synchronize their activities and communicate with each other through semaphores event flags mutexes and message queues Real world events are handled through interrupt routines and communicated to tasks using semaphores and event flags Memory allocation for tasks is selectively managed by OS21 the C run time library or the user Tasks can be given priorities and are scheduled accordingly Timer functions are provided to implement time and delay functions An OS21 application is a single executable image that can be loaded on the target either through a debug port or from Flash ROM This single executable is typically written in C and statically linked with the C run time library the OS21 library and the OS21 board support library The application author has control of initializing the OS21 kernel and switching on preemptive multi tasking support When the OS21 kernel starts the full OS21 API can be used A very simple OS21 application test c is shown below include lt os21 h gt include lt os21 st200 h gt include lt stdio h gt void my_task char message printf Hello from the child task nMessage is s n message int main void ta
138. der file has the same name as the source file but with the c extension replaced with h The following example accepts a definition file called myapp def and generates an os21decodetrace control file called myapp in a GDB command script called myapp cmd a linker script called myapp wrap 1d and a C source file called myapp wrap c Although the file is not explicitly named on the command line using the s option also creates a header file for myapp wrap c called myapp wrap h os21usertrace d myapp in g myapp cmd 1 myapp wrap ld s myapp wrap c myapp def User definition file os21usertrace takes as its input one or more definition files This file contains details of the user APIs to be traced by OS21 Trace and the specifications for the custom activity APIs to be created for use by the user application The tool os21usertracegen can generate a suitable definition file from an ELF object or executable file and a list of function names See Section 11 1 3 os21usertracegen host tool on page 103 for more information The structure of a definition file in modified Backus Naur Form is as follows format spec list spec list spec spec list spec spec USER INCLUDE header spec USER API group class name type spec list USER ACTIVITY group class name type spec list comment header spec filename lt filename gt filename type spec list type spec type spec list type spec type spec
139. directory earlier in the PATH environment variable than the toolset bin directory There are a number of other tools provided with the toolset that do not have Cygwin pathname support In these cases only a proper Windows pathname works To convert pathnames from Cygwin format to Windows format and back again use the cygpath utility part of Cygwin 8063762 Rev 9 189 246 Toolset tips ST200 A 11 190 246 Watchpoint support ST200 provides both hardware watchpoints supported only on silicon and software watchpoints supported on both silicon and in a simulation environment 9 5 Hardware watchpoints are hardware assisted that is the ST200 provides registers to define the watched memory region and comparison operation Because ST200 register resources are limited only one hardware watchpoint is allowed at a time Hardware watchpoints are triggered when the instruction address matches criteria established through the registers In this condition the target stops execution and sends GDB a specific signal See the ST2xx core and instruction set architecture Reference manual for details Software watchpoints do not rely on hardware facilities and are therefore unlimited This kind of watchpoint is natively provided by GDB when executing in a simulation environment Another situation when software watchpoints are used is when setting more than one watchpoint on silicon From the users point of view software watchpoints pro
140. ds in the 1xgdbinit files that require confirmation assume affirmative responses Any line beginning with is ignored Using the st200gdb or st200insight tools When the st200gdb or st200insight tools launch GDB there is no requirement to create any additional 1xgdbinit files However the 1xgdbinit files are still useful for setting user preferences and defaults Using the Ix elf32 gdb Ix elf32 insight or Ix elf32 gdbtui tools When the Ix elf32 gdb Ix elf32 insight or Ix elf32 gdbtui tools launch GDB a user defined 1xgdbinit file can enable the ST200 simulator and silicon support Use the source command to source the default 1xgdbinit in the subdirectory 1x elf32 stdcmd ofthe release installation directory The default 1xgdbinit file assumes that the 1x e1 32 stdcmd directory is on the GDB search path To display the path use the GDB show directories command and to set the path use the GDB dir command The standard command files containing the ST200 configuration and target connection mechanisms are located in the 1x el1 32 stdcmd directory and have a cmd extension Connecting to a running target The ST200 Micro Toolset supports connecting to a running target attached to either an ST Micro Connect 1 or an ST Micro Connect 2 This feature provides the full debugging interface that would be available after a standard connect without disrupting the application already running on the target A typical situation whe
141. e automatically appending the results to a file every time the program stops and then resetting the profiler data profiler mode dsu profiler period 1ms profiler type trac profiler trace 65536 profiler enable define hook stop profiler append a dat profiler reset end continue profiler disable The following script describes a similar example that uses the range profiler except that the results file and the gmon out file are overwritten each time the target stops and the profiler data continues to accumulate on the ST Micro Connect profiler mode dsu profiler period 1ms profiler type range profiler range 8 profiler enable define hook stop profiler save a dat profiler gmonout gmon out end continue profiler disable To produce a human readable profiling report using the st200gprof tool use following command line gt st200gprof no graph appname out gmon out The no graph option is necessary in this case because the gmon out file produced by the profiler plugin does not contain call graph information 232 246 8063762 Rev 9 ST200 ST TargetPack plugin Appendix E ST TargetPack plugin E 1 The ST TargetPack plugin provides the following services to GDB e Itdefines the memory mapped registers specified for an SoC by the ST TargetPack as GDB convenience variables e Itdefines GDB commands that can be used for displaying the contents of the memory mapped registers i
142. e characters Usually this is not a problem because although the tools do not understand them they just pass them through and Windows still recognizes them However some wide characters contain as one of their two bytes the directory separator character or These are correctly interpreted by Windows but in some cases are misinterpreted by the GNU tools leading to malformed paths and apparently missing files and directories Note The preferred encoding for GNU is UTF 8 and there are no problems with 2 or more byte unicode encodings being misinterpreted as slashes 186 246 8063762 Rev 9 ky ST200 Toolset tips A 7 3 Power up and connection sequence STMicroelectronics recommends that the target board is either powered up after the ST Micro Connect or that the target is reset after power up of the ST Micro Connect The reason for this is that the ribbon cable connection between the target and ST Micro Connect can drag down the JTAG lines while the ST Micro Connect is not powered During the power up of the ST Micro Connect the JTAG signals are transiently undefined To clear any invalid state use a target reset A 8 Polling for keyboard input To enable host keyboard polling from an application running on the target use the _pollkey function _pollkey Poles the host keyboard Definition int _pollkey int keycode Arguments keycode The address of an int to receive the ASCII keycode of the pressed key Retur
143. e dev dev uc Ea Eh assert vmem virt to phys dev amp dev phys 0821 SUCCESS dev uc struct device vmem create dev phys sizeof struct device NULL VMEM CREATE UNCACHED VMEM CREATE READ VMEM CREATE WRITE assert dev uc NULL assert vmem delete dev uc OS21 SUCCESS 182 246 8063762 Rev 9 ky ST200 Toolset tips A 6 Debugging with OS21 Note Further information on debugging can be found in the Debugging with GDB manual A 6 1 Understanding OS21 stack traces Every time OS21 is entered through an interrupt or exception OS21 captures the context of the CPU on the current stack If interrupts nest it captures multiple contexts one for each interrupt The information stored includes the complete register state of the CPU details of what caused the context to be saved interrupt or exception and the task that was active at the time Whenever an unexpected exception occurs it produces a stack trace On the ST200 these stack traces have the following general form OS21 2222 2 2 2 2 2 2 2 2 2 2z2 z2 z2 2z2 z2 22 22 2222222222222222222222222 22 22 2 OS21 Stack trace n of lt N gt OS21 Fatal exception detected ST200 exception code OS21 Description of exception possibly with faulting address OS21 Active Task ID task ID OS21 Active Task Stackp stack pointer 0821 Active Task name task name Register dump Note The lines marked with a
144. e or 0 Description The rl load size function returns the memory load size of a loaded module It returns 0 if the handle does not hold a loaded module or if the handle passed is the main program handle rl file name Return the filename associated with the loaded module handle Definition const char rl file name rl handle t handle Arguments handle The handle for the loaded module Returns The filename associated with the loaded module handle or NULL Description The rl file name function returns the filename associated with the loaded module handle It returns NULL if no filename is associated with the current loaded module if the handle does not hold a loaded module or if the handle passed is the main program handle 150 246 8063762 Rev 9 ky ST200 Relocatable loader library rl set file name Specify a filename for the handle Definition int rl set file name rl handle t handle const char f name Arguments handle The handle for the module f name The filename to specify for the handle Returns Returns 0 for success 1 for failure Description The rl set file name function is used to specify a filename for a handle This filename is attached to the next module that will be loaded It can be used to specify a filename for modules loaded from memory or to force a different filename for a module loaded from a file This function returns 0 if the filename was successfully set or 1 and the error code r
145. e CPU Any interrupts that have a priority that is strictly greater than the CPU s interrupt priority can interrupt the CPU Any interrupts that have a priority less than or equal to the CPU s interrupt priority are masked out and cannot therefore affect the CPU The CPU s interrupt level is normally zero meaning that all interrupts are unmasked Any interrupt masked by the CPU s interrupt level when it becomes active is asserted to the CPU when the CPU s interrupt priority is lowered below that of the active interrupts 8063762 Rev 9 ky ST200 Toolset tips A 4 2 To serialize with an interrupt handler that is interrupting at level X only the interrupts up to level X need to be masked This stops all interrupts with a priority less than or equal to X from reaching the CPU but leaves higher priority interrupts unaffected interrupt mask sets the CPU s interrupt level to the value specified and interrupt mask all sets the CPU s interrupt level to its maximum To prevent pre emption interrupt mask andinterrupt mask all also perform an implicit task lock This is because if a context switch occurs while under an interrupt mask the CPU s interrupt priority would be changed to the value required by the incoming task which breaks the critical section Ensure that an explicit deschedule does not occur while interrupts are masked for example blocking on a busy semaphore or mutex task task critical sections OS21 ha
146. e TLB REPLACE register is adjusted accordingly Description The bsp mmu memory unmap function removes the mapping and protection for a block of program address space including the range address address length assumed to have been set by bsp mmu memory map If address is not the address of a mapping established by a prior call to bsp mmu memory map the behavior is undefined The bsp mmu memory map function may perform an implicit bsp mmu memory unmap See also bsp mmu memory map bsp mmu reset Reset TLBs settings Definition include lt platform h gt int bsp mmu reset void Arguments None Returns Returns the error condition Description Resets the MMU unit in TLB settings bsp pm clock get Read the PM Clock counter Definition include lt platform h gt long long bsp pm clock get void Arguments None Returns Returns the current value of the Clock counter Description This function reads the PM Clock counter and returns its current value See also bsp pm clock set 214 246 8063762 Rev 9 ky ST200 ST200 board support package BSP bsp pm clock set Write the PM Clock counter Definition include lt platform h gt int bsp pm clock set long long value Arguments value The initialization value to be loaded in PM clock Returns Returns the error condition Description This function writes value to the PM Clock counter See also bsp pm clock get bsp pm counter g
147. e an executable created by the code development tools see ST200 Micro Toolset compiler manual 7508723 to run on a variety of simulator and hardware platforms through the GNU debugger GDB GDB has been enhanced in the ST200 configuration to provide better support for the ST200 simulator and silicon targets see Section 5 3 The GNU debugger on page 43 ST TargetPacks are used to configure a target through an ST Micro Connect 2 or an ST Micro Connect 1 see the ST TargetPack user manual 8020851 Simulation packs provide configuration data for simulated targets and are described in Chapter 8 ST200 simulator on page 83 For a complete list of the ST TargetPacks supplied with the ST Micro Connect see the ST Micro Connect Release Notes and follow the link to the ST TargetPacks This also lists the elements that form the TargetString that is used to specify a particular TargetPack See Connecting to a targetin Section 5 3 1 Using GDB on page 43 Loading and executing a target program To build the program a out for the IPBR1100 target platform mb424 from the source file hello c st200cc mcore st231 msoc sti5300 mboard mb424 o a out hello c The following example uses st200xrun to execute the a out application on an IPBR1100 connected to an ST Micro Connect with the network IP address TP address see Section 5 4 Using st200xrun on page 55 st200xrun c st200tp t IP address mb424 st231 e a out The option c specifies the conn
148. e guards are filled with a known pattern when the block is allocated and are checked when the block is freed in order to detect writes that have occurred outside of the block for example writing past the end of an array When OS21 terminates the partition manager reports any blocks of memory that are allocated but not freed newlib provides Doug Lea s allocator version 2 6 4 The design of Doug Lea s allocator is discussed at length in gee cs oswego edu dl html malloc html The design goals for this widely used allocator include minimizing execution time and memory fragmentation newlib can be rebuilt with debugging switched on in malloc r c DDEBUG to enable extensive run time checking With debugging enabled calls to malloc stats and mallinfo attempt to check that every memory block in the heap is consistent 8063762 Rev 9 177 246 Toolset tips ST200 A 3 A 4 A 4 1 178 246 OS21 scheduler behavior The scheduler in OS21 provides priority based preemptive FIFO scheduling with optional timeslicing The following list summarizes its behavior 256 priority levels e FIFO scheduling within priority level e Tasks get preempted when higher priority tasks become runnable e Preemption can be disabled and re enabled with task 1ock and task unlock see task lock and task unlock Preemptions held pending while task 1ock is in effect occur when task unlock releases the lock e Task
149. e if they match the ones it was built with If they do then OS21 awareness is enabled and the shtdi service uses the in memory data tables to determine how to parse the OS21 data structures If the CRCs do not match then the shtdi service and OS21 were not built from the same source base and the shtdi service cannot operate in OS21 aware mode When modifying OS21 changing the relative order of certain fields in key data structures or renaming them can render the shtdi service unable to debug the resulting OS21 executables with task awareness 8063762 Rev 9 ky ST200 OS21 source guide 9 3 1 Generation of the shtdi server data tables The following Perl script invoked automatically as part of the build process performs the generation of the shtdi server data src os21 scripts mkgdb pl Key OS21 header files are scanned for special mark ups that identify which structures and the fields in those structures are exposed to the shtdi server The mark ups are very simple and invisible to the C compiler GDB_STRUCT struct Declares this structure as containing information required by the shtdi server This declaration triggers the generation of the following data objects a size_t with the size of the structure given the name struct size an array of offset and size descriptors given the name struct descs a size t with the value of the number of elements in the above array given the name struct descs size
150. e in Figure 30 shows the most recent branch branch 0 is a RETURN from 0x40000858 in the function unc1 found in branch sb c line 27 back to 0x40000b20inbrtrace subroutine branch sb c line 68 8063762 Rev 9 225 246 Profiler plugin ST200 Appendix D Profiler plugin 226 246 Profiling is a performance analysis technique that identifies the areas in an application where the CPU spends most time Having identified these areas it is then possible to target optimization efforts on the specific parts of the code that will yield the greatest benefit in terms of improving performance When a connection is made to a target using an ST Micro Connect commands may be issued through GDB to instruct the ST Micro Connect to collect sampling information about a running application This data is stored in a file and can then be analyzed using a profiling tool such as STWorkbench or st200gprof The profiler plugin is provided for ST200 targets and facilitates two different types of profiling trace The profiler samples the PC over a given period time stamping each sample This method provides a view of the application s activities over a period of time See Section D 2 Trace profile output format on page 229 range The profiler accumulates the number of times that a particular region of the application s code is executed in the manner of gprof see the GNU gprof documentation for more details See also Section D 2 Trace pro
151. e is an error mapping memory BSP EMFILE No TLB is available BSP EINTNOTHNDL The interrupt was not handled BSP EINTNOTPENDING No pending bits are set Note The function bsp print error obtains a short error message corresponding to the error received ky 8063762 Rev 9 191 246 ST200 board support package BSP ST200 B 2 B 2 1 B 2 2 192 246 Caches All variants of the ST200 processor use caches to reduce the time taken for the CPU to access memory and greatly increase system performance The ST200 has an instruction cache I cache and a data or operand cache D cache The I cache is read only while the D cache is read write Writes use a write back method When using a data cache there is a risk that it can become incoherent with main memory this is where the contents of the cache conflicts with the contents of main memory For example devices that perform direct memory access DMA modify the main memory without updating the contents of the cache potentially leaving its contents invalid For this reason extra care should be taken when performing DMA On the ST200 the I cache cannot be disabled however the D cache can be selectively disabled for specific regions of memory It is also possible to flush specific blocks of memory from either cache In this way application software can safely manage the cache Managing the caches When the D cache is enabled any data written to main memory by the CPU is stor
152. e menu select Target Settings The Target Selection window opens see Figure 11 Figure 11 Target Selection window Target Selection Connection MV Set breakpoint at main Target po Iv Set breakpoint at exit Baud Rate 38400 bad I Set breakpoint a o T Display Download Dialog Port comi M v Fewer Options Run Options Run Method Run Program T Attach to Target TI Download Program C Continue from Last Stop Command to issue after attaching PC CC BB Cancel Help 2 From the Target drop down list select ST Debug Interface see Figure 12 3 Specify any Options required for example to run the example on an IPBR1100 board mb424 connected to an ST Micro Connect with a network address of rPaddress enter st200tp lt IPaddress gt mb424 ST231 see Figure 12 Alternatively to run on a simulator target enter st200sp st231simle Figure 12 Target Selection window example Target Selection E X Connection F Set breakpoint at main Target ST Debug Interface F Set breakpoint at exit Options st200t stmc mb424 st23 s p r Set breakpoint at Port comi b More Options T Display Download Dialog 4 Click the OK button 68 246 8063762 Rev 9 ky ST200 Using Insight 7 5 Configuring breakpoints When a program runs it continues as far as the first breakpoint If Set breakpoint at mai
153. eads and writes bypass the caching mechanism and generate requests directly The CMC is responsible for arbitrating between reads and writes from the data cache and reads from the instruction cache This is done according to a fixed priority scheme therefore data reads have highest priority and data writes have lowest priority CORE_MHZ lt number gt Processor clock speed in MHz 450 BUS MHZ number Bus clock speed in MHz 166 MEMSYSTEM a e S he Internal latency of memory subsystem in processor cycles 5 86 246 8063762 Rev 9 ST200 ST200 simulator Table 17 Target configuration options continued Option BUS LATENCY Description Default value Intrinsic latency of the STBus in bus cycles 40 number y y PERIPHERAL Memory latency for peripheral register accesses in bus cycles 15 LATENCY number emory ARNEY TOF benphera TEJISIET aC ycles BUS BYTES PER US S PER The number of bytes that can be transferred in one bus cycle 8 bytes CYCLE number TRANSACTION T The number of extra processor cycles required for each bus SETUP CYCLES transaction di lt number gt i BUS BYTES PER im pira The number of bytes that can be transferred in one bus TRANSACTION i 32 transaction lt number gt EXTERNAL MEMORY SIZE number Size of external memory in bytes By default the toolset genera
154. ect it is now known as the ST Micro Connect 1 and the term ST Micro Connect is used to refer to the family of ST Micro Connect devices The ST Micro Connect 2 replaces the ST Micro Connect 1 These names are abbreviated to STMC STMC1 and STMC2 Conventions used in this guide General notation The notation in this document uses the following conventions sample code keyboard input and file names variables code variables and code comments equations and math screens windows dialog boxes and tool names instructions Hardware notation The following conventions are used for hardware notation e REGISTER NAMES and FIELD NAMES PIN NAMES and SIGNAL NAMES 8063762 Rev 9 11 246 Preface ST200 Software notation Syntax definitions are presented in a modified Backus Naur Form BNF unless otherwise specified e Terminal strings of the language that is those not built up by rules of the language are printed in teletype font For example void e Non terminal strings of the language that is those built up by rules of the language are printed in italic teletype font For example name e lfanon terminal string of the language starts with a non italicized part it is equivalent to the same non terminal string without that non italicized part For example vspace name e Each phrase definition is built up using a double colon and an equals sign to separate the two sides
155. ection D 3 Range profile output format on page 230 Updated Section D 5 Examples on page 232 08 Jul 2008 Supports the ST200 R6 2 Minor clarifications to Chapter 1 Toolset overview on page 13 Removed host and info directories from Table 1 The release directories on page 19 changed docs to doc Updated the list of supplied examples in Section 1 5 on page 20 Added Linux 4 0 and removed Windows 2000 from the list of supported platforms in Section 3 1 on page 25 Updated Section 3 2 st200cc command line on page 26 and Section 4 1 Configuring the run time code for a target on page 27 to better differentiate configuration options for st200cc and st200xrun Updated steps 6 and 8 in Section 4 3 3 Defining a custom board target and compiling a program on page 35 Added note to Chapter 5 Cross development tools on page 40 to direct users to the STMC release notes for details of TargetPacks Corrected Section 5 3 The GNU debugger on page 43 Added Section 5 3 3 Connecting to a running target on page 46 Added the command disconnect to Table 9 st200gdb command quick reference in Section 5 3 5 on page 49 Continued overpage 238 246 8063762 Rev 9 ST200 Revision history Table 62 Document revision history continued Date 08 Jul 2008 Revision C continued Changes Added the command ondisconnect to Table 10 ST200 st200gdb non specific commands in Section 5 3 6 on pa
156. ection procedure to be used In this case st200tp specifies that a TargetPack rather than a simulator pack is to be used The option t specifies the target string The option e specifies the name of the executable c st200tp is an st200xrun default and so need not be specified it is included here for completeness Further information about TargetPacks and TargetStrings can be found in the ST TargetPack user manual 8020851 supplied with the ST Micro Connect To launch the a out application on the ST200 simulator configured to simulate the IPBR1100 use the following command st200xrun c st200sp t mb424sim e a out 8063762 Rev 9 ky ST200 Cross development tools 5 2 5 2 1 Note Target code structure and initialization This section describes the Target address space usage initialization sequence and start parameters Target address space usage By default the toolset is configured for the program to load and execute in 8 Mbytes of LMI RAM memory from 0x08000000 to 0x08800000 Figure 3 shows how the toolset uses the ST200 address space to load and execute a C program when the program is compiled and executed with the default options In order to change the memory location where the program is loaded and executed memory settings must be changed in the board 14d linker script located in ctools dirs target board my boards When DEFAULT RAMEND DEFAULT TEXT BASE and memory mapping are modified build
157. ed at startup The expectation is that the user enables them using STWorkbench or GDB However it may be convenient to always run an application with logging enabled from the outset The example in Figure 28 on page 144 customizes OS21 Trace without having to change the application source To use this example compile the example code and add the object to the link command line for the application 8063762 Rev 9 143 246 OS21 Trace ST200 The example defines the following functions os21 trace constructor user This function is called by the trace buffer constructor os21 trace constructor in the OS21 Trace library my os21 trace destructor This function runs after exit Note The destructor function may not be very useful as embedded applications typically never terminate Figure 28 Example to customize trace include stdio h include os21 h include os21trace h if defined TRACE SIZE define TRACE SIZE 256 Trace buffer size endif static int trace enabled flag 0 const unsigned int os21 trace constructor size TRACE SI Run by OS21 Trace constructor void os21 trace constructor user void Enable trace os21 trace set enable 1 os21 activity set global enable 1 os21 api set global enable 1 os21 task trace set enable 1 trace enabled flag 1 Run after exit void my os21 trace destructor void attribute des
158. ed before 0os21 trace initialize has been called Note os21 trace initialize data can be used to clear the trace buffer if data refers to the existing trace buffer 126 246 8063762 Rev 9 ky ST200 OS21 Trace os21 trace initialize activity monitors Initialize activity monitors Definition void os21 trace initialize activity monitors void Arguments None Returns Void Description Use this function to initialize the activity monitors os21 trace set mode Set the action on trace buffer full Definition typedef enum os21 trace mode e os21 trace mode stop 1 os21 trace mode wrap 2 os21 trace mode e os21 trace mode e os21 trace set mode os21 trace mod mode Arguments mode Buffer full action stop or wrap Returns The previous trace mode Description Set the action to be performed when the task trace buffer is full The options are stop or wrap os21 trace overflow User defined trace overflow function Definition void os21 trace overflow void data unsigned int size Arguments data The current trace buffer size The size in bytes of data in the buffer Returns Void Description A function with this name is called when the trace buffer overflows in stop mode or before wraparound occurs in wrap mode The data and size parameters are the current trace data buffer and the size of the data saved in the buffer The default implementation of this function is a no op that the user c
159. ed by the boot program This is the default behavior This option is only meaningful when BOOT_FROM_RESET is set to true pair ter aid This is the value of the program counter immediately after reset 0 and can equivalently be thought of as the entry point to the boot code RESET_DELAY_ The number of processor cycles it takes to reset the core 512 CYCLES lt number gt POOT ROM BESE Byte address of the base of the boot ROM 0x0 lt number gt ky 8063762 Rev 9 87 246 ST200 simulator ST200 Table 17 Target configuration options continued Option BOOT ROM SIZE number Description Size of the boot ROM in bytes Default value 0x10000 64 Kbytes PERIPHERAL BASE The addresses of registers associated with the timer interrupt dus controller and DSU are defined relative to a peripheral base Ox1F000000 mS address All ST200 cores have a dedicated control register This determines whether or not the simulator produces a code execution trace If set to true the default operation is to output a TRACING ON bool i Ka false textual trace to stdout An alternative location can be specified by setting the OUTPUT TRACE FILE configuration item ji This item only takes effect when TRACING_ON is set to true It s OUTPUT TRACE a BOE Ur ILE E effect is to output the trace to the specified filename If the string is E empty
160. ed in the D cache and marked as dirty so that at some point in the future it can be properly stored to main memory The BSP ST200 cache API can purge that is to simultaneously flush and invalidate specific D cache lines Purging is required when writing to data structures in memory that are accessed through the D cache but are to be shared with another bus master for example another CPU or DMA device You can use BSP to manipulate shared data either avoiding the cache altogether or through the cache with software cache coherency support To safely handle dynamic code loading the read only I cache can be invalidated Cache header file machine bsp cache h All the definitions related to the cache are in the header file machine bsp cache h Table 41 Functions defined in machine bsp cache h Function Description Invalidates addresses within the specified range bsp cache invalidate instruction fromthe h truction cache bsp_cache_invalidate_instruction_ Invalidates the entire instruction cache all Purges addresses within the specified range from bsp cache purge data the data cache bsp cache purge data all Purges the entire data cache 8063762 Rev 9 ky ST200 ST200 board support package BSP B 2 3 L2 cache If a Level 2 cache interface is present in the hardware refer to your SoC datasheet for details then the BSP requires customization in order to use it 1 Def
161. endent structure and how to configure it with the mcore msoc and mboard toolset options e howto customize an existing board for customer needs e howto configure a new board or SoC for an ST200 family core 4 1 Configuring the run time code for a target As stated in Section 3 2 st200cc command line on page 26 there are three system configuration parameters that are required by st200cc to compile and link an application for a specified board target e corelevel The settings that are related to a core type and independent of either the SoC in which the core is embedded or the board on which the SoC is used e SoClevel The settings necessary for a given SoC independent of any board e board level The settings required to configure a given board target For each board several board targets can exist one for each ST200 CPU To configure the execution of the user program so that it is specific for the board target the run time must be aware of the sysconf parameters These parameters are hardware parameters such as the core and bus clock frequency that together with the handling of their access are found in the sysconf c module By default the sysconf module linked with the application fits the needs of all simulator targets For hardware boards a dedicated sysconf module specific to each board must override the default sysconf 8063762 Rev 9 27 246 Board target configuration ST200 Note 28 246 To load and run an appl
162. equest reporting enable_os21_profiler_stop_signaled disable_os21_profiler_stop_signaled The same as above but the target remains stopped and must be manually restarted Profiler monitor status show_os21_profiler_monitor_status Show the status of the OS21 profiler monitor Table 36 gives a list of possible states Table 36 OS21 profiler monitor state State Description INACTIVE The monitor is not initialized IDLE The monitor is waiting to perform an action BUSY The monitor has yet to complete the action Profiler status show_os21_profiler_status Show the status of the OS21 profiler including the type if active Table 37 gives a list of possible states Table 37 OS21 profiler state State Description INACTIVE The profiler is not initialized INITIALIZED The profiler is initialized but not started STARTED The profiler is running STOPPED The profiler is stopped 1 In this state profile data is available for dumping by the os21 profiler dump command show_os21_profiler_internal_status This is similar to show_os21_profiler_status except that it shows the internal status of the OS21 profiler 8063762 Rev 9 171 246 Dynamic OS21 profiling ST200 13 5 Analyzing the results After the OS21 profile data has been saved using the os21 profile write Or os21 profile dump commands use the os21prof tool to perform the analysis
163. er requests from GDB See Section 13 1 Overview on page 167 for details In the default configuration GDB uses the OS21 0821 INTERRUPT DEBUGGER interrupt to signal the monitor task of a pending action The user may change the interrupt used for signalling the monitor task by overriding the following items e Define the symbol interrupt name t os21 profiler monitor interrupt to specify the interrupt that GDB uses to signal to the monitor task The default is OS21 INTERRUPT DEBUGGER This should not normally need changing This override is defined using the linker defsym option as follows Wl defsym os21 profiler monitor interrupt 0521 INTERRUPT name 8063762 Rev 9 173 246 Dynamic OS21 profiling ST200 174 246 e Ifthesymbol os21 profiler monitor interrupt is defined the dynamic OS21 profiler calls an external function supplied by the user to clear the interrupt The function has the following prototype void os21 profiler monitor interrupt clear interrupt t handle e Define the GDB command os21 profiler signal raise to raise the interrupt specified by the symbol os21 profiler monitor interrupt This command is required only if the interrupt to be raised is not the default 0521 INTERRUPT DEBUGGER If no interrupt is available the monitor task can be configured to check periodically if an action needs to be performed The dynamic OS21 profiler provides the following
164. ersion requires the GNU development environment for the host platform To build a big endian version substitute LE with BE this builds the 311 or so in the ReleaseLE directory To instruct the simulator to use a specific device plugin specify a configuration item to the simulator in the usual way either on the command line or in a configuration file To customize the sample plugin use the ST231 EVAL board STi5300 plugin sources provided with the toolset as a starting point 8063762 Rev 9 91 246 OS21 source guide ST200 9 Note 9 1 92 246 OS21 source guide Within the terms and conditions of the OS21 Software License Agreement you may freely rebuild OS21 for your own purposes A copy of the license agreement is available from the licence htm file in the doc subdirectory of the release installation directory The toolset release includes the source code for OS21 located in the subdirectory src os21 ofthe release installation directory To build OS21 and its board support libraries use the makefile GNU make compatible in this directory This top level makefile has three build rules build Build all of OS21 and its board support libraries the default rule buildbsp Build just the OS21 board support libraries clean Remove all built files object files and libraries The resulting libraries are placed in the directory src os21 lib The OS21 source enables you to refer to the OS21 sour
165. ertracegen input i file option function name where fileis an ELF format file and function name is the name of a global function The default is to generate a definition file for all global functions defined by the DWARF debug information in the ELF format file specified by the input option The set of global functions contributing to the definitions file can be customized by using command line options to only include functions satisfying a specified criteria The command line options are described in Table 23 There is a long form and short form alternative for each option The position of some options within the command line is significant Also some options can be specified multiple times Table 23 os21usertracegen command line options Option Description General options input file Name of the ELF format object or executable input file 24 file containing the DWARF debug information warn Enable warnings If specified then os21usertracegen issues a warning for each function definition that specifies an mW unsupported parameter or return type help Display help h a st200cc creates an ELF format file with DWARF debug information when the g compilation option is specified 8063762 Rev 9 103 246 OS21 Trace ST200 104 246 Table 23 os21usertracegen command line options continued Option Output format options Description decl Output definitions
166. es for OS21 target Target libraries The documents directory Several HTML files are provided to navigate the documentation These can all be accessed from the index htm file in the release installation directory Table 2 lists the main pages Table 2 The HTML files in the doc directory File acknow htm acroread htm Description The acknowledgements page Instructions on installing and using Acrobat Reader buglist htm Known bugs list cdmap htm An index of the information provided i Iset and report decbug hth Instructions on how to get support on the toolset and repo problems in the documentation A list of the documentation supplied with the toolset Each docs htm document can be accessed from this page by clicking on the relevant link installation linux htm Instructions on installing under Linux installation win htm Instructions on installing under Windows licence htm Links to each of the licence files that the software is shipped under 8063762 Rev 9 19 246 Toolset overview ST200 Table 2 The HTML files in the doc directory continued File release htm Description Release notes STS toolsReg htm ST200 registration versionIDs htm ST200 cores version identifiers 1 4 2 GDB command scripts directory The directory 1x e1 32 stdcmd contains GDB command script files for a selection of target evaluatio
167. es of data Ensure that the data uses the endianness of the ST200 being modelled DevWrite DEVICE API bool DevWrite const unsigned char from unsigned int address unsigned int numBytes const char byteEnables This function is called whenever a write is requested on the STBus The plugin returns true if a write at the given address is handled It returns false if it does not map the address If the plugin handles the request it reads numBytes of data from the rom array and deals with it appropriately If byteEnables is not NULL then it specifies which of the numBytes are valid Ensure that the data uses the endianness of the ST200 being modelled Callbacks into the simulator The plugin can make use of the CPinout object in a C environment or the SPinout in a C environment object passed into the DevInitialise function These enable the plugin to have access to the internals of the core Examples of how to use this functionality are in the SampleDevice code Details of CPinout and SPinout are in Pinout h and PinoutC h respectively Building and running the plugin The sample plugin shows how to use some of the functions defined in the SampleDevice h header file To build the sample On Windows nmake CONFIG ReleaseLE f MakefilePC mak The Windows version requires the Microsoft development environment for Windows On Linux make CONFIG ReleaseLE f MakefileLinux mak The Linux v
168. es the freguency that samples are to be taken in hertz For example os21 profiler initialize 16 5000 initializes the OS21 profiler to use 16 instructions per bucket and a sampling frequency of 5 KHz os21 profiler deinitialize Destroys the OS21 profiler by calling the OS21 API profile deinit torelease the memory and resources allocated by profiler_init If the OS21 profiler is currently running when this command is issued the OS21 API profiler stop is called first OS21 profiler start When the OS21 profiler has been initialized use one of the following commands to start profiling If the OS21 profiler is already running the OS21 API profiler stop is called first os21 profiler start all Starts the system wide OS21 profiler that is profiling every task and interrupt level by calling the OS21 API profile start all os21 profiler start interrupt interrupt level Starts the OS21 profiler for the specified interrupt level by calling the OS21 API profile start interrupt os21 profiler start task task handle Starts the OS21 profiler for the task specified by task hand e by calling the OS21 API profile start task The argument task handle is the address of an OS21 task t object This address can be extracted from the thread list reported by GDB os21 profiler start task number task number Starts the OS21 profiler for the task specified by task number where task number is the OS21 task number and not the number as
169. esses within the specified range from the data cache Definition include lt platform h gt int bsp cache purge data void base address size t length Arguments base address The start address of the range to purge length The length of the range in bytes Returns Returns the error condition Description This function purges any valid data cache lines which fall within the address range specified Any dirty cache lines are first written back to memory and then the cache lines are invalidated See also bsp cache purge data all 204 246 8063762 Rev 9 ky ST200 ST200 board support package BSP bsp cache purge data all Purge the entire data cache Definition include lt platform h gt int bsp cache purge data all void Arguments None Returns Returns the error condition Description This function purges any valid data cache lines within the D cache Any dirty cache lines are first written back to memory and then the cache lines are invalidated See also bsp cache purge data bsp core interrupt install Install an exception handler for a specified exception cause Definition include lt platform h gt int bsp core interrupt install InterruptVector t NewExceptionHandler InterruptVector t OldExceptionHandler int ExceptionNumber Arguments NewExceptionHandler The exception handler to attach to the specified exception OldExceptionHandler The previously installed excepti
170. et Read the current value of a PM counter Definition include lt platform h gt unsigned int bsp pm counter get int counter Arguments counter The counter to read Returns Returns the current value of the counter Description This function reads the PM counter and returns its current value See also bsp pm counter set bsp pm counter set Write change the value of a PM counter Definition include lt platform h gt int bsp pm counter set int counter unsigned int value Arguments counter The counter to write value The value to assign to the counter Returns Returns the error condition Description This function writes value to the PM counter specified in counter See also bsp pm counter get 8063762 Rev 9 215 246 ST200 board support package BSP ST200 bsp pm event get Definition Arguments Returns Description See also bsp pm event set Definition Arguments Returns Description See also bsp pm reset Definition Arguments Returns Description bsp pm start Definition Arguments Returns Description See also 216 246 Returns the event monitored by the PM counter include lt platform h gt unsigned int bsp pm event get int counter counter The counter to read Returns the event associated with the counter This function reads the PM counter specified in counter and returns the event with which it is associated bsp pm event set Set
171. ete with its own makefile into a wrapper project with STWorkbench At the end of the tutorial you will have built an ST200 application that can be run or debugged Debugging C C Applications This tutorial describes the process of starting an ST200 debug session with a previously built binary executable It also describes common debugging steps such as modifying breakpoints examining variables call stacks and tasks Running C C Applications This tutorial describes the process of running an ST200 application with a previously built binary executable Branch Trace View This page describes how to use the Branch Trace view to display the last eight branches that the program performed before arriving at the place where the debugger is currently stopped Execute from Command Line STWorkbench supports the ability to launch a debug session directly from the command line This page describes how to use this facility Performance Monitor view This page describes how to use the ST200 Performance Monitor view to examine the data provided by the ST200 Performance Monitor facility Statistics view simulator only This page describes how to display ST200 simulator statistics using the ST200 Statistics view 8063762 Rev 9 ky ST200 Using STWorkbench 6 3 ST200 System Analysis tutorials and reference pages There are several tutorials on how to use the ST System Analysis formerly the Profiling and Coverage feature
172. eturned by r1 errno is set accordingly if a module is already loaded or if the application runs out of memory rl load buffer Load a relocatable module into memory Definition int rl load buffer rl handle t handle const char image Arguments handle The handle for the module image The image of the load module Returns Returns 0 for success 1 for failure Description The r1 load buffer function loads a relocatable module into memory from the image referenced by image It allocates the space for the loaded module in the heap loads the segments from the memory image of the loadable module links the module to the parent module of the handle and relocates and initializes the loaded module This function calls the action callback functions for RL ACTION LOAD after loading and before executing any code in the loaded module The value 0 is returned if the loading was successful The value 1 is returned on failure and the error code returned by x1 errno is set accordingly 8063762 Rev 9 151 246 Relocatable loader library ST200 rl load file Definition Arguments Returns Description 152 246 Load a relocatable module into memory from a file int rl load file rl handle t handle const char f name handle The handle for the module f name The file from which to load the relocatable module Returns 0 for success 1 for failure The r1 load file function loads a relocatable mod
173. event 0 00 eee 119 11 9 7 Enable OS21 API function 2 0 0 ene 119 11 9 8 Enable task information logging 120 11 9 9 Dump buffer to file llli 121 11 9 10 Flush buffers and reset 000 cece eee 121 11 9 11 Type and event enables cee ee 121 11 10 User GDBcontrolcommands 123 11 10 1 User activity control commands 123 11 10 2 User API control commands cence eee 124 11 10 3 Miscellaneous commands 125 11 11 Trace library API iocus eus ge RRRXER BRA RAR RE NE ene ene aus 126 11 12 Variables and APIs that can be overridden 138 11 13 User trace runtime APIs 139 11 13 1 User activity control APIs ee eee 139 11 13 2 User API control APIs 140 11 13 38 User activity APIs AIKA eee 142 11 14 Correspondence between GDB commands and APIs 142 11 15 Trace always On 143 6 246 8063762 Rev 9 ky ST200 Contents 12 Relocatable loader library cece eee 145 12 1 Run time model overview 145 12 2 Relocatable run time model 0 0 e eee 146 12 2 1 The relocatable code generation model 148 12 3 Relocatable
174. external interrupt program error for example misaligned access bad instruction failed protection check After the BSP initialization only external interrupts are handled The default behavior when an unexpected exception occurs is to print a message detailing the exception dump the whole context and then shut down by calling exit To replace the currently installed exception handlers use the BSP CORE EXTERN INT function All external interrupts are treated as BSP CORE EXTERN INT exceptions the interrupt dispatcher is set during the BSP initialization Exceptions types Table 50 lists the exceptions that can occur for ST231 and ST240 cores 8063762 Rev 9 ky ST200 ST200 board support package BSP Table 50 ST231 and ST240 exceptions defined in machine bsp core h ST231 exceptions BSP CORE STBUS IC ERROR BSP CORE SYSCALL BSP CORE STBUS DC ERROR BSP CORE DBREAK BSP CORE EXTERN INT BSP CORE MISALIGNED TRAP BSP CORE IBREAK BSP CORE CREG NO MAPPING BSP CORE ITLB BSP CORE CREG ACCESS VIOLATION BSP CORE SBREAK BSP CORE DTLB BSP CORE ILL INST BSP CORE SDI TIMEOUT The exception handlers are defined as typedef int InterruptVector t regcontext For example int MySyscallHandle regcontext regs f DoSomething bsp errno BSP OK return BSP OK main f InterruptVector
175. f myapp debug write def myapp other def myapp deref def 7 Next compile the source file generated in step 6 st200cc mruntime os21 fno zero initialized in bss g c myapp wrap c b See Building on page 114 in Section 11 6 2 User API and user activity trace tor further information about the fno zero initialized in bss option 106 246 8063762 Rev 9 ky ST200 OS21 Trace Note Note 8 The final step is to re link the application with trace enabled see Section 11 3 Building an application for OS21 Trace for details st200cc application link options g o myapp out myapp wrap o trace trace api trace api no time Wl Gmyapp wrap ld The use of single quotes in the above examples are not required nor accepted by the os21usertracegen fool but are present to illustrate the use of quoting to protect the regular expressions from being interpreted by a Unix shell Under Windows use double quotes instead of single quotes to protect the regular expressions Use of regular expressions os21usertracegen uses the Perl Compatible Regular Expressions PCRE library which is more powerful and flexible than many other regular expression libraries This is an open source library see www pcre org for details with many reference and tutorial resources available on the Internet Print a string to the OS21 Trace buffer It is possible to invoke a USER ACTIVITY function to record that the program h
176. f the PC register of the first stack trace in the example this is 0xC000041C Use st2000bjdump to generate a disassembly starting before and stopping after this address This shows the name of the function that generated the exception If it does not start the disassembly further back For example st2000bjdump d j text start address 0xC0000408 stop address 0xC0000420 a out a out file format elf32 littlelx Disassembly of section text c0000408 my task c0000408 cc Of 00 a5 stw 0 0x0 r12 c000040c 0c 84 00 a5 stw 8 0x8 r12 c0000410 5d 00 80 15 c0000414 40 92 04 08 mov r9 47689 Oxba49 c0000418 0c 82 00 a0 ldw r8 8 0x8 r12 c000041c 48 02 00 a5 stw O 0xO r8 r9 r63 r16 Wo Using st200addr2line st200addr2line provides the source file and line number for a specified address Taking the PC to be the same as above 0xc000041c pass it to st200addr2line for example st200addr21ine e a out f 0xC000041C my task source directory test c 5 The program must contain debug information 8063762 Rev 9 185 246 Toolset tips ST200 A 6 3 Catching program termination with GDB The normal exit path for an application is to call exit a breakpoint on this function catches typical application exit scenarios However if OS21 detects an internal error it panics This calls the kernel panic function with a string describing the situation To catch abnormal kernel situati
177. fer reset argument If 1 then the trace buffer is cleared otherwise it is not reset and the buffer remains intact Use this API in conjunction with os21 trace status To ensure that the information returned by os21 trace status remains valid for the call to os21 trace write buffer these API calls must be encapsulated within calls toos21 trace set enable 1 andos21 trace set enable 0 8063762 Rev 9 135 246 OS21 Trace ST200 os21 task trace write file Write task information buffer to a file Definition int os21 task trace write file const char name int reset Arguments name File name to create reset Clear 1 or keep 0 buffer Returns O if OK 1 if an error occurred Description Write the contents of the task information buffer to the file name The second parameter reset is the buffer reset argument If 1 then the buffer is cleared otherwise it is not reset and remains intact os21 task trace status Get task information status Definition typedef struct os21 task trace status s int version unsigned int size os21 task trace status t void os21 task trace status os21 task trace status t status Arguments A structure status with the following fields to be filled in by the function version The version number for the task information buffer format size The current size of the data in the task information buffer Returns Void Description Get the task information buffer st
178. file output format on page 229 Profiling operates in one of three modes none The profiler collects samples only when the target stops at a breakpoint or an I O request occurs dsu The profiler provides non intrusive sampling of the program counter It is performed through the core s DSU interface to obtain the current address on the instruction bus This mode is only valid for ST240 targets interrupt This mode stops the target to read the PC directly before continuing This mode has a significant impact on the real time performance of the target although it has the advantage of being able to read the PC directly The ST Micro Connect profiler features are accessible through the GDB profiler command 8063762 Rev 9 ky ST200 Profiler plugin D 1 Profiler plugin reference The profiler command is enabled automatically when the host connects to a ST200 target It can also be enabled by issuing the command enable profiler defined in the st200profiler cmd GDB command script file gdb profiler subcommand options This command controls the profiler function specified by subcommand and options The subcommands supported by the profiler command are listed in Table 59 Table 59 Profiler subcommands Subcommand help Option subcommand Description Display help for the profiler command If a subcommand is specified then more detailed help for the subcommand is displayed enable Start the p
179. filer and Coverage features enable profiling and coverage analysis to be collected e 0821 real time kernel The software design of embedded systems is supported by a real time kernel OS21 which facilitates the decomposition of a design into a collection of communicating tasks and interrupt handlers e AC C run time system The newlib C library provides ANSI C C run time functions including support for C I O using the facilities of the host system The C run time system is provided by the GNU GCC libstdc library which includes support for the STL and iostream ISO C standard libraries e File I O is provided as well as terminal I O 8063762 Rev 9 13 246 Toolset overview ST200 1 2 1 2 1 14 246 Trace and statistical data analysis tools The ST200 simulator provides tools to visualize performance information and for the ST240 GDB branch trace facilities are supported Rebase tool The st200 rebase tool enables the memory layout of an application to be changed after linking and is described in the ST200 Micro Toolset compiler manual 7508723 Flash ROM examples Several Flash ROM examples are provided These create applications which are able to boot from ROM on the supported targets Support for the ST Micro Connect Provides the download route to the board through the JTAG interface The ST Micro Connect supports download through Ethernet from any host machine The ST Micro Connect interface is connected to the D
180. finition include lt platform h gt int bsp interrupt clear int interrupt number int type Arguments interrupt number The interrupt to clear type Flag to select between eternal and internal interrupts Values accepted INTERNAL INTERRUPTS EXTERNAL INTERRUPTS Returns Returns the error condition Description This function clears a specific interrupt bsp itc interrupt clear is kept for backward compatibility and it is equivalent to call bsp interrupt clear using type EXTERNAL INTERRUPTS bsp interrupt disable Disable a specific interrupt Definition include lt platform h gt int bsp interrupt disable int interrupt number int type Arguments interrupt number The interrupt to enable type Flag to select between eternal and internal interrupts Values accepted INTERNAL INTERRUPTS EXTERNAL INTERRUPTS Returns Returns the error condition Description This function disables a specific interrupt bsp itc interrupt disable is kept 206 246 for backward compatibility and it is equivalent to call bsp interrupt disable using type EXTERNAL INTERRUPTS 8063762 Rev 9 ky ST200 ST200 board support package BSP bsp interrupt enable Enable a specific interrupt Definition include lt platform h gt int bsp interrupt enable int interrupt number int type Arguments interrupt number The interrupt to enable type Flag to select between eternal and internal interrupts Values accepted
181. format f int result va list args va start args format result TRACE VPrint format args va end args return result Next define TRACE VPrint in the definition file as follows USER API STAPI TRACE TRACE VPrint int d const char s va_list p a 102 246 8063762 Rev 9 ST200 OS21 Trace Note 11 1 3 Note e Non scalar argument and return types are not supported If possible convert the API into an equivalent form taking a reference to the type and define this in the definition file e Avoid defining USER ACTIVITY APIs with parameters with a type that is a derived type that is a typedef unless it can be guaranteed that the derived type is declared when the header file created by the wrap source option is included The format codes are used by OS21 Trace to decide how to decode and store the return value and arguments of the user and custom activity APIs os21usertracegen host tool The ST200 Micro Toolset provides the os21usertracegen tool to generate a definition file for input to the os21usertrace tool See Section 11 1 2 User definition file on page 100 for details of the definition file format os21usertracegen accepts as input an ELF object or executable file but not a library archive file and uses the DWARF debug information contained within to generate the definitions required by os21usertrace The command line for os21usertracegen is os21us
182. formed explicitly by the application see Chapter 13 7 Profiler library API profiler no constructor Running the application By default an application built with dynamic OS21 profiling support initially starts with OS21 profiler disabled To enable the GDB control of the dynamic OS21 profiler use the following command source os21profile cmd See Section 13 4 GDB commands on page 168 for a complete list of commands GDB commands This section contains a list of the dynamic OS21 profiler GDB commands accessible when the file os21profiler cmd is sourced within GDB For information on a given command use the GDB command help command OS21 profiler initialization Use the following commands to initialize and de initialize profiling os21 profiler initialize instructions per bucket frequency Configures the OS21 profiler by calling the OS21 API profile init If profiling has already been configured this command removes the existing configuration by calling profiler deinit and reconfigures it with the new parameters If the OS21 profiler is currently running when this command is issued the OS21 API profiler stop is called first 8063762 Rev 9 ky ST200 Dynamic OS21 profiling This command accepts two arguments instructions per bucket The number of instructions allocated to a single bucket when capturing profile data A bucket is a counter associated with an address range freguency Indicat
183. function to retrieve a pointer to the function symbol exec A in A 4 For A the main program loads the module D and references to printf are resolved to the printf in main In addition references to malloc in D are also resolved to the malloc in main The main program retrieves a pointer to exec D in D using the x1 sym function The main program at some point invokes the function exec A The exec A function loads the two modules B and C The undefined reference to printf in B is resolved to the printf in main the loader searches first in A and then in main 9 The undefined reference to malloc in C is resolved to the malloc in A the loader searches for and finds it in A Note that the malloc function called from D malloc of main is then different from the malloc function called from B or C or A which is the malloc of A 10 After retrieving symbol addresses using the x1 sym function module A can indirectly call functions or reference data in B and C Oo NOW At any time the main module or the module A can unload one of the loaded modules 8063762 Rev 9 147 246 Relocatable loader library ST200 12 2 1 12 3 12 3 1 148 246 The relocatable code generation model The relocatable code generation model is the same as the code generation model for the System V model with the following differences e Nosymbol can be preempted Dynamic symbol binding always searches the current module first This h
184. ge 51 Updated Section 5 4 2 st200xrun command line reference on page 55 throughout and added new options u D and Updated Section 5 4 3 st200xrun command line examples on page 56 adding new examples Updated Section 6 1 Getting started with STWorkbench on page 58 Re written Section 6 2 STWorkbench tutorials on page 62 listing the latest tutorials Updated 6 3 ST Profiling and Coverage tutorials Section 6 3 ST200 System Analysis tutorials and reference pages on page 63 in revision F of this manual Updated the instructions in Section 7 4 Changing the target on page 68 Updated Figure 16 Figure 21 and Figure 22 in Chapter 7 to use current processors Added Section 7 17 Using the Debug Support Unit Window on page 82 Corrected st200xrun command line in Section 8 1 Simulator pack on page 84 Changed 1x e1f32 src os21 1lib ST200 to src os21 lib in Chapter 9 OS21 source guide on page 92 Added Appendix C Branch trace buffer on page 223 Added Appendix D Profiler plugin on page 226 Changed target string to TargetString throughout Corrected other minor non technical errors 13 Feb 2008 The GDB extended commands appendix has been removed and the contents merged with Section 5 3 6 ST200 GDB commands on page 51 The Building open sources chapter has been removed Section 1 2 3 Configuration scripts updated Section 5 3 1 Using GDB updated Additional items added to Table 13 st200xrun command line
185. get core my core Parameter location D my core Macros D MY CORE tools dir lib my core endianness crtl o crti o lt run time gt crtl o r a tools dir lib my cores xendiannesss Grtl o crti o z lt run time gt crt1 o lt tools dir gt lib lt my_core gt lt endianness gt crtn o crtn o crtbegin o crtbegin o run time cr lt tools dir gt 1 run time cr o ib lt my_core gt lt endianness gt O crtend o crtend o lt tools dir gt 1 ib lt my_core gt lt endianness gt run time crt O Core library search path Core initialization library L tools dir lib my cores lt endianness gt lt run time gt lcore libcore a lt tools dir gt target core lt my_core gt lt endianness gt lt run time gt a 8063762 Rev 9 31 246 Board target configuration ST200 Table 4 Core contribution continued Item Value Parameter location tools dir target core my core bootcore o F endianness run time bootcore o UE ls di Core initialization init core function Stoo18 017 gt target core lt mp Gore lt endianness gt lt run time gt libcore a SoC contribution The msoc my soc option controls the SoC contribution Table 5 SoC contribution Item Include search path Value I lt tools dir gt target soc lt my
186. hat describe and control the virtual address space on the system The SCU controls whether or not speculative also known as dismissible loads from physical address ranges are allowed The SCU has a fixed number of entries that are used to enable speculative loads for certain physical address ranges Initial memory map When the ST200 comes out of reset the MMU is disabled In this mode all data fetches are uncached The C run time boot sequence programs the MMU to contain an identity mapping for system RAM with caching enabled It also programs the SCU so that speculation is enabled for system RAM The boot sequence then enables the MMU and the ST200 starts running from a virtual address space The mapping set up in the TLBs by the bare run time is an identity mapping therefore the system RAM is shown in the virtual address space at the same addresses as it does in the physical address map Table 42 Initial memory map Start address Size rss Cacheable Description text start 8 MBytes rwx rwx Yes RAM read write execute 0x00000000 8 KBytes rwx rwx No boot ROM Peripheral base 16 KBytes rw No Peripheral registers a E l8 KBytes r x No DSU ROM Managing the MMU The bare run time Board Support Package only has a minimal support for the MMU and SCU The OS21 BSP has a more extended API for MMU and SCU modules MMU header file machine bsp mmu h All the definitions related to the MMU av
187. having the IP address address the connection command is gdb st200tp address mb424 st231 In this case lt address gt mb424 st231 is the lt TargetString gt e The ST200 simulator connects to st200gdb using the st200sp ST200 simulator pack connection command The ST200 simulator pack is the set of st200gdb procedures that enable the usage of st200gdb on the ST200 simulator For example to connect st200gdb to the ST200 simulator set up for the IPBR1100 board mb424 use the following connection command gdb st200sp mb424sim In this case mb424sim is the lt TargetString gt e Some silicon targets are not supported by the ST200 TargetPack For these targets a connection commando exists for each board target and the lt TargetString gt is the IP address of the ST Micro Connect used for the connection For example to connect st200gdb to an mb392 audiodec board target through an ST Micro Connect that has the IP address address the connection command is gdb mb392 audioenc address In this case address is the lt TargetString gt Executing the program If the program loads and executes immediately it simply runs until it reaches completion or an error To ensure that the program stops at a point of interest set a breakpoint to enable inspection or single stepping of the program state Breakpoints can be set on specific functions lines or addresses using the break command for example gdb break
188. his is the name of the function at the given address indicates that the function name is not known This is the source address of the given address if known This is the class of branch being recorded This can be gn sb traps or N A if the class in unknown or decode mode is off See Table 57 on page 223 for details of traceable branch classes This is the mnemonic of the branch instruction or if this is not a branch instruction a hexadecimal number The report displays Ox ffffftif decode mode is off Figure 30 shows an example of a branch trace report Figure 30 Example branch trace output 0 to 0x40000b20 in brtrace_subroutine at test_brt branch_sb c 68 from 0x40000858 in funcl at test_brt branch_sb c 27 Mode sb RETURN 1 to 0x40000798 in funcl at test_brt branch_sb c 22 from 0x400009d0 in func2 at test_brt branch_sb c 43 Mode sb RETURN 2 to 0x40000910 in func2 at test_brt branch_sb c 38 from 0x40000aa0 in func3 at test_brt branch_sb c 55 Mode sb RETURN 3 to 0x400009d8 in func3 at test_brt branch_sb c 46 from 0x40000908 in func2 at test_brt branch_sb c 38 Mode sb CALL 4 to 0x40000860 in func2 at test brt branch sb c 31 from 0x40000790 in funcl at test brt branch sb c 22 Mode sb CALL 5 to 0x400006e8 in funcl at test brt branch sb c 15 from 0x40000b18 in brtrace subroutine at test brt branch sb c 67 Mode sb CALL The exampl
189. hows a message describing its version and configuration followed by a command prompt gdb There are many GDB commands available For full instructions on all these commands use the GDB help command or refer to the GNU Debugging with GDB manual All of the commands can be abbreviated to the shortest name that is still unique The GDB command line supports auto completion of both commands and where possible parameters In addition many of the most common commands have single letter aliases Most of the commands serve no purpose until GDB has connected to and initialized a target 8063762 Rev 9 43 246 Cross development tools ST200 44 246 Connecting to a target There is a range of different target types that can be used to debug the executable The connection command varies according to this type The connection commands for st200gdb have three forms based on the following line gdb connection command lt TargetString gt e Connections to several silicon targets are supported by the ST200 TargetPack for these targets the connection command is st200tp The ST TargetPack notation is the recommended method for describing target systems based on ST system on chip SoC devices It is part of the ST Micro Connection Package the software companion of the ST Micro Connect host target interface some legacy silicon targets are not supported For example to connect st200gdb to an IPBR1100 board through an ST Micro Connect
190. hpoints 51 66 190 loader agua XR DRE Rau 15 Windows 25 platforms 13 WZ se coste RE e ai LANANG 34 245 246 8063762 Rev 9 ky ST200 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT T
191. ication on a target board or simulator a detailed description of the target system in the form of an ST TargetPack or simulator pack is specified to st200xrun see Chapter 5 Cross development tools on page 40 for details To get valid results and for benchmarking purposes time functions such as clock require a correct run time configuration The sysconf code module The toolset delivers a set of sysconf code modules located in the tools dir target board directory Within the board directory there is one subdirectory for each board src sysconf c The module managing sysconf parameters for the corresponding board target board 1d The board target specific linker directives including the memory map definition It defines the memory configuration for the board target makefile The makefile to rebuild bootboard o and libboard a A template directory within the board directory contains a template for sysconf c The template shows where to add code to create a new board target used by the toolset The syscon parameters can be accessed directly from a user program For example include stdio h include lt machine sysconf h gt main unsigned int fclock pclock ramsize rambase fclock sysconf SC LX CORE CLOCK FREQ pclock sysconf SC LX PERIPH CLOCK FREQ ramsize sysconf SC LX RAMSIZE rambase sysconf SC LX RAMBASE printf cpu clock dMhz periph clock dMhz ramsize 0x 8 8x rambase 0x 8 8 n clock 10
192. ication with the generated linker script st200cc mboard platform mruntime os21 trace myapp wrap o W1 myapp wrap 1ld Execution Use GDB to load and run the application The following GDB session uses the ST TargetPack st200tp command to connect to the platform gdb file a out gdb st200tp stmc platform core gdb load gdb break main gdb continue Source the command script myapp cmd in order to use the GDB commands for controlling tracing gdb source myapp cmd gdb enable user activity global gdb enable user api global When the trace data has been gathered use f1ush all trace buffers to flush the data to file Finally use os21decodetrace to decode the trace file os21decodetrace e a out user myapp in n os21tasktrace bin os21trace bin Note The user myapp in option is required so that os21decodetrace can interpret the data for the user defined APIs and activities 114 246 8063762 Rev 9 ST200 OS21 Trace 11 7 Trace overhead It should be understood that OS21 Trace is intrusive The level of intrusiveness depends upon the choice of linker and runtime options Therefore take this into consideration when analyzing the trace results as tracing affects the real time behavior of the application The following points identify some of the costs to consider when using OS21 Trace e The default trace buffer requires 2 Mbytes of heap Use the variable os21 trace constructor size fto change
193. ice plugin for the ST200 simulator The source of the sample device plugin is in the standard release tools dir host st200sim src Plugins SampleDevice subdirectory The simulator uses the following functions to communicate with the device plugin The functions are defined in the SampleDevice h header file Devinitialise DEVICE API void DevInitialise void pinout void pinoutStruct char args To enable the plugin to initialize any state it holds this function is called at startup The CPinout reference pinout should be stored so that the other API functions can use it later see Section 8 3 1 Callbacks into the simulator DevTerminate DEVICE API void DevTerminate This function is called at shutdown so that the plugin can release any resources held DevClock DEVICE API void DevClock This function is called once per core clock cycle to enable the plugin to account for time DevRead DEVICE API bool DevRead unsigned char to unsigned int address unsigned int numBytes This function is called whenever a read is requested on the STBus The plugin returns true if a read at the given address is handled It returns false if it does not map the address If 8063762 Rev 9 ky ST200 ST200 simulator 8 3 1 8 3 2 Note Note the plugin decides to handle the request it completes the to array with numByt
194. ies a unique identifier of the form nnnnnnn Rev x where nnnnnnn is the document number and x is the revision Whenever making comments on this document quote the complete identification nnnnnnn Rev x License information The ST200 Micro Toolset is based on a number of open source packages Details of the licenses that cover all these packages can be found in the file 1icense htm This file is located in the doc subdirectory and can be accessed from index htm ST200 documentation suite The ST200 documentation suite comprises the following volumes ST200 Micro Toolset user manual 8063762 This manual describes the overall contents of the ST200 Micro Toolset including brief introductions to the code development tools the OS21 run time kernel library and the STWorkbench interactive development environment It describes in detail the cross development tools used to run and debug an ST200 binary executable on an ST200 simulator or on a silicon target system including an ST200 CPU core It describes the target libraries available and also how to configure the toolset to support a new type of target ST200 Micro Toolset compiler manual 7508723 This manual provides a detailed guide to using the ANSI C and C compiler drivers for compiling and linking source code to produce an executable binary The compiler drivers are introduced in terms of how they fit into the complete ST200 toolchain The manual then concentrates on the facilities
195. ime information can be found in the file trace file ticks for example os21trace bin ticks trace file Usage of the m mode option The various modes of the m option are intended to be used with specific output formats Table 26 shows how the m modes can be combined with the different output formats Table 26 Permitted combinations of mode and output format Output format t option Mode m option summary workbench text csv details Yes No No No metrics Yes Yes No No Zero Yes No No No max Yes No No No min Yes No No No simple Yes No No No ticks Yes Yes Yes Yes usecs Yes Yes Yes Yes 1 Displays real time in microseconds milliseconds seconds minutes and hours Yes indicates that the given mode generates meaningful output when used for the given output format No indicates that the mode cannot be used for the given output format If no t option precedes the m mode option os21decodetrace assumes t summary 8063762 Rev 9 111 246 OS21 Trace ST200 11 5 2 os21decodetrace control file The os21decodetrace options os21 and user both require a control file that describes the APIs and activities being traced For user defined APIs and activities this file is generated by the decode script option of the os21usertrace tool The structure of a control file in modified Backus Naur Form is as follows file format spec list spec list spec spec l
196. imers and one internal interrupt source from the performance monitors Each of these 68 sources has a mask and a test bit associated with it For specific information about the maskable interrupt lines and other information refer to the system specific core SoC board datasheets Interrupt handler installation An interrupt handler is a user defined function that executes whenever a particular interrupt line is raised This API provides the means to specify and install user defined interrupt handlers The interrupt handler has to return BSP OK in case of success interrupt correctly installed or BSP FAILURE and bsp errno set to the corresponding error number in case of failure Interrupts header file machine bsp interrupt h All the definitions related to the interrupts available in bare run time environment are in the single header file machine bsp interrupt h see Table 52 The introduction for the ST240 of two set of interrupts internal and external required the definition of a new API for the interrupt handler All functions that have itc in their name are renamed so that itc is removed For example bsp itc interrupt disable is now bsp interrupt disable Table 52 Functions defined in machine bsp interrupt h Function Description bsp interrupt clear Clears an interrupt bsp interrupt disable Disable an interrupt bsp interrupt enable Enable an interrupt bsp interrupt install Inst
197. including the Debug Variables and Breakpoints views One or more perspectives can exist in a single workbench Each perspective contains one or more views and editors Each perspective may have a different set of views but all perspectives share the same set of editors A view is a window within the workbench It is typically used to navigate through a hierarchy of information such as the resources in the workbench open an editor or display properties for the active editor Modifications made in a view are saved immediately Several views in the Debug perspective can be duplicated to show multiple views of the same type of information with each locked into different contexts in the Debug view For more information see STWorkbench Help Pin and Clone The title bar of the Workbench indicates which perspective and workspace is active In Figure 7 the C C Projects perspective is in use and the workspace is located at C TutorialWorkspace Figure 7 C C perspective 5 C C G Tutorial Workspace STWorkbench C Tutorial Workspace File Edit Refactor Navigate Search Project Run Window Help Ire a Ja S E Debug Run Q External Tools Jes macc Project Explorer 3 B Outin 23 N Make An outiine is not available Problems 3 Z Tasks EJ Console CI Properties lo errors 0 warnings 0 infos Description Resource Path a o
198. ine the symbol L2 CACHE SYSTEM ADDRESS in the board nomem la file or board 1d For example L2 Cache base address L2 CACHE SYSTEM ADDRESS 0X1E000000 2 Ifthe TLBs are configured then define the TLB settings for the L2 cache in the BSP For example bsp memory map t platform 12 maps void amp L2 CACHE SYSTEM ADDRESS 0x200 8 1024 0 7 7 NO MAP bsp memory map t bsp board map init void return platform 12 maps ip 3 In order to connect to hardware and use L2 cache then set the following parameter in the connection string 12cache lt address gt For example st200xrun c st200tp t stmc ip platform core l2cache address e user application st200gdb ex st200tp stmc ip platform core 12cache lt address gt user application Note The 12cache parameter must be used only in the connection with real hardware it is not to be used with a simulator 8063762 Rev 9 193 246 ST200 board support package BSP ST200 B 3 B 3 1 B 3 2 B 3 3 194 246 Memory management Some variants of the ST200 processor ST231 onwards support a memory management unit MMU and a speculative load control unit SCU The MMU has hardware that controls the D cache behavior across address ranges as well as performing the traditional role of controlling virtual address translation and protection The MMU has a fixed number of translation look aside buffers TLBs t
199. ing ee eee eee 183 243 246 8063762 Rev 9 ky ST200 Index polling keyboard input 187 semaphores 24 181 preprocessor Shitdl ias e aaa kaa 94 symbols ad eee ded inaen 92 data tables 2c eee eee 95 printable strings 15 simple allocator 177 profiler ia 14 226 232 simulator rerien eaaa 83 91 PROFILING 89 fast mode cece eee 83 PROFILING_OUTPUT_FILE 89 ISS Mod ssec bi wea eds 83 program execution startup 20 reference mode 83 program termination 186 SuperH aa 14 simulator pack 16 28 37 44 55 57 68 84 90 R SoC CUSTOM neus AG NAA GAN LAGA Kha 37 R Absolute 145 selection 32 R PIC By KAG AA MARA aah NA si dic NS a pad 145 software R HelocatablB 145 notation 12 real time kernel 18 16 22 parameters 42 Red Hat cR 13 source files reference mode 83 RA MM 19 release directories 19 special purpose allocator 175 relocatable loader library 15 145 ST Micro Connect 11 14 23 40 file management 161 connecting to a running target
200. ing the start and end addresses explicitly The start and end addresses can be specified symbolically or with absolute addresses The range subcommand is mandatory when the type of the profiler is set to range 228 246 8063762 Rev 9 ST200 Profiler plugin D 2 Trace profile output format If the profiler type is set to trace using the command profile type trace the profiler trace display consists of a header line followed by a time stamped list of sampled program counter PC values The header line has the following format Trace Profiler saved saved records total total records time end time where e saved records is the number of records saved in the buffer total records is the number of records captured since the profiling session started end timeisthe time of the last record captured since the profiling session started and the profiler was reset Using the trace profiler between two breakpoints provides an simple way to get an approximation of the elapsed time between two given points in an application To do this start or reset the profiler at the first breakpoint then display the profiler data at the second breakpoint The end time value gives the time elapsed between the two breakpoints If the saved records value is less than the total records value the sample buffer has wrapped The number of discarded records is calculated from total records saved records The remainde
201. ion that has special caching issues To manage a memory partition do the following 1 Find the location of the memory and its size This can be implicitly known for example the address and size of on chip RAM is a characteristic of the CPU To select a pool of memory to manage with an allocator declare it statically static unsigned char my device RAM SOME ADDRESS allocate it from another partition static unsigned char my static pool 655360 allocate it from the general heap unsigned char my alloced pool malloc 65536 2 Select the allocation strategy to use with the memory OS21 has three managers see Section A 2 Memory managers on page 177 my pp partition create simple my pool 65536 my pp partition create fixed my pool 65536 block size my pp partition create heap my pool 65536 Alternatively use a special purpose allocator Use the partition create any call to create a partition that uses the required memory management implementation This call takes the size of a control structure that the allocator uses to manage the memory and the addresses of functions that perform allocation freeing reallocation and status reporting The following example implements a simple linear allocator with no ree or realloc methods include lt os21 h gt include lt stdio h gt Declare memory to be managed by our partition static unsigned char my_memory 65536 AA
202. ipS 175 A 1 Managing memory partitions with OS21 175 A 2 Memory managers 177 A 3 0821 schedulerbehavior 178 A 4 Managing critical sectionsinOS21 178 A 4 1 task interrupt critical sections 178 A 4 2 task task critical sections cee 179 ky 8063762 Rev 9 7 246 Contents ST200 Ab Access to uncached memory 182 AG Debugging with OS21 183 A 6 1 Understanding OS21 stack traces 183 A 6 2 Identifying a function that causes an exception 184 A 6 3 Catching program termination with GDB 186 A 7 General tips for GDB ee 186 A 7 1 Handling target connections 186 A 7 2 Windowspathnames 186 A 7 3 Power up and connection seguence 187 A 8 Polling for keyboard input 0 00 cee ee 187 AQ Justintimeinitialization 188 ATO USING CYYWI TC CEPR 189 A 11 Watchpointsupport 190 Appendix B ST200 board support package BSP 191 B 1 Error handling esie EREPARPRN ER E RR a RR REA Gea TEASE
203. ipts implement the connection procedures e simulator targets To retrieve the configuration scripts st200gdb st200insight and st200xrun automatically read the GDB startup script file 1xgdbinit found in the subdirectory 1x e1f32 stdcmd of the ST200 Toolset installation directory Note ST TargetPack the connection support package for ST200 hardware platforms is described in the ST TargetPack user manual 8020851 The simulator pack which has the same role for simulated targets is described in Section 8 1 Simulator pack on page 84 1 2 4 Sources This package contains full sources for the OS21 real time kernel library The combined source package containing the open source components of the ST200 Micro Toolset can be found on the ftp site from which the toolset was obtained 1 2 5 Examples Various example applications including those using OS21 and illustrating the construction of Flash ROM systems are supplied see Section 1 5 The examples directory on page 20 16 246 8063762 Rev 9 ky ST200 Toolset overview 1 3 Note 1 3 1 Note Libraries delivered ANSI ISO C and C run time libraries and header files are shipped with the ST200 Micro Toolset supporting both OS21 and bare machine applications for various target application configurations A bare machine application is a non OS21 application built without real time kernel libraries Figure 1 The relationship between the libraries Applicatio
204. irectly by acting on the timer registers that hide the differences between ST200 cores These functions are not checked against conflicts against other timer functions for example bsp timer now and should be only used to program user timer 2 and eventually the user timer 1 if profiling is not enabled Table 46 Functions defined in machine bsp timer h Functions Description bsp timer start Start the timer bsp timer start all Start all the timers bsp timer stop Stop the timer bsp timer divide set Set the TIMEDIVIDE registry bsp timer divide get Get the TIMEDIVIDE registry Set the initial value of the counter of the specific bsp timer count set timer T Get the initial value of the counter of the specific bsp timer count get i timer Y Set the value to be reloaded into the specific timer bsp timer reload set on reaching zero bsp timer reload get Get the reload value of the specific timer bsp timer interrupt enable Enable the timer interrupts the processor bsp timer interrupt disable Disable the timer interrupt bsp timer interrupt clear Clear the timer interrupt B 4 5 Timer header file machine bsp timer h All the definitions related to the timer available in bare run time environment are in the single header file machine bsp timer h see Table 47 and Table 48 Table 47 Functions defined in machine bsp timer h Function Description bsp timer now Return the current time Set a user timer eventual
205. ist spec spec A code group class name parameter type spec P code group class name return type spec parameter type spec return type spec format format type list parameter type spec format format type list type list type type list type where codeis a number group class name format and type are strings e A record of type A specifies an activity and a record of type P specifies an API e group class name is the same as used in the USER API and USER ACTIVITY specifications but with all white space removed See Section 11 1 2 on page 100 format is a concatenation of all the format codes specified for the parameters of an API or activity It is zero length for a void return type or an empty parameter list in which case a type 1ist is not present 5 typeis the the same as used in the USER API and USER ACTIVITY specifications but with all superfluous white space removed See Section 11 1 2 on page 100 a 112 246 8063762 Rev 9 ST200 OS21 Trace 11 6 Examples 11 6 1 OS21 activity and OS21 API trace A simple example is provided in the examples os21 0s21 trace directory of the toolset A makefile is available in this location to build run the application and decode the resulting OS21 Trace Data is automatically dumped to the host in a file called test tracedump A README file provides further details about how
206. ivalent to the option interpreter tui Debugs the program exe and passes the command line c d arguments args to the program exe Processes the command line options including any scripts from the batch command option and then exits This option is similar to batch except that the debugger batch silent suppresses all normal output messages other than errors command file Sources the commands in the file file This is useful for setting up x file functions or automating downloads Executes the specified GDB command command This option can eval command command be specified multiple times to execute multiple commands When ex command used in conjunction with command the commands and scripts are executed in the order specified on the command line 8063762 Rev 9 ky ST200 Cross development tools 5 3 5 a Table 8 st200gdb command line options continued Option Description interpreter interface ui interface i interface Sets the GDB user interface to interface Standard user interfaces are console tui insight and mi The return value given by GDB is the return value from the target return child result application unless an explicit value is given to the GDB quit command or an error occurs GDB command quick reference Table 9 lists some of the most useful GDB commands It does not include any of the additional commands for connecting and
207. l errno rl handle t handle handle The handle for the module The error code for the last failed function The rl errno function returns the error code for the last failed function Table 34 lists the possible codes Table 34 Errors returned by rl errno Possible error causing Error code Diagnostic function RL ERR NONE No previous call has failed load buffer load file load stream set file name Ran out of memory r1 memalign RL ERR MEM ma failed Bip Dt load buffer load file load stream set file name RL ERR ELF The load module is not a valid ELF file Bi Bi 8063762 Rev 9 ky ST200 Relocatable loader library Table 34 Errors returned by rl errno continued Error code Diagnostic possibls BITBI causing function rl load buffer pa rl load file RL ERR DYN The load module is not a dynamic library tl load stream rl_set_file_name rl load buffer The load module has invalid segment rl load file RL ERR SEG information rl load stream rl set file name rl load buffer The load module contains invalid rl load file RL ERR REL relocations rl load stream rl set file name A symbol was not found a load time El load buffer HL San EHDSYM t th bol rl load file
208. l or Natural mantissa and exponent for floating point values Edit Edit the expression value Delete Delete the highlighted expression from the list Dump Memory at Displays the selected watch expression in the Memory window Help Displays the online help window Close Close the Watch window 8063762 Rev 9 75 246 Using Insight ST200 Note 7 11 76 246 The display of values can also be adjusted by normal C type casting Structures and classes can be expanded as a tree The look and feel of the Watch window was enhanced in Insight 6 1 The following information is displayed for each item item name type value string pointed by value as an address gt Using the Local Variables window The Local Variables window shows all the variables in the current stack frame To open the Local Variables window either click the button or from the View menu in the Source Window select Local Variables Figure 20 Local Variables window Local Variables fp FILE x 8x18 buf char 8x8881d1f8 Lxbuf char 8 X8 mode int 2013210464 size size t 2281826652 ret int 2013177208 Right click on a variable to open following the context sensitive menu options Format Change the format of the variable It can be Hex Decimal Octal Binary or Natural mantissa and exponent for float variables Edit Edit the value of the selected variable Delete Delete the highlighted
209. lator s bundle checking on pres B mode This checks that each instruction bundle obeys the rules true specified in the Core and Instruction Set Architecture manuals B NDEE CHECKING Setting this item to true prints an error message to the screen o when the simulator s bundle checking mode detects an illegal false RE ON bool bundle 88 246 8063762 Rev 9 x ST200 ST200 simulator Table 17 Target configuration options continued Option PROFILING bool Description When this is set to true the simulator produces the following gprof style output files gmon out standard execution profile gmon outDCACHE time spent in each function waiting on Dcache stalls gmon outICACHE time spent in each function waiting on Icache stalls Default value false PROFILING _ OUTPUT_FILE lt filename gt By default profiler information is recorded in a file in which the last part of the filename is an incrementing integer for example 0042 The width of this numeric field is determined by the form of the filename For example gmon results in a succession of filenames gmon0000 gmon0001 and so on gmon DEVICE_PLUGIN_ MODULES lt filename gt filename Device plugins are used to simulate memory mapped devices on the STBus Multiple plugins can be specified by separating their names with a semicolon For example
210. lete Flash ROM image file that can be created by the mkbinrom p1 tool as its input To create a self flashing executable tool that programs the Flash ROM from the embedded image the flasher tool can be combined with a Flash ROM image created by the mkbinrom p1 tool All Flash ROM examples create a self flashing executable tool The flasher tool has a companion tool called flashdir that displays the contents of Flash ROM The mkimage p1 Perl script converts target executable files into the component image file format It can process ST40 and ST200 ELF files executable files and relocatable libraries as well as ST20 hex and S record ROM format files Executable files and relocatable 8063762 Rev 9 ky ST200 Booting OS21 from Flash ROM libraries are decomposed into a number of sections that are placed in the component image file To update the existing contents of Flash ROM use the flasher tool with component image files Any component image file placed in Flash results in an update to the Flash directory pages Multiple application images can be stored in Flash Each image is tagged in the Flash directory with its relevant CPU A CPU can have multiple application images stored in Flash but only one is tagged as the boot application for that CPU The mkbinrom p1 Perl script creates a complete binary ROM image in a single file It takes component image files as input as well as executable and relocatable library ELF files dire
211. linker see Chapter 4 Board target configuration on page 27 This example compiles hello c using the default run time library bare to be linked with the executable and the default mode of endianness little endianness used for code generation The endianness can be selected by adding EB or EL to the command line The run time can be selected by adding mruntime bare or mruntime os21 see Appendix B ST200 board support package BSP on page 191 and Chapter 2 Introducing OS21 on page 22 8063762 Rev 9 ky ST200 Board target configuration 4 Board target configuration In the context of the ST200 toolset a board target or board identifies e asilicon target composed of one core processor on a specific System on Chip SoC e aspecific system board e allthe resources assigned to the processor including the assigned RAM address space by hardware or software design choices peripherals For example the STi7109 Mboard MB442 is based on one STi7109 SoC that has one ST40 core two ST231 cores and a complex set of on chip peripherals Therefore this system board hosts a number of boards as intended in the ST200 development system terminology identified as mb442 audio mb442 video mb442 7109 audio mb442 7109 video mb442 se 7109 audio and mb442 se 7109 video The toolset supports all of these boards This chapter describes e howto configure the run time for a board e the contents of the toolset target dep
212. ls If n is specified do this n times print exp r printf format arg1 argn Prints the value of the expression exp or contents of the register r for example r0 or pc Same as print but with a format string It enables more than one parameter to be printed Parameters must be separated by commas quit code Exits GDB with the return value code if specified If code is not specified GDB exits with the return value of 0 Note that the GDB convenience variable exitcode is set to the return value of the target application and therefore may be used as the value for code for example quit exitcode rbreak regexp regs Sets a breakpoint on all functions that match regexp Prints the contents of the registers info registers provides more information run file args Runs the program The program must already have been downloaded using 1oad when using the GDB simulator If an executable was given on the command line then file must not be given here set args args list The command set args takes a list of arguments to be passed to the application program Used before starting the program set variable Sets the value of a variable or register var exp Continues execution to next source line If n is specified do this n step n times stepi n Executes exactly one instruction If n is specified do this n times ky 8063762 Rev 9
213. lset overview ST200 1 3 2 1 3 3 1 3 4 Note 18 246 The C library libstdc The C library is part of GNU Compiler Collection and uses the underlying C library for its basic functionality The libdtf library libdtf is intended to be the newlib backend library To enable access to I O and other system resources through a standardized trap interface recognized by the GNU GDB simulator libdtf implements the interface between newlib and the underlying system The data transfer format DTF component The DTF component of the libdtf library implements the POSIX I O mechanism used with the ST Micro Connect or the ST200 simulator It implements most of the basic file 1 0 features required by the C library The debug link performs the I O and requires the correct host side software to be present the supplied GDB connection commands handle this automatically The syscalls low level I O interface The syscalls low level I O interface consists of the following functions The functions are _chmod _chown _close_r _creat _execv _execve_r _exit _fork_r _fstat_r _getenv _getpid_r _gettimeofday_r _kill_r _link_r lseek_r _open_r _pipe _pollkey _raise _read_r _readenv_r _rename_r _sbrk_r _stat_r _system_r _times_r _unlink_r _utime _wait_r _write setup_argv_and_call_main writev isatty The syscalls functions provide all the I O entry and exit and process control routines that
214. lue right click on a register s value to open the following context sensitive menu options Hex Decimal Unsigned Change the format Open Memory Window Open a Memory window at the location specified by the currently selected register see Section 7 9 Add to Watch Remove from Display Display all Registers Help Open the online help window Close Close the Registers window Add the selected register to the Watch window see Section 7 10 on page 75 Delete the selected register from the window Restore all registers that have been removed from the display To view only the registers belonging to a specific group general float system vector all use the Group selection box 8063762 Rev 9 ST200 Using Insight 7 9 Using the Memory window The Memory window enables you to view and modify the current state of memory on the target The window can be resized to view more memory information To open the Memory window either click the button or from the View menu in the Source Window select Memory Figure 17 Memory window Memory Addresses Address 0x0000000008019270 m Target is LITTLE endian 8 4 8 t ASCII 6x 6666666668619276 6x66782578 Ox32534F Ba 8x2a283a31 8x454282a2a xZx 0S21 xxx D 6x 66666606086192860 6x73617369 6x626d6573 8x6f28796c 6x26796c6e isassembly only 6x 6060000968 619290 6x69617661 6x6c62616c 6x6e692665 6x62656426 available in deb 8x88888888888192a8
215. ly attach an interrupt bsp timer_user handle and enable the corresponding interrupt bsp timer ticks per sec Return the number of clock ticks per second Table 48 Types defined by machine bsp timer h Type Description bspclock t Number of processor clock ticks 8063762 Rev 9 197 246 ST200 board support package BSP ST200 B 5 B 5 1 B 6 B 6 1 198 246 Performance monitor PM The PM module is a hardware instrumentation system that enables you to simultaneously monitor up to four events in a variable set of predefined events Hardware abstraction layer for the PM module The BSP has a set of functions to help program the performance monitor directly acting on the registers see Table 49 Table 49 Functions defined in machine bsp pm h Functions Description bsp pm reset Reset all counters bsp pm start Start all the event counters bsp pm stop Stop all the event counters bsp pm clock get Read the PM Clock counter bsp pm clock set Write the PM Clock counter bsp pm counter get Read the current value of a PM counter bsp pm counter set Write change the current value of a PM counter bsp pm event get Returns the event monitored by the PM counter bsp pm event set Set the event being monitored by a PM counter Exception handling Exceptions on the ST200 can occur for the following reasons e program request syscall instruction e
216. mes An editor is a visual component within the workbench It is typically used to edit or browse a resource Multiple instances of an editor may exist within a workbench window Depending on the type of file being edited the appropriate editor appears in the editor area For example if a txt file is being edited a text editor appears The name of the file 60 246 8063762 Rev 9 ky ST200 Using STWorkbench appears in the editor tab If an asterisk appears on the left of the tab it shows the editor has unsaved changes If you try to close the editor or exit the workbench without saving a prompt to save the editor s changes appears When an editor is active the workbench menu bar and toolbar contain operations applicable to the editor When a view becomes active the editor operations are disabled However certain operations may be appropriate in a view and remain enabled The editors can be stacked in the editor area Click the tab for a particular editor to use it Editors can also be tiled side by side in the editor area so their content can be viewed simultaneously Changing a perspective s views The views that make up a perspective can be changed For example to add the Disassembly view to the Debug perspective perform the following steps 1 If necessary change to the Debug perspective by selecting Window gt Open Perspective Debug or Window Open Perspective Other Debug 2 Select Window Sh
217. module data in the buffer buffer of length Length until the module is loaded into memory The loader always calls the callback function with a buffer length strictly greater than 0 The stream cookie argument passed to rl load streamis passed to the callback function in its cookie parameter The cookie parameter is intended to be used by the callback function to update a private state The callback function must return the number of bytes transferred If the returned value is less than the given buffer length or is 1 x1 load stream will in turn return an error and the error code returned by x1 errno is set accordingly The r1 load stream function allocates the space for the loaded module from the heap loads the segments by calling the callback function links the module to the parent module of the handle relocates and initializes the loaded module This function calls the action callback functions for RL ACTION LOAD after loading and before executing any code in the loaded module 0 is returned if the load was successful 1 is returned on failure and the error code returned by r1 errno is set accordingly This function can be used as an alternative to x1 load buffer or rl load file to allow any loading method to be implemented 8063762 Rev 9 153 246 Relocatable loader library ST200 rl unload Definition Arguments Returns Description 154 246 The following example illustrates how the x1 load file
218. mp all user definable options to the specified file filename MODE FAST ISS The operation mode the options are FAST ISS and REFERENCE REFERENCE REFERENCE REF or REF See Chapter 4 Board target configuration on page 27 Valid values are ICACHE MODEL NANA See Table 18 on string BASIC page 90 DETAILED For a detailed description see DCACHE_MODEL Although the following explanation refers to DCACHE_MODEL values it applies to both data and instruction caches see ICACHE_MODEL NONE Cache modelling is not required In practice this situation is modelled using a null cache that transmits requests through to a simple bus model BASIC A more detailed model that takes account of the cost of memory transactions through user configurable latencies When basic cache models are specified for both instruction and data caches they act independently and do not accurately represent situations where bus transactions would interact It does not model some DCACHE_MODEL parts of the memory subsystem for example the write buffer and See Table 18 on lt string gt prefetch buffer page 90 DETAILED Incorporates a more accurate account of the interaction between the caches and the bus In particular the data cache has an added write back buffer Both caches compete for bus cycles through the CMC core memory controller and the bus itself models the latency associated with the bus and its attached devices Noncached r
219. mpilation directory comp dir annotation e foreach matching function name in the compilation unit the name of the function 44 unction annotation the function prototype dec1 annotation and an equivalent function prototype specified with compatible base types base dec1 annotation e ifnofunction definition can be generated because its specification is not supported by OS21 Trace then the reason is included in the 4t function annotation In addition e functions appear in the definitions file in the order that they are defined in the DWARF debug information not in the order they are specified on the command line e afunction definition can only be defined once in the definitions file 8063762 Rev 9 105 246 OS21 Trace ST200 11 1 4 os21usertracegen example This section shows an example using an ELF executable file to demonstrate the flexibility of the os21usertracegen tool 1 The first step is to link the application compiled with DWARF debug information enabled to generate an ELF executable file called myapp out st200cc application link options g o myapp out 2 From the ELF executable file created in step 7 match function names that do not start with DEBUG write and have been compiled in a directory ending in debug and output their definitions to the file myapp debug other def os21usertracegen i myapp out o myapp debug other def d myapp directory debug g debug c other DEBUG wri
220. n i Relocatable loader Compiler librl alibrl s so a P GE intrinsic library 0821 C pei Program libos21 alibbsp a libstdct a libgcc eh a code v A Target specific newlib libraries Tipe libcore a libm a libsoc a libboard sa Back end Y H interface syscalls m Data transfer format Communication Data transfer format System i ST200 simulator Hardware The header files shipped with the toolset are located in the include subdirectory of the release installation directory and include the header files for OS21 support The OS21 header files are located under include os21 The target specific libraries are made available including the header file include platform h The C library newlib newlib implements a version of the C library that is suitable for use in embedded systems newlib supports the most common functions used in C programs but not the more specialized features available in standard operating systems such as networking support Wide character support is not enabled in the supplied version of newlib newlib assumes a minimal set of OS interface functions the syscalls API These provide all the I O and process entry and exit control functions required by programs using newlib The syscalls API is implemented by the libdtf library 8063762 Rev 9 17 246 Too
221. n Run time initialization Before calling main the following default initialization is performed in init core e the ST200 exception handler is setup e the hardware is initialized for clock function setting in bare mode only e the memory access units and dismissable loads behavior are set to a default value e performance monitor initialization for ST240 targets The default setting for the memory access unit is iis initialized to enable the use of the data cache for all memory access between text start and ramend and prevents any dismissable load in the peripheral control register area The default initialization sequence is located in the libcore a libboard a and libsoc a modules linked with the program The source code for the initialization sequence is in the following directories tools dir target core st2xy src lt tools dir gt target board lt board gt src tools dir target soc soc src 8063762 Rev 9 ky ST200 Cross development tools 5 2 5 5 3 5 3 1 Initialization hook If itis necessary to change the behavior of the init sequence before main for example peripheral initialization or target environment setup use the hook mechanism put in place in the startup phase of the run time To enable user initialization of hardware or software before executing the main program there are two types of hooks e Thebsp user start handle andbsp user end handle are invoked from
222. n in the Target Selection window is selected this is the first real line of the program Figure 13 Breakpoint examples 2 3 int main void ms 4 a return 8 l O oc The red square in the left hand margin indicates the position of a breakpoint The hyphens indicate valid positions for potential breakpoints The green highlighting shows the position of the current PC program counter Orange highlighting shows the current position in that stack frame the real position is at the top of the stack When the mouse pointer hovers over a variable or function name a tooltip shows the current value of that variable Variables and types have a context sensitive menu right click on the item to open the context menu that has various actions for example setting watchpoints and dumping memory To set a breakpoint click on the hyphen next to the line of code The breakpoint is shown as a red square Right click on a breakpoint position shown as a hyphen to open the context sensitive menu for the following breakpoint options Set Breakpoint Set a breakpoint on the selected line The breakpoint is shown as a red square Set Temporary Breakpoint Set a temporary one time only breakpoint on the selected line The breakpoint is shown as an orange square Set Breakpoint on Thread s Seta breakpoint on the thread If more than one thread is available the Thread Selection window is displayed to select the requi
223. n include lt platform h gt int bsp timer start int timer Arguments timer The timer to start see Table 45 ST200 timer assignments on page 196 Returns Returns the error condition Description This function starts the timer It should only be used with TIMER1 and TIMER2 however TIMER2 should only be used if the profiler is not enabled Do not use this function with TIMER SYSTEM bsp timer stop Stop the timer Definition include lt platform h gt int bsp timer stop int timer Arguments timer The timer to stop see Table 45 ST200 timer assignments on page 196 Returns Returns the error condition Description This function stops the timer It should only be used with TTMER1 and TIMER2 however TIMER1 should only be used if the profiler is not enabled Do not use this function with TIMER SYSTEM bsp timer ticks per sec Return the number of clock ticks per second Definition include lt platform h gt bspclock t bsp timer ticks per sec void Arguments None Returns The number of ticks per second Description bsp timer ticks per sec returns the number of clock ticks per second ky 8063762 Rev 9 221 246 ST200 board support package BSP ST200 bsp timer user Set a user timer attach an interrupt handle and enable the Definition Arguments Returns Description 222 246 corresponding interrupt include lt platform h gt
224. n boards supplied by STMicroelectronics for which the TargetPack is not available and for the simulator targets see Chapter 8 ST200 simulator on page 83 1 5 The examples directory The examples directory has a set of subdirectories with examples of programs that use the bare run time bsptest clock example cpuclock hello hellomulti lpng125 profiling sleep symbolise syscalls 20 246 Usage of the bare run time cannot run in OS21 mode Possible implementation of the posix clock call based on ST200 run time The clock function is obtained using the bsp timer now function Contains an example that shows how to measure elapsed time between two C code lines of a ST200 program Contains a simple Hello World program Contains an example of parallel debugging on multiple ST200 cores Contains an implementation of the png library This is an example of a nontrivial application that includes two static libraries How to build an application for profiling and how to use st200gprof Illustrates the use of the system function to execute a Sleep seconds command on the host Illustrates the use of the st200symbolise st240symbolise tool to augment the simulator STISS trace with a large amount of information delivered from the trace Contains a sample implementation of the syscalls low level I O interface see Section 1 3 4 The syscalls low level I O interface on page 19 806
225. n various formats The convenience variables and GDB commands are similar to those generated by the gdb mmrs option of the sttpdebug tool provided in the ST Micro Connection Package See ST TargetPack user manual 8020851 for information about the sttpdebug tool These features are accessible through the GDB targetpack command The targetpack command When a host connects to a target using an ST TargetPack the targetpack command is enabled automatically It can also be enabled by issuing the GDB command enable target as defined in the GDB command script file targetpack cmd The targetpack command has the following format targetpack subcommand options This command controls the ST TargetPack function specified by subcommand and options The subcommands supported by the targetpack command are listed in Table 61 Table 61 Targetpack subcommands Subcommand Options Description Display help for the targetpack command If help subcommand subcommand is specified then more detailed help for subcommand is displayed Import the ST TargetPack register set associated with the specified targetstring If connecting to a target using the st200tp or related connection command then the command targetpack import is automatically invoked after connecting to the target import targetstring Export the register convenience variables and commands into GDB To export the convenience export file variables and commands to a GDB command
226. nd line gt st200xrun c st200sp t st231simle e hello out The command st200sp hooks the simulator pack to st200xrun and the TargetString st231simle identifies the ST231 default simulator configuration in little endian mode Customized simulator targets From R6 0 of the ST200 toolset all supported boards have a board definition for the simulator The customization uses the same memory layout as the real hardware and configures the PLL clock registers to the same values found on the boards Applications that are compiled for a real board can run on a simulated board without modification A GDB command script located in the ST200TOOLS 1x elf32 stdcmd subdirectory manages the ST200 simulator The simulated target is selected by st200gdb and st200xrun using st200sp as the command and an appropriate procedure name as the target For example to run the hello application on a simulated IPBR1100 board mb424 use the command st200xrun c st200sp t mb424sim e hello out or st200gdb hello out gdb st200sp mb424sim To add a specific customization change the configuration string inside the correct st200targets lt board gt cmd file The following example changes the clock frequency of the core for the IPBR1100 board 1 Open the st200targets mb424 cmd file with the editor 2 Locate the correct command in this case mb424sim 3 Locate the configuration string CORE MHZ 300 PERIPHERAL BASE 0x30000000 EXTERNAL MEMORY
227. newlib requires DTF provides four additional functions opendir closedir readdir rewinddir The example provided with the toolset contains minimal implementations of the functions These versions are sufficient to compile link and execute an application see the syscalls directory in the examples directory However the application cannot perform I O or utilize any of the services that these functions provide until fully implemented versions are provided The example implementation provides an overview of each function but for further information the POSIX standard should be used as a reference It is not required to implement all functions 8063762 Rev 9 ky ST200 Toolset overview 1 4 1 4 1 Release directories Table 1 lists the directories of the installation Some of these directories are described in more detail in the following sections Table 1 The release directories Directory Contents bin The tools dus The documentation set see Section 1 4 1 The documents directory examples Example applications include C C library header files lib cmplrs Host compiler library files lib core endianess runtime Run time library files lx elf32 stdcmd GDB command script files see Section 1 4 2 GDB command scripts directory man man manual pages microprobe ST Micro Connect support files share GDB GUI configuration files src ST200 source fil
228. ng the application source the generated command script see Section 11 4 Running the application on page 106 The element user in the names of the GDB commands listed in the following sections can be changed with the option user prefix of the os21usertrace tool User activity control commands os21usertrace creates the following commands for controlling the generation of trace records for user activities Use these commands for enabling or disabling tracing for any group class or named activity that was specified in the os21usertrace definition file If no user activities are defined then none of the following commands are defined show user activity groups Display all the user activity trace groups in the application as a simple list enable user activity group all disable user activity group all Enable or disable the logging of all the activities for all groups show user activity group all Display the logging status of all the activities for all groups show user activity group group classes Display all the classes of the user trace group group where group is one of the groups listed by show user activity groups enable user activity group group class all disable user activity group group class all Enable or disable the logging of all the activities for all classes of the user trace group group show user activity group group class all Display the logging status of all the activities for all classes of the
229. ng the value of the variable LIST CONFIG with the required configuration and modify the path to include the defines mkf file in toolset dir target defines mkf The valid values for LIST CONFIG have the following format core endianess runtime For example LIST CONFIG st231 le bare LIST CONFIG st231 le os21 6 Update the src sysconf c and src init c files with the board specific code The file sysconf c contains the sys custom sysconf function pointer which must point to the board specific function boardname sys custom sysconf This function is also contained in sysconf c and returns the board configuration parameter of choice The init c file contains two functions which can be customized and that are executed respectively at the beginning and at the end of the execution 7 Build the board library running make in the board directory for example a Navigate to new target dir board my board b make A new directory tree is created to contain the libraries for the selected configurations For example if the only selected configuration is st231 1e bare see step 5 the following directory is created new target dir board my board st231 1le bare This directory contains 1ibboard a used when building an application for this board 36 246 8063762 Rev 9 ky ST200 Board target configuration 4 3 4 4 4 8 Create new TargetPack and simulator pack files for the new
230. not operating in wrap mode the data is logged into the buffer only while space is available When the buffer is full no more logging occurs until the buffer is emptied and reset When the buffer full breakpoint is raised a GDB script invokes the appropriate function to flush the buffer and then continues The function is one of the following foros21 trace set mode the script calls flush os21 trace buffer foros21 task trace set mode the script calls flush os21 task trace buffer This means that the contents of the buffer are automatically extracted when full to provide a complete log However the target is stopped for a comparatively long time during each download Enable OS21 Trace enable os21 trace Enable OS21 Trace logging for both OS21 and user trace events OS21 Trace logging is enabled by default disable os21 trace Disable OS21 Trace logging enable os21 trace Display the status of OS21 Trace logging 8063762 Rev 9 117 246 OS21 Trace ST200 11 9 3 11 9 4 11 9 5 118 246 Enable trace control commands The following GDB commands control the saving of arguments and context information in the trace records for both OS21 and user trace events enable os21 trace control control Enable the saving of the information indicated by control where control is one of the following save activity save api enter save api exit save activity args save api enter args save api exit
231. ns 0 if no key was pressed 1 if a key was pressed No errors are returned Description _pollkey polls the host keyboard for a keypress If no keypress is detected the function returns O If a keypress is detected then the function returns 1 and the int pointed to by keycode receives the ASCII keycode of the key that was pressed ky 8063762 Rev 9 187 246 Toolset tips ST200 A 9 188 246 Just in time initialization A common problem when writing a library is performing just in time initialization It is usually accepted that the first thread to call a library function is responsible for initializing it This often requires allocating memory or synchronization objects like semaphores The problem is how to ensure that this is atomic that is the initialization is performed precisely once Allocation can result in the caller blocking therefore special consideration has to be given as to how to achieve this atomic initialization The following example describes a simple strategy that guarantees atomicity For a library to initialize the first caller must create a semaphore to serialize access to the library resources The following code which omits error condition checking to aid clarity guarantees that the semaphore is created precisely once static semaphore t volatile library sem if library sem NULL f semaphore t local sem semaphore create fifo 1 task lock if library sem NULL library_sem
232. objects can be declared as internal hidden visibility This option can be used to specify these visibility declarations In this case only the functions that are external have an associated overhead The other internal functions have a very reduced overhead For a full inter procedural optimization of the relocatable library use the ipa option In this case when combined with the declaration of external functions the library is generated with a minimal overhead for the dynamic linking support For detailed information on the visibility specification refer to the compiler options documentation and to the ELF System V Dynamic Linking ABI 8063762 Rev 9 163 246 Relocatable loader library ST200 12 6 164 246 Debugging support The debugging of dynamically loaded modules is possible in the same way as for System V dynamic shared objects The main module debugging information loads at load time of the application The load modules debugging information loads at load time of the load modules To update debugging information the loader maintains a list of loaded modules together with their filenames the file contains the debugging information and the load address of the module Each time a new module loads the loader calls a specific function The debugger has to set a breakpoint on this specific function and when the breakpoint is hit traverse the list to find new loaded modules and load the debugging information For the
233. ode 215 archiver 13 bsp pm counter get 215 assembler 14 bsp pm counter set 215 bsp pm event get 216 bsp pm event set 216 B bsp pm reset 216 Backus Naur Form 12 bsp pm start 216 binutils bsp pm stop IIIA 217 GNU package 14 bsp rtrecord get 217 BNF See Backus naur Form bsp scu disable nkong an ahn WA HG AG 217 board bsp scu dump SCU Settings 217 DUBD UB doe eub abra Had ERG 27 bsp scu read 218 selection 32 bsp scu write 218 board support bsp timer count get 218 libraries AA AA 16 94 bsp timer count sel 219 Deco sas 24 bsp timer interrupt clear 219 board targets bsp timer interrupt enable 219 building and debugging 37 bsp timer now 220 configuration 27 bsp timer reload get 220 CUSTOM s kasa day oae aan uted ane 34 bsp mer reload set 220 generating code 28 bsp timer start aaan 221 BOOT FROM RESET 87 bsp timer stop 221 BOOT ROM
234. of each parameter for the API as the return type is always void if type specifies an explicit function pointer type that is type is not a typedef then a s placeholder for the parameter name must be inserted into the type definition This is to aid os21usertrace in the generation of the C source file For example if the parameter type is int void then the type specification must be int s void 8063762 Rev 9 101 246 OS21 Trace ST200 Table 22 lists the available format codes used by type spec Table 22 Format codes Code Description b 8 bit word B pointer to 8 bit word w 16 bit word W pointer to 16 bit word d 32 bit word D pointer to 32 bit word q 64 bit word Q pointer to 64 bit wordl s string p object pointer function pointer T OS21 task t pointer 1 Ifa NULL pointer is used with these format codes the de referenced value is assumed to be zero 2 If a NULL pointer is used with a string an empty string is assumed The following restrictions apply e Strings are truncated to 255 characters e APIs with variable argument lists are not supported If possible convert the API into an equivalent form that takes a va list parameter and define this in the definition file For example replace int TRACE Print const char format withthe following int TRACE VPrint const char format va list args f int TRACE Print const char
235. of the fields described in Table 28 Table 28 File format of os21trace bin ticks Field Format Comment version INT32 For the current version this is 0x00000003 Size of the trace code field in the code size INT32 os21trace bin format see Table 27 The valid sizes are 1 2 or 4 bytes tick rate INT64 time ticks per sec last time INT64 time now for most recent trace record 116 246 8063762 Rev 9 ky ST200 OS21 Trace 11 8 3 11 9 11 9 1 11 9 2 os21tasktrace bin This file contains the contents of the task information buffer It is a sequence of records where each record has the structure given in Table 29 Table 29 File format of os21tasktrace bin Field Format Comment handle INT32 Task task t object pointer priority INT32 Task priority when created stack base INT32 Location of task stack stack size INT32 Size of task stack task name INT8 16 Task name GDB commands This section lists the OS21 Trace GDB commands accessible when the file os21trace cmd is sourced within GDB For more information on a given command use the GDB command help command Buffer full action os21 trace set mode stop wrap Default mode is wrap os21 task trace set mode stop wrap Default mode is stop If either mode is set to stop then a breakpoint is enabled to signal when the buffer is full If set to wrap this breakpoint is disabled If the buffer is
236. om a loaded module it returns the handle that holds the loaded module This function is used when allocating a handle with x1 handle new It can also be used for example to retrieve a symbol in the current module void symbol ptr rl sym rl this symbol ky 8063762 Rev 9 149 246 Relocatable loader library ST200 rl parent Return the handle for the parent of the current handle Definition rl handle t rl parent void Arguments None Returns The handle for the parent of the current handle Description The rl parent function returns the handle for the parent of the current handle as returned by r1 this It may be used for example to find a symbol in one of the parent modules void symbol in parents rl sym rec rl parent symbol rl load addr Return the memory load address of a loaded module Definition const char rl load addr rl handle t handle Arguments handle The handle for the loaded module Returns The memory load address of the loaded module or NULL Description The r1 load addr function returns the memory load address of a loaded module It returns NULL if the handle does not hold a loaded module or if the handle passed is the main program handle rl load size Return the memory load size of a loaded module Definition unsigned int rl load size rl handle t handle Arguments handle The handle for the loaded module Returns The memory load size of the loaded modul
237. on handler ExceptionNumber The exception to which the handler has to be attached Returns On successful completion bsp core interrupt install returns BSP OK otherwise it returns BSP FAILURE and sets bsp errno to indicate an error Description This function installs the exception handler for the exception specified in ExceptionNumber See also bsp core interrupt lock bsp core interrupt unlock bsp core interrupt lock Disable external interrupts at core level Definition include lt platform h gt int bsp core interrupt lock void Arguments None Returns On successful completion bsp core interrupt lock returns BSP OK otherwise it returns BSP FAILURE and sets bsp errno to indicate an error Description This function disables all external interrupts at core level See also bsp core interrupt install bsp core interrupt unlock ky 8063762 Rev 9 205 246 ST200 board support package BSP ST200 bsp core interrupt unlock Enable external interrupts at core level Definition include lt platform h gt int bsp core interrupt unlock void Arguments None Returns On successful completion bsp core interrupt unlock returns BSP OK otherwise it returns BSP FAILURE and sets bsp errno to indicate an error Description This function enables all external interrupts at core level See also bsp core interrupt install bsp core interrupt lock bsp interrupt clear Clear a specific interrupt De
238. on iterates over all the segments of the loaded module handle and calls back the user supplied function For each segment the function callback fnis called with the following parameters handle The handle passed to the function seg info The segment information pointer filled with the current segment information cookie The callback cookie argument passed to the function The segment information returned in seg info is a pointer to the following structure typedef unsigned int rl segment flag t define RL SEG EXEC 1 define RL SEG WRITE 2 define RL SEG READ 4 struct rl segment info t const char seg addr unsigned int seg size rl segment flag t seg flags Yi The user callback function must return 0 on success or 1 on error In the case where the callback function returns an error the rl foreach segment function returns 1 and the error code returned by rl errno is set to RL ERR SEGMENTF Otherwise the function returns 0 8063762 Rev 9 ST200 Relocatable loader library rl add action callback Add a user action callback function to the user Definition Arguments Returns Description action callback list typedef unsigned int rl action t define RL ACTION LOAD 1 define RL ACTION UNLOAD 2 define RL ACTION ALL rl action t 1 typedef int rl action func t rl handle t handle rl action t action void cookie int rl add
239. on of trace records for user APIs Use these commands for enabling or disabling tracing for any group class or named API that was specified in the os21usertrace definition file Note If no user APIs are defined then none of the following commands are defined show_user_api_groups Display all the user API trace groups in the application as a simple list enable user api group all disable user api group all Enable or disable the logging of all the APIs for all groups show user api group all Display the logging status of all the APIs for all groups show user api group group classes Display all the classes of the user trace group group where group is one of the groups listed by show user api groups enable user api group group class all disable user api group group class all Enable or disable the logging of all the APIs for all classes of the user trace group group show user api group group class all Display the logging status of all the APIs for all classes of the user trace group group c These commands are not qualified by class or group since the activity must be unique 124 246 8063762 Rev 9 ky ST200 OS21 Trace 11 10 3 enable user api group group class class disable user api group group class class Enable or disable the logging of all the APIs within the class c1ass of the user trace group group where class is one of the classes reported by show user api group group classes
240. only one DSU register is read If reg and numregs parameters are not specified all DSU registers are read dsu dpoke reg DATA Write 32 bit word value in hex format prepend by Ox in the DSU register dsu flush low address high address Flush an address range from data and instruction caches using the DSU FLUSH debug ROM operation as described in the ST231 Core and Instruction Set Architecture Manual 7645929 low address and high address specify the inclusive address range and must be aligned to word addresses dsu dsu dsu dsu ibreak either lower upper ibreak in range lower upper ibreak masked lower upper ibreak out range lower upper The IBREAK CONTROLE registers determine the comparison operations performed on the breakpoint addresses If the comparison is true then a breakpoint exception is signaled For the instruction breakpoints the currently executing bundle address PC is used for comparison dsu ibreak disable Disables ibreak if an ibreak was already set range and condition are lost 8063762 Rev 9 53 246 Cross development tools ST200 54 246 The pmblock st200gdb command The ST200 cores are equipped with a performance monitoring block This block is capable of recording core relevant events such as data cache hits instruction cache hits and several others see the appropriate Core and instruction set architecture manual The pmblock set of commands gi
241. ons place a breakpoint on kernel panic kernel panic calls down to bsp panic that provides a hook for your own panic handler Due to all the exit paths going through the internal run time library function exit a breakpoint here catches every exit path A 7 General tips for GDB This sections describes a variety of general tips for GDB A 7A Handling target connections To avoid typing a sequence of commands when debugging using the GDB command line interface use a simple script and invoke it with x For example st200gdb x script cmd To connect to your target define a user defined command in your 1xgdbinit file The following example sets up a command that connects to a target board in this case an STi5300 ST231 evaluation board connected to an ST Micro Connect with its IP address set to lt address gt and loads the program ready for debugging define target1 file Sarg0 st200tp address mb424 st231 load end To connect to the target from GDB with the executable a out invoke target1 with a out as its parameter gdb target1 a out A 7 2 Windows path names Windows permits spaces to appear within path names However because spaces can cause some GDB commands to break do not use spaces in your path names When using autocomplete GDB does not recognize the usual DOS path name separator the backslash 1 instead use the Unix style forward slash Windows permits file names to have 2 byte wid
242. ool os21usertrace accepts a user supplied definition file specifying the APIs and events to be traced and then generates all the output files required to build a version of the application that is instrumented for tracing The user events are written to the same memory buffer as the OS21 events See Section 11 1 1 os21usertrace host tool on page 99 The tool os21usertracegen accepts an ELF object or executable file and a list of function names and generates a definition file that can be used by os21usertrace See Section 11 1 3 os21usertracegen host tool on page 103 The trace data is extracted by dumping the trace memory buffer to a file on the host This file is then decoded using the os21decodetrace tool See Section 11 5 Analyzing the results on page 109 Support and visualization of OS21 Trace is provided in STWorkbench For more information search for OS21 System Activity in the STWorkbench help system In addition the user may control OS21 Trace using GDB commands see Section 1 1 9 GDB commands on page 117 and Section 11 10 User GDB control commands on page 123 and by embedding function calls in the application to enable and disable tracing for specific parts of the application see Section 11 11 Trace library API on page 126 and Section 11 13 User trace runtime APIs on page 139 11 1 User trace records User APIs and user defined events are organized into a three tier hierarchy group class and name For any application
243. options Chapter 3 Code development tools added Two OS21 commands removed from Chapter 9 OS21 source guide General update of the language used throughout the document 13 Sep 2007 a Initial release 8063762 Rev 9 239 246 ST200 Index Index Symbols bsp core interrupt lock 205 rambase 34 35 bsp core imerrupi unlack NA ARE ES a ramsize bode PALAGIANG PD BAD pah 34 35 bsp ipu region get CA a tombase ee 34 35 bsp itc interrupt clear WA QD CE 206 romsize T 34 35 bsp itc interrupt disable LN EAE 206 EA CNN NM MONA qaz Bop IBS desecicentensaie a stack 34 bsp_itc_interrupt_install 208 dd M cd c E bsp itc interrupt poll 209 bsp itc interrupt raise 209 A bsp itc interrupt uninstall 210 address conversion 14 bsp memory maps paagi dc oe AA 38 address space usage 41 bsp mmu dump TLB Settings 210 allocators bsp mmu memory map 211 fied DOR sucus ode whwing edcrici pe lida B4 PNU MEMU UM aa a dpa eats ela simple 24 bspmmureset 214 user definable 24 bsp pm clock get 214 archive 14 bsppmclock set 215 generate index 15 bsp pm count m
244. or future extensions Returns The newly initialized handle Description The rl handle new function allocates and initializes a new handle that can be used for loading and unloading a load module The handle of the parent module to which the loaded module will be connected is specified by the parent argument The mode argument is reserved for future extensions and must always be 0 Generally a load module will be attached to the module using this function therefore a handle will typically be allocated as follows rl handle t new handle rl handle new rl this 0 rl handle delete Finalize and deallocate a module handle Definition int rl handle delete rl handle t handle Arguments handle The handle to deallocate Returns Returns 0 for success 1 for failure Description The rl handle delete function finalizes and deallocates a module handle The handle must not hold a loaded module The loaded module must have been first unloaded by r1 unload before calling this function If successful the value returned is 0 Otherwise the value returned is 1 and the error code returned by rl errno is set accordingly rl this Return the handle for the current module Definition rl handle t rl this void Arguments None Returns The handle for the current module Description The r1 this function returns the handle for the current module If called from the main module it returns the handle of the main module If called fr
245. or the file cannot be opened the trace is output to stdout ee Cycle on which to start tracing 0 CYCLE lt number gt TRACE_END_CYCLE pa ud Cycle on which to end tracing 0 BUS TRAFFIC Enables a textual trace describing all the traffic on the bus to be a TRACING ON bool output BUS TRAFFIC This item only takes effect when BUS TRAFFIC TRACING ON is OUTPUT TRACE Set to true It s effect is to output the trace to the specified mw FILE lt filename gt filename If the string is empty the trace is output to stdout BUS TRAFFIC TRACE START Cycle on which to start tracing the bus traffic 0 CYCLE number BUS TRAFFIC TRACE END CYCLE Cycle on which to end tracing the bus traffic 0 number OUTPUT LOG FILE lt filename gt By default output from the simulator is recorded in a file in which the last part of the filename is an incrementing integer for example 0042 The width of this numeric field is determined by the form of the filename For example simlog results ina succession of filenames simlog0000 simlog0001 and so on If the null string is specified output is to the console simlog HAZARD_CHECKING_ If hazard checking is switched on the instruction stream is checked for violation of pipeline latency constraints during ON bool simulation false This is not guaranteed to detect all static hazards BUDE CHECKING Setting this item to true enables the simu
246. ormation is enabled by default disable os21 task trace Disable logging of task information show os21 task trace Display the logging status of task information enable os21 activity task trace Enable logging of task information by OS21 activity events task create and task switch this is enabled by default disable os21 activity task trace Disable logging of task information by OS21 activity events show os21 activity task trace Display the status of logging task information by OS21 activity events 120 246 8063762 Rev 9 ky ST200 OS21 Trace 11 9 9 Note 11 9 10 11 9 11 Dump buffer to file dump os21 trace buffer file 0 1 dump os21 task trace buffer file 0 1 Dump the contents of the buffer to file The optional second parameter is the buffer reset argument If 1 the default then the buffer is cleared otherwise it is not reset and the trace data remains intact file is created the first time that data is written Subsequent invocations append data to the existing file Take care to always use the same name for the task information buffer as this holds details of all the tasks created by the application A file named file ticks is also created when dumping the trace buffer Flush buffers and reset flush os21 trace buffer is equivalent to invoking dump os21 trace buffer os21trace bin flush os21 task trace buffer is equivalent to invoking dump os21 task trace buffer os21ta
247. ory subsystem bus including the write buffer and prefetch buffer e thetranslation unit memory management unit ISS or instruction set accurate mode Each instruction runs to completion before the next instruction begins It models the caches basic versions and the translation units It behaves in a manner similar to the hardware This mode does not model e pipeline e latencies e interlocking Fast functional mode This mode models only the minimal set of components required to run correct code correctly This mode has the highest performance but the lowest accuracy This mode does not model e memory subsystem caches protection units bus errors external interrupts device plugin functionality 8063762 Rev 9 83 246 ST200 simulator ST200 8 1 84 246 Simulator pack The simulator pack st200sp configuration procedure for st200xrun and st200gdb is the entry point for all the configurations of the ST200 simulator The simulator uses the TargetString to identify the simulator configuration name The associated GDB command file implements the simulator configuration name and passes the configuration options at start time to the ST200 simulator For example to run the program he11o out on the ST200 simulator built for the default ST231 simulator in little endian with the command gt st200cc mcore st231 msoc default mboard default EL o hello out hello c use st200xrun with the following comma
248. os21 api class reset os21 api class semaphore os21 api class scu os21 api class task os21 api class time os21 api class vmem os21 api class xpu os21 api class EOF os21 api class e void os21 api set class enable os21 api class e code int mode code OS21 API class mode Enable 1 or disable 0 Void Enable or disable logging for the specified OS21 API class 8063762 Rev 9 Enable OS21 API logging for class ST200 OS21 Trace os21 api set enable Enable logging for the given API Definition int os21 api set enable os21 api e code int mode Arguments code OS21 API type mode Enable 1 or disable 0 Returns The previous mode Description Enable or disable logging of the specified OS21 API type os21 task trace set enable Enable task information logging Definition int os21 task trace set enable int mode Arguments mode Enable 1 or disable 0 Returns The previous mode Description Enable or disable logging of task information Initially set to 1 os21 trace get control Get trace control Definition typedef struct os21 trace control s unsigned int save activity 1 unsigned int save api enter 1 unsigned int save api exit 1 unsigned int save activity args 1 unsigned int save api enter args 1 unsigned int save api exit args 1 unsigned int save caller address 1 unsigned int save frame address 1 os21 trace control t void os21 trace get control
249. os21 activity set task trace enable dump os21 trace buffer os21 trace write file dump os21 task trace buffer os21 task trace write file Table 31 lists the user GDB commands and their equivalent APIs Table 31 Correspondence between GDB commands and APIs GDB command enable user api group all disable user api group all enable user api group group class all disable user api group group class all API user api set group enable enable user api group group class class disable user api group group class class user api set group group class enable enable user api disable user api enable user api global disable user api global user api set enable user api set global enable enable user activity group all disable user activity group all enable user activity group group class all disable user activity group group class all enable user activity group group class class disable user activity group group class class user activity set group enable user activity set group group class enable enable user activity disable user activity user activity set enable enable user activity global disable user activity global 11 15 Trace always on user activity set global enable The default is that the OS21 activity and OS21 API logging is disabl
250. os21 trace control t control Arguments control The control settings Returns Void Description Get the control settings for OS21 Trace ky 8063762 Rev 9 133 246 OS21 Trace ST200 os21 trace set control Set trace control Definition typedef struct os21 trace control s unsigned int save activity 1 unsigned int save api enter 1 unsigned int save api exit 1 unsigned int save activity args 1 unsigned int save api enter args 1 unsigned int save api exit args 1 unsigned int save caller address 1 unsigned int save frame address 1 os21 trace control t void os21 trace set control os21 trace control t control Arguments control The control settings Returns Void Definition Set the control settings for OS21 Trace os21 trace print Print a string into the trace buffer Definition void OS21 TRACE PRINT const char string Arguments string The string to be written to the buffer Returns Void Description Print a string into the trace buffer Use the 0521 TRACE PRINT API in preference to the alternative os21 trace print API as the former allows the application to link successfully when not linked with the OS21 Trace libraries whereas the latter does not os21 trace write file Write trace buffer to a file Definition int os21 trace write file const char name int reset Arguments name File name to create reset Clear 1 or keep 0 buffer Returns O if OK 1 if an error occurred
251. ounter 0 616 Event 0 type DHIT j Counter 1 155 Event 1 type DMISS v bat counter 2 11366 Event 2 type IHIT Counter 3 Event 3 type EXCEPTIONS x Clock r Switches Reset all Stop Apply Refresh Close To make any changes in the editable fields effective click the Apply button The buttons in the Switches area of the window are active immediately When counting events is enabled the Start button toggles to Stop 8063762 Rev 9 81 246 Using Insight ST200 7 17 Note 7 17 1 Note 82 246 Using the Debug Support Unit Window The Debug support unit DSU allows both the software and hardware to be debugged from a host by giving direct access to the ST2xx core The Debug Support Unit window provides a simple interface to monitoring and editing DSU registers DSRO is always read only while DSR31 is read only just on ST240 cores because it represents the virtual PC To display the Debug Support Unit window do one of the following e click the 3 amp button e from the View menu in the Source Window select Dsu viewer e press the Ctrl J keys on the keyboard Figure 26 The Debug Support Unit window Debug Support Unit 0x02050001 0x00000000 0x00340042 0xc0014f00 0x00000007 0x00000000 Oxc1fffO00 0xc0000188 0x00000000 0xc000e000 0x00000001 0x00000000 0x00000000 0x00000000 0x00000000 0x00000006 0x00000000 0xc0000330 0x00000000 0x00000020 Oxc0000334 0x000
252. ow View Disassembly to display the Disassembly view 3 Select Window Save Perspective As The Save Perspective As dialog is displayed Figure 8 Save Perspective As dialog Save Perspective As Enter or select a name to save the current perspective as Name 2E Existing Perspectives Eie C C4 4 default Bacvs Repository Exploring Kb Debug P5 Resource O ST Profiler Perspective amp Team Synchronizing 4 Select Debug in the Existing Perspectives list and click on OK You are prompted A perspective with the name Debug already exists Do you want to overwrite 5 Click on Yes to save the Debug perspective with the currently open views 8063762 Rev 9 61 246 Using STWorkbench ST200 6 2 62 246 STWorkbench tutorials The on line help provides a number of tutorials to guide the user through the steps to build run and debug an ST200 application The tutorials are accessed through the STWorkbench help system by selecting Help Help Contents STWorkbench for ST200 Micro Toolset menu Concepts The purpose of this tutorial is to familiarize new users with the various basic elements of the workbench Getting Started This tutorial provides instructions on how to build a simple OS21 Hello World C application Import an existing project This tutorial describes how to build a C C application by importing an existing source tree compl
253. pendent When MAP LOCKED is set the LIMIT field of the TLB REPLACE register is changed To avoid this TLB could be impacted from random TLB replacement routines ST200 implementation specifics The bsp mmu memory map utility is implemented for the ST231 architecture using the TLB hardware feature The policy of the TLB index allocation is to use high index values first starting at TLB SIZE 1 and decreasing toward O The MAP SPARE RESOURCES specific allocation policy ensures that no more than half of the TLB index is used to map a single area It may also increase the page size used to cover the area despite the lack of accuracy This function invalidates any valid instruction cache lines which fall within the address range specified If it is not possible to flush individual cache lines then the entire instruction cache is invalidated bsp mmu memory unmap 8063762 Rev 9 213 246 ST200 board support package BSP ST200 bsp mmu memory unmap Delete a memory mapping Definition include lt platform h gt int bsp mmu memory unmap void address size t length Arguments address The virtual start address of the range to invalidate length The length of the range in bytes Returns On successful completion bsp mmu memory unmap returns BSP OR otherwise it returns BSP FAILURE and sets bsp errno to indicate an error If the removed TLBs were set as MAP LOCKED then the LIMIT field of th
254. ple kernel timeslice 0 Critical section kernel timeslice 1 Use this approach carefully as the kernel timeslice API has an immediate global effect If the task blocks in this region for example calls task delay blocks waiting for a synchronization object or signals a synchronization object and gets preempted as a result then timeslicing remains disabled for all other tasks This can result in a task not timeslicing in order to share the CPU 8063762 Rev 9 181 246 Toolset tips ST200 A 5 Access to uncached memory To get uncached views of physical memory use the OS21 virtual memory API The following is the sequence of OS21 virtual memory API calls 1 To obtain the physical address for the virtual address to be accessed through an uncached view call vnem virt to phys 2 To obtain a virtual address that gives an uncached view of the physical memory call vmem create With the physical address obtained in step 7 with the mode VMEM CREATE UNCACHED VMEM CREATE READ VMEM CREATE WRITE 3 To release the virtual address when it is no longer required call vnem delete with the virtual address obtained in step 2 If the virtual address has been dynamically mapped through the MMU use vmem delete to release a UTLB entry for reuse This reduces page faults and improves performance The following example uses the OS21 virtual memory APIs void dev phys struct devic
255. port script defines the set of symbols and only these that must be exported to the other modules through the dynamic symbol table These symbols are then accessible by the load time symbol binding process and by the calls to x1 sym and r1 sym rec The export script is not mandatory as all global symbols are exported by default There are two common cases for generating export scripts e Whenan import script is required for the module the export script can be generated at the same time This is because the symbols to export are generally those that are imported e Foraload module that has a well known external interface the export script can be generated from a list of symbols to export The following example shows how to generate an export script and import script for a list of modules that is then used when linking the main module Only the symbols from 1iba rl and libb r1 are imported into the main module and exported by it st200rltool i e o prog import export ld liba rl libb rl st200cc o prog exe rmain object files o prog import export ld 8063762 Rev 9 ky ST200 Relocatable loader library 12 5 2 To generate an export script for a load module with a well defined interface specified in the file liba export lst one symbol per line st200rltool e s o liba export ld liba export lst st200cc o liba r1 rlib o liba export ld Optimization options When compiling a load module with the fpic option
256. provided by the compiler drivers to produce efficient code It covers command line options predefined macros supported pragmas compiler optimization techniques GNU C and C language extensions and asm construct the assembly language and intrinsic functions ST200 Run time architecture manual 7521848 This manual describes the common software conventions for the ST200 processor run time architecture 10 246 8063762 Rev 9 ky ST200 Preface OS21 user manual 7358306 This manual describes the royalty free light weight OS21 multitasking operating system OS21 for ST200 user manual 7410372 This manual describes the use of OS21 on ST200 platforms It describes how specific ST200 facilities are exploited by the OS21 API It also describes the OS21 board support packages for ST200 platforms ST200 ELF specification 7932400 This document describes the use of the ELF file format for the ST200 processor It provides information needed to create and interpret ELF files and is specific to the ST200 processor ST231 Core and instruction set architecture 7645929 This manual describes the architecture and the instruction set of the ST231 core as used by STMicroelectronics ST240 Core and instruction set architecture 8059133 This manual describes the architecture and the instruction set of the ST240 core as used by STMicroelectronics Terminology The first ST Micro Connect product was named the ST Micro Conn
257. r disabling the logging of classes of user defined activities within each of the user defined trace groups There is one API for each group For example if there is a group of user defined activities called 1ibc then the API to enable or disable the logging of any given class of activity within the 1ibc group is user activity set group libc class enable An enumeration with the name user activity group group class e Where group is the name of an activity group is defined for each activity group in the header file generated by os21usertrace 8063762 Rev 9 139 246 OS21 Trace ST200 user activity set enable Enable tracing for an activity Definition int user activity set enable user activity e code int mode Arguments code Activity to enable or disable mode Enable 1 or disable 0 Returns 0 for success Description Enable or disable the logging of the user defined activity specified by coae The enumeration user activity e is defined in the header file generated by os21usertrace user api set global enable Enable global tracing for activities Definition int user activity set global enable int mode Arguments mode Enable 1 or disable 0 Returns 0 for success Description Enable or disable the logging of user activity types initially set to O 11 13 2 User API control APIs The following APIs are created by os21usertrace for controlling the generation of trace records for user APIs Note If no user
258. r now returns the number of ticks since the system started running The exact time at which counting starts is implementation specific but is done in the core initialization The units of ticks is an implementation dependent quantity but it is approximately 1 microseconds see bsp timer ticks per sec on page 221 bsp timer reload get Get the reload value of the specific timer Definition include lt platform h gt unsigned int bsp timer reload get int timer Arguments timer The timer see Table 45 ST200 timer assignments on page 196 Returns The value to be reloaded into the timer on reaching zero Description This function returns the reload value of the given timer bsp timer reload set Set the value to be reloaded into the specific timer on reaching zero Definition include lt platform h gt int bsp timer reload set int timer unsigned int reload Arguments timer The timer to reload see Table 45 ST200 timer assignments on page 196 value The value to be used for reload initialization Returns Returns the error condition Description This function initializes the reload register of a given timer It should only be used with 220 246 H IMER1 and TIMER2 however TIMER2 should only be used if the profiler is not enabled Do not use this function with TIMER SYSTEM 8063762 Rev 9 ky ST200 ST200 board support package BSP bsp timer start Start the timer Definitio
259. r of the profiler output is a list of PC samples The number of samples is equal to saved records The list has the following format accumulated delta address function at location where accumulated delta is the accumulation of the time delta between samples since profiling started address is the sampled PC address function is the name of the function at the given address indicates that the function name is unknown location is the source location of the given address if known Figure 31 provides an example of the output displayed for profile type trace Figure 31 Example profile type trace output Trace Profiler saved 232 total 232 time 53393 0000000000 0x84016f70 fn_0_993 at fn2 0 c 6956 0000000171 0x84016e68 fn O 990 at fn2 0 c 6935 0000053206 0x84001bd4 fn 0 5 at fn2 0 c 42 0000053393 0x84001a24 fn O O at fn2 0 c 5 8063762 Rev 9 229 246 Profiler plugin ST200 D 3 Note 230 246 Range profile output format If the profiler type is set to range using the command profile type range the profiler trace display consists of a header line followed by a list of the sample counters each representing a range of program memory For each sample taken the profiler increments the counter for the address range slot where the PC is currently located The header line has the following format Range Profiler range address address step step slot
260. r through a call to the loader library the loader performs dynamic symbol binding when loading a module and symbols are searched in the load modules hierarchy bottom up to the main module sharing of code and data objects between modules is achieved by linking to the objects in a common ancestor the loader library is statically linked with the main module the system support archive library should be linked with the main module Figure 29 shows an example of an application that has four load modules A B C and D 8063762 Rev 9 ky ST200 Relocatable loader library Note Figure 29 Example of an application with four load modules printf x a Module B printf x Module A E t main malloc printf exec C malloc malloc Module C printf vides Module D In Figure 29 curved arrows from load modules to parent module represent load time symbol binding performed while the load module loads Straight arrows from loader module to loaded module represent explicit symbol address resolution performed through the loader library API The following describes a possible scenario 1 Atrun time the main module loads the module A into memory through the rl load file function 2 The loader in the process of loading A into memory binds the symbol printf undefined in A to the printf function defined in main 3 The main program uses the r1 sym
261. r user defined APIs and activities source the GDB command script that was generated by the gdb script option of os21usertrace In the following example that file is named myapp cmd The example also assumes the default prefix of user source myapp cmd enable user activity global enable user api global 8063762 Rev 9 ST200 OS21 Trace 11 4 1 Note Trace buffer The default for the trace buffer is to wrap This means that when this buffer is full tracing wraps to the start of the buffer and overwrites the oldest existing events In this case the trace buffer full breakpoint does not occur When the buffer wraps time stamping continues from the previously recorded sample The time recorded also includes time spent when profiling is disabled either as a result of an I O request or because the ST200 is under control of GDB With tracing enabled and while the target is running timestamped events are written to the trace buffer To access this data GDB must take control of the target To do this either set a breakpoint and wait for the break to match or stop the target either with a Ctrl C from within GDB or the Stop button in STWorkbench or Insight When GDB has control of the target extract the trace data by invoking the following GDB command flush all trace buffers This command extracts data from the task information and trace buffers writes them to files on the host and then resets the buffers The
262. ranch trace buffer can be configured to trace branch classes selectively The traceable branch classes and their symbolic names are listed in Table 57 Table 57 Traceable branch classes Traceable branch class Symbol Description general gn BR BRF and GOTO instructions subroutine sb CALL and RETURN instructions traps traps All non debug traps and RFI traps No branches none Trace nothing 8063762 Rev 9 223 246 Branch trace buffer ST200 C 2 Note 224 246 The branchtrace command The branchtrace command is enabled automatically when the host connects to a target It can also be enabled by issuing the GDB command enable branch trace defined in the brtrace cmd GDB command script file The branchtrace command has the following format gdb branchtrace subcommand options This command controls the branch trace buffer function specified by subcommand and options For convenience the branchtrace command is aliased to the brt command The subcommands supported by the branchtrace command are listed in Table 58 on page 224 Table 58 Branchtrace subcommands Subcommand Options Description Display help for the branchtrace command If a help subcommand subcommand is specified then more detailed help for the subcommand is displayed Switch the decoding of ST240 opcodes on or off in decode onloff order to report the branch type The default is on Display the branch trace buffer conten
263. ranchtrace command on page 224 adding the reset option to the display and save subcommands Added Appendix E ST TargetPack plugin on page 233 Added Appendix F GDB os21 time logging user command on page 235 15 Jun 2009 Supports the ST200 R6 4 Throughout removed all references to ST220 which is no longer supported Updated Section 1 5 The examples directory on page 20 and Chapter 10 Booting OS21 from Flash ROM on page 96 to add os21 rombootrom Updated set args in Table 9 st200gdb command quick reference on page 49 and removed the command target sim Updated T timeout in Table 13 st200xrun command line options on page 55 Updated Chapter 11 OS21 Trace on page 98 Updated Section 11 9 GDB commands on page 117 throughout Updated Section 11 11 Trace library API on page 126 adding the functions os21 trace initialize activity moditors os21 trace set mode os21 task trace set mode os21 activity set class enable os21 activity set enable os21 set task trace enable os21 api set class enable os21 api set enable Added new Chapter 13 Dynamic OS21 profiling on page 167 Added Section B 9 Retrieving internal run time data on page 203 Updated Section B 10 BSP function definitions on page 204 adding the function bsp rtrecord get 8063762 Rev 9 237 246 Revision history ST200 Table 62 Document revision history continued Date 20 Dec 2008 Revision Changes S
264. rap 1d and os21wrap ld class located at lt toolset_dir gt target os21 trace api class Use in conjunction with trace to initialize OS21 API tracing for all functions in the specified class of OS21 API For example trace trace api cache performs tracing only on the OS21 functions that belong to the class event trace trace api no class no constructor Use this option in conjunction with the trace api option to exclude the specified class of API from tracing For example trace trace api trace api no cache performs tracing on all OS21 functions except those that belong to the class cache Use this option to disable the automatic initialization of the OS21 Trace buffers 1 Where classis one of the following cache callback event exception interrupt kernel memory message mutex partition power profile scu semaphore task time Or vmem Running the application By default an application built for OS21 Trace initially starts with trace logging disabled To enable tracing of the OS21 kernel and API from GDB invoke the following commands source os21trace cmd enable os21 activity global enable os21 api global The command script os21trace cmd automatically creates two breakpoints One is on the function that is invoked when the trace buffer is full and the other is on the function that is invoked when the task information buffer is full To enable tracing fo
265. re this would be used is when an application has been burnt to flash and is running after a reboot of the target In order to debug the application the connect to a running target mechanism is used to avoid core reset and memory initialization that would destroy the running process Figure 4 Process flows for connecting to a target on page 47 shows the different process steps for each connection method and their different characteristics 8063762 Rev 9 ky ST200 Cross development tools Figure 4 Process flows for connecting to a target Flow A Flow B Application burnt on target flash and running Standard connect Connect to a running target Core chip reset L Debug support initialization Memory initialization Debug support initialization Application load Debug Application run Debug Connecting to a running target with the executable available The prerequisite for this type of connection is that the application is currently running The following command lines show how to launch st200gdb and perform the connect for the application sample out gt st200gdb sample out gdb st200tp lt IP_address gt lt board gt gt lt core gt no_reset 1 no_pokes 1 gdb After the target has been halted it is possible to inspect the code set breakpoints and continue execution 8063762 Rev 9 47 246 Cross development
266. red threads The breakpoint is displayed as a pink square To replace the three Set Breakpoint options with Disable Breakpoint and Delete Breakpoint options right click on an existing breakpoint Disabled breakpoints appear as black squares 8063762 Rev 9 69 246 Using Insight ST200 7 5 1 Note 7 6 70 246 The Breakpoints window To open the Breakpoints window either click the EI Source Window select Breakpoints button or from the View menu in the The Breakpoints window does not enable the creation of new breakpoints but does permit existing ones to be viewed and edited Figure 14 Breakpoints window Breakpoints Breakpoint Global fiddress File 88880b5c2 exit c 88881d86 mandel c 88601d84 mandel c 88881dae mandel c Line Function 61 325 322 331 exit main main nain Click on a breakpoint to select it To change the breakpoint use the check boxes and the Breakpoint and Global menus Breakpoint menu Normal Temporary Enabled Disabled Remove Global menu Show Threads Disable All Enable All Remove All Store Breakpoints Restore Breakpoints Using the help To open the help files from the Help menu select Help Topics Set the breakpoint to normal permanent or temporary one time Enable or disable the breakpoint Delete the selected breakpoint Add an additional column to the window showing the threads the breakpoint
267. rief introduction to the code development tools For detailed information please refer to the ST200 Micro Toolset compiler manual 7508723 The code development tools are invoked through the st200cc compilation driver tool Its purpose is to manage the stages of the compilation process preprocessing compiling into assembly language assembling and linking The assembler file is compiled using st200as and linked using st200ld to provide an ST200 binary image All these phases are hidden using the driver tool st200cc A GNU C compiler is provided by the driver tool st200c Toolset overview The ST200 Micro Toolset is a set of tools that enable C and C programs compiled for an ST200 target to be simulated on a host workstation or executed on an ST200 target Supported platforms are e RedHat Enterprise Linux 4 0 and 5 0 e Windows XP and Windows 7 The ST200 Micro Toolset is intended for tool developers for operating system development and for applications that require modeling interrupts and real time behavior It includes the complete set of tools for manipulating ST200 object files and includes the ST200 assembler compiler linker load run tool debugger archiver ST200 assembler files are translated to ST200 object files that the linker merges to produce an ST200 executable image This image file does not run natively on the host workstation and requires an interpreter to be executed Figure 2 shows the main components of the
268. roelectronics h Display the help for st200xrun Execute the GDB script file filename The command source filename is issued to GDB The GNU Debugging with GDB manual provides examples of script file syntax This option can be specified more than once i filename 8063762 Rev 9 55 246 Cross development tools ST200 5 4 3 56 246 Table 13 st200xrun command line options continued Option Description Specifies the target with which to be connected in the ST TargetPack SimulatorPack idiom For hardware targets see ST TargetPack user manual 8020851 and for simulated targets see Chapter 4 Board target configuration on page 27 t targetstring u gdbname Specify the name of GDB v Display verbose information x filename Execute filename as the default startup script instead of 1xgdbinit Execute lt gdbcommand gt after running the program For example A lt gdbcommand gt st200xrun c st200sp t st231simle A statistic gt file txt e hello out Execute lt gdbcommand gt before running the program For example B lt gdbcommand gt st200xrun c st200sp t st231simle B Statistic gt file txt e hello out Sets further target options For example st200xrun c st200sp t st231sim C DUMP CONFIG FILE filename txt C MODE FAST e C target opt hello out Targetpack example st200xrun c st200tp t ipaddr mb424 st231 C msglvel info e
269. rofiler on the STMC the next time the target is re started Samples are only taken and stored by the STMC while the target is running When the target is stopped no samples are taken disable Stop the profiler on the STMC Stopping the profiler implies a reset reset Discard the stored profiler data on the STMC display save append file Display the profiler data stored on the STMC Save or append the profiler data stored on the STMC to file gmonout file Save or append the range profiler data stored on the STMC to file using the gprof compatible gmon out file format mode period none dsu interrupt delay Set the profiler sampling mode none records samples when the target stops at a breakpoint or an I O request this is the default dsu records samples using the non intrusive method of sampling the PC only applies to ST240 targets See Section D 2 Trace profile output format on page 229 interrupt records samples by briefly stopping the target to sample the PC See Section D 2 Trace profile output format on page 229 Set the minimum sampling period for the profiler The de1ay period can be specified in seconds s milliseconds ms or microseconds us by using the appropriate suffix If no suffix is specified microseconds are assumed If period is not specified profiling is effectively disabled It is therefore mandatory to set the sampling period
270. run time model The whole application is a single module that is R Absolute statically linked at a fixed load address Relocatable run time model The application has a main module and several load modules The main module is statically linked and loaded as for an R Absolute application The load modules are loaded on demand by explicit calls to the loader at run time The load modules are loaded at an arbitrary address and dynamic symbol binding is applied by the loader for symbols undefined in the load modules In the hierarchy of loaded modules the dynamic symbol binding traverses the modules from the bottom up see Section 12 2 Relocatable run time model for details R Relocatable System V run time model The application has a main module and several load modules The main module is typically statically linked but possibly has references to symbols in the load modules The main module is loaded with support from the dynamic loader that also loads load modules and binds symbols before the application starts At run time the application can load R PIC other modules on demand The dynamic symbol binding traverses the load modules in an order defined by the static link order and the run time loading order In addition to dynamic loading and linking in a multi process environment the load module s segments can be shared between several applications This model usually relies on file system support and virtual memory management
271. s slots rate us us per sample where address address is the start and end address of the memory range stepisthe size of each slot in bytes as set by the range subcommand e slotsisthe total number of slots usisthe rate of sampling in microseconds per sample The remainder of the profiler output has the following form count address address function where count is the sample count obtained for the given address range address address is the start and end address of the slot functionis the name of the function in which the slot is located indicates that the function name is unknown The report displays only non zero sample counters Figure 32 provides an example of the output displayed for profile type range Figure 32 Example profile type range output Range Profiler range 0x88001000 0x880174f2 step 16 slots 5713 rate 128us per sample 0000000001 0x88001790 0x880017a0 f1 0000002911 0x880017a0 0x880017b0 f1 0000004159 0x880017b0 0x880017c0 f1 0000002182 0x880017c0 0x88001740 f2 0000001065 0x880017d0 0x880017e0 f2 0000001382 Ox880017e0 0x880017f0 f2 0000002129 0x880017 0 0x88001800 f2 0000000468 0x88001800 0x88001810 f3 0000000889 0x88001810 0x88001820 f3 0000001446 0x88001820 0x88001830 f3 0000000433 0x88001830 0x88001840 f4 0000000753 0x88001840 0x88001850 f4 0000001063 0x88001850 0x88001860 f4 8063762 Rev 9
272. s The tutorials are accessed through the STWorkbench help system by selecting Help 5 Help Contents 5 ST200 trace profile and coverage ST200 Static Analysis STWorkbench supports the generation and display of profiling coverage and OS21 Profiler data These features are described in the following tutorials STgprof This tutorial describes the STgprof profiler and provides a guide on using this tool to determine which parts of a program take most of the execution time STgcov This tutorial describes the STgcov profiler and provides a guide on using this tool to identify the parts of a program that have never been exercised OS21 Profiler This tutorial describes the OS21Profiler profiler and provides a guide on using this tool to analyze the performance characteristics of an OS21 application ST200 Interactive Analysis Interactive support is available for OS21 System Activity STMC sampling and OS21 Profiler These features are described in the following help pages OS21 System Activity This tutorial describes the OS21 Activity analyzer and provides a guide for using this tool to analyze and monitor the life cycles of interrupts and tasks in an OS21 application STMC sample profiler These pages describe the STMC sample profiler a facility that uses the ST Micro Connect to obtain profiling data on the application The generated result is similar to STgprof STMC sample history These pages describe the STMC sample history whi
273. s which does not allow the application to be linked unless it is also linked with the OS21 Trace libraries Use of the latter API is not recommended 11 14 Correspondence between GDB commands and APIs Table 30 lists the OS21 Trace GDB commands and their equivalent APIs Table 30 Correspondence between GDB commands and APIs GDB command API os21 trace set mode os21 trace set mode os21 task trace set mode os21 task trace set mode enable os21 trace os21 trace set enable disable os21 trace enable os21 activity global os21 activity set global enable disable os21 activity global enable os21 api global os21 api set global enable disable os21 api global enable os21 activity class class os21 activity set class enable disable os21 activity class class enable os21 activity os21 activity set enable disable os21 activity enable os21 api class class os21 api set class enable disable os21 api class class enable os21 api os21 api set enable disable os21 api enable os21 trace control enable os21 trace control all os21 trace set control disable os21 trace control disable os21 trace control all enable os21 task trace os21 task trace set enable disable os21 task trace 142 246 a 8063762 Rev 9 ST200 OS21 Trace Table 30 Correspondence between GDB commands and APIs continued GDB command enable os21 activity task trace disable os21 activity task trace API
274. s 3462 Num issued instructions 5787 Num issued extended immediates Num issued nops 90 ICache hits 5650 Cache misses 120 IBuffer insufficient data cycles 12492 Cache hit wage 97 920 Cache miss age 2 080 Cache miss penalty cycles 18175 Cache miss cycle age 42 466 The Start button calls the start statistics command It starts the statistics counters for the ST200 processor By default the counting is enabled The Stop button calls the stop statistics command It stops the statistics counters for the ST200 processor The Reset button calls the reset statistics command For example to compute the statistics use this before executing a sequence of code 8063762 Rev 9 ky ST200 Using Insight 7 16 Using the Performance Monitoring window The Performance Monitoring window gives access to all the features provided by the ST200 cores performance monitoring block The counter values update whenever their values change To set the type of event counted by the counters and their values it is possible to start and stop the event counting Figure 25 shows an example of the Performance Monitoring window To display the Performance Monitoring window do one of the following e click the button e from the View menu in the Source Window select Performance Monitoring press the Ctrl X keys on the keyboard Figure 25 The Performance Monitoring window v Performance Monitoring r Counters C
275. s a number of mechanisms for achieving task task critical sections each of which has its own cost and benefit task lock and task unlock These calls provide a lightweight mechanism to prevent preemption With a task 1ock the running task is guaranteed so that the scheduler does not preempt it if a higher priority task becomes runnable or a timeslice interrupt occurs In addition any calls to task reschedule have no effect It is possible for the running task to explicitly give up the CPU while a task 1ock is active This is the only way to schedule another task while the running task holds a task lock Explicit yielding of the CPU occurs when the running task calls either task yield ora blocking OS21 function for example e calls to task delay or task delay until specifying a time in the future e waiting on an unposted event flag busy semaphore or empty message queue with the timeout period not set to TIMEOUT IMMEDIATE e waiting for a busy mutex When the running task resumes execution OS21 automatically reinstates task lock Due to the critical section provided by task 1ock and task unlock being broken if the task blocks it is weak If a strong critical section is required when using these calls ensure that called functions do not block This is not always possible for example when calling a library function Advantages e light weight e noneedto allocate a synchronization object
276. s all Display the logging status of all OS21 activity events in all classes enable os21 activity class class Enable the logging of the OS21 activity events in the class class where class is one of the classes listed by show os21 activity classes disable os21 activity class class Disable the logging of the OS21 activity events in the class class show os21 activity class class Display the logging status of the OS21 activity events in the class c1ass enable os21 activity code Enable the logging of the OS21 activity event specified by code All events are enabled by default The command show os21 activity class all lists all valid code parameters see Section 11 9 11 Type and event enables on page 121 For an event to be logged both the event code and the type OS21 activity in this case must be enabled Disabling the type prevents logging of all the events that belong to that type although it does not disable them disable os21 activity code Disable the logging of the OS21 activity event specified by code show os21 activity code Display the logging status of the OS21 activity event specified by code Enable OS21 API function show 0s21 api classes Display the OS21 API classes The supported classes are cache callback event exception interrupt kernel memory message mutex partition power profile reset semaphore task time Of vmem enable os21 api class all Enable logging of all OS21 APIs in all classes
277. s defined by this API are described in the following sections os21 trace initialize Create a trace buffer Definition typedef enum os21 trace mode e os21 trace mode stop 1 os21 trace mode wrap 2 os21 trace mode e void os21 trace initialize void data unsigned int size os21 trace mode e mode Arguments data The buffer to use size The size in bytes of the buffer to create mode Buffer full action stop or wrap Returns Void Description This function allocates and initializes a trace buffer specified by the size parameter If Gata is NULL the API returns the current buffer to the heap and allocates a new buffer specified by size On startup of OS21 Trace the default constructor invokes this function to create a buffer of size 2 Mbytes enough for 128k simple records in os21 trace mode wrap mode This default size can be overridden by the user See Section 11 12 Variables and APIs that can be overridden on page 138 os21 trace initialize data Replace an existing trace buffer Definition void os21 trace initialize data void data unsigned int size Arguments data The buffer to use size The size in bytes of the buffer to create Returns Void Description Replace the existing trace buffer with the buffer specified by the data and size parameters If data is NULL the API returns the current buffer to the heap and allocates a new buffer of the specified size This function must not be us
278. s for an expression starts with lists all functions that start with the expression contains lists all functions that contain the expression ends with to list all functions which end with the expression matches regexp lists all functions that match the regular expression Files This shows all the files within the application Only the selected files are searched for using the expression Functions This shows all the functions within the selected files To delete and set breakpoints at the start of each function use the Delete BP and Set BP buttons The lower section of the window shows the source code for the selected function To set breakpoints use the same method as for the Source Window see Section 7 5 Configuring breakpoints on page 69 Figure 22 Function Browser window Function Browser Function Filter Show if function starts vith FUP sp board type T Hide hfiles Select All Delete DelteBP sese Set ge Vspilotro snap 080121 deviimage src os2 1 erc st200 bsp board m 8xc 0014789 bsp board type goto r63 Bxc0610784 bsp board typer4 nou r16 1873 8xc0014788 lt bsp board type 8 5 E aaa ee aS board mb424 c 1 SOURCE 8063762 Rev 9 ky ST200 Using Insight 7 14 Using the Processes window The Processes window shows the active threads To open the Processes window from the View menu in the Source Window select Thread Li
279. s to the other load modules To avoid a load error when loading a module it is usual for the referenced symbols to be linked into the main module When the services are present in a library at the time of linking the main module import the corresponding symbols To import symbols the linker requires an import script The st200rltool utility can generate an import script The following gives the two common cases for generating an import script e When the required services are well defined pass the list of symbols to the st200rltool utility e When the list of services is not defined but the load modules are available pass the load modules to the st200rltool utility The st200rltool utility generates an import script from the set of symbols that the load modules require The following command generates an import script from a list of symbols specified in the file prog import lst one symbol per line st200rltool i s o prog import ld prog import lst The following command generates an import script that the main module can load from a list of load modules liba rl and libb r1 st200rltool i o prog import ld liba rl libb rl Use the import script to link the main module for example st200cc o prog exe rmain object files o prog import ld In addition to import scripts the st200rltool utility can also generate export scripts that reduce the size of the dynamic symbol table in the main module or the load modules The ex
280. s which get preempted are placed at the head of the run queue for their priority level e Tasks which yield are placed at the tail of the run queue for their priority level e Tasks which become runnable are placed at the tail of the run queue for their priority level e Tasks which get timesliced are placed at the tail of the run queue for their priority level e Timeslicing is optional off by default and can be enabled or disabled by calling kernel timeslice e The default timeslice frequency is 50 Hz e Thetimeslice frequency can be set between 1 and 500 Hz by changing the value of the variable bsp timeslice frequency hz either before calling kernel initialize orinthe BSP library routine bsp initialize Managing critical sections in OS21 A critical section is a region of code where exactly one thread of execution can run at any one time There are two forms of critical section to consider e task interrupt e task task task interrupt critical sections Within the context of a running task task interrupt critical sections are implemented by masking interrupts so that the interrupt handler you are serializing with cannot run OS21 has three calls for interrupt masking and unmasking interrupt mask interrupt mask all and interrupt unmask This OS21 API enables the priority level of the CPU to be raised and lowered The CPU s interrupt level provides a simple mechanism to mask interrupts from reaching th
281. signed to the task by GDB This command converts task number into a task handle by scanning the OS21 task list The command then calls the OS21 API profile start task With task handle b Target memory is read when scanning the task list 8063762 Rev 9 169 246 Dynamic OS21 profiling ST200 Note Note 170 246 OS21 profiler contextual initialization and start The OS21 dynamic profiler can be initialized and started using the following combined commands os21 profiler initialize and start all instructions per bucket frequency os21 profiler initialize and start interrupt instructions per bucket frequency level os21 profiler initialize and start task instructions per bucket frequency task os21 profiler initialize and start task number instructions per bucket frequency task number Each command is equivalent to the corresponding two line sequence os21 profiler initialize instructions per bucket frequency os21 profiler start options OS21 profiler stop Use the following command to stop profiling os21 profiler stop Stops the OS21 profiler by calling the OS21 API profile stop OS21 profiler write data Use the following commands to write the gathered profile data to a file os21 profiler write file Writes the OS21 profile data to file by calling the OS21 API profiler write lf the OS21 profiler is currently running the OS21 API profiler stop is called first os21 profiler dump file Writes the
282. sing the template directory use an existing board directory that is similar to the required new directory 4 If required modify the mapping settings in the linker script file board 1a The board 14d file is located in the new target dir board my board and contains the following mappings rambase ramsize rombase romsize 8063762 Rev 9 35 246 Board target configuration ST200 For example to define a board with 16 Mbytes of RAM at address 0x12000000 and 4 Mbytes of Flash at address 0x00000000 enter the following definitions rambase DEFINED rambase rambase 0x12000000 ramsize DEFINED ramsize ramsize 16M D Wonbase DEFINED rombase rombase 0x0 Sneius DEFINED romsize romsize 4M Replicate the same information in the MEMORY section for example reset flash ORIGIN 0x0 LENGTH 0x10000 boot ORIGIN 0x1000 LENGTH 4M 0x10000 ram ORIGIN 0x12000000 LENGTH 16M The two entries reset_flash and boot only need to be modified if the application is built to start from Flash and does not use the standard configuration for Flash which can be viewed in the template 0s21 board 1a file board nomem 1d contains similar information but does not contain the MEMORY section and is only needed in association with lt tools dir gt target platform_nomem 1d 5 Edit the makefile changi
283. sk_t task kernel_initialize NULL kernel start a This executable can load relocatable libraries see Chapter 12 Relocatable loader library on page 145 8063762 Rev 9 ky ST200 Introducing OS21 printf Hello from the root taskWMn task task create void void my task Hi ya OS21 DEF MIN STACK SIZE MAX USER PRIORITY my task 0 task wait amp task 1 TIMEOUT INFINITY printf All tasks ended Bye n return 0 To compile and run this program on the ST231 processor of an IPBR1100 platform mb424 connected to an ST Micro Connect with IP address STMC IP address gt gt st200cc mruntime os21 mcore st231 msoc sti5300 mboard mb424 o test out test c gt st200xrun c st200tp t STMC IP address gt mb424 st231 e test out The output is Hello from the root task Hello from the child task Message is Hi ya All tasks ended Bye For more information on OS21 see the OS21 user manual 7358306 and the OS21 for ST200 user manual 7410372 8063762 Rev 9 23 246 Introducing OS21 ST200 2 1 24 246 OS21 features The following summarizes the key features of OS21 OS21 is a simple royalty free multi tasking package There is a single address space and single name space the application has one executable image There is a 256 level priority based FIFO scheduler It has optional timeslicing It has inter task synchronization
284. sktrace bin flush all trace buffers is equivalent to invoking flush os21 trace buffer flush os21 task trace buffer These functions flush the contents of both the trace and task information buffers to predefined file names and then reset the buffers They write data to the files if any data is extracted os21trace bin os21trace bin ticks and os21tasktrace bin Type and event enables To support convenient enabling and disabling of related OS21 events with a single operation the events are divided into classes and classes are divided into types A trace event is logged written into the trace buffer only if the event itself is enabled as well as its type Two types are supported e 0821 activity e OS21API For each of these the following command displays the logging status of the type see Section 11 9 4 Enable OS21 activity on page 118 and Section 11 9 5 Enable OS21 API on page 118 show type global The following command lists all the classes in a type show type classes 8063762 Rev 9 121 246 OS21 Trace ST200 122 246 For example gdb show os21 activity classes exception general interrupt task The following command displays the logging status of all the events that belong to a class show type class class For example display the logging status of the OS21 APIs in the time class with the command gdb show os21 api class time time after enabled time minus enabled
285. st see Figure 23 Figure 23 Processes window Processes Thread Thread Thread Thread Thread Thread Thread task4 task3 task2 task1 task8 terminated 8x888371F8 md terminated 8x88832ce8 md terminated 8x8882e7c8 md terminated 8x8882a2b8 md unknown state 8x88825d98 Idle Task active 80x88823888 md Root Task active amp running 0x8861b314 task delet kernel syscall a kernel syscall kernel syscall kernel syscall md kernel syscal kernel task laur The Processes window shows the thread number and details such as current status To set a thread as the current thread click on it This causes the debugger to switch contexts and updates all windows 8063762 Rev 9 79 246 Using Insight ST200 7 15 80 246 Using the ST200 Statistics window The ST200 Statistics window is available only on the simulator target The ST200 Statistics window shows the results of the statistics command The window updates each time the state of the processor changes Figure 24 shows an example of the ST200 Statistics window To display the ST200 Statistics window do one of the following e click the 3 button e from the View menu in the Source Window select ST200 Statistics e press the Ctrl I keys on the keyboard Figure 24 The ST2x0 Statistics window Apu Statistics Total cycles 42799 Real time ms 0 107 Num issued bundle
286. t display reset If reset is specified then display the initial branch trace contents instead of the current contents Set the mode of the branch trace buffer where mode mode mode is one of the symbols in Table 57 on page 223 Stop the trace an reset the branch trace buffer reset content Write the branch trace to file The file is written in the same format as the display command If reset is specified then save the initial branch trace contents instead of the current contents save file reset status Display the configuration for the branch trace buffer When using either the display Or save subcommands use the reset option to report the data held in the branch trace buffer immediately after connecting to the target with GDB This can be useful as a post mortem debugging aid when reconnecting to a target after a crash 8063762 Rev 9 ST200 Branch trace buffer C 3 Output format The display and save subcommands report the details of the eight branches taken most recently with the details of each branch described as follows index to address in function from address in function Mode where index address function location type opcode type at location at location opcode This is the record number 0 is the most recent branch performed by the target 7 is the oldest This is the address of the branch source or destination T
287. t OldHandler InterruptVector t NewHandler NewHandler MySyscallHandle bsp core interrupt install amp NewHandler amp OldHandler BSP CORE MISALIGNED TRAD B 6 2 Exceptions header file machine bsp core h All the definitions related to the exception handling are in the single header file machine bsp core h Table 51 Functions defined in machine bsp core h Functions Description Install an exception handler for a specified bsp core interrupt install exception cause bsp core interrupt lock Disable external interrupts at core level bsp core interrupt unlock Enable external interrupts at core level ky 8063762 Rev 9 199 246 ST200 board support package BSP ST200 B 7 B 7 1 B 7 2 Note 200 246 Interrupts Interrupts are events external to the CPU that are signaled to it through sampled lines When an interrupt occurs an interrupt handler interrupts the CPU s normal flow of execution The normal execution flow resumes after the interrupt handler terminates The ST200 cores have 64 lines of external interrupts A subset of these lines can be masked that is disabled individually In the ST231 the first three lines are connected to the three system timers O 1 and 2 The remaining 61 lines are connected to system specific subsystems The ST240 interrupt controller supports up to 64 external interrupt sources three internal interrupt sources from the t
288. t d USER API test esr esr api const char s size ted USER API test isr isr api const char s size ted USER API test task task api const char s task t T The example definition file in Figure 27 myapp def specifies e several of the C library heap allocation APIs sbrk r malloc r memalign r calloc r realloc r and free r e three custom activity event API definitions esr signal isr signal and task signal e three APIs from the user application esr api isr api and task api Each are defined using an appropriate group class name triplet and each API has its return value and parameters defined Several header files are also required as these define the types referenced by the APIs 8063762 Rev 9 113 246 OS21 Trace ST200 To generate the source files necessary for building the application run os21usertrace with the following command line os21usertrace d myapp in g myapp cmd 1 myapp wrap ld s myapp wrap c myapp def Building Use st200cc to compile the generated C source file myapp wrap c st200cc mruntime os21 fno zero initialized in bss g c myapp wrap c Warning The generated C source file must be compiled using the fno zero initialized in bss option to ensure that the data structures in target memory used by the generated GDB command scripts are correctly initialized when the application is loaded onto the target The next step performs the final link of the appl
289. t install using type EXTERNAL INTERRUPTS 208 246 8063762 Rev 9 ky ST200 ST200 board support package BSP bsp interrupt poll Poll a specific interrupt Definition include lt platform h gt int bsp interrupt poll int interrupt number int value int type Arguments interrupt number The interrupt to poll in the range from O to 63 value The pointer to the returned value If the returned value is 0 the interrupt has not been raised type Flag to select between eternal and internal interrupts Values accepted INTERNAL INTERRUPTS EXTERNAL INTERRUPTS Returns Returns the error condition Description This function informs the user whether an interrupt has been raised bsp itc interrupt poll is kept for backward compatibility and it is equivalent to call bsp interrupt poll using type EXTERNAL INTERRUPTS bsp interrupt raise Raises a specific interrupt Definition include lt platform h gt int bsp interrupt raise int interrupt number int type Arguments interrupt number The interrupt to be raised type Flag to select between eternal and internal interrupts Values accepted INTERNAL INTERRUPTS EXTERNAL INTERRUPTS Returns Returns the error condition Description This function raises a specific interrupt bsp itc interrupt raise is kept for backward compatibility and it is equivalent to call bsp interrupt raise using type EXTERNAL INTERRUPTS ky 8063762 Rev
290. t nelts void file The r1 load file function uses these functions to open read and close a file handle The default behavior for these functions is to call the standard C library functions fopen fread and fclose respectively If providing a custom implementation override all three functions and link them with the main program Building a relocatable library or main module To build a relocatable library that can be loaded by the rl lib loader additional compile time and link time options must be used The following is a simple example of building a hello world loadable module st200cc o rl hello o fpic c rl hello c st200cc o rl hello rl rlib rl hello o Alternatively the compile and link phases can be carried out with a single command st200cc o rl hello rl fpic rlib ri hello c To build a main module suitable for loading a relocatable library specific link time options are required No specific compile time option are required for the main module The following is an example of building a main module st200cc o prog o prog c st200cc o prog exe rmain prog o 8063762 Rev 9 161 246 Relocatable loader library ST200 12 5 1 162 246 The compile and link phases can be carried out with a single command st200cc o prog exe rmain prog c Importing and exporting symbols For the relocatable loader system to function the main module or a loaded module must provide service
291. te where myapp directory is the directory containing the source code for myapp 3 Match function names that start with DEBUG write and have the same compilation directory as in step 2 and output their definitions de referencing pointer and string types to the file myapp debug write def os21usertracegen i myapp out o myapp debug write def d myapp directory debug n s g debug c write DEBUG write 4 Match function names that start with OS EVENT or TRACE that have not been compiled in a directory ending in debug and output their definitions de referencing pointer and string types to the file myapp deref def os21usertracegen i myapp out o myapp deref def d myapp directory debug n s g myapp c OS OS c EVENT EVENT c TRACE TRACE 5 Match function names that have the same compilation directory as in step 4 but excluding those that start with OS EVENT or TRACE and output their definitions to the file myapp other def os21usertracegen i myapp out o myapp other def d myapp directory lt debug g myapp c other OS EVENT TRACE 6 Use os21usertrace to process the definition files generated in steps 2 to 5 to create a C source file called myapp wrap c containing the instrumented functions as well as the other companion source files os21usertrace d myapp in g myapp cmd 1 myapp wrap ld s myapp wrap c myapp debug other de
292. ternal run time data Function defined in machine rtrecord h The bare machine run time software stores configuration data records All data is accessible by using the function defined in the single header file machine rtrecord h see Table 55 Function bsp rtrecord get Description Retrieve run time configuration data Table 56 Configuration data fields Configuration data fields that can be retrieved are listed in Table 56 Configuration data field RUNTIME BOARDNAME Description Board name Field format char RUNTIME BOOTADDRESS boot section address unsigned int RUNTIME BSSEND End address of bss section unsigned int RUNTIME BSSSTART Start address of bss section unsigned int RUNTIME BUSCLOCK BUS clock frequency unsigned int RUNTIME CLEARDSS Flag indicating if the bss section is cleared at boot unsigned int RUNTIME CORENAME RUNTIME CPUCLOCK Core name CPU clock frequency char unsigned int RUNTIME DEBUGRAM Debug RAM address unsigned int RUNTIME L2 CACHE SYSTEM ADDRESS L2 cache base address unsigned int RUNTIME MODE RUNTIME PERIPH BASE RUNTIME RAMEND run time mode execution supervisor or user Peripheral base address RAM end address unsigned int unsigned int unsigned int RU
293. tes programs that use 0x800000 bytes 8 Mbytes of memory size To specify a larger or smaller memory usage for the program edit the board 1d linker script and rebuild the program see Section 4 3 3 Defining a custom board target and compiling a program on page 35 0x4000000 for ST231 and ST240 2 m Byte address of the base of external memory 0x8000000 EXTERNAL MEMORY Size of external memory in bytes ix SIZEx number Where x is 1 2 or 3 EXTERNAL MEMORY Byte address of the base of external memory m BASEx number Where x is 1 2 or 3 NONCACHEABLE The size in bytes of noncacheable memory Buffers associated 0x4000 MEM SIZE number with a number of I O related system calls are copied into this area 16 Kbytes KERNEL STACK 0x4000 SIZE number 2 Size of the kernel stack in bytes 16 Kbytes BOOT FROM RESET In a real operational context the processor typically executes some sort of boot program before starting execution of an application code By loading bootcode into external memory and specifying the reset address see RESET ADDRESS the boot eeu sequence can be exercised false In the majority of cases however it is sufficient to begin executing code at the application s start symbol after having placed the simulator in a state that is equivalent to that achiev
294. the 1ibcore a library in the BSP initialization respectively at the start and the end of the BSP initialization see Section B 10 BSP function definitions on page 204 e The init soc and init board functions are located in the 1ibsoc a and libboard a libraries respectively The GNU debugger The GNU debugger GDB supports the downloading and debugging of applications on e silicon using the ST Micro Connect e the ST200 simulator Although the GDB supplied includes the text user interface TUI and the Insight GUI this section describes only the standard command line interface Details of the TUI are provided in the GNU Debugging with GDB manual and the Insight GUI is described in Chapter 7 Using Insight on page 64 The STWorkbench IDE is also provided to build and debug see Chapter 6 Using STWorkbench on page 58 There are several tools supplied with the GDB for debugging applications The following GDB tools support the ST200 simulators and silicon e st200gdb e st200insight st200insight is identical to st200gdb except that it defaults to starting the Insight GUI instead of the command line interface Therefore wherever st200gdb is referenced the same also applies to st200insight Using GDB GDB can execute any program but it can only be used effectively to debug programs compiled with debugging information using the g compilation option When a program is compiled start GDB as follows st200gdb executable GDB s
295. the simulator statistic counters statistics Output the current simulator statistics to screen statistics filename Output the current simulator statistics to file Statistics filename stop statistics Append the current simulator statistics to file Stop the simulator statistic counters trace off Turn tracing off trace on Turn tracing on 52 246 8063762 Rev 9 ST200 Cross development tools Table 11 Simulator and DSU commands continued Command Description DSU commands only available when connected to a silicon target enable dsu Enables the DSU commands enable dsu is executed automatically when the host connects to a physical ST200 target dsu dsu dsu dsu dbreak either lower upper dbreak in range lower upper dbreak masked lower upper dbreak out range lower upper The DBREAK CONTROL registers determine the comparison operations performed on the breakpoint addresses If the comparison is true then a breakpoint exception is signaled For the data breakpoints the data effective address of loads and stores are used for comparison Prefetches and purges do not trigger data breakpoints dsu dbreak disable Disables dbreak if a dbreak was already set range and condition are lost dsu dpeek reg numregs Read and show the contents of numregs DSU registers starting from reg If numregs is not specified
296. the size of the buffer e The default trace buffer constructor can be disabled using the trace no constructor option The user can then initialize the trace buffer directly using os21 trace initialize e The default task information buffer requires 64 Kbytes of heap Use the variable os21 task trace constructor size to change the size of the buffer e The default task information buffer constructor can be disabled using the trace no constructor option The user can then initialize the task information buffer directly using os21 task trace initialize Note For more information on the variables and functions named above see Section 11 11 Trace library API on page 126 e Fora representative audio and video decode application that contains 4 Mbytes of code the approximate increases in code size are as follows OS21 activity tracing adds 3 Kbytes 0 1 increase OS21 API tracing adds 17 Kbytes 0 4 increase including OS21 activity e Forthe same representative application the approximate times to fill the default sized trace buffer the core is actually 5096 idle during the run are as follows OS21 activity tracing takes 25 secs OS21 API tracing takes 1 2 secs including OS21 activity e The profile of code and data cache utilization is perturbed 11 8 Structure of trace binary files As described in Section 11 4 Running the application on page 108 the command flush all trace buffers outputs the contents of
297. the trace buffer to three binary files This section describes the internal structure of each of these files In the format column in Table 27 Table 28 and Table 29 e INT8isan 8 bit unsigned integer e INT16 is a 16 bit unsigned integer little endian format e INT32 is a 32 bit unsigned integer little endian format e INT64is a 64 bit unsigned integer little endian format 8063762 Rev 9 115 246 OS21 Trace ST200 11 8 1 os21trace bin This file contains the contents of the trace buffer It is a sequence of records where each record has the structure given in Table 27 Table 27 File format of os21trace bin Field Format Comment time stamp INT32 Delta from previous trace record Po d See os21 context ein os21trace tracecodes h context INT32 task t object pointer or interrupt INTEVT code MINANE TANA TERR See os21 trace type ein YP os21trace tracecodes h nis defined by the code size field in the os21trace bin ticks format see Table 28 trace code INTn See os21 activity e and os21 api ein os21trace tracecodes h The following bits are set to indicate which of the optional fields are included in the record options INT32 0 to 7 number of arguments 8 caller address field 9 frame address field caller address INT32 Optional frame address INT32 Optional arguments INT32 Optional 11 8 2 os21trace bin ticks This file contains OS21 time information It consists
298. there can be one or more groups each of which contain one or more classes and each class can contain one of more names name is either the name of an API that is to be traced or a reference to a specific event to be traced The group and class levels are customizable and should be chosen to reflect the way in which tracing may be applied Tracing can be controlled at any of the three levels For instance all the APIs and events belonging to a group can be traced as a single entity or particular classes within a group can be traced individually The user can control tracing at runtime either through customized GDB commands see Section 11 10 User GDB control commands on page 123 or by using APIs linked with the application see Section 11 13 User trace runtime APIs on page 139 98 246 8063762 Rev 9 ky ST200 OS21 Trace 11 1 1 os21usertrace host tool The ST200 Micro Toolset provides the os21usertrace tool to help with instrumenting a user application for tracing with OS21 Trace os21usertrace accepts one or more definition files created by the user and from these it generates a set of output files These output files consist of e asingle GDB command script that defines the control commands for STWorkbench and GDB see Section 11 10 User GDB control commands on page 123 e asingle C source and header file containing the implementation of the instrumented user APIs custom activity APIs and control APIs to be compiled
299. tialize See also os21 trace initialize data on page 126 extern const unsigned int os21 trace constructor size The size of the trace buffer in bytes defaults to 128k records extern void os21 task trace constructor data Defaults to NULL in which case the initial task information buffer is allocated by os21 task trace initialize See also os21 task trace initialize data on page 128 extern const unsigned int os21 task trace constructor size The size of the task information buffer in bytes defaults to 2k records The following APIs can be overridden by the user os21 trace constructor user User definable trace buffer constructor Definition void os21 trace constructor user void Returns Void Description The default trace buffer constructor calls a function with this name as its final action The default implementation of this function is a no op that the user can override with their own implementation see Figure 28 on page 144 for an example os21 task trace constructor user User definable task information buffer constructor Definition void os21 task trace constructor user void Returns Void Description The default task information buffer constructor calls a function with this name as its final action The default implementation of this function is a no op that the user can override with their own implementation 138 246 8063762 Rev 9 ky ST200 OS21 Trace 11 13 User trace runtime
300. time To read the value of system time use bsp timer now include lt machine bsp timer h gt bspclock t bsp timer now void ST200 timer assignments ST200 BSP uses the Timer0 as system timer and Timer1 only if the profiling is enabled Timer2 is always free for users Timer1 is also available for users if the profiling feature is not enabled Table 45 ST200 timer assignments Timer name BSP usage TIMER SYSTEM System timer TIMER PROFILER Profiling timer TIMER USER1 User timer 1 r timer 2 onl i i iler i TTMER USER Use er 2 only available if profiler is not present To return the system time bsp timer now uses the free running system timer On ST200 the system time bsp clock t is a 64 bit value ST200 BSP maintains the top 32 bits of the 64 bit time through an interrupt handler that is called each time the 32 bit timer reaches zero The lower 32 bits of the system time are the value in the system timer If the profiling feature is enabled the profiling timer is programmed to the profiling sampling interval otherwise it is available for the user as TIMER USER2 The user Timer1 is always available for the user 8063762 Rev 9 ky ST200 ST200 board support package BSP Hardware abstraction layer HAL for the ST200 timer module The BSP has a set of functions to help program the timer d
301. time now enabled time plus enabled time ticks per sec enabled The following command displays the logging status of a specific event show type event For example display the status of the OS21 API semaphore wait event with the command gdb show os21 api semaphore wait semaphore wait enabled The following alternative command displays the logging status of all events for a type show type class all Each of the show commands has an enable disable equivalent except the show type classes commands For example gdb disable os21 activity task switch gdb disable os21 activity class interrupt gdb show os21 activity class all excp enter enabled excp exit enabled excp install enabled excp uninstall enabled general print enabled intr enter disabled intr exit disabled intr install disabled intr uninstall disabled task create enabled task delete enabled task exit enabled task switch disabled a 8063762 Rev 9 ST200 OS21 Trace 11 10 Note 11 10 1 Note User GDB control commands When used with the gdb script command line option the tool os21usertrace creates a GDB command script that defines a set of GDB commands for controlling the generation of user trace records These commands are used to show the status of tracing or to enable or disable tracing for a given group class or event To make these commands available when debuggi
302. tion_t pp void ptr Start OS21 x a 8063762 Rev 9 ST200 Toolset tips A 2 kernel initialize NULL kernel start Create new partition e pp partition create any sizeof my state t memory allocate fn my alloc NULL no free method NULL no realloc method memory status fn my status Initialize it Af my initialize pp my memory sizeof my memory Try it out printf Alloc 16 bytes p n memory_allocate pp 16 printf Alloc 10 bytes p n memory allocate pp 10 printf Alloc 1 bytes p n memory allocate pp 1 printf DoneWMn return 0 Memory managers The run time libraries have several memory managers These provide heap simple and fixed block allocators The OS21 heap algorithm is very simple It maintains a single free list of blocks and allocates from the first one which can satisfy the request Blocks added to the free list are coalesced with neighbors to reduce fragmentation When OS21 is built with the DCONF DEBUG ALLCC option specified the partition manager in OS21 can provide extensive run time checking for all partitions including those maintained by user supplied routines see Section A 1 on page 175 With the DCONF_DEBUG_ALLOC option enabled the partition manager over allocates and places scribble guards above and below the block of memory that is passed back to the user Thes
303. tions Go To Show the selected memory location Open New Window at Open an additional Memory window showing the selected memory location 8063762 Rev 9 73 246 Using Insight ST200 7 9 1 Displaying multiple Memory windows To show multiple Memory windows either click the button or from the View menu in the Source Window select Memory Figure 18 Multiple memory windows Addresses Address Esci m zi us is LITTLE endian ASCII 6x 68 667996 6x666006666 Ox 08088888 Ox 008806688 Ox 00008682 8x088079a0 0x087fbff 6x 087FbFc O 0x087fbfc 6x 66666666 6x 68 0679b 5 0x087fffe8 Hx 900006061 0x00000001 Ox 69699661 Bx 68 6679c B 0x 88888888 Bx 08888888 6x17d78466 Ox 67ed6b46 Ox 68667906 0x 08808888 6x 66061 666 Ox 68066666 Ox 088 08800 6x 68 6679e6 Hx 080080601 0x 080800868 Ox 00000868 Ox 68 6687 60 Ox 080879 8 0x 08808da8 6x 68 668da8 Ox 98067 68c 0x 08007 094 6x 68 6674606 6x 68667 694 0x088879c 000000008 6x17d78466 4 5 x Address EEEE Target is LITTLE endian ASCII es EE 6x 66660606 TT 0x080079a0 Ox 087FbFF4 8x887fbfcO Ox B87FbFCO 9000099990 Ox 680079b0 Ox 087FFfFeD 6x 66666661 Ox 69000001 0x 68808801 8x 088879c 8 Ex 68888888 6x 66666606 0170784090 6x67ed6b48 8x888879d8 9894888898 Ox 606061 609 Ox 88808080 0x 8800009 8x888879e8 0x88800801 0x 00000880 Ox 88888808 Ox 98 0087 90 6x 68 6679F 6 Ox 98 608da8 Ox 68668d
304. tions The board my board directory contains the majority of the target dependent information Toolset configuration To control the executable generation and execution there are three options mcore adds the core type specific contribution msoc adds the SoC specific contribution mboard adds the board contribution When one of the options is not defined the default value is used The configuration data related to the target configuration is in the lt tools dir gt target directory Table 3 lists the parameters managed by the toolset and how they interact with each other Table 3 ST200 toolset parameters Item Set up by Used by Core include path Compiler driver C Preprocessor SoC include path Compiler driver C Preprocessor Board include path Compiler driver C Preprocessor Macros for example ST231 Compiler driver C Preprocessor crtl o Compiler driver Linker crti o Compiler driver Linker crtn o Compiler driver Linker crtbegin o Compiler driver Linker crtend o Compiler driver Linker Core initialization library Compiler driver Linker Core library search path Compiler driver Linker SoC initialization library Compiler driver Linker SoC library search path Compiler driver Linker Board initialization library Compiler driver Linker Board library search path Compiler driver Linker DEFAULT RAMEND Linker script Linker loader DEFAULT RESET A
305. to launch the test The example is driven by the GDB command script traceexec cmd This script enables OS21 tracing both activity and API executes the application and then flushes the trace buffers onto the default host file before exiting The example application is a simple demonstration of OS21 task usage with time slicing enabled 11 6 2 User API and user activity trace This section provides a simple example of using OS21 Trace to trace APIs and some custom activity events within a user application os21usertrace The first step is to create a definition file for os21usertrace This specifies each of the user API functions and user activity events to trace using the format described in Section 1 1 1 2 User definition file on page 100 Figure 27 Example definition file myapp def USER INCLUDE stdlib h USER INCLUDE malloc h USER INCLUDE os21 h USER API libc sys sbrk r void p struct reent Gp ptrdiff ted USER API libc heap malloc r void p struct _reent p size tedj USER API libc heap memalign r void p struct _reent p size t d size ted USER API libc heap calloc r void p struct _reent p size t d size ted USER API libc heap realloc r void p struct _reent p void p size ted USER API libc heape free r void struct _reent p void p USER ACTIVITY test esr esr signal unsigned int d USER ACTIVITY test isr isr signal unsigned int d USER ACTIVITY test task task signal unsigned in
306. tools ST200 5 3 4 48 246 Connecting to a running target without the executable available Even if the program executing on the target is not known and thus not available on the host machine it is still possible to connect to the running target The only information that st200gdb must be aware of is the target architecture The following command lines show how to launch st200gdb perform the connect set the architecture and disassemble code starting from the current program counter gt st200gdb gdb st200tp IP address board core no reset 1 no pokes 1 gdb set architecture st231 st2405 gdb gdb disass Spec pc 10 GDB command line reference Table 8 lists some of the most useful command line options Table 8 st200gdb command line options Option Description nw Disables the Insight GUI and uses the command line interface nowindows Equivalent to the option interpreter console Prevents GDB from sourcing any 1xgdbinit files or reading the gdbtkinit file if they exist EN If the environment variable INSIGHT FORCE READ PREFERENCES is set then nx does not prevent the reading of the gdbtkinit file Enables the Insight GUI instead of the command line interface see DW Chapter 7 Using Insight on page 64 windows Equivalent to the option interpreter insight Enables the GDB text user interface TUI instead of the command tui line interface Equ
307. tors size 0x8 lma 0090245964 section data size fx1724 Ina 0088245979 Start address xc880080308 load size 155792 Transfer rate 1246336 bits in lt 1 sec 19474 bytes write Breakpoint 5 6xc860080328 in main gdb If the Console Window is open when a GDB command is issued it shows the output For example the load command Insight GUI commands such as continue Or step are not visible in the Console Window unless they are issued directly at the Console Window prompt The display output of the Insight GUI and the GDB console commands are synchronized To view the ST200 simulator instruction trace data or to switch the performance data gathering of the simulator on or off use the console You can issue any GDB command through the Console Window If you use console off the program output is visible on the terminal from which Insight was launched and not in the console window For this reason use console on in conjunction with Insight 8063762 Rev 9 77 246 Using Insight ST200 7 13 78 246 Using the Function Browser window To search for functions in the application and show the source code for that function use the Function Browser window see Figure 22 This makes it easy to add breakpoints throughout the code To open the Function Browser window from the View menu in the Source Window select Function Browser The following fields are available to search for functions Function Filter Searche
308. tructor void my os21 trace destructor void if trace_enabled_flag Disable trace os21 trace set enable 0 os21 task trace set enable 0 Save trace and task information data os21 trace write file os21trace bin 1 os21 task trace write file os21tasktrace bin 1 144 246 8063762 Rev 9 ST200 Relocatable loader library 12 Note 12 1 Note Relocatable loader library The relocatable loader library rl lib supports the creation and loading of DSOs dynamic shared objects also known as load modules in an embedded environment rl lib implements DSOs as defined in the standard for supporting ELF System V Dynamic Linking For applications that do not rely on advanced OS features such as file systems virtual memory management and multi process segment sharing use rl lib as an alternative to the standard ELF System V Dynamic Loader 1ibdl so Run time model overview The ELF System V ABI supports several run time models Only some run time models are suitable for embedded systems without the support of traditional operating system services The run time model for an application dictates the method used for linking and loading Table 32 lists the different run time models Table 33 summarizes the features supported by each model rl lib implements only the R Relocatable run time model Table 32 Run time models Run time model Description Absolute
309. tructures of type bsp memory map t terminated by a NO MAP element The bsp memory map t structure has the following format typedef struct bsp memory map s f void addr size_t len int page_size int policy int user_prot int super_prot bsp_memory_map_t Where addr and len are the starting point and the length of the memory area to be mapped The page_size parameter specifies the preferred size of the page to be used for the TLBs allowed values are PAGE 256MB Page size of 256 MBytes PAGE 4MB Page size of 4 MBytes PAGE 8KB Page size of 8 KBytes PAGE_4KB Page size of 4 KBytes ST240 only The policy parameter can have the following values OXTLB ENTRYO POLICY UNCACHED 0 Uncached mode OXTLB ENTRYO POLICY CACHED 1 Cached mode XTLB ENTRYO POLICY WCUNCACHED 2 Write combining uncached The parameters user prot and super prot define the protection rating for the area used for user and supervisor applications Allowed values are XTLB PROT EXECUTE 1 Execute permission UXTLB PROT READ 2 Read Prefetch amp Purge permission XTLB PROT WRITE 4 Write permission For example the following code will create a TLB entry in bare runtime initialization int STIxxxx PERIPHERAL BASE PMA 0xf0000000 Periph at Oxf0000000 int STIxxxx PERIPHERAL SIZE 0x10000000 256 MB 8063762 Rev 9 ky
310. ule into memory from the file specified by name It opens the specified file with an open call allocates the space for the loaded module in the heap loads the segments from the file links the module to the parent module of the handle relocates and initializes the loaded module The file is closed with fclose before returning This function calls the action callback functions for the RL ACTION LOAD after loading and before executing any code in the loaded module 0 is returned if the load was successful 1 is returned on failure and the error code returned by r1 errno is set accordingly 8063762 Rev 9 ky ST200 Relocatable loader library rl load stream Load a relocatable module into memory from a byte stream Definition Arguments Returns Description typedef int rl stream func t void cookie char buffer int length int rl load stream rl handle t handle rl stream func t stream func void stream cookie handle The handle for the module stream func The user specified callback function stream cookie The user specified state Returns 0 for success 1 for failure The rl load stream function loads a relocatable module into memory from a byte stream provided through a user specified callback function stream func and the user specified state stream cookie The callback function must be of type r1 stream func t ltis called multiple times by the loader to retrieve the load
311. upports the ST200 R6 3 Updated Section 1 3 4 The syscalls low level I O interface on page 18 Added syscalls to Section 1 5 The examples directory on page 20 and os21 trace to OS21 examples on page 21 Corrected st200xrun command line in Chapter 2 Introducing OS21 Corrected Note in Section 5 1 Loading and executing a target program on page 40 Updated the examples in Section 5 3 3 Connecting to a running target on page 46 Corrected gdb example in Section 8 1 1 Customized simulator targets on page 84 Added Chapter 11 OS21 Trace on page 98 Added Section A 11 Watchpoint support on page 190 Removed bsp timer count mode from Table 47 in Section B 4 5 Timer header file machine bsp timer h on page 197 and from Section B 10 BSP function definitions Removed bsp pm count mode from Table 49in Section B 5 1 Hardware abstraction layer for the PM module on page 198 and from Section B 10 Corrected bsp mmu memory map description in Section B 10 BSP function definitions on page 204 Updated Table 57 in Section C 1 Branch trace buffer modes on page 223 Updated Table 58 in Section C 2 The branchtrace command on page 224 Added Section C 3 Ouiput format on page 225 Updated Appendix D Profiler plugin on page 226 to describe the profiler modes none dsu and interrupt The profiler modes none and interrupt now apply to all ST200 cores dsu mode applies to ST240 only Added Section D 2 Trace profile output format on page 229 and S
312. user supplied callback function is called in the context of a high priority task The example contains the source for the timer library and a small test program that uses the library Demonstrates how to extract OS21 system trace information from a simple OS21 example using tasks The example makes use of the os21trace library and tools for decoding trace output into several readable formats including STWorkbench How to use OS21 in a C application 8063762 Rev 9 21 246 Introducing OS21 ST200 2 22 246 Introducing OS21 OS21 is a royalty free lightweight multi tasking operating system developed by STMicroelectronics It is an evolution of the OS20 API and is intended for applications where a small footprint and excellent real time responsiveness are required It has a multi priority preemptive scheduler with low context switch and interrupt handling latencies OS21 assumes an unprotected single address space model and is easily portable between chip architectures OS21 provides an OS20 compatible API to handle task memory messaging synchronization and time management In addition OS21 enhances the OS20 memory API and introduces API extensions to control mutexes event flags and target specific APIs for interrupts and caches OS21 aware debugging is available through GDB Multi tasking is widely accepted as the optimal method of implementing real time systems Applications can be broken down into a number of in
313. using their declared types The default is to use compatible base types this avoids the need to specify C include files see include declaring the types required when compiling the os21usertrace generated source Output definitions using C struct or enum tags as their base types The default is to use compatible types void instead of struct and int instead of enum this avoids the need to specify C include files see include declaring the types required when compiling the os21usertrace generated Source deref Output definitions with format codes to de reference pointer string types The default is not to de reference pointer types For example with this option the type int is output with the format code of D instead of the default format code of p Only use this option with functions that are known to reference valid that is initialized pointers and where a de reference does not have side effects Output definitions with the s format code to decode char types as a NUL 10 terminated strings Only use this option with functions that are known to reference valid that is NUL terminated strings Function match options function name Specifies that only functions that match the name function name are to be included in the definitions file If no function name is specified then the default is to match all function names The interpretation of function name is dictated by whi
314. variables to configure this operation unsigned int os21 profiler monitor wakeup period Use this variable to specify the frequency in hertz at which the monitor task is to check if an action has been requested The higher the frequency the greater the intrusion on the operation of the application The default is 1 KHz unsigned int os21 profiler monitor priority Use this variable to define the priority at which the monitor task runs By default this is the maximum OS21 priority 0521 MAX USER PRIORITY It should not be changed unless the monitor task has been configured to periodically check if an action has been requested Reducing the priority of the monitor task increases the latency between the request being raised and the monitor task performing the action 8063762 Rev 9 ky ST200 Toolset tips Appendix A Toolset tips The following sections give tips for using the ST200 Micro Toolset A 1 Managing memory partitions with OS21 For managing areas of memory OS21 enables the creation of memory partitions see the OS21 user manual 7358306 There are several reasons for creating memory partitions for example e to implement an allocation algorithm that is appropriate to an application for example to apply some alignment constraint to allocated blocks e tomanage a special area of memory not visible to the normal memory managers for example on chip RAM or peripheral device RAM e to manage a memory reg
315. ven the extension osa to enable them to o output file be opened automatically in STWorkbench If any other extension is used the files must be opened in STWorkbench using the Open with option Optional name of the control file describing the OS21 APIs and traceable activities Use this option to override the default definition of os21 file OS21 APIs and traceable activities The format of the control file is described in Section 11 5 2 on page 112 Use m to modify the format selected by the t option where mode is one of the following details shows detailed information for each task and interrupt context This includes the number of trace records associated with each task or interrupt context and the time spent in ticks executing in the task or interrupt context Task priority and stack location information is provided for each task context metrics shows timing metrics for each recorded task and interrupt context The metrics include the number of times a task or interrupt was scheduled or descheduled and the minimum maximum and average times that the task or interrupt context was active or inactive zero includes in the report the tasks and interrupt handlers that have zero time max is equivalent to specifying m details m metrics m zero min does not show individual task and interrupt handler information simple uses an alternative time accounting regime that is based upon the conte
316. ves the user access to this block on both simulator and real targets Table 12 PMblock specific commands Command Description Enables the performance monitoring commands enable pmblock is executed automatically when enable pmblock the host connects to a physical ST200 target When connected to a simulated target this command can be executed at anytime pmblock listevents List all the available event types pmblock reset Reset all counters pmblock resetidle Reset idle flag pmblock setclock value Set the clock counter to value pmblock setcounter counter Set the counter counter to value value pmblock setevent counter event Setthe counter counter to count event pmblock show Display the PM block registers content pmblock showclock Display the clock counter value pmblock showcounter counter Display the content of counter counter pmblock start Enable starts the event counting pmblock stop Disable stops the event counting 8063762 Rev 9 ST200 Cross development tools 5 4 Using st200xrun st200xrun provides a simple batch mode interface to GDB This enables users to connect and configure a target system then load and execute an application on the target system st200xrun invokes GDB with all the options and scripts required to execute the program 5 4 1 Setting the environment The setup of st200xrun is identical
317. vide the same functionality of hardware ones but differ in that they do not emulate the hardware watchpoint trigger mechanism When software watchpoints are used GDB steps through every instruction checking whether the value of the data in the watch region has been changed Although this is effective it reduces program performance significantly To set a watchpoint use one of the commands listed in Table 39 where location can be either an address or a symbolic object name Table 39 Hardware watchpoint commands Command When triggered watch location Write accesses only rwatch location Read accesses only awatch location Both read and write accesses Watchpoints set using the watch command only trigger if the value of the data in the watch region has been changed and not just written to a Setting subsequent watchpoints is allowed but results in setting software watchpoints In this case even the first hardware watchpoint is treated as a software watchpoint until all subsequent watchpoints are active neither deleted nor out of scope b Itis not possible to explicitly differentiate which type of watchpoints hardware or software to set using the commands in Table 39 GDB makes this decision depending on the execution environment On silicon it can be either type depending on the number of hardware watchpoint already set On a simulator only the software type is allowed 8063762 Rev 9 ky ST200 ST200
318. xrun KUIA WA 55 compilation See st200cc st200c and STWork bench CONF CALLBACK SUPPORT 93 CONF DEBUG ses sess 93 CONF DEBUG ALLOC 93 CONF DEBUG CHECK EVT 93 CONF DEBUG CHECK MTX 93 CONF DEBUG CHECK SEM 93 CONF DISPLAY CLOCK FREQS 93 CONF INLINE FUNCTIONS 93 CONFIG FILE 86 configuration files 19 configuration matrix 33 configuration options 9921 es bs ska ade RR US be 92 st200cc compiler 26 33 target system See TargetPack and simulator pack configuration script 16 20 connection to target 44 56 84 for Insight 0 eee eee eee 68 thatis running eee eee 46 core selection ie AE eee eee 31 core registers 42 initialization 2 eee 42 CORE MHZ 86 counting semaphores 24 CAC 6 05 ha hee ie Sa et tee see 94 241 246 8063762 Rev 9 critical sections 178 custom board target 34 cyclic redundancy check 94 Cygwin 189 D DCACHE MODEL 86 debug kernel 00 00 eee eee 93 debugger eee eee 13 15 43 INSIQN se AA 67 debugging cece ee ee 43 board targets
319. xt information recorded with each trace record instead of context changes reported by the OS21 activity monitors This option is most useful when API tracing has been enabled ticks to output timing information in ticks usecs to output timing information in real time at microsecond resolution This is the default Not all of the modes are applicable to all output formats See Section 11 5 1 on page 111 for more information on the usage of this option m mode Optional output format where type is one of the following summary to display a summary This is the default workbench to generate output in a format suitable for STWorkbench text to display one record per line The first field is the absolute time OS21 API trace records also contain the parameters and return value of each function csv is similar to text except that the token separator is a comma The t option can be followed by an optional m option to modify the format of the output of os21decodetrace t type 110 246 8063762 Rev 9 ST200 OS21 Trace 11 5 1 Table 25 os21decodetrace command line options continued Option Description Optional name of the control file describing the user APIs and traceable activities The format of the control file is described in Section 11 5 2 on page 112 user file Trace data file for example os21trace bin os21decodetrace assumes that the OS21t
320. y GDB When the target is restarted the monitor task is woken up and it reads the structure and performs the requested action On completion of the action the monitor task writes the result back to the same structure and calls a signal function to inform GDB GDB can then read the structure and report the result of the request to the user The interface between GDB and the monitor task can be configured by the user For details of the configuration options see Section 13 7 2 Overrides on page 173 a The monitor task has the name 0821 Profiler in the OS21 task list 8063762 Rev 9 167 246 Dynamic OS21 profiling ST200 13 2 13 3 13 4 168 246 Building an application for dynamic OS21 profiling Table 35 lists the st200cc linker options required to enable the dynamic OS21 profiling features Table 35 st200cc linker options to enable dynamic OS21 profiling s200cc options Description Initialize dynamic OS21 profile support The dynamic OS21 profiler constructor is called by the OS21 profiler API function kernel start The dynamic OS21 profiler destructor is called during OS21 shutdown Adding this option to the profiler one disables the automatic initialization of the dynamic OS21 profiler This option also prevents the destructor for the dynamic OS21 profiler from being installed In this case the initialization and the deinitialization of the dynamic OS21 profiler must be per
321. y from Flash ROM Overview of booting from Flash ROM The ST200 Micro Toolset supports both single CPU and multicore CPU chips where each CPU boots from the same Flash ROM This section does not consider chips that have ST200 cores where the host processor is an ST40 core because the ST40 Micro Toolset supports the ROM booting The STi5300 has a single ST231 core and boots from offset 0x7FFFFFFFF in Flash ROM The OS21 examples in the ST200 Micro Toolset that use Flash ROM provide tools for laying out the Flash ROM in the same way for most chips The layout used by the tools in the examples supports boot vectors for up to eight CPUs at 0x40 byte offsets from the base of the Flash ROM bootstrap information for up to eight CPUs e anoptional fail safe application that runs before the main applications to check the integrity of the Flash ROM and report fix any problems e amain application image directory e main application image control structures for images in the directory that point to the real code data sections located throughout the rest of the Flash ROM More detail on the Flash ROM layout are in the comments near the start of the flasher c or mkbinrom pl files in the examples that use Flash ROM The flasher Flash ROM programming tool included in the examples can place applications in Flash ROM The flasher tool can either take component image files for example for bootvectors bootstraps or applications or a comp
322. y peeking and poking The ST200 Micro Toolset provides an integrated set of tools to support the development of embedded applications Toolset features The ST200 Micro Toolset has the following features e Supported host platforms The toolset is available on Windows XP and Windows 7 and Red Hat Linux Enterprise Workstation Version 4 0 and 5 0 for x86 e Code development tools assembler compiler and linker Program development is supported by the GCC compatible optimizing C and C compilers GNU assembler linker and archiver librarian tools e The ST200 simulator This provides an accurate software simulation of the entire family of STMicroelectronics ST200 CPU cores e Cross development with GDB The GNU debugger GDB supports both the ST200 simulator and the hardware development boards GDB also includes a text user interface and the Insight GUI as a graphical user interface on all supported host platforms The st200xrun tool is also available to provide a command line driven interface to simplify downloading and running applications on the supported targets using GDB e STWorkbench Integrated Development Environment IDE The STWorkbench is built on the Eclipse IDE The framework is extended using the CDT C C Development Tools and ST200 specific plugins which provide a fully functional C and C IDE for STWorkbench This allows the user to develop execute and debug ST200 applications interactively Additionally the ST Pro
323. y task is waiting for and a mid level priority task starts running the low priority task cannot run and therefore cannot release the mutex causing the high priority task to wait Ownership of FIFO or priority mutexes has the effect of making the task immortal that is immune to task ki11 This is intended to prevent deadlock in the event that a task owning a mutex is killed the mutex would otherwise be left owned by a dead task and therefore it would be locked out for ever If task ki11 is carried out on a mutex owning task the task remains running until it releases the mutex at which point the task ki11 is actioned Both forms of mutex can be recursively taken by the owning task without deadlock Advantages robust critical section can be recursively taken without deadlock tasks are immortal while holding a mutex FIFO mutexes provide strictly fair access to the mutex priority mutexes provide priority ordered access with priority inheritance Disadvantages e mutexes have to be created before they can be used e more costly than task 1ock and task unlock priority mutexes have a higher cost than FIFO mutexes due to priority inheritance logic e strictly for task task interlock cannot be used by interrupt handlers 180 246 8063762 Rev 9 ky ST200 Toolset tips Semaphores Semaphores in OS21 can be used for a variety of purposes see the OS21 for ST200 user manual 7410372 They can be used to provide
324. y window Stack Ctrl S Display the Stack window Watch Expressions Ctrl W Display the Watch Expressions window Local Variables Ctrl L Display the Local Variables window Breakpoints Ctrl B Display the Breakpoints window Console Ctrl N Display the Console Window Down Stack Frame Move to the stack frame called by the current frame Up Stack Frame Move to the stack frame that called the current frame Go To Bottom of Stack kiu c je ee sm I Move to the bottom most stack frame Many parts of a window have context sensitive menus to open a context sensitive menu click the right hand mouse button For example right clicking on a breakpoint position shown as a hyphen displays a context sensitive menu with the following options Continue the application and stop at the selected line Jump directly to the specified line Unlike the Continue option this modifies only the Program Counter This option is advantageous for going backward after the contents of a variable has been manually modified or for skipping over defective code as a red square Set Temporary Breakpoint Set a temporary one time only breakpoint on the selected line The breakpoint is shown as an orange square Set a breakpoint on the selected line The breakpoint is shown Set a breakpoint on the thread If more than one thread is available the Thread Selection window opens
325. zed simulator targets 84 8 1 2 Simulated boards naming convention 85 8 1 3 Simulator targets 85 8 2 Target configuration options eee ee 86 8 3 The sample device plugin for the ST200 simulator 90 8 3 1 Callbacks into the simulator 91 8 3 2 Building and running the plugin 0 0 eee ee eee 91 9 0821 Source guide 92 9 1 Configurable options 92 9 1 1 Configurable options in the standard OS21 libraries 93 9 2 Building the OS21 board support libraries 94 9 2 1 Adding support for new boards 94 9 3 GDB OS21 awareness support 94 9 3 1 Generation of the shtdi server data tables 95 10 Booting OS21 from Flash ROM 96 10 1 Overview of booting from Flash ROM 96 11 S21 If868B esses ace xac gw e Rog CR Oca RC uu eae MCI a CR dica 98 11 1 Usertrac records senakRREESEDPRSVEP ERROR E US NU EE PE 98 11 1 1 os2tusertrace host tool 99 11 1 2 User definition file 100 11 1 3 os21usertracegen host tool 1

Download Pdf Manuals

image

Related Search

Related Contents

  第108号 平成18年 4月12日    Operating Instructions for JHV  Tripp Lite SmartPro 120V 1.5kVA 1.35kW Line-Interactive Sine Wave UPS, SNMP, Webcard option, 2U Rack, LCD, USB, DB9 Serial  Samsung DN-Z45 User Manual  警告 注意 - TOTO  Farmnavigator    取扱説明書 - アソビックス  

Copyright © All rights reserved.
Failed to retrieve file