2 /* =============================================================================
3 * Copyright (c) Texas Instruments Incorporated 2020
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 var Defaults = xdc.useModule('xdc.runtime.Defaults');
34 var Diags = xdc.useModule('xdc.runtime.Diags');
35 var Error = xdc.useModule('xdc.runtime.Error');
36 var Log = xdc.useModule('xdc.runtime.Log');
37 var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
38 var Main = xdc.useModule('xdc.runtime.Main');
39 var Memory = xdc.useModule('xdc.runtime.Memory')
40 var System = xdc.useModule('xdc.runtime.System');
41 var Text = xdc.useModule('xdc.runtime.Text');
42 var Clock = xdc.useModule('ti.sysbios.knl.Clock');
43 var Task = xdc.useModule('ti.sysbios.knl.Task');
44 var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
45 var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
46 var GateSwi = xdc.useModule('ti.sysbios.gates.GateSwi');
48 var BIOS = xdc.useModule('ti.sysbios.BIOS');
49 var Hwi = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Hwi');
50 var Core = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Core');
51 var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
52 var SysMin = xdc.useModule('xdc.runtime.SysMin');
53 /* System stack size (used by ISRs and Swis) */
54 Program.stack = 0x2000;
55 var Task = xdc.useModule('ti.sysbios.knl.Task');
56 Task.defaultStackSize = 0x4000;
57 Task.common$.namedInstance = true;
58 Task.common$.namedModule = true;
60 /* Enable cache */
61 var Cache = xdc.useModule('ti.sysbios.family.arm.v7r.Cache');
62 Cache.enableCache = true;
64 /*
65 * Direct CIO to UART
66 */
67 /* System.SupportProxy = SysUart; */
68 System.SupportProxy = SysMin;
70 /*
71 * Program.argSize sets the size of the .args section.
72 * The examples don't use command line args so argSize is set to 0.
73 */
74 Program.argSize = 0x0;
76 /*
77 * Uncomment this line to globally disable Asserts.
78 * All modules inherit the default from the 'Defaults' module. You
79 * can override these defaults on a per-module basis using Module.common$.
80 * Disabling Asserts will save code space and improve runtime performance.
81 Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
82 */
84 /*
85 * Uncomment this line to keep module names from being loaded on the target.
86 * The module name strings are placed in the .const section. Setting this
87 * parameter to false will save space in the .const section. Error and
88 * Assert messages will contain an "unknown module" prefix instead
89 * of the actual module name.
90 Defaults.common$.namedModule = false;
91 */
93 /* Create default heap and hook it into Memory */
94 var heapMemParams = new HeapMem.Params;
95 heapMemParams.size = 16384*3;
96 var heap0 = HeapMem.create(heapMemParams);
98 Memory.defaultHeapInstance = heap0;
100 /*
101 * Minimize exit handler array in System. The System module includes
102 * an array of functions that are registered with System_atexit() to be
103 * called by System_exit().
104 */
105 System.maxAtexitHandlers = 4;
107 /*
108 * Uncomment this line to disable the Error print function.
109 * We lose error information when this is disabled since the errors are
110 * not printed. Disabling the raiseHook will save some code space if
111 * your app is not using System_printf() since the Error_print() function
112 * calls System_printf().
113 Error.raiseHook = null;
114 */
116 /*
117 * Uncomment this line to keep Error, Assert, and Log strings from being
118 * loaded on the target. These strings are placed in the .const section.
119 * Setting this parameter to false will save space in the .const section.
120 * Error, Assert and Log message will print raw ids and args instead of
121 * a formatted message.
122 Text.isLoaded = false;
123 */
125 /*
126 * Uncomment this line to disable the output of characters by SysMin
127 * when the program exits. SysMin writes characters to a circular buffer.
128 * This buffer can be viewed using the SysMin Output view in ROV.
129 SysMin.flushAtExit = false;
130 */
132 /*
133 * Create and install logger for the whole system
134 */
135 var loggerBufParams = new LoggerBuf.Params();
136 loggerBufParams.numEntries = 32;
137 var logger0 = LoggerBuf.create(loggerBufParams);
138 Defaults.common$.logger = logger0;
139 Main.common$.diags_INFO = Diags.ALWAYS_ON;
141 BIOS.libType = BIOS.LibType_Custom;
142 BIOS.cpuFreq.lo = 1000000000;
143 BIOS.cpuFreq.hi = 0;
145 var coreId = java.lang.System.getenv("CORE");
147 var DMTimer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
148 DMTimer.checkFrequency = false;
149 for (var i=0; i < DMTimer.numTimerDevices; i++) {
150 DMTimer.intFreqs[i].lo = 19200000;
151 DMTimer.intFreqs[i].hi = 0;
152 }
154 if(coreId=="mcu1_0")
155 {
156 Core.id = 0;
157 /* DM timer cfg */
158 Clock.timerId = 1;
159 }
160 if(coreId=="mcu1_1")
161 {
162 Core.id = 1;
163 /* DM timer cfg */
164 Clock.timerId = 2;
165 }
166 if(coreId=="mcu2_0")
167 {
168 Core.id = 0;
169 Clock.timerId = 0;
170 /* DMTimer #12 - in general, address is 0x024x0000 where x is timer # */
171 DMTimer.timerSettings[0].baseAddr = 0x024c0000;
172 DMTimer.timerSettings[0].intNum = 168;
173 }
174 if(coreId=="mcu2_1")
175 {
176 Core.id = 1;
177 Clock.timerId = 1;
178 /* DMTimer #13 - in general, address is 0x024x0000 where x is timer # */
179 DMTimer.timerSettings[1].baseAddr = 0x024d0000;
180 DMTimer.timerSettings[1].intNum = 169;
181 }
182 if(coreId=="mcu3_0")
183 {
184 Core.id = 0;
185 Clock.timerId = 2;
186 /* DMTimer #14 - in general, address is 0x024x0000 where x is timer # */
187 DMTimer.timerSettings[2].baseAddr = 0x024e0000;
188 DMTimer.timerSettings[2].intNum = 170;
189 }
190 if(coreId=="mcu3_1")
191 {
192 Core.id = 1;
193 Clock.timerId = 3;
194 /* DMTimer #15 - in general, address is 0x024x0000 where x is timer # */
195 DMTimer.timerSettings[3].baseAddr = 0x024f0000;
196 DMTimer.timerSettings[3].intNum = 171;
197 }
199 /* Set base address of Vector Interrupt Manager */
200 if((coreId=="mcu2_0") || (coreId=="mcu2_1") || (coreId=="mcu3_0") || (coreId=="mcu3_1"))
201 {
202 var Hwi = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Hwi');
203 Hwi.vimBaseAddress = 0x0ff80000;
204 }
206 var Reset = xdc.useModule("xdc.runtime.Reset");
207 Reset.fxns[Reset.fxns.length++] = "&utilsCopyVecs2ATcm";
209 /*
210 * Initialize MPU and enable it
211 *
212 * Note: MPU must be enabled and properly configured for caching to work.
213 */
214 xdc.loadCapsule("r5_mpu_ipc.xs");
216 /* Check if application needs to update with custom configuration options */
217 var cfgUpdate = java.lang.System.getenv("XDC_CFG_UPDATE")
218 if ((cfgUpdate != '')&&(cfgUpdate != null))
219 {
220 xdc.print("Loading configuration update " + cfgUpdate);
221 xdc.loadCapsule(cfgUpdate);
222 }