1 Microsoft's Azure RTOS ThreadX for Cortex-M23 2 3 Using the GNU Tools 4 5 61. Building the ThreadX run-time Library 7 8An example .bat file is in the example_build directory. 9Files tx_thread_stack_error_handler.c and tx_thread_stack_error_notify.c 10replace the common files of the same name. 11 122. Demonstration System 13 14No demonstration example is provided. 15 16 173. System Initialization 18 19The entry point in ThreadX for the Cortex-M23 using gnu tools uses the standard GNU 20Cortex-M23 reset sequence. From the reset vector the C runtime will be initialized. 21 22The ThreadX tx_initialize_low_level.S file is responsible for setting up 23various system data structures, the vector area, and a periodic timer interrupt 24source. 25 26In addition, _tx_initialize_low_level determines the first available 27address for use by the application, which is supplied as the sole input 28parameter to your application definition function, tx_application_define. 29 30 314. Register Usage and Stack Frames 32 33The following defines the saved context stack frames for context switches 34that occur as a result of interrupt handling or from thread-level API calls. 35All suspended threads have the same stack frame in the Cortex-M23 version of 36ThreadX. The top of the suspended thread's stack is pointed to by 37tx_thread_stack_ptr in the associated thread control block TX_THREAD. 38 39 40 Stack Offset Stack Contents 41 42 0x00 LR Interrupted LR (LR at time of PENDSV) 43 0x04 r8 44 0x08 r9 45 0x0C r10 46 0x10 r11 47 0x14 r4 48 0x18 r5 49 0x1C r6 50 0x20 r7 51 0x24 r0 (Hardware stack starts here!!) 52 0x28 r1 53 0x2C r2 54 0x30 r3 55 0x34 r12 56 0x38 lr 57 0x3C pc 58 0x40 xPSR 59 60 615. Improving Performance 62 63To make ThreadX and the application(s) run faster, you can enable 64all compiler optimizations. 65 66In addition, you can eliminate the ThreadX basic API error checking by 67compiling your application code with the symbol TX_DISABLE_ERROR_CHECKING 68defined. 69 70 716. Interrupt Handling 72 73ThreadX provides complete and high-performance interrupt handling for Cortex-M23 74targets. There are a certain set of requirements that are defined in the 75following sub-sections: 76 77 786.1 Vector Area 79 80The Cortex-M23 vectors start at the label __tx_vectors or similar. The application may modify 81the vector area according to its needs. There is code in tx_initialize_low_level() that will 82configure the vector base register. 83 84 856.2 Managed Interrupts 86 87ISRs can be written completely in C (or assembly language) without any calls to 88_tx_thread_context_save or _tx_thread_context_restore. These ISRs are allowed access to the 89ThreadX API that is available to ISRs. 90 91ISRs written in C will take the form (where "your_C_isr" is an entry in the vector table): 92 93void your_C_isr(void) 94{ 95 96 /* ISR processing goes here, including any needed function calls. */ 97} 98 99ISRs written in assembly language will take the form: 100 101 102 .global your_assembly_isr 103 .thumb_func 104your_assembly_isr: 105; VOID your_assembly_isr(VOID) 106; { 107 PUSH {r0, lr} 108; 109; /* Do interrupt handler work here */ 110; /* BL <your interrupt routine in C> */ 111 112 POP {r0, r1} 113 MOV lr, r1 114 BX lr 115; } 116 117 118Note: the Cortex-M23 requires exception handlers to be thumb labels, this implies bit 0 set. 119To accomplish this, the declaration of the label has to be preceded by the assembler directive 120.thumb_func to instruct the linker to create thumb labels. The label __tx_IntHandler needs to 121be inserted in the correct location in the interrupt vector table. This table is typically 122located in either your runtime startup file or in the tx_initialize_low_level.S file. 123 124 1257. Revision History 126 127For generic code revision information, please refer to the readme_threadx_generic.txt 128file, which is included in your distribution. The following details the revision 129information associated with this specific port of ThreadX: 130 13106-02-2021 Release 6.1.7 changes: 132 tx_thread_secure_stack_initialize.S New file 133 tx_thread_schedule.S Added secure stack initialize to SVC hander 134 tx_thread_secure_stack.c Fixed stack pointer save, initialize in handler mode 135 13604-02-2021 Release 6.1.6 changes: 137 tx_port.h Updated macro definition 138 tx_thread_schedule.s Added low power support 139 14003-02-2021 The following files were changed/added for version 6.1.5: 141 tx_port.h Added ULONG64_DEFINED 142 14312-31-2020 The following files were 144 changed/added for port specific version 6.1.3: 145 146 tx_port.h Remove unneeded include files, 147 use builtin functions, 148 modified comments. 149 150 tx_thread_secure_stack.c Remove unneeded include file, 151 use inline get/set functions, 152 modified comments. 153 15409-30-2020 Initial ThreadX 6.1 version for Cortex-M23 using GNU tools. 155 156 157Copyright(c) 1996-2020 Microsoft Corporation 158 159 160https://azure.com/rtos 161 162