From f22b51c00b8d085fcfa9aecc6f287df8621cfe16 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Sun, 14 Jun 2026 05:46:10 +0530 Subject: [PATCH 01/11] Add HW spinlock usage examples (assembly/C) in academy/spinlock Closes #120. Demonstrates the PRU_ICSSG local hardware spinlock accessed over the broadside interface (XIN/XOUT), as recommended in the issue: - lock id (0-63) in R1.b0 - acquire: XIN 0x90, &R1.b3, 1 -> status in R1.b3 bit 0 (1 = acquired) - release: XOUT 0x90, &R1.b3, 1 (same id in R1.b0) Files: - spinlock.asm: C-callable spinlock_acquire()/spinlock_release(). - main.c: C example - PRU0/PRU1 contend for one lock, scope via debug GPO. - spinlock_example.asm: pure-asm example with M_SPINLOCK_ACQUIRE/RELEASE macros. - readme.md: usage, semantics, and build notes. All sources assemble/compile with clpru --silicon_version=3 (ti-cgt-pru 2.3.3); main.c builds for both PRU0 and PRU1. Co-Authored-By: Claude Opus 4.8 --- academy/spinlock/main.c | 77 +++++++++++++++++ academy/spinlock/readme.md | 114 ++++++++++++++++++++++++++ academy/spinlock/spinlock.asm | 66 +++++++++++++++ academy/spinlock/spinlock_example.asm | 70 ++++++++++++++++ 4 files changed, 327 insertions(+) create mode 100644 academy/spinlock/main.c create mode 100644 academy/spinlock/readme.md create mode 100644 academy/spinlock/spinlock.asm create mode 100644 academy/spinlock/spinlock_example.asm diff --git a/academy/spinlock/main.c b/academy/spinlock/main.c new file mode 100644 index 000000000..d848a3179 --- /dev/null +++ b/academy/spinlock/main.c @@ -0,0 +1,77 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ + * + * Spinlock Example - C Version (PRU_ICSSG local hardware spinlock) + * + * Demonstrates mutual exclusion between PRU0 and PRU1 using the PRU-local + * hardware spinlock, accessed over the broadside interface (XIN/XOUT). The + * low-level acquire/release are implemented in spinlock.asm; this file shows + * the usage pattern. + * + * Each PRU repeatedly takes the same spinlock, drives a debug GPO high while it + * holds the lock, waits a (per-core different) number of cycles, then releases + * and drives the debug GPO low. Probing the two debug pins shows that the two + * cores never hold the lock at the same time. + */ + +#include + +/* + * Acquire/release are defined in spinlock.asm (separately linked). They use + * broadside XID 0x90, which is the spinlock in the *local* PRU subsystem; a + * separate function would be needed for a spinlock in a different subsystem. + * + * spinlock_acquire() is a single non-blocking attempt: it returns 1 if the + * lock was acquired, 0 otherwise. The spin loop lives here in C. + */ +uint8_t spinlock_acquire(uint8_t flag_id); +void spinlock_release(uint8_t flag_id); + +/* Spinlock flag id (valid range 0-63). Both PRUs must use the same id. */ +#define SPINLOCK_FLAG 11 + +/* R30 drives the PRU GPO signals; use a debug pin to scope lock ownership. */ +/* TODO: pinmux the debug signals (see the GPIO lab) and update the shift to */ +/* match your board. PRU0 is selected via -DPRU0 in the makefile. */ +volatile register uint32_t __R30; +#if PRU0 +#define DEBUG_PIN_SHIFT 4 /* PRU0 debug pin */ +#else +#define DEBUG_PIN_SHIFT 5 /* PRU1 debug pin */ +#endif + +/* Hold the lock for a different time per core so contention is observable. */ +#if PRU0 +#define HOLD_SPINLOCK_TIME 1000 /* PRU0 holds for 1000 cycles */ +#else +#define HOLD_SPINLOCK_TIME 2000 /* PRU1 holds for 2000 cycles */ +#endif + +void main(void) +{ + uint8_t result = 0; + + /* Start with all GPO signals low. */ + __R30 = 0x00000000; + + while (1) { + /* Spin until we own the lock (acquire returns 1 on success). */ + result = 0; + do { + result = spinlock_acquire(SPINLOCK_FLAG); + } while (result != 1); + + /* Critical section: we hold the lock. Drive the debug pin high. */ + __R30 |= (1 << DEBUG_PIN_SHIFT); + + __delay_cycles(HOLD_SPINLOCK_TIME); + + /* Release the lock, then drop the debug pin. */ + spinlock_release(SPINLOCK_FLAG); + __R30 &= ~(1 << DEBUG_PIN_SHIFT); + } + + /* Not reached because of the while(1) loop above. */ + __halt(); +} diff --git a/academy/spinlock/readme.md b/academy/spinlock/readme.md new file mode 100644 index 000000000..80d9f7a7d --- /dev/null +++ b/academy/spinlock/readme.md @@ -0,0 +1,114 @@ +# Spinlock Usage Examples + +This lab shows how a PRU core uses the **PRU_ICSSG local hardware spinlock** to get +mutual exclusion over a resource shared between PRU0, PRU1 and/or the host CPU. + +## How the PRU-local spinlock works + +The PRU_ICSSG includes a hardware spinlock accelerator with **64 ownership flags** +(lock id `0`–`63`). A PRU core reaches it over the **broadside interface** using the +`XIN`/`XOUT` instructions — there is no memory-mapped load/store on the critical path, +so acquire/release are only a couple of cycles. + +- The broadside device id (XID) **`0x90` (= 144)** selects the spinlock in the + **local** PRU subsystem. A different XID is needed to reach a spinlock in another + PRU subsystem. +- The **lock id** to operate on is placed in **`R1.b0`**. +- **Acquire** (`XIN 0x90, &R1.b3, 1`): the accelerator returns the acquisition status + in **`R1.b3`** — **bit 0 = 1** means the lock is now owned by this core, **bit 0 = 0** + means it is held by someone else, so retry. A single `XIN` is one attempt; busy-wait + until you get a 1. +- **Release** (`XOUT 0x90, &R1.b3, 1`): with the same lock id still in `R1.b0`, frees + the lock. + +Consequences: + +- You acquire by **spinning on the status bit**, not by writing a value. +- A spinlock provides **mutual exclusion only** — it is not a mailbox. To pass data or + events between cores, guard a shared buffer with the lock and signal separately (ICSS + shared RAM + a system event / interrupt; see *Signalling* below). +- Only the owner should release a lock, and it must release promptly. + +## Files + +- `spinlock.asm`: C-callable `spinlock_acquire()` / `spinlock_release()` built on the + broadside `XIN`/`XOUT` spinlock primitives. +- `main.c`: C example — both PRUs take the same lock, drive a debug GPO while holding it, + and release. The spin loop lives in C; the per-attempt acquire is in `spinlock.asm`. +- `spinlock_example.asm`: pure-assembly example using `M_SPINLOCK_ACQUIRE` / + `M_SPINLOCK_RELEASE` macros. + +## How to Build + +Adapt the silicon version to your device (`--silicon_version=3` for AM62x/AM64x/AM243x +class ICSSG). + +### Assembly only + +```bash +clpru --silicon_version=3 spinlock_example.asm +``` + +### C + assembly + +Compile both and link together; select the core with `-DPRU0` for the PRU0 build: + +```bash +clpru --silicon_version=3 -DPRU0=1 main.c spinlock.asm # PRU0 firmware +clpru --silicon_version=3 main.c spinlock.asm # PRU1 firmware +``` + +## Acquire / release pattern + +### Assembly (macros) + +```asm +INT_SPIN_XID .set 144 ; XID 0x90 - local PRU spinlock +SPINLOCK_ID .set 0 ; lock 0-63 + +M_SPINLOCK_ACQUIRE .macro + .newblock + LDI R1.b0, SPINLOCK_ID +$1: + XIN INT_SPIN_XID, &R1.b3, 1 ; status in R1.b3 + QBBC $1, R1.b3, 0 ; bit 0 clear -> retry + .endm + +M_SPINLOCK_RELEASE .macro + XOUT INT_SPIN_XID, &R1.b3, 1 + .endm +``` + +### C (calling the assembly helpers) + +```c +uint8_t spinlock_acquire(uint8_t flag_id); /* returns 1 if acquired */ +void spinlock_release(uint8_t flag_id); + +/* Acquire: spin until acquire returns 1. */ +while (spinlock_acquire(SPINLOCK_FLAG) != 1) { /* busy-wait */ } + +/* ... critical section ... */ + +spinlock_release(SPINLOCK_FLAG); +``` + +## Signalling (what NOT to do with a spinlock) + +A spinlock only provides mutual exclusion. To pass data or events between the PRU and +another core, guard a shared buffer with the lock and signal separately: + +```c +while (spinlock_acquire(0) != 1) { } +shared->command = value; /* protected write to ICSS shared RAM */ +spinlock_release(0); +/* then raise a PRU system event (R31) to interrupt the other core */ +``` + +## References + +- Device-specific Technical Reference Manual (TRM) — PRU_ICSSG broadside interface and + spinlock accelerator. +- *PRU Assembly Instruction User Guide* (SPRUIJ2) — `XIN` / `XOUT` / `XCHG`. +- *PRU Optimizing C/C++ Compiler User's Guide* — function calling conventions. +- E2E reference thread: "PRU accessing HW-Spinlocks with __xin __xout". diff --git a/academy/spinlock/spinlock.asm b/academy/spinlock/spinlock.asm new file mode 100644 index 000000000..9e1910651 --- /dev/null +++ b/academy/spinlock/spinlock.asm @@ -0,0 +1,66 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ + +;****************************************************************************** +; File: spinlock.asm +; +; Brief: C-callable acquire/release for the PRU-local hardware spinlock, +; accessed over the broadside interface with XIN/XOUT. +; +; Hardware semantics (PRU_ICSSG local spinlock accelerator): +; - The spinlock accelerator owns 64 ownership flags (lock id 0..63). +; - It is reached from the PRU over the broadside interface using the +; XIN/XOUT instructions with broadside device id (XID) 0x90 (= 144), +; which selects the PRU's *local* spinlock. A different XID is needed +; to reach a spinlock in another PRU subsystem. +; - The lock id is presented to the accelerator in R1.b0. +; - ACQUIRE: an XIN returns the acquisition status in R1.b3 (bit 0): +; * bit0 == 1 -> the lock is now OWNED BY YOU +; * bit0 == 0 -> the lock is held by someone else; retry +; The acquire is non-blocking - one XIN is one attempt. The caller +; (here, C) spins until it gets a 1. +; - RELEASE: an XOUT with the same lock id in R1.b0 frees the lock. +; +; Note: +; These helpers use XID 0x90 (local PRU subsystem). A separate function +; would be needed for accessing spinlocks in a different PRU subsystem. +;****************************************************************************** + +; Required for building .out with an assembly file + .retain + .retainrefs + +INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock + +;****************************************************************************** +; uint8_t spinlock_acquire(uint8_t flag_id); +; +; One non-blocking attempt to acquire spinlock 'flag_id'. +; Returns 1 if the lock was acquired, 0 if it is held by someone else. +; +; Calling convention (PRU C/C++ compiler): the uint8_t argument arrives in +; R14.b0 and the uint8_t return value is passed back in R14.b0. The return +; address is in r3.w2. +;****************************************************************************** + .sect ".text:spinlock_acquire" + .clink + .global spinlock_acquire +spinlock_acquire: + MOV R1.b0, R14.b0 ; lock id -> R1.b0 (presented to accel) + XIN INT_SPIN_XID, &R1.b3, 1 ; status returned in R1.b3 (bit0=acquired) + MOV R14.b0, R1.b3 ; return status + JMP r3.w2 + +;****************************************************************************** +; void spinlock_release(uint8_t flag_id); +; +; Release spinlock 'flag_id'. Only the owner should release, and it must do +; so promptly. +;****************************************************************************** + .sect ".text:spinlock_release" + .clink + .global spinlock_release +spinlock_release: + MOV R1.b0, R14.b0 ; lock id -> R1.b0 + XOUT INT_SPIN_XID, &R1.b3, 1 ; release the lock + JMP r3.w2 diff --git a/academy/spinlock/spinlock_example.asm b/academy/spinlock/spinlock_example.asm new file mode 100644 index 000000000..88f57e7ff --- /dev/null +++ b/academy/spinlock/spinlock_example.asm @@ -0,0 +1,70 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ + +;****************************************************************************** +; File: spinlock_example.asm +; +; Brief: Pure-assembly example of acquiring and releasing the PRU-local +; hardware spinlock over the broadside interface (XIN/XOUT). +; +; Hardware semantics (PRU_ICSSG local spinlock accelerator): +; - Reached over the broadside interface with XIN/XOUT using broadside +; device id (XID) 0x90 (= 144), which selects the *local* spinlock. +; - The lock id (0..63) is presented in R1.b0. +; - ACQUIRE: XIN returns acquisition status in R1.b3; bit 0 set means the +; lock is now owned by this core. Busy-wait until bit 0 is set. +; - RELEASE: XOUT with the same lock id in R1.b0 frees the lock. +; +; Steps to build: +; clpru --silicon_version=3 spinlock_example.asm +;****************************************************************************** + +; Required for building .out with an assembly file + .retain + .retainrefs + +INT_SPIN_XID .set 144 ; XID 0x90 - local PRU spinlock accelerator +SPINLOCK_ID .set 0 ; lock id 0-63, fixed in PRU firmware + +;****************************************************************************** +; Macro: M_SPINLOCK_ACQUIRE +; Acquire the spinlock and busy-wait until successful. +; R1.b0 - Input : spinlock id (set to SPINLOCK_ID) +; R1.b3 - Output: acquisition status (bit 0: 0=failed, 1=acquired) +; Best case 3 cycles; worst case unbounded (busy-wait). +;****************************************************************************** +M_SPINLOCK_ACQUIRE .macro + .newblock + LDI R1.b0, SPINLOCK_ID ; lock id (0-63) +$1: + XIN INT_SPIN_XID, &R1.b3, 1 ; attempt acquire; status in R1.b3 + QBBC $1, R1.b3, 0 ; bit 0 clear -> not acquired, retry + .endm + +;****************************************************************************** +; Macro: M_SPINLOCK_RELEASE +; Release the spinlock. Must follow M_SPINLOCK_ACQUIRE (lock id is still +; in R1.b0). 2 cycles. +;****************************************************************************** +M_SPINLOCK_RELEASE .macro + XOUT INT_SPIN_XID, &R1.b3, 1 ; release lock held in R1.b0 + .endm + +;******** +;* MAIN * +;******** + .global main + .sect ".text" +main: + ; Clear the register space before starting. + zero &r0, 120 + + M_SPINLOCK_ACQUIRE + + ;-------------------------------------------------------------------------- + ; Critical section: we now own SPINLOCK_ID. Access the shared resource here. + ;-------------------------------------------------------------------------- + + M_SPINLOCK_RELEASE + + halt From b8f13399b9aec2e99f89d6588b73625d49958cbd Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 26 Jun 2026 22:56:30 +0530 Subject: [PATCH 02/11] Add function metadata to spinlock.asm acquire/release Add the required PRU assembly function metadata (pseudocode, registers modified, peak cycle count) to spinlock_acquire and spinlock_release, matching the repo convention (e.g. multicore_scheduler pwm_toggle.asm). Documents timing and register-clobber assumptions for the low-level synchronization primitive. Comments only; assembles with clpru 2.3.3. Co-Authored-By: Claude Opus 4.8 --- academy/spinlock/spinlock.asm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/academy/spinlock/spinlock.asm b/academy/spinlock/spinlock.asm index 9e1910651..ec482af73 100644 --- a/academy/spinlock/spinlock.asm +++ b/academy/spinlock/spinlock.asm @@ -41,6 +41,14 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock ; Calling convention (PRU C/C++ compiler): the uint8_t argument arrives in ; R14.b0 and the uint8_t return value is passed back in R14.b0. The return ; address is in r3.w2. +; +; Pseudocode: +; R1.b0 = flag_id ; present lock id to the accelerator +; XIN(XID 0x90) -> R1.b3 ; one acquire attempt, bit0 = acquired +; return R1.b3 ; 1 = acquired, 0 = held by another +; +; Registers modified : R1 (R1.b0, R1.b3), R14.b0 (return value) +; Peak Cycles : 4 (one acquire attempt; excludes any C-side retry spin) ;****************************************************************************** .sect ".text:spinlock_acquire" .clink @@ -56,6 +64,16 @@ spinlock_acquire: ; ; Release spinlock 'flag_id'. Only the owner should release, and it must do ; so promptly. +; +; Calling convention (PRU C/C++ compiler): the uint8_t argument arrives in +; R14.b0. The return address is in r3.w2. +; +; Pseudocode: +; R1.b0 = flag_id ; present lock id to the accelerator +; XOUT(XID 0x90) ; free the lock +; +; Registers modified : R1.b0 +; Peak Cycles : 3 ;****************************************************************************** .sect ".text:spinlock_release" .clink From 67c816b8a81f2021618e17ba01a7635b5d62a824 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:17:53 +0530 Subject: [PATCH 03/11] academy/spinlock: give the other core a turn; build with -v4 for ICSSG Tested on LP-AM243 (ICSSG0 PRU0/PRU1). The lock gives mutual exclusion (200000/200000 contended increments, zero overlaps), but main.c starved PRU1: it re-acquired straight after releasing, before PRU1's retry loop came round, and PRU1 never got the lock in 200 samples. main.c now waits OUTSIDE_TIME cycles after releasing, and drops the debug pin before the release so the two pins never overlap on a scope. readme: --silicon_version=4 for AM64x/AM243x PRU_ICSSG (open-pru's AM243x makefiles use PRU_VERSION 4; the asm assembles to identical code with -v3), document that an owner re-acquire also reads 1, and that the lock is not fair. Co-Authored-By: Claude Opus 5.5 --- academy/spinlock/main.c | 14 ++++++++++++-- academy/spinlock/readme.md | 16 +++++++++++----- academy/spinlock/spinlock_example.asm | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/academy/spinlock/main.c b/academy/spinlock/main.c index d848a3179..461a88c13 100644 --- a/academy/spinlock/main.c +++ b/academy/spinlock/main.c @@ -41,6 +41,13 @@ volatile register uint32_t __R30; #define DEBUG_PIN_SHIFT 5 /* PRU1 debug pin */ #endif +/* + * Cycles spent outside the lock before the next attempt. The lock is not fair: + * with no gap, the core that just released re-acquires before the other core's + * retry loop comes round, every time. On LP-AM243 PRU1 never got the lock. + */ +#define OUTSIDE_TIME 200 + /* Hold the lock for a different time per core so contention is observable. */ #if PRU0 #define HOLD_SPINLOCK_TIME 1000 /* PRU0 holds for 1000 cycles */ @@ -67,9 +74,12 @@ void main(void) __delay_cycles(HOLD_SPINLOCK_TIME); - /* Release the lock, then drop the debug pin. */ - spinlock_release(SPINLOCK_FLAG); + /* Drop the debug pin, then release, so the two pins never overlap. */ __R30 &= ~(1 << DEBUG_PIN_SHIFT); + spinlock_release(SPINLOCK_FLAG); + + /* Work outside the lock, so the other core gets a turn. */ + __delay_cycles(OUTSIDE_TIME); } /* Not reached because of the while(1) loop above. */ diff --git a/academy/spinlock/readme.md b/academy/spinlock/readme.md index 80d9f7a7d..cc323c576 100644 --- a/academy/spinlock/readme.md +++ b/academy/spinlock/readme.md @@ -20,6 +20,8 @@ so acquire/release are only a couple of cycles. until you get a 1. - **Release** (`XOUT 0x90, &R1.b3, 1`): with the same lock id still in `R1.b0`, frees the lock. +- An acquire by the core that **already holds** the lock also returns 1: the status says + "this core holds the lock", it is not a nesting count. Do not use the lock recursively. Consequences: @@ -28,6 +30,10 @@ Consequences: events between cores, guard a shared buffer with the lock and signal separately (ICSS shared RAM + a system event / interrupt; see *Signalling* below). - Only the owner should release a lock, and it must release promptly. +- The lock is **not fair**. A core that tries to re-acquire straight after releasing can + win every time, because the other core's retry loop is longer than that gap. Measured on + LP-AM243 with the first version of `main.c`: PRU1 never got the lock. Do some work + outside the lock (or wait) before trying again, as `main.c` does. ## Files @@ -40,13 +46,13 @@ Consequences: ## How to Build -Adapt the silicon version to your device (`--silicon_version=3` for AM62x/AM64x/AM243x -class ICSSG). +Adapt the silicon version to your device: `--silicon_version=4` for the AM64x/AM243x +PRU_ICSSG (the open-pru AM243x makefiles use `PRU_VERSION := 4`). ### Assembly only ```bash -clpru --silicon_version=3 spinlock_example.asm +clpru --silicon_version=4 spinlock_example.asm ``` ### C + assembly @@ -54,8 +60,8 @@ clpru --silicon_version=3 spinlock_example.asm Compile both and link together; select the core with `-DPRU0` for the PRU0 build: ```bash -clpru --silicon_version=3 -DPRU0=1 main.c spinlock.asm # PRU0 firmware -clpru --silicon_version=3 main.c spinlock.asm # PRU1 firmware +clpru --silicon_version=4 -DPRU0=1 main.c spinlock.asm # PRU0 firmware +clpru --silicon_version=4 main.c spinlock.asm # PRU1 firmware ``` ## Acquire / release pattern diff --git a/academy/spinlock/spinlock_example.asm b/academy/spinlock/spinlock_example.asm index 88f57e7ff..8fb59daae 100644 --- a/academy/spinlock/spinlock_example.asm +++ b/academy/spinlock/spinlock_example.asm @@ -16,7 +16,7 @@ ; - RELEASE: XOUT with the same lock id in R1.b0 frees the lock. ; ; Steps to build: -; clpru --silicon_version=3 spinlock_example.asm +; clpru --silicon_version=4 spinlock_example.asm ;****************************************************************************** ; Required for building .out with an assembly file From ad52b0054de3e269018bb862c4d7e4150e84868a Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Fri, 16 Oct 2026 09:22:27 +0530 Subject: [PATCH 04/11] academy/spinlock: address Qodo review - spinlock_acquire returns bit 0 of the status only (AND, same cycle count), matching the documented 0/1 contract. Silicon returned exactly 0x00/0x01, so behaviour on LP-AM243 is unchanged. - spinlock_example.asm macros: pseudocode, registers modified, cycles. - main.c: file name in the header, no TODO marker, single spaces. - readme: the busy-wait has no upper bound. Co-Authored-By: Claude Opus 5.5 --- academy/spinlock/main.c | 8 +++++--- academy/spinlock/readme.md | 3 ++- academy/spinlock/spinlock.asm | 4 ++-- academy/spinlock/spinlock_example.asm | 19 +++++++++++++++---- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/academy/spinlock/main.c b/academy/spinlock/main.c index 461a88c13..7d861dd53 100644 --- a/academy/spinlock/main.c +++ b/academy/spinlock/main.c @@ -2,6 +2,8 @@ * SPDX-License-Identifier: BSD-3-Clause * Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ * + * File: main.c + * * Spinlock Example - C Version (PRU_ICSSG local hardware spinlock) * * Demonstrates mutual exclusion between PRU0 and PRU1 using the PRU-local @@ -26,14 +28,14 @@ * lock was acquired, 0 otherwise. The spin loop lives here in C. */ uint8_t spinlock_acquire(uint8_t flag_id); -void spinlock_release(uint8_t flag_id); +void spinlock_release(uint8_t flag_id); /* Spinlock flag id (valid range 0-63). Both PRUs must use the same id. */ #define SPINLOCK_FLAG 11 /* R30 drives the PRU GPO signals; use a debug pin to scope lock ownership. */ -/* TODO: pinmux the debug signals (see the GPIO lab) and update the shift to */ -/* match your board. PRU0 is selected via -DPRU0 in the makefile. */ +/* Before use: pinmux the debug signals (see the GPIO lab) and update the */ +/* shift to match your board. PRU0 is selected via -DPRU0 in the makefile. */ volatile register uint32_t __R30; #if PRU0 #define DEBUG_PIN_SHIFT 4 /* PRU0 debug pin */ diff --git a/academy/spinlock/readme.md b/academy/spinlock/readme.md index cc323c576..3ae9a247b 100644 --- a/academy/spinlock/readme.md +++ b/academy/spinlock/readme.md @@ -17,7 +17,8 @@ so acquire/release are only a couple of cycles. - **Acquire** (`XIN 0x90, &R1.b3, 1`): the accelerator returns the acquisition status in **`R1.b3`** — **bit 0 = 1** means the lock is now owned by this core, **bit 0 = 0** means it is held by someone else, so retry. A single `XIN` is one attempt; busy-wait - until you get a 1. + until you get a 1. The wait has **no upper bound**: it lasts as long as the other + core holds the lock, so keep critical sections short and bounded. - **Release** (`XOUT 0x90, &R1.b3, 1`): with the same lock id still in `R1.b0`, frees the lock. - An acquire by the core that **already holds** the lock also returns 1: the status says diff --git a/academy/spinlock/spinlock.asm b/academy/spinlock/spinlock.asm index ec482af73..495afb4e1 100644 --- a/academy/spinlock/spinlock.asm +++ b/academy/spinlock/spinlock.asm @@ -45,7 +45,7 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock ; Pseudocode: ; R1.b0 = flag_id ; present lock id to the accelerator ; XIN(XID 0x90) -> R1.b3 ; one acquire attempt, bit0 = acquired -; return R1.b3 ; 1 = acquired, 0 = held by another +; return R1.b3 & 1 ; 1 = acquired, 0 = held by another ; ; Registers modified : R1 (R1.b0, R1.b3), R14.b0 (return value) ; Peak Cycles : 4 (one acquire attempt; excludes any C-side retry spin) @@ -56,7 +56,7 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock spinlock_acquire: MOV R1.b0, R14.b0 ; lock id -> R1.b0 (presented to accel) XIN INT_SPIN_XID, &R1.b3, 1 ; status returned in R1.b3 (bit0=acquired) - MOV R14.b0, R1.b3 ; return status + AND R14.b0, R1.b3, 1 ; return bit 0 only: 1 = acquired JMP r3.w2 ;****************************************************************************** diff --git a/academy/spinlock/spinlock_example.asm b/academy/spinlock/spinlock_example.asm index 8fb59daae..20d52ee37 100644 --- a/academy/spinlock/spinlock_example.asm +++ b/academy/spinlock/spinlock_example.asm @@ -29,9 +29,14 @@ SPINLOCK_ID .set 0 ; lock id 0-63, fixed in PRU firmware ;****************************************************************************** ; Macro: M_SPINLOCK_ACQUIRE ; Acquire the spinlock and busy-wait until successful. -; R1.b0 - Input : spinlock id (set to SPINLOCK_ID) -; R1.b3 - Output: acquisition status (bit 0: 0=failed, 1=acquired) -; Best case 3 cycles; worst case unbounded (busy-wait). +; +; Pseudocode: +; R1.b0 = SPINLOCK_ID +; do { XIN(XID 0x90) -> R1.b3 } while (R1.b3 bit 0 == 0) +; +; Registers modified : R1.b0 (lock id), R1.b3 (status, bit 0 = 1 on exit) +; Peak Cycles : 3 if the lock is free; unbounded while another core holds it +; (2 cycles per retry) ;****************************************************************************** M_SPINLOCK_ACQUIRE .macro .newblock @@ -44,7 +49,13 @@ $1: ;****************************************************************************** ; Macro: M_SPINLOCK_RELEASE ; Release the spinlock. Must follow M_SPINLOCK_ACQUIRE (lock id is still -; in R1.b0). 2 cycles. +; in R1.b0). +; +; Pseudocode: +; XOUT(XID 0x90) with lock id R1.b0 ; frees the lock +; +; Registers modified : none +; Peak Cycles : 1 (one XOUT) ;****************************************************************************** M_SPINLOCK_RELEASE .macro XOUT INT_SPIN_XID, &R1.b3, 1 ; release lock held in R1.b0 From 4ac9f68c80c9591cde48fddf666a125e337a21f5 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Sat, 14 Nov 2026 00:25:59 +0530 Subject: [PATCH 05/11] academy/spinlock: address review: return XIN status with MOV, trim readme, 2026 headers spinlock_acquire returns R1.b3 with MOV, as in the issue #120 reference (same encoding size and cycles). Readme reduced to what the files are, a pointer to the PRU Academy spinlock page, and the three behaviours measured on LP-AM243. main.c points to the c_and_assembly lab and no longer reads as if PRU1 never gets the lock. spinlock_example.asm notes that R1.b0 must hold the lock id at release. --- academy/spinlock/main.c | 10 +- academy/spinlock/readme.md | 134 +++++--------------------- academy/spinlock/spinlock.asm | 10 +- academy/spinlock/spinlock_example.asm | 4 +- 4 files changed, 35 insertions(+), 123 deletions(-) diff --git a/academy/spinlock/main.c b/academy/spinlock/main.c index 7d861dd53..370f6789e 100644 --- a/academy/spinlock/main.c +++ b/academy/spinlock/main.c @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: BSD-3-Clause - * Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ * * File: main.c * @@ -26,6 +26,9 @@ * * spinlock_acquire() is a single non-blocking attempt: it returns 1 if the * lock was acquired, 0 otherwise. The spin loop lives here in C. + * + * For how mixed C and assembly projects work, see the PRU Getting Started Labs + * > c_and_assembly (academy/getting_started_labs/c_and_assembly). */ uint8_t spinlock_acquire(uint8_t flag_id); void spinlock_release(uint8_t flag_id); @@ -45,8 +48,9 @@ volatile register uint32_t __R30; /* * Cycles spent outside the lock before the next attempt. The lock is not fair: - * with no gap, the core that just released re-acquires before the other core's - * retry loop comes round, every time. On LP-AM243 PRU1 never got the lock. + * without this gap, the core that just released re-acquires before the other + * core's retry loop comes round, and the other core never gets the lock. With + * the gap, both cores take turns. */ #define OUTSIDE_TIME 200 diff --git a/academy/spinlock/readme.md b/academy/spinlock/readme.md index 3ae9a247b..e5dfb9be7 100644 --- a/academy/spinlock/readme.md +++ b/academy/spinlock/readme.md @@ -1,121 +1,31 @@ # Spinlock Usage Examples -This lab shows how a PRU core uses the **PRU_ICSSG local hardware spinlock** to get -mutual exclusion over a resource shared between PRU0, PRU1 and/or the host CPU. +These examples show PRU0 and PRU1 sharing a resource through the PRU_ICSSG local +hardware spinlock, which a PRU reaches over the broadside interface with `XIN`/`XOUT` +(XID `0x90`, lock id `0`-`63` in `R1.b0`, status in `R1.b3`). -## How the PRU-local spinlock works - -The PRU_ICSSG includes a hardware spinlock accelerator with **64 ownership flags** -(lock id `0`–`63`). A PRU core reaches it over the **broadside interface** using the -`XIN`/`XOUT` instructions — there is no memory-mapped load/store on the critical path, -so acquire/release are only a couple of cycles. - -- The broadside device id (XID) **`0x90` (= 144)** selects the spinlock in the - **local** PRU subsystem. A different XID is needed to reach a spinlock in another - PRU subsystem. -- The **lock id** to operate on is placed in **`R1.b0`**. -- **Acquire** (`XIN 0x90, &R1.b3, 1`): the accelerator returns the acquisition status - in **`R1.b3`** — **bit 0 = 1** means the lock is now owned by this core, **bit 0 = 0** - means it is held by someone else, so retry. A single `XIN` is one attempt; busy-wait - until you get a 1. The wait has **no upper bound**: it lasts as long as the other - core holds the lock, so keep critical sections short and bounded. -- **Release** (`XOUT 0x90, &R1.b3, 1`): with the same lock id still in `R1.b0`, frees - the lock. -- An acquire by the core that **already holds** the lock also returns 1: the status says - "this core holds the lock", it is not a nesting count. Do not use the lock recursively. - -Consequences: - -- You acquire by **spinning on the status bit**, not by writing a value. -- A spinlock provides **mutual exclusion only** — it is not a mailbox. To pass data or - events between cores, guard a shared buffer with the lock and signal separately (ICSS - shared RAM + a system event / interrupt; see *Signalling* below). -- Only the owner should release a lock, and it must release promptly. -- The lock is **not fair**. A core that tries to re-acquire straight after releasing can - win every time, because the other core's retry loop is longer than that gap. Measured on - LP-AM243 with the first version of `main.c`: PRU1 never got the lock. Do some work - outside the lock (or wait) before trying again, as `main.c` does. - -## Files - -- `spinlock.asm`: C-callable `spinlock_acquire()` / `spinlock_release()` built on the - broadside `XIN`/`XOUT` spinlock primitives. -- `main.c`: C example — both PRUs take the same lock, drive a debug GPO while holding it, - and release. The spin loop lives in C; the per-attempt acquire is in `spinlock.asm`. -- `spinlock_example.asm`: pure-assembly example using `M_SPINLOCK_ACQUIRE` / +- `spinlock_example.asm`: assembly, using the `M_SPINLOCK_ACQUIRE` / `M_SPINLOCK_RELEASE` macros. +- `main.c` + `spinlock.asm`: C, calling the C-callable `spinlock_acquire()` / + `spinlock_release()`. Both PRUs take the same lock and drive a debug GPO while they + hold it. -## How to Build - -Adapt the silicon version to your device: `--silicon_version=4` for the AM64x/AM243x -PRU_ICSSG (the open-pru AM243x makefiles use `PRU_VERSION := 4`). - -### Assembly only - -```bash -clpru --silicon_version=4 spinlock_example.asm -``` - -### C + assembly - -Compile both and link together; select the core with `-DPRU0` for the PRU0 build: - -```bash -clpru --silicon_version=4 -DPRU0=1 main.c spinlock.asm # PRU0 firmware -clpru --silicon_version=4 main.c spinlock.asm # PRU1 firmware -``` - -## Acquire / release pattern - -### Assembly (macros) - -```asm -INT_SPIN_XID .set 144 ; XID 0x90 - local PRU spinlock -SPINLOCK_ID .set 0 ; lock 0-63 - -M_SPINLOCK_ACQUIRE .macro - .newblock - LDI R1.b0, SPINLOCK_ID -$1: - XIN INT_SPIN_XID, &R1.b3, 1 ; status in R1.b3 - QBBC $1, R1.b3, 0 ; bit 0 clear -> retry - .endm - -M_SPINLOCK_RELEASE .macro - XOUT INT_SPIN_XID, &R1.b3, 1 - .endm -``` - -### C (calling the assembly helpers) - -```c -uint8_t spinlock_acquire(uint8_t flag_id); /* returns 1 if acquired */ -void spinlock_release(uint8_t flag_id); - -/* Acquire: spin until acquire returns 1. */ -while (spinlock_acquire(SPINLOCK_FLAG) != 1) { /* busy-wait */ } - -/* ... critical section ... */ - -spinlock_release(SPINLOCK_FLAG); -``` - -## Signalling (what NOT to do with a spinlock) +For how the spinlock accelerator works, see the PRU Academy page +AM243x/AM64x PRU Academy > Hardware information > PRU Broadside Accelerators > Spinlock: -A spinlock only provides mutual exclusion. To pass data or events between the PRU and -another core, guard a shared buffer with the lock and signal separately: +- AM64x: https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__AXw28VmX5TFHmSGgvY-0qw__AM64-ACADEMY__WI1KRXP__LATEST +- AM243x: https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__Ac5K7fXpNm5GbT1YWvI-8g__AM24X-ACADEMY__ZPSnq-h__LATEST -```c -while (spinlock_acquire(0) != 1) { } -shared->command = value; /* protected write to ICSS shared RAM */ -spinlock_release(0); -/* then raise a PRU system event (R31) to interrupt the other core */ -``` +## Usage notes -## References +Measured on LP-AM243 (ICSSG0 PRU0 and PRU1): -- Device-specific Technical Reference Manual (TRM) — PRU_ICSSG broadside interface and - spinlock accelerator. -- *PRU Assembly Instruction User Guide* (SPRUIJ2) — `XIN` / `XOUT` / `XCHG`. -- *PRU Optimizing C/C++ Compiler User's Guide* — function calling conventions. -- E2E reference thread: "PRU accessing HW-Spinlocks with __xin __xout". +- The lock is not fair. A core that tries to re-acquire straight after releasing wins + every time, because the other core's retry loop is longer than that gap. In a test + version of `main.c` with no gap, PRU1 never got the lock. Do some work outside the lock before trying + again, as `main.c` does with `OUTSIDE_TIME`. +- An acquire by the core that already holds the lock also returns 1. The status means + "this core holds the lock"; it is not a nesting count, so do not take the lock + recursively. +- An acquire is one attempt. Waiting for the lock has no upper bound: it lasts as long + as the other core holds it, so keep critical sections short. diff --git a/academy/spinlock/spinlock.asm b/academy/spinlock/spinlock.asm index 495afb4e1..916cea98a 100644 --- a/academy/spinlock/spinlock.asm +++ b/academy/spinlock/spinlock.asm @@ -1,5 +1,5 @@ ; SPDX-License-Identifier: BSD-3-Clause -; Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ +; Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ ;****************************************************************************** ; File: spinlock.asm @@ -20,10 +20,6 @@ ; The acquire is non-blocking - one XIN is one attempt. The caller ; (here, C) spins until it gets a 1. ; - RELEASE: an XOUT with the same lock id in R1.b0 frees the lock. -; -; Note: -; These helpers use XID 0x90 (local PRU subsystem). A separate function -; would be needed for accessing spinlocks in a different PRU subsystem. ;****************************************************************************** ; Required for building .out with an assembly file @@ -45,7 +41,7 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock ; Pseudocode: ; R1.b0 = flag_id ; present lock id to the accelerator ; XIN(XID 0x90) -> R1.b3 ; one acquire attempt, bit0 = acquired -; return R1.b3 & 1 ; 1 = acquired, 0 = held by another +; return R1.b3 ; 1 = acquired, 0 = held by another ; ; Registers modified : R1 (R1.b0, R1.b3), R14.b0 (return value) ; Peak Cycles : 4 (one acquire attempt; excludes any C-side retry spin) @@ -56,7 +52,7 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock spinlock_acquire: MOV R1.b0, R14.b0 ; lock id -> R1.b0 (presented to accel) XIN INT_SPIN_XID, &R1.b3, 1 ; status returned in R1.b3 (bit0=acquired) - AND R14.b0, R1.b3, 1 ; return bit 0 only: 1 = acquired + MOV R14.b0, R1.b3 ; return status: 1 = acquired JMP r3.w2 ;****************************************************************************** diff --git a/academy/spinlock/spinlock_example.asm b/academy/spinlock/spinlock_example.asm index 20d52ee37..abaf4a917 100644 --- a/academy/spinlock/spinlock_example.asm +++ b/academy/spinlock/spinlock_example.asm @@ -1,5 +1,5 @@ ; SPDX-License-Identifier: BSD-3-Clause -; Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ +; Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ ;****************************************************************************** ; File: spinlock_example.asm @@ -76,6 +76,8 @@ main: ; Critical section: we now own SPINLOCK_ID. Access the shared resource here. ;-------------------------------------------------------------------------- + ; M_SPINLOCK_RELEASE uses the lock id in R1.b0. If the critical section + ; overwrites R1.b0, reload it (LDI R1.b0, SPINLOCK_ID) before releasing. M_SPINLOCK_RELEASE halt From 21be85879200cbf53e87e266054d5b37c77644ef Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Sat, 14 Nov 2026 00:27:40 +0530 Subject: [PATCH 06/11] academy/spinlock: drop .newblock from M_SPINLOCK_ACQUIRE, as in the issue #120 reference clpru already gives each macro expansion its own \ label (checked: two expansions in one file assemble, and each QBBC loops on its own XIN). Same machine code. --- academy/spinlock/spinlock_example.asm | 1 - 1 file changed, 1 deletion(-) diff --git a/academy/spinlock/spinlock_example.asm b/academy/spinlock/spinlock_example.asm index abaf4a917..d76fe9b1b 100644 --- a/academy/spinlock/spinlock_example.asm +++ b/academy/spinlock/spinlock_example.asm @@ -39,7 +39,6 @@ SPINLOCK_ID .set 0 ; lock id 0-63, fixed in PRU firmware ; (2 cycles per retry) ;****************************************************************************** M_SPINLOCK_ACQUIRE .macro - .newblock LDI R1.b0, SPINLOCK_ID ; lock id (0-63) $1: XIN INT_SPIN_XID, &R1.b3, 1 ; attempt acquire; status in R1.b3 From 01e7a8299af16fdaa432aa85b3e46cbd6aea76b2 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Thu, 19 Nov 2026 06:08:52 +0530 Subject: [PATCH 07/11] academy/spinlock: return only bit 0 of the XIN status (AND, not MOV) Signed-off-by: Pratheesh Gangadhar --- academy/spinlock/spinlock.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/academy/spinlock/spinlock.asm b/academy/spinlock/spinlock.asm index 916cea98a..7de23ef40 100644 --- a/academy/spinlock/spinlock.asm +++ b/academy/spinlock/spinlock.asm @@ -41,7 +41,7 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock ; Pseudocode: ; R1.b0 = flag_id ; present lock id to the accelerator ; XIN(XID 0x90) -> R1.b3 ; one acquire attempt, bit0 = acquired -; return R1.b3 ; 1 = acquired, 0 = held by another +; return R1.b3 & 1 ; 1 = acquired, 0 = held by another ; ; Registers modified : R1 (R1.b0, R1.b3), R14.b0 (return value) ; Peak Cycles : 4 (one acquire attempt; excludes any C-side retry spin) @@ -52,7 +52,7 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock spinlock_acquire: MOV R1.b0, R14.b0 ; lock id -> R1.b0 (presented to accel) XIN INT_SPIN_XID, &R1.b3, 1 ; status returned in R1.b3 (bit0=acquired) - MOV R14.b0, R1.b3 ; return status: 1 = acquired + AND R14.b0, R1.b3, 1 ; return bit 0 only: 1 = acquired JMP r3.w2 ;****************************************************************************** From eb27ed6b589d832a52bd53608d9dc9e7ddb288e6 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Sat, 21 Nov 2026 15:22:30 +0530 Subject: [PATCH 08/11] academy/spinlock: make spinlock and spinlock_c buildable projects Review on #142 asked for every merged project to build from the top-level make. Split the example into two projects that follow the gpio_toggle / gpio_toggle_c layout from #178: - academy/spinlock/spinlock: firmware/spinlock_example.asm (assembly) - academy/spinlock/spinlock_c: firmware/main.c + firmware/spinlock.asm (C), PRU0 and PRU1 firmware Each builds PRU0 and PRU1 firmware plus an R5F FreeRTOS loader for am64x-evm, am243x-evm and am243x-lp, and is listed in academy/makefile and academy/readme.md. am261x/am263x/am62x are N-hw: the local spinlock is a PRU_ICSSG feature. spinlock_c debug pins: - The pinmux for both pins is in example.syscfg. The EVM loader also enables the TCA6424 I/O expander, as in #178. It is guarded by PRU_GPIO_VIA_IOEXP, which only the EVM makefiles define, because the LaunchPad has no expander. - Each core now drives its own GPO4. PRU1 used GPO5, which on LP-AM243 goes to the CAN transceiver's MCAN0_STB and to no header. - The LaunchPad's PRU1 build passes -DDEBUG_PIN_SHIFT=0, because PRU1 GPO4 reaches no header there either. Its pins are BoosterPack J2.17 (PRU0 GPO4) and J2.11 (PRU1 GPO0), per SPRUJ12E. - The make build now passes -DPRU0/-DPRU1, as the CCS projectspecs already did, so main.c's per-core hold time applies there too. - Dropped the unreachable __halt() after while(1). It caused a compiler warning, and the generated code is unchanged. Built with CCS 21.0, MCU+ SDK am243x 12.01.00.33, SysConfig 1.28.0, clpru 2.3.3 and armllvm 4.0.4: - `make` in academy/ for am243x exits 0, building both projects. - `make pru` for am64x exits 0. The am64x R5F loader was not built, because no am64x MCU+ SDK is installed here. - The PRU objects match the 2026-10-16 LP-AM243 hardware run (25/25 passed) instruction for instruction. The only difference is PRU1's SET/CLR bit number in main.obj. Signed-off-by: Pratheesh Gangadhar --- academy/makefile | 2 + academy/readme.md | 8 + academy/spinlock/readme.md | 31 -- .../ti-pru-cgt/example.projectspec | 80 ++++ .../icss_g0_pru0_fw/ti-pru-cgt/linker.cmd | 52 +++ .../icss_g0_pru0_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 80 ++++ .../icss_g0_pru1_fw/ti-pru-cgt/linker.cmd | 52 +++ .../icss_g0_pru1_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 80 ++++ .../icss_g0_pru0_fw/ti-pru-cgt/linker.cmd | 52 +++ .../icss_g0_pru0_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 80 ++++ .../icss_g0_pru1_fw/ti-pru-cgt/linker.cmd | 52 +++ .../icss_g0_pru1_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 80 ++++ .../icss_g0_pru0_fw/ti-pru-cgt/linker.cmd | 52 +++ .../icss_g0_pru0_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 80 ++++ .../icss_g0_pru1_fw/ti-pru-cgt/linker.cmd | 52 +++ .../icss_g0_pru1_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../firmware}/spinlock_example.asm | 0 academy/spinlock/spinlock/makefile | 120 ++++++ .../r5fss0-0_freertos/example.syscfg | 260 +++++++++++++ .../am243x-evm/r5fss0-0_freertos/main.c | 57 +++ .../ti-arm-clang/example.projectspec | 121 ++++++ .../r5fss0-0_freertos/ti-arm-clang/makefile | 355 +++++++++++++++++ .../ti-arm-clang/makefile_ccs_bootimage_gen | 113 ++++++ .../ti-arm-clang/makefile_projectspec | 16 + .../ti-arm-clang/syscfg_c.rov.xs | 12 + .../r5fss0-0_freertos/example.syscfg | 259 +++++++++++++ .../am243x-lp/r5fss0-0_freertos/main.c | 57 +++ .../ti-arm-clang/example.projectspec | 121 ++++++ .../r5fss0-0_freertos/ti-arm-clang/makefile | 355 +++++++++++++++++ .../ti-arm-clang/makefile_ccs_bootimage_gen | 113 ++++++ .../ti-arm-clang/makefile_projectspec | 16 + .../ti-arm-clang/syscfg_c.rov.xs | 12 + .../r5fss0-0_freertos/example.syscfg | 260 +++++++++++++ .../am64x-evm/r5fss0-0_freertos/main.c | 57 +++ .../ti-arm-clang/example.projectspec | 121 ++++++ .../r5fss0-0_freertos/ti-arm-clang/makefile | 357 ++++++++++++++++++ .../ti-arm-clang/makefile_ccs_bootimage_gen | 114 ++++++ .../ti-arm-clang/makefile_projectspec | 16 + .../ti-arm-clang/syscfg_c.rov.xs | 12 + academy/spinlock/spinlock/mcuplus/spinlock.c | 52 +++ academy/spinlock/spinlock/readme.md | 52 +++ .../ti-pru-cgt/example.projectspec | 85 +++++ .../icss_g0_pru0_fw/ti-pru-cgt/linker.cmd | 99 +++++ .../icss_g0_pru0_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 85 +++++ .../icss_g0_pru1_fw/ti-pru-cgt/linker.cmd | 100 +++++ .../icss_g0_pru1_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 85 +++++ .../icss_g0_pru0_fw/ti-pru-cgt/linker.cmd | 99 +++++ .../icss_g0_pru0_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 86 +++++ .../icss_g0_pru1_fw/ti-pru-cgt/linker.cmd | 100 +++++ .../icss_g0_pru1_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 85 +++++ .../icss_g0_pru0_fw/ti-pru-cgt/linker.cmd | 99 +++++ .../icss_g0_pru0_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../ti-pru-cgt/example.projectspec | 85 +++++ .../icss_g0_pru1_fw/ti-pru-cgt/linker.cmd | 100 +++++ .../icss_g0_pru1_fw/ti-pru-cgt/makefile | 48 +++ .../ti-pru-cgt/makefile_projectspec | 16 + .../spinlock/{ => spinlock_c/firmware}/main.c | 19 +- .../{ => spinlock_c/firmware}/spinlock.asm | 0 academy/spinlock/spinlock_c/makefile | 120 ++++++ .../r5fss0-0_freertos/example.syscfg | 276 ++++++++++++++ .../am243x-evm/r5fss0-0_freertos/main.c | 57 +++ .../ti-arm-clang/example.projectspec | 122 ++++++ .../r5fss0-0_freertos/ti-arm-clang/makefile | 356 +++++++++++++++++ .../ti-arm-clang/makefile_ccs_bootimage_gen | 113 ++++++ .../ti-arm-clang/makefile_projectspec | 16 + .../ti-arm-clang/syscfg_c.rov.xs | 12 + .../r5fss0-0_freertos/example.syscfg | 268 +++++++++++++ .../am243x-lp/r5fss0-0_freertos/main.c | 57 +++ .../ti-arm-clang/example.projectspec | 121 ++++++ .../r5fss0-0_freertos/ti-arm-clang/makefile | 355 +++++++++++++++++ .../ti-arm-clang/makefile_ccs_bootimage_gen | 113 ++++++ .../ti-arm-clang/makefile_projectspec | 16 + .../ti-arm-clang/syscfg_c.rov.xs | 12 + .../r5fss0-0_freertos/example.syscfg | 276 ++++++++++++++ .../am64x-evm/r5fss0-0_freertos/main.c | 57 +++ .../ti-arm-clang/example.projectspec | 122 ++++++ .../r5fss0-0_freertos/ti-arm-clang/makefile | 356 +++++++++++++++++ .../ti-arm-clang/makefile_ccs_bootimage_gen | 114 ++++++ .../ti-arm-clang/makefile_projectspec | 16 + .../ti-arm-clang/syscfg_c.rov.xs | 12 + .../spinlock/spinlock_c/mcuplus/spinlock_c.c | 98 +++++ academy/spinlock/spinlock_c/readme.md | 82 ++++ 102 files changed, 8862 insertions(+), 41 deletions(-) delete mode 100644 academy/spinlock/readme.md create mode 100644 academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec rename academy/spinlock/{ => spinlock/firmware}/spinlock_example.asm (100%) create mode 100644 academy/spinlock/spinlock/makefile create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/main.c create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/main.c create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec create mode 100644 academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs create mode 100644 academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg create mode 100644 academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/main.c create mode 100644 academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec create mode 100644 academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile create mode 100644 academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen create mode 100644 academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec create mode 100644 academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs create mode 100644 academy/spinlock/spinlock/mcuplus/spinlock.c create mode 100644 academy/spinlock/spinlock/readme.md create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec create mode 100644 academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd create mode 100644 academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile create mode 100644 academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec rename academy/spinlock/{ => spinlock_c/firmware}/main.c (86%) rename academy/spinlock/{ => spinlock_c/firmware}/spinlock.asm (100%) create mode 100644 academy/spinlock/spinlock_c/makefile create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/main.c create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/main.c create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec create mode 100644 academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs create mode 100644 academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg create mode 100644 academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/main.c create mode 100644 academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec create mode 100644 academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile create mode 100644 academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen create mode 100644 academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec create mode 100644 academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs create mode 100644 academy/spinlock/spinlock_c/mcuplus/spinlock_c.c create mode 100644 academy/spinlock/spinlock_c/readme.md diff --git a/academy/makefile b/academy/makefile index c257180e5..0e20d9eef 100644 --- a/academy/makefile +++ b/academy/makefile @@ -7,6 +7,8 @@ SUBDIRS := \ gpio/gpio_toggle_c \ intc/intc_mcu \ mac/mac mac/mac_multiply mac/mac_c \ + spinlock/spinlock spinlock/spinlock_c \ + spinlock/spinlock spinlock/spinlock_c \ uart/uart_loopback # "make" or "make all" builds projects that match $(DEVICE) set in imports.mak diff --git a/academy/readme.md b/academy/readme.md index 3f1ec045f..74b15001f 100644 --- a/academy/readme.md +++ b/academy/readme.md @@ -55,6 +55,12 @@ mac/mac_c mac/mac_multiply * How to use the MAC module in Multiply-Only mode (assembly) +spinlock/spinlock +* How to acquire and release the PRU_ICSSG local hardware spinlock (assembly) + +spinlock/spinlock_c +* How PRU0 and PRU1 share a resource through the hardware spinlock (C) + uart/uart_loopback * Loopback example with the PRU hardware UART peripheral @@ -94,4 +100,6 @@ For more information about the PRU features on each processor, refer to app note | mac/mac | Yport | Y | Y | Y | Yport | Yport | | mac/mac_c | Yport | Yport | Yport | Yport | Y | Y | | mac/mac_multiply | Yport | Y | Y | Y | Yport | Yport | +| spinlock/spinlock | Y | N-hw | N-hw | N-hw | N-hw | Y | +| spinlock/spinlock_c | Y | N-hw | N-hw | N-hw | N-hw | Y | | uart/uart_loopback | Yport | Yport | Yport | Yport | Y | Yport | diff --git a/academy/spinlock/readme.md b/academy/spinlock/readme.md deleted file mode 100644 index e5dfb9be7..000000000 --- a/academy/spinlock/readme.md +++ /dev/null @@ -1,31 +0,0 @@ -# Spinlock Usage Examples - -These examples show PRU0 and PRU1 sharing a resource through the PRU_ICSSG local -hardware spinlock, which a PRU reaches over the broadside interface with `XIN`/`XOUT` -(XID `0x90`, lock id `0`-`63` in `R1.b0`, status in `R1.b3`). - -- `spinlock_example.asm`: assembly, using the `M_SPINLOCK_ACQUIRE` / - `M_SPINLOCK_RELEASE` macros. -- `main.c` + `spinlock.asm`: C, calling the C-callable `spinlock_acquire()` / - `spinlock_release()`. Both PRUs take the same lock and drive a debug GPO while they - hold it. - -For how the spinlock accelerator works, see the PRU Academy page -AM243x/AM64x PRU Academy > Hardware information > PRU Broadside Accelerators > Spinlock: - -- AM64x: https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__AXw28VmX5TFHmSGgvY-0qw__AM64-ACADEMY__WI1KRXP__LATEST -- AM243x: https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__Ac5K7fXpNm5GbT1YWvI-8g__AM24X-ACADEMY__ZPSnq-h__LATEST - -## Usage notes - -Measured on LP-AM243 (ICSSG0 PRU0 and PRU1): - -- The lock is not fair. A core that tries to re-acquire straight after releasing wins - every time, because the other core's retry loop is longer than that gap. In a test - version of `main.c` with no gap, PRU1 never got the lock. Do some work outside the lock before trying - again, as `main.c` does with `OUTSIDE_TIME`. -- An acquire by the core that already holds the lock also returns 1. The status means - "this core holds the lock"; it is not a nesting count, so do not take the lock - recursively. -- An acquire is one attempt. Waiting for the lock has no upper bound: it lasts as long - as the other core holds it, so keep critical sections short. diff --git a/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..1c0f73cfd --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..ff7b62c76 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x PRU0 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..62cff1d75 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_am243x-evm_icss_g0_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock/firmware/am243x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..020f4dd87 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am243x-evm_icss_g0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..2926f5d9f --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..7d0445552 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x PRU1 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..58bbb45f9 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_am243x-evm_icss_g0_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock/firmware/am243x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..e824e696a --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am243x-evm_icss_g0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..f6a2f84e8 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..ff7b62c76 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x PRU0 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..2c8c898f3 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_am243x-lp_icss_g0_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..769b3df64 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am243x-lp_icss_g0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..4f733d53a --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..7d0445552 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM243x_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM243x PRU1 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..382789878 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_am243x-lp_icss_g0_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..eb12607a5 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am243x-lp_icss_g0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..b3cc8b35f --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..bb67e0959 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM64x_PRU0.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM64x PRU0 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..2956c3eb6 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_am64x-evm_icss_g0_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock/firmware/am64x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am64x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..43eed88cf --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am64x-evm_icss_g0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..5369b45f1 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..4804d56cd --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,52 @@ +/* + * AM64x_PRU1.cmd + * + * Example Linker command file for linking assembly programs built with the TI-PRU-CGT + * on AM64x PRU1 cores + */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..6fd34133b --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_am64x-evm_icss_g0_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock/firmware/am64x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am64x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..94354d2f1 --- /dev/null +++ b/academy/spinlock/spinlock/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am64x-evm_icss_g0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_example.asm b/academy/spinlock/spinlock/firmware/spinlock_example.asm similarity index 100% rename from academy/spinlock/spinlock_example.asm rename to academy/spinlock/spinlock/firmware/spinlock_example.asm diff --git a/academy/spinlock/spinlock/makefile b/academy/spinlock/spinlock/makefile new file mode 100644 index 000000000..e820a5c2d --- /dev/null +++ b/academy/spinlock/spinlock/makefile @@ -0,0 +1,120 @@ +include ../../../imports.mak + +####################### +# project information # +####################### + +PROJECT_NAME := spinlock +SUPPORTED_PROCESSORS := am64x am243x +# Does the PRU code have dependencies outside of the open-pru repo? +PRU_DEPENDENCIES := +# Use NON_PRU_DEPENDENCIES to select which makefiles to call for non-PRU cores +NON_PRU_DEPENDENCIES := mcuplus + +################### +# Prebuild checks # +################### +BUILD_PROJECT := y +DEVICE_NON_PRU := + +# Only build project if $(DEVICE) is in $(SUPPORTED_PROCESSORS) +ifeq (,$(findstring $(DEVICE),$(SUPPORTED_PROCESSORS))) +BUILD_PROJECT := n +MESSAGE := Project $(PROJECT_NAME) does not have a build option for $(DEVICE) +endif + +# Only build project if PRU dependencies exist +ifneq (,$(PRU_DEPENDENCIES)) +# MCU+ SDK dependency? +ifeq (mcuplus,$(findstring mcuplus,$(PRU_DEPENDENCIES))) +ifneq ($(BUILD_MCUPLUS),y) +BUILD_PROJECT := n +MESSAGE ?= Project $(PROJECT_NAME) depends on MCU+ SDK, but BUILD_MCUPLUS != y. +endif +endif +# Additional PRU dependency checks go here. For example: +#ifeq (dependency,$(findstring dependency,$(PRU_DEPENDENCIES))) +#if (dependency check fails) +#BUILD_PROJECT := n +#MESSAGE ?= Project $(PROJECT_NAME) depends on dependency, but dependency does not exist. +#endif +#endif +endif + +# Only build non-PRU code if the non-PRU code is enabled in imports.mak +ifeq ($(BUILD_MCUPLUS),y) +ifeq (mcuplus,$(findstring mcuplus,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_mcuplus +endif +endif +ifeq ($(BUILD_LINUX),y) +ifeq (linux,$(findstring linux,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_linux +endif +endif + +########################### +# Make and clean commands # +########################### + +ifeq ($(BUILD_PROJECT),y) +# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak +# "make" builds PRU firmware first, then host (non-PRU) code +all: MESSAGE = "Building $(PROJECT_NAME) for $(DEVICE)" +all: pre_build_message + $(MAKE) pru + $(MAKE) host + +# "make pru" builds only PRU firmware for $(DEVICE) +pru: ARGUMENTS_PRU = all +pru: $(DEVICE) + +# "make host" builds only host (non-PRU) code for $(DEVICE) +host: ARGUMENTS_MCUPLUS = all +host: $(DEVICE_NON_PRU) + +# "make clean" cleans projects that match $(DEVICE) set in imports.mak +clean: ARGUMENTS_PRU = clean +clean: ARGUMENTS_MCUPLUS = scrub +clean: MESSAGE = "Cleaning $(PROJECT_NAME) for $(DEVICE)" +clean: pre_build_message $(DEVICE) $(DEVICE_NON_PRU) + +else +# if a prebuild check failed, print message and exit +all clean pru host: pre_build_message +endif + +pre_build_message: + @echo $(MESSAGE) + +###################### +# Target definitions # +###################### + +# provide target definitions for each supported processor +# PRU firmware should be built before any RTOS code that includes it + +am64x: +# am64x-evm + $(MAKE) -C firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am64x_mcuplus: +# am64x-evm + $(MAKE) -C mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang $(ARGUMENTS_MCUPLUS) + +am243x: +# am243x-evm + $(MAKE) -C firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) +# am243x-lp + $(MAKE) -C firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am243x_mcuplus: +# am243x-evm + $(MAKE) -C mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang $(ARGUMENTS_MCUPLUS) +# am243x-lp + $(MAKE) -C mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang $(ARGUMENTS_MCUPLUS) + +.PHONY: all clean pru host pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS) diff --git a/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg new file mode 100644 index 000000000..122f776e1 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,260 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALV_beta" --part "ALV" --package "ALV" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM243x@12.00.00" --product "OPEN_PRU@2026.02.00" + * @v2CliArgs --device "AM2434" --package "FCBGA (ALV)" --variant "AM2434-D" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM243x@12.00.00" --product "OPEN_PRU@2026.02.00" + * @versions {"tool":"1.27.0+4565"} + */ + +/** + * Import the modules used in this configuration. + */ +const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false); +const pruicss1 = pruicss.addInstance(); +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); +const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false); +const default_linker1 = default_linker.addInstance(); +const general = scripting.addModule("/memory_configurator/general", {}, false); +const general1 = general.addInstance(); +const region = scripting.addModule("/memory_configurator/region", {}, false); +const region1 = region.addInstance(); +const section = scripting.addModule("/memory_configurator/section", {}, false); +const section1 = section.addInstance(); +const section2 = section.addInstance(); +const section3 = section.addInstance(); +const section4 = section.addInstance(); +const section5 = section.addInstance(); +const section6 = section.addInstance(); +const section7 = section.addInstance(); +const section8 = section.addInstance(); +const section9 = section.addInstance(); +const section10 = section.addInstance(); +const section11 = section.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ + +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; + +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +const uart_v0_template = scripting.addModule("/drivers/uart/v0/uart_v0_template", {}, false); +const uart_v0_template1 = uart_v0_template.addInstance({}, false); +uart_v0_template1.$name = "drivers_uart_v0_uart_v0_template0"; +debug_log.uartLog.child = uart_v0_template1; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x80000000; +mpu_armv76.size = 31; + +default_linker1.$name = "memory_configurator_default_linker0"; + +general1.$name = "CONFIG_GENERAL0"; +general1.linker.$name = "TIARMCLANG0"; + +region1.$name = "MEMORY_REGION_CONFIGURATION0"; +region1.memory_region.create(9); +region1.memory_region[0].type = "TCMA_R5F"; +region1.memory_region[0].$name = "R5F_VECS"; +region1.memory_region[0].size = 0x40; +region1.memory_region[0].auto = false; +region1.memory_region[1].type = "TCMA_R5F"; +region1.memory_region[1].$name = "R5F_TCMA"; +region1.memory_region[1].size = 0x7FC0; +region1.memory_region[2].type = "TCMB_R5F"; +region1.memory_region[2].$name = "R5F_TCMB0"; +region1.memory_region[2].size = 0x8000; +region1.memory_region[3].$name = "NON_CACHE_MEM"; +region1.memory_region[3].auto = false; +region1.memory_region[3].manualStartAddress = 0x70060000; +region1.memory_region[3].size = 0x8000; +region1.memory_region[4].$name = "MSRAM"; +region1.memory_region[4].auto = false; +region1.memory_region[4].manualStartAddress = 0x70080000; +region1.memory_region[4].size = 0x40000; +region1.memory_region[5].type = "FLASH"; +region1.memory_region[5].$name = "FLASH"; +region1.memory_region[5].auto = false; +region1.memory_region[5].manualStartAddress = 0x60100000; +region1.memory_region[5].size = 0x80000; +region1.memory_region[6].$name = "USER_SHM_MEM"; +region1.memory_region[6].auto = false; +region1.memory_region[6].manualStartAddress = 0x701D0000; +region1.memory_region[6].size = 0x180; +region1.memory_region[6].isShared = true; +region1.memory_region[6].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[7].auto = false; +region1.memory_region[7].manualStartAddress = 0x701D0180; +region1.memory_region[7].size = 0x3E80; +region1.memory_region[7].$name = "LOG_SHM_MEM"; +region1.memory_region[7].isShared = true; +region1.memory_region[7].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[8].auto = false; +region1.memory_region[8].manualStartAddress = 0x701D4000; +region1.memory_region[8].size = 0xC000; +region1.memory_region[8].$name = "RTOS_NORTOS_IPC_SHM_MEM"; +region1.memory_region[8].isShared = true; +region1.memory_region[8].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; + +section1.$name = "Vector Table"; +section1.load_memory = "R5F_VECS"; +section1.group = false; +section1.output_section.create(1); +section1.output_section[0].$name = ".vectors"; +section1.output_section[0].palignment = true; + +section2.$name = "Text Segments"; +section2.load_memory = "MSRAM"; +section2.output_section.create(5); +section2.output_section[0].$name = ".text.hwi"; +section2.output_section[0].palignment = true; +section2.output_section[1].$name = ".text.cache"; +section2.output_section[1].palignment = true; +section2.output_section[2].$name = ".text.mpu"; +section2.output_section[2].palignment = true; +section2.output_section[3].$name = ".text.boot"; +section2.output_section[3].palignment = true; +section2.output_section[4].$name = ".text:abort"; +section2.output_section[4].palignment = true; + +section3.$name = "Code and Read-Only Data"; +section3.load_memory = "MSRAM"; +section3.output_section.create(2); +section3.output_section[0].$name = ".text"; +section3.output_section[0].palignment = true; +section3.output_section[1].$name = ".rodata"; +section3.output_section[1].palignment = true; + +section4.$name = "Data Segment"; +section4.load_memory = "MSRAM"; +section4.output_section.create(1); +section4.output_section[0].$name = ".data"; +section4.output_section[0].palignment = true; + +section5.$name = "Memory Segments"; +section5.load_memory = "MSRAM"; +section5.output_section.create(3); +section5.output_section[0].$name = ".bss"; +section5.output_section[0].palignment = true; +section5.output_section[0].output_sections_start = "__BSS_START"; +section5.output_section[0].output_sections_end = "__BSS_END"; +section5.output_section[1].$name = ".sysmem"; +section5.output_section[1].palignment = true; +section5.output_section[2].$name = ".stack"; +section5.output_section[2].palignment = true; + +section6.$name = "Stack Segments"; +section6.load_memory = "MSRAM"; +section6.output_section.create(5); +section6.output_section[0].$name = ".irqstack"; +section6.output_section[0].output_sections_start = "__IRQ_STACK_START"; +section6.output_section[0].output_sections_end = "__IRQ_STACK_END"; +section6.output_section[0].input_section.create(1); +section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;"; +section6.output_section[1].$name = ".fiqstack"; +section6.output_section[1].output_sections_start = "__FIQ_STACK_START"; +section6.output_section[1].output_sections_end = "__FIQ_STACK_END"; +section6.output_section[1].input_section.create(1); +section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;"; +section6.output_section[2].$name = ".svcstack"; +section6.output_section[2].output_sections_start = "__SVC_STACK_START"; +section6.output_section[2].output_sections_end = "__SVC_STACK_END"; +section6.output_section[2].input_section.create(1); +section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;"; +section6.output_section[3].$name = ".abortstack"; +section6.output_section[3].output_sections_start = "__ABORT_STACK_START"; +section6.output_section[3].output_sections_end = "__ABORT_STACK_END"; +section6.output_section[3].input_section.create(1); +section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;"; +section6.output_section[4].$name = ".undefinedstack"; +section6.output_section[4].output_sections_start = "__UNDEFINED_STACK_START"; +section6.output_section[4].output_sections_end = "__UNDEFINED_STACK_END"; +section6.output_section[4].input_section.create(1); +section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;"; + +section7.$name = "Initialization and Exception Handling"; +section7.load_memory = "MSRAM"; +section7.output_section.create(3); +section7.output_section[0].$name = ".ARM.exidx"; +section7.output_section[0].palignment = true; +section7.output_section[1].$name = ".init_array"; +section7.output_section[1].palignment = true; +section7.output_section[2].$name = ".fini_array"; +section7.output_section[2].palignment = true; + +section8.$name = "User Shared Memory"; +section8.type = "NOLOAD"; +section8.load_memory = "USER_SHM_MEM"; +section8.group = false; +section8.output_section.create(1); +section8.output_section[0].$name = ".bss.user_shared_mem"; +section8.output_section[0].alignment = 0; + +section9.$name = "Log Shared Memory"; +section9.load_memory = "LOG_SHM_MEM"; +section9.type = "NOLOAD"; +section9.group = false; +section9.output_section.create(1); +section9.output_section[0].$name = ".bss.log_shared_mem"; +section9.output_section[0].alignment = 0; + +section10.$name = "IPC Shared Memory"; +section10.type = "NOLOAD"; +section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM"; +section10.group = false; +section10.output_section.create(1); +section10.output_section[0].$name = ".bss.ipc_vring_mem"; +section10.output_section[0].alignment = 0; + +section11.$name = "Non Cacheable Memory"; +section11.load_memory = "NON_CACHE_MEM"; +section11.group = false; +section11.type = "NOLOAD"; +section11.output_section.create(1); +section11.output_section[0].$name = ".bss.nocache"; +section11.output_section[0].alignment = 0; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/main.c b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/main.c new file mode 100644 index 000000000..edddae714 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/main.c @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void spinlock_main(void *args); + +void freertos_main(void *args) +{ + spinlock_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..cd6cb5a4f --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 000000000..8aa66f2dd --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,355 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +COV=$(CG_TOOL_ROOT)/bin/tiarmcov +PROFDATA=$(CG_TOOL_ROOT)/bin/tiarmprofdata +COVERAGE_PATH=$(abspath .) +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=spinlock.$(PROFILE).out +COREOUTNAME:=spinlock.$(PROFILE).optishare.out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=spinlock.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=spinlock.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=spinlock.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=spinlock.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=spinlock.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=spinlock.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=spinlock.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=spinlock.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) + + +FILES_common := \ + main.c \ + spinlock.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MCU_PLUS_SDK_PATH}/source \ + -I${OPEN_PRU_PATH}/source \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am243x/r5f \ + -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \ + -I${OPEN_PRU_PATH}/academy/spinlock/spinlock/firmware/am243x-evm \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + -DOS_FREERTOS \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -Wno-vla-cxx-extension \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + generated/linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/board/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ + + +LIBS_NAME = \ + freertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + ${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + ${MCU_PLUS_SDK_PATH}/source/board/lib \ + ${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +ifeq ($(INSTRUMENTATION_MODE), yes) +CFLAGS += -fprofile-instr-generate -fcoverage-mapping +endif +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +SYSTEM_FLAG ?= false + +ifeq ($(SYSTEM_FLAG), false) + SYSTEM_COMMAND := syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) +else + SYSTEM_COMMAND := $(OBJS) $(LNK_FILES) $(LIBS_NAME) +endif + +$(OUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +coreout: $(COREOUTNAME) +$(COREOUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Relinking Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ with OptiShare SSO.. + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml -Wl,--import_sso=$(SSO_PATH) + @echo Relinking with optishare: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:freertos:ti-arm-clang spinlock ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin + $(RM) \*.lnkxml + $(RM) \*.ossr +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin + $(RM) *.lnkxml + $(RM) *.ossr +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +ifeq ($(SYSTEM_FLAG), false) +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --context r5fss0-0 --part ALV --package ALV --output generated/ ../example.syscfg +endif + +syscfg-gui: + $(SYSCFG_GUI_SCRIPT) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM243x_ALV_beta --context r5fss0-0 --part ALV --package ALV --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for spinlock.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o spinlock.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=spinlock.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=spinlock.$(PROFILE).profdata > coverage/spinlock.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/spinlock.$(PROFILE).profdata.json --output-json=coverage/spinlock.$(PROFILE).analysis.json --output=../spinlock.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..5bcdc554e --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,113 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - OPEN_PRU_PATH +# - MCU_PLUS_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs + $(RM) $(BOOTIMAGE_NAME) +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..3981e98b2 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am243x-evm_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,12 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "kernel/freertos/rov/FreeRTOS.rov.js", +]; + +var objectViewerFiles = [ + "kernel/freertos/rov_theia/FreeRTOS_Theia.rov.js", +]; diff --git a/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg new file mode 100644 index 000000000..7b82de8e0 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,259 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALX_beta" --part "ALX" --package "ALX" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM243x@12.00.00" --product "OPEN_PRU@2026.02.00" + * @versions {"tool":"1.27.0+4565"} + */ + +/** + * Import the modules used in this configuration. + */ +const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false); +const pruicss1 = pruicss.addInstance(); +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); +const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false); +const default_linker1 = default_linker.addInstance(); +const general = scripting.addModule("/memory_configurator/general", {}, false); +const general1 = general.addInstance(); +const region = scripting.addModule("/memory_configurator/region", {}, false); +const region1 = region.addInstance(); +const section = scripting.addModule("/memory_configurator/section", {}, false); +const section1 = section.addInstance(); +const section2 = section.addInstance(); +const section3 = section.addInstance(); +const section4 = section.addInstance(); +const section5 = section.addInstance(); +const section6 = section.addInstance(); +const section7 = section.addInstance(); +const section8 = section.addInstance(); +const section9 = section.addInstance(); +const section10 = section.addInstance(); +const section11 = section.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ + +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; + +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +const uart_v0_template = scripting.addModule("/drivers/uart/v0/uart_v0_template", {}, false); +const uart_v0_template1 = uart_v0_template.addInstance({}, false); +uart_v0_template1.$name = "drivers_uart_v0_uart_v0_template0"; +debug_log.uartLog.child = uart_v0_template1; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x80000000; +mpu_armv76.size = 31; + +default_linker1.$name = "memory_configurator_default_linker0"; + +general1.$name = "CONFIG_GENERAL0"; +general1.linker.$name = "TIARMCLANG0"; + +region1.$name = "MEMORY_REGION_CONFIGURATION0"; +region1.memory_region.create(9); +region1.memory_region[0].type = "TCMA_R5F"; +region1.memory_region[0].$name = "R5F_VECS"; +region1.memory_region[0].size = 0x40; +region1.memory_region[0].auto = false; +region1.memory_region[1].type = "TCMA_R5F"; +region1.memory_region[1].$name = "R5F_TCMA"; +region1.memory_region[1].size = 0x7FC0; +region1.memory_region[2].type = "TCMB_R5F"; +region1.memory_region[2].$name = "R5F_TCMB0"; +region1.memory_region[2].size = 0x8000; +region1.memory_region[3].$name = "NON_CACHE_MEM"; +region1.memory_region[3].auto = false; +region1.memory_region[3].manualStartAddress = 0x70060000; +region1.memory_region[3].size = 0x8000; +region1.memory_region[4].$name = "MSRAM"; +region1.memory_region[4].auto = false; +region1.memory_region[4].manualStartAddress = 0x70080000; +region1.memory_region[4].size = 0x40000; +region1.memory_region[5].type = "FLASH"; +region1.memory_region[5].$name = "FLASH"; +region1.memory_region[5].auto = false; +region1.memory_region[5].manualStartAddress = 0x60100000; +region1.memory_region[5].size = 0x80000; +region1.memory_region[6].$name = "USER_SHM_MEM"; +region1.memory_region[6].auto = false; +region1.memory_region[6].manualStartAddress = 0x701D0000; +region1.memory_region[6].size = 0x180; +region1.memory_region[6].isShared = true; +region1.memory_region[6].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[7].auto = false; +region1.memory_region[7].manualStartAddress = 0x701D0180; +region1.memory_region[7].size = 0x3E80; +region1.memory_region[7].$name = "LOG_SHM_MEM"; +region1.memory_region[7].isShared = true; +region1.memory_region[7].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[8].auto = false; +region1.memory_region[8].manualStartAddress = 0x701D4000; +region1.memory_region[8].size = 0xC000; +region1.memory_region[8].$name = "RTOS_NORTOS_IPC_SHM_MEM"; +region1.memory_region[8].isShared = true; +region1.memory_region[8].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; + +section1.$name = "Vector Table"; +section1.load_memory = "R5F_VECS"; +section1.group = false; +section1.output_section.create(1); +section1.output_section[0].$name = ".vectors"; +section1.output_section[0].palignment = true; + +section2.$name = "Text Segments"; +section2.load_memory = "MSRAM"; +section2.output_section.create(5); +section2.output_section[0].$name = ".text.hwi"; +section2.output_section[0].palignment = true; +section2.output_section[1].$name = ".text.cache"; +section2.output_section[1].palignment = true; +section2.output_section[2].$name = ".text.mpu"; +section2.output_section[2].palignment = true; +section2.output_section[3].$name = ".text.boot"; +section2.output_section[3].palignment = true; +section2.output_section[4].$name = ".text:abort"; +section2.output_section[4].palignment = true; + +section3.$name = "Code and Read-Only Data"; +section3.load_memory = "MSRAM"; +section3.output_section.create(2); +section3.output_section[0].$name = ".text"; +section3.output_section[0].palignment = true; +section3.output_section[1].$name = ".rodata"; +section3.output_section[1].palignment = true; + +section4.$name = "Data Segment"; +section4.load_memory = "MSRAM"; +section4.output_section.create(1); +section4.output_section[0].$name = ".data"; +section4.output_section[0].palignment = true; + +section5.$name = "Memory Segments"; +section5.load_memory = "MSRAM"; +section5.output_section.create(3); +section5.output_section[0].$name = ".bss"; +section5.output_section[0].palignment = true; +section5.output_section[0].output_sections_start = "__BSS_START"; +section5.output_section[0].output_sections_end = "__BSS_END"; +section5.output_section[1].$name = ".sysmem"; +section5.output_section[1].palignment = true; +section5.output_section[2].$name = ".stack"; +section5.output_section[2].palignment = true; + +section6.$name = "Stack Segments"; +section6.load_memory = "MSRAM"; +section6.output_section.create(5); +section6.output_section[0].$name = ".irqstack"; +section6.output_section[0].output_sections_start = "__IRQ_STACK_START"; +section6.output_section[0].output_sections_end = "__IRQ_STACK_END"; +section6.output_section[0].input_section.create(1); +section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;"; +section6.output_section[1].$name = ".fiqstack"; +section6.output_section[1].output_sections_start = "__FIQ_STACK_START"; +section6.output_section[1].output_sections_end = "__FIQ_STACK_END"; +section6.output_section[1].input_section.create(1); +section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;"; +section6.output_section[2].$name = ".svcstack"; +section6.output_section[2].output_sections_start = "__SVC_STACK_START"; +section6.output_section[2].output_sections_end = "__SVC_STACK_END"; +section6.output_section[2].input_section.create(1); +section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;"; +section6.output_section[3].$name = ".abortstack"; +section6.output_section[3].output_sections_start = "__ABORT_STACK_START"; +section6.output_section[3].output_sections_end = "__ABORT_STACK_END"; +section6.output_section[3].input_section.create(1); +section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;"; +section6.output_section[4].$name = ".undefinedstack"; +section6.output_section[4].output_sections_start = "__UNDEFINED_STACK_START"; +section6.output_section[4].output_sections_end = "__UNDEFINED_STACK_END"; +section6.output_section[4].input_section.create(1); +section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;"; + +section7.$name = "Initialization and Exception Handling"; +section7.load_memory = "MSRAM"; +section7.output_section.create(3); +section7.output_section[0].$name = ".ARM.exidx"; +section7.output_section[0].palignment = true; +section7.output_section[1].$name = ".init_array"; +section7.output_section[1].palignment = true; +section7.output_section[2].$name = ".fini_array"; +section7.output_section[2].palignment = true; + +section8.$name = "User Shared Memory"; +section8.type = "NOLOAD"; +section8.load_memory = "USER_SHM_MEM"; +section8.group = false; +section8.output_section.create(1); +section8.output_section[0].$name = ".bss.user_shared_mem"; +section8.output_section[0].alignment = 0; + +section9.$name = "Log Shared Memory"; +section9.load_memory = "LOG_SHM_MEM"; +section9.type = "NOLOAD"; +section9.group = false; +section9.output_section.create(1); +section9.output_section[0].$name = ".bss.log_shared_mem"; +section9.output_section[0].alignment = 0; + +section10.$name = "IPC Shared Memory"; +section10.type = "NOLOAD"; +section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM"; +section10.group = false; +section10.output_section.create(1); +section10.output_section[0].$name = ".bss.ipc_vring_mem"; +section10.output_section[0].alignment = 0; + +section11.$name = "Non Cacheable Memory"; +section11.load_memory = "NON_CACHE_MEM"; +section11.group = false; +section11.type = "NOLOAD"; +section11.output_section.create(1); +section11.output_section[0].$name = ".bss.nocache"; +section11.output_section[0].alignment = 0; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/main.c b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/main.c new file mode 100644 index 000000000..edddae714 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/main.c @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void spinlock_main(void *args); + +void freertos_main(void *args) +{ + spinlock_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..64fa1878c --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 000000000..b4bcb5951 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,355 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +COV=$(CG_TOOL_ROOT)/bin/tiarmcov +PROFDATA=$(CG_TOOL_ROOT)/bin/tiarmprofdata +COVERAGE_PATH=$(abspath .) +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=spinlock.$(PROFILE).out +COREOUTNAME:=spinlock.$(PROFILE).optishare.out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=spinlock.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=spinlock.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=spinlock.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=spinlock.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=spinlock.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=spinlock.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=spinlock.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=spinlock.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) + + +FILES_common := \ + main.c \ + spinlock.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MCU_PLUS_SDK_PATH}/source \ + -I${OPEN_PRU_PATH}/source \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am243x/r5f \ + -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \ + -I${OPEN_PRU_PATH}/academy/spinlock/spinlock/firmware/am243x-lp \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + -DOS_FREERTOS \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -Wno-vla-cxx-extension \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + generated/linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/board/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ + + +LIBS_NAME = \ + freertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + ${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + ${MCU_PLUS_SDK_PATH}/source/board/lib \ + ${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +ifeq ($(INSTRUMENTATION_MODE), yes) +CFLAGS += -fprofile-instr-generate -fcoverage-mapping +endif +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +SYSTEM_FLAG ?= false + +ifeq ($(SYSTEM_FLAG), false) + SYSTEM_COMMAND := syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) +else + SYSTEM_COMMAND := $(OBJS) $(LNK_FILES) $(LIBS_NAME) +endif + +$(OUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +coreout: $(COREOUTNAME) +$(COREOUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Relinking Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ with OptiShare SSO.. + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml -Wl,--import_sso=$(SSO_PATH) + @echo Relinking with optishare: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:freertos:ti-arm-clang spinlock ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin + $(RM) \*.lnkxml + $(RM) \*.ossr +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin + $(RM) *.lnkxml + $(RM) *.ossr +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +ifeq ($(SYSTEM_FLAG), false) +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg +endif + +syscfg-gui: + $(SYSCFG_GUI_SCRIPT) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM243x_ALX_beta --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for spinlock.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o spinlock.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=spinlock.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=spinlock.$(PROFILE).profdata > coverage/spinlock.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/spinlock.$(PROFILE).profdata.json --output-json=coverage/spinlock.$(PROFILE).analysis.json --output=../spinlock.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..5bcdc554e --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,113 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - OPEN_PRU_PATH +# - MCU_PLUS_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs + $(RM) $(BOOTIMAGE_NAME) +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..553a9abb8 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am243x-lp_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,12 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "kernel/freertos/rov/FreeRTOS.rov.js", +]; + +var objectViewerFiles = [ + "kernel/freertos/rov_theia/FreeRTOS_Theia.rov.js", +]; diff --git a/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg new file mode 100644 index 000000000..c04a46f33 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,260 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM64x" --part "Default" --package "ALV" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM64x@11.02.00" --product "OPEN_PRU@2026.02.00" + * @v2CliArgs --device "AM6442" --package "FCBGA (ALV)" --variant "AM6442-D" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM64x@11.02.00" --product "OPEN_PRU@2026.02.00" + * @versions {"tool":"1.27.0+4565"} + */ + +/** + * Import the modules used in this configuration. + */ +const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false); +const pruicss1 = pruicss.addInstance(); +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); +const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false); +const default_linker1 = default_linker.addInstance(); +const general = scripting.addModule("/memory_configurator/general", {}, false); +const general1 = general.addInstance(); +const region = scripting.addModule("/memory_configurator/region", {}, false); +const region1 = region.addInstance(); +const section = scripting.addModule("/memory_configurator/section", {}, false); +const section1 = section.addInstance(); +const section2 = section.addInstance(); +const section3 = section.addInstance(); +const section4 = section.addInstance(); +const section5 = section.addInstance(); +const section6 = section.addInstance(); +const section7 = section.addInstance(); +const section8 = section.addInstance(); +const section9 = section.addInstance(); +const section10 = section.addInstance(); +const section11 = section.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ + +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; + +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +const uart_v0_template = scripting.addModule("/drivers/uart/v0/uart_v0_template", {}, false); +const uart_v0_template1 = uart_v0_template.addInstance({}, false); +uart_v0_template1.$name = "drivers_uart_v0_uart_v0_template0"; +debug_log.uartLog.child = uart_v0_template1; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x80000000; +mpu_armv76.size = 31; + +default_linker1.$name = "memory_configurator_default_linker0"; + +general1.$name = "CONFIG_GENERAL0"; +general1.linker.$name = "TIARMCLANG0"; + +region1.$name = "MEMORY_REGION_CONFIGURATION0"; +region1.memory_region.create(9); +region1.memory_region[0].type = "TCMA_R5F"; +region1.memory_region[0].$name = "R5F_VECS"; +region1.memory_region[0].size = 0x40; +region1.memory_region[0].auto = false; +region1.memory_region[1].type = "TCMA_R5F"; +region1.memory_region[1].$name = "R5F_TCMA"; +region1.memory_region[1].size = 0x7FC0; +region1.memory_region[2].type = "TCMB_R5F"; +region1.memory_region[2].$name = "R5F_TCMB0"; +region1.memory_region[2].size = 0x8000; +region1.memory_region[3].$name = "NON_CACHE_MEM"; +region1.memory_region[3].auto = false; +region1.memory_region[3].manualStartAddress = 0x70060000; +region1.memory_region[3].size = 0x8000; +region1.memory_region[4].$name = "MSRAM"; +region1.memory_region[4].auto = false; +region1.memory_region[4].manualStartAddress = 0x70080000; +region1.memory_region[4].size = 0x40000; +region1.memory_region[5].type = "FLASH"; +region1.memory_region[5].$name = "FLASH"; +region1.memory_region[5].auto = false; +region1.memory_region[5].manualStartAddress = 0x60100000; +region1.memory_region[5].size = 0x80000; +region1.memory_region[6].$name = "USER_SHM_MEM"; +region1.memory_region[6].auto = false; +region1.memory_region[6].manualStartAddress = 0x701D0000; +region1.memory_region[6].size = 0x80; +region1.memory_region[6].isShared = true; +region1.memory_region[6].shared_cores = ["a53ss0-0","a53ss0-1","m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[7].auto = false; +region1.memory_region[7].manualStartAddress = 0x701D0080; +region1.memory_region[7].size = 0x3F80; +region1.memory_region[7].$name = "LOG_SHM_MEM"; +region1.memory_region[7].isShared = true; +region1.memory_region[7].shared_cores = ["a53ss0-0","a53ss0-1","m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[8].auto = false; +region1.memory_region[8].manualStartAddress = 0x701D4000; +region1.memory_region[8].size = 0xC000; +region1.memory_region[8].$name = "RTOS_NORTOS_IPC_SHM_MEM"; +region1.memory_region[8].isShared = true; +region1.memory_region[8].shared_cores = ["a53ss0-0","a53ss0-1","m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; + +section1.$name = "Vector Table"; +section1.load_memory = "R5F_VECS"; +section1.group = false; +section1.output_section.create(1); +section1.output_section[0].$name = ".vectors"; +section1.output_section[0].palignment = true; + +section2.$name = "Text Segments"; +section2.load_memory = "MSRAM"; +section2.output_section.create(5); +section2.output_section[0].$name = ".text.hwi"; +section2.output_section[0].palignment = true; +section2.output_section[1].$name = ".text.cache"; +section2.output_section[1].palignment = true; +section2.output_section[2].$name = ".text.mpu"; +section2.output_section[2].palignment = true; +section2.output_section[3].$name = ".text.boot"; +section2.output_section[3].palignment = true; +section2.output_section[4].$name = ".text:abort"; +section2.output_section[4].palignment = true; + +section3.$name = "Code and Read-Only Data"; +section3.load_memory = "MSRAM"; +section3.output_section.create(2); +section3.output_section[0].$name = ".text"; +section3.output_section[0].palignment = true; +section3.output_section[1].$name = ".rodata"; +section3.output_section[1].palignment = true; + +section4.$name = "Data Segment"; +section4.load_memory = "MSRAM"; +section4.output_section.create(1); +section4.output_section[0].$name = ".data"; +section4.output_section[0].palignment = true; + +section5.$name = "Memory Segments"; +section5.load_memory = "MSRAM"; +section5.output_section.create(3); +section5.output_section[0].$name = ".bss"; +section5.output_section[0].palignment = true; +section5.output_section[0].output_sections_start = "__BSS_START"; +section5.output_section[0].output_sections_end = "__BSS_END"; +section5.output_section[1].$name = ".sysmem"; +section5.output_section[1].palignment = true; +section5.output_section[2].$name = ".stack"; +section5.output_section[2].palignment = true; + +section6.$name = "Stack Segments"; +section6.load_memory = "MSRAM"; +section6.output_section.create(5); +section6.output_section[0].$name = ".irqstack"; +section6.output_section[0].output_sections_start = "__IRQ_STACK_START"; +section6.output_section[0].output_sections_end = "__IRQ_STACK_END"; +section6.output_section[0].input_section.create(1); +section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;"; +section6.output_section[1].$name = ".fiqstack"; +section6.output_section[1].output_sections_start = "__FIQ_STACK_START"; +section6.output_section[1].output_sections_end = "__FIQ_STACK_END"; +section6.output_section[1].input_section.create(1); +section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;"; +section6.output_section[2].$name = ".svcstack"; +section6.output_section[2].output_sections_start = "__SVC_STACK_START"; +section6.output_section[2].output_sections_end = "__SVC_STACK_END"; +section6.output_section[2].input_section.create(1); +section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;"; +section6.output_section[3].$name = ".abortstack"; +section6.output_section[3].output_sections_start = "__ABORT_STACK_START"; +section6.output_section[3].output_sections_end = "__ABORT_STACK_END"; +section6.output_section[3].input_section.create(1); +section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;"; +section6.output_section[4].$name = ".undefinedstack"; +section6.output_section[4].output_sections_start = "__UNDEFINED_STACK_START"; +section6.output_section[4].output_sections_end = "__UNDEFINED_STACK_END"; +section6.output_section[4].input_section.create(1); +section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;"; + +section7.$name = "Initialization and Exception Handling"; +section7.load_memory = "MSRAM"; +section7.output_section.create(3); +section7.output_section[0].$name = ".ARM.exidx"; +section7.output_section[0].palignment = true; +section7.output_section[1].$name = ".init_array"; +section7.output_section[1].palignment = true; +section7.output_section[2].$name = ".fini_array"; +section7.output_section[2].palignment = true; + +section8.$name = "User Shared Memory"; +section8.type = "NOLOAD"; +section8.load_memory = "USER_SHM_MEM"; +section8.group = false; +section8.output_section.create(1); +section8.output_section[0].$name = ".bss.user_shared_mem"; +section8.output_section[0].alignment = 0; + +section9.$name = "Log Shared Memory"; +section9.load_memory = "LOG_SHM_MEM"; +section9.type = "NOLOAD"; +section9.group = false; +section9.output_section.create(1); +section9.output_section[0].$name = ".bss.log_shared_mem"; +section9.output_section[0].alignment = 0; + +section10.$name = "IPC Shared Memory"; +section10.type = "NOLOAD"; +section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM"; +section10.group = false; +section10.output_section.create(1); +section10.output_section[0].$name = ".bss.ipc_vring_mem"; +section10.output_section[0].alignment = 0; + +section11.$name = "Non Cacheable Memory"; +section11.load_memory = "NON_CACHE_MEM"; +section11.group = false; +section11.type = "NOLOAD"; +section11.output_section.create(1); +section11.output_section[0].$name = ".bss.nocache"; +section11.output_section[0].alignment = 0; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/main.c b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/main.c new file mode 100644 index 000000000..1f04b7f6e --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/main.c @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void spinlock_main(void *args); + +void freertos_main(void *args) +{ + spinlock_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..930c6ab83 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 000000000..bfc018290 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,357 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +COV=$(CG_TOOL_ROOT)/bin/tiarmcov +PROFDATA=$(CG_TOOL_ROOT)/bin/tiarmprofdata +COVERAGE_PATH=$(abspath .) +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=spinlock.$(PROFILE).out +COREOUTNAME:=spinlock.$(PROFILE).optishare.out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=spinlock.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=spinlock.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=spinlock.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=spinlock.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=spinlock.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=spinlock.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=spinlock.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=spinlock.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) + + +FILES_common := \ + main.c \ + spinlock.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MCU_PLUS_SDK_PATH}/source \ + -I${OPEN_PRU_PATH}/source \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am64x/r5f \ + -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \ + -I${OPEN_PRU_PATH}/academy/spinlock/spinlock/firmware/am64x-evm \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM64X \ + -DOS_FREERTOS \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -Wno-vla-cxx-extension \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + generated/linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/board/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am64x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am64x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am64x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ + + +LIBS_NAME = \ + freertos.am64x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am64x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am64x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + ${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + ${MCU_PLUS_SDK_PATH}/source/board/lib \ + ${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +ifeq ($(INSTRUMENTATION_MODE), yes) +CFLAGS += -fprofile-instr-generate -fcoverage-mapping +endif +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am64x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am64x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +SYSTEM_FLAG ?= false + +ifeq ($(SYSTEM_FLAG), false) + SYSTEM_COMMAND := syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) +else + SYSTEM_COMMAND := $(OBJS) $(LNK_FILES) $(LIBS_NAME) +endif + +$(OUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Linking: am64x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml + @echo Linking: am64x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +coreout: $(COREOUTNAME) +$(COREOUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Relinking Linking: am64x:r5fss0-0:freertos:ti-arm-clang $@ with OptiShare SSO.. + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml -Wl,--import_sso=$(SSO_PATH) + @echo Relinking with optishare: am64x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am64x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am64x:r5fss0-0:freertos:ti-arm-clang spinlock ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin + $(RM) \*.lnkxml + $(RM) \*.ossr +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin + $(RM) *.lnkxml + $(RM) *.ossr +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +ifeq ($(SYSTEM_FLAG), false) +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --context r5fss0-0 --part Default --package ALV --output generated/ ../example.syscfg +endif + +syscfg-gui: + $(SYSCFG_GUI_SCRIPT) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM64x --context r5fss0-0 --part Default --package ALV --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_a53ss0-0 = 0 +BOOTIMAGE_CORE_ID_a53ss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for spinlock.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o spinlock.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=spinlock.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=spinlock.$(PROFILE).profdata > coverage/spinlock.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/spinlock.$(PROFILE).profdata.json --output-json=coverage/spinlock.$(PROFILE).analysis.json --output=../spinlock.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..8bc8150ba --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,114 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - OPEN_PRU_PATH +# - MCU_PLUS_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_a53ss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs + $(RM) $(BOOTIMAGE_NAME) +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..42a798205 --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_am64x-evm_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,12 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "kernel/freertos/rov/FreeRTOS.rov.js", +]; + +var objectViewerFiles = [ + "kernel/freertos/rov_theia/FreeRTOS_Theia.rov.js", +]; diff --git a/academy/spinlock/spinlock/mcuplus/spinlock.c b/academy/spinlock/spinlock/mcuplus/spinlock.c new file mode 100644 index 000000000..b457ac6dd --- /dev/null +++ b/academy/spinlock/spinlock/mcuplus/spinlock.c @@ -0,0 +1,52 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_drivers_open_close.h" +#include "ti_board_open_close.h" +#include + +#include +#include + +/* + * The R5F loads the same spinlock firmware onto PRU0 and PRU1 of ICSSG0. + * The firmware drives no PRU pins, so no PRU pinmux or I/O expander setup + * is needed here. + */ + +PRUICSS_Handle gPruIcss0Handle; + +void spinlock_main(void *args) +{ + Drivers_open(); // check return status + + int status; + status = Board_driversOpen(); + DebugP_assert(SystemP_SUCCESS == status); + + gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0); + + status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU0)); + DebugP_assert(status != 0); + + status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU1)); + DebugP_assert(status != 0); + + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_PRU0, PRU0Firmware_0, sizeof(PRU0Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_PRU1, PRU1Firmware_0, sizeof(PRU1Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + + while (1) + { + ClockP_usleep(1); + } + + Board_driversClose(); + Drivers_close(); +} diff --git a/academy/spinlock/spinlock/readme.md b/academy/spinlock/spinlock/readme.md new file mode 100644 index 000000000..954f20484 --- /dev/null +++ b/academy/spinlock/spinlock/readme.md @@ -0,0 +1,52 @@ +# Spinlock (assembly) + +## Introduction + +This example shows how a PRU takes and releases the PRU_ICSSG local hardware +spinlock from assembly. The same pattern written in C, with both PRUs +contending for one lock, is in `spinlock_c`. + +## Overview + +The PRU reaches the spinlock accelerator over the broadside interface with +`XIN`/`XOUT` (XID `0x90`). The lock id (`0`-`63`) goes in `R1.b0`, and an +acquire returns its status in `R1.b3`. + +`firmware/spinlock_example.asm` defines two macros: + +- `M_SPINLOCK_ACQUIRE` busy-waits until bit 0 of the status is set, which + means this core now owns the lock. +- `M_SPINLOCK_RELEASE` frees the lock. + +`main` takes the lock once, leaves room for a critical section, releases the +lock and halts. The R5F core (running FreeRTOS) loads the firmware onto PRU0 and +PRU1 of ICSSG0. The firmware drives no pins. + +For how the spinlock accelerator works, see the PRU Academy page +AM243x/AM64x PRU Academy > Hardware information > PRU Broadside Accelerators > Spinlock: + +- AM64x: https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__AXw28VmX5TFHmSGgvY-0qw__AM64-ACADEMY__WI1KRXP__LATEST +- AM243x: https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__Ac5K7fXpNm5GbT1YWvI-8g__AM24X-ACADEMY__ZPSnq-h__LATEST + +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | ------------------------------------------------- | +| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am64x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | + +## Steps to Run the Example + +1. Build the project from the top-level make (`make` in `academy`, or in this + folder), with `DEVICE` set to `am243x` or `am64x` in `imports.mak`. +2. Load and run the R5F image. It loads the firmware onto PRU0 and PRU1. +3. Connect to a PRU core in CCS and step through `main` to watch `R1.b3` while + the core acquires and releases the lock. diff --git a/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..d0c858786 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..20e89c137 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,99 @@ +/* + * AM243x_PRU0.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM243x PRU0 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 CREGISTER=24 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 CREGISTER=25 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* XXX: PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + MII_G_RT : org = 0x00033000 len = 0x00000F44 CREGISTER=9 + TM_CFG_PRU0 : org = 0x0002A000 len = 0x0000004C CREGISTER=10 + PRU0_CTRL : org = 0x00022000 len = 0x00000030 CREGISTER=11 + PA_STATS_QRAM : org = 0x00027000 len = 0x00001000 CREGISTER=12 + PA_STATS_CRAM : org = 0x0002C000 len = 0x00001000 CREGISTER=13 + MII_MDIO : org = 0x00032400 len = 0x00000088 CREGISTER=21 + PRU_RTU_RAT0 : org = 0x00008000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + MII_RT : org = 0x00032000 len = 0x00000070 CREGISTER=27 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD14 : org = 0x00024800 len = 0x00000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x00000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x00000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x00000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x00000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x00000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x00000100 CREGISTER=20 + RSVD23 : org = 0xC0000000 len = 0x00000100 CREGISTER=23 + /* Random length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..1019f5d72 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_c_am243x-evm_icss_g0_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock_c/firmware/am243x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DPRU0 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..8edfbd044 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am243x-evm_icss_g0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..4b4f6c601 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..c8e67a3df --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,100 @@ +/* + * AM243x_PRU1.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM243x PRU1 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 CREGISTER=24 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 CREGISTER=25 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* XXX: PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + MII_G_RT : org = 0x00033000 len = 0x00000F44 CREGISTER=9 + TM_CFG_PRU1 : org = 0x0002A200 len = 0x0000004C CREGISTER=10 + PRU1_CTRL : org = 0x00024000 len = 0x00000030 CREGISTER=11 + + PA_STATS_QRAM : org = 0x00027000 len = 0x00001000 CREGISTER=12 + PA_STATS_CRAM : org = 0x0002C000 len = 0x00001000 CREGISTER=13 + MII_MDIO : org = 0x00032400 len = 0x00000088 CREGISTER=21 + PRU_RTU_RAT1 : org = 0x00009000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + MII_RT : org = 0x00032000 len = 0x00000070 CREGISTER=27 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD14 : org = 0x00024800 len = 0x00000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x00000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x00000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x00000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x00000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x00000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x00000100 CREGISTER=20 + RSVD23 : org = 0xC0000000 len = 0x00000100 CREGISTER=23 + /* Random length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..3fb116630 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_c_am243x-evm_icss_g0_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock_c/firmware/am243x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DPRU1 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..c76556d14 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am243x-evm_icss_g0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..d999c9365 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..20e89c137 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,99 @@ +/* + * AM243x_PRU0.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM243x PRU0 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 CREGISTER=24 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 CREGISTER=25 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* XXX: PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + MII_G_RT : org = 0x00033000 len = 0x00000F44 CREGISTER=9 + TM_CFG_PRU0 : org = 0x0002A000 len = 0x0000004C CREGISTER=10 + PRU0_CTRL : org = 0x00022000 len = 0x00000030 CREGISTER=11 + PA_STATS_QRAM : org = 0x00027000 len = 0x00001000 CREGISTER=12 + PA_STATS_CRAM : org = 0x0002C000 len = 0x00001000 CREGISTER=13 + MII_MDIO : org = 0x00032400 len = 0x00000088 CREGISTER=21 + PRU_RTU_RAT0 : org = 0x00008000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + MII_RT : org = 0x00032000 len = 0x00000070 CREGISTER=27 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD14 : org = 0x00024800 len = 0x00000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x00000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x00000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x00000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x00000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x00000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x00000100 CREGISTER=20 + RSVD23 : org = 0xC0000000 len = 0x00000100 CREGISTER=23 + /* Random length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..a03400337 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_c_am243x-lp_icss_g0_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock_c/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DPRU0 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..aee3d06f8 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am243x-lp_icss_g0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..19a8d3d54 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..c8e67a3df --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,100 @@ +/* + * AM243x_PRU1.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM243x PRU1 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 CREGISTER=24 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 CREGISTER=25 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* XXX: PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + MII_G_RT : org = 0x00033000 len = 0x00000F44 CREGISTER=9 + TM_CFG_PRU1 : org = 0x0002A200 len = 0x0000004C CREGISTER=10 + PRU1_CTRL : org = 0x00024000 len = 0x00000030 CREGISTER=11 + + PA_STATS_QRAM : org = 0x00027000 len = 0x00001000 CREGISTER=12 + PA_STATS_CRAM : org = 0x0002C000 len = 0x00001000 CREGISTER=13 + MII_MDIO : org = 0x00032400 len = 0x00000088 CREGISTER=21 + PRU_RTU_RAT1 : org = 0x00009000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + MII_RT : org = 0x00032000 len = 0x00000070 CREGISTER=27 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD14 : org = 0x00024800 len = 0x00000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x00000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x00000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x00000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x00000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x00000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x00000100 CREGISTER=20 + RSVD23 : org = 0xC0000000 len = 0x00000100 CREGISTER=23 + /* Random length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..bcb291a22 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_c_am243x-lp_icss_g0_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock_c/firmware/am243x-lp/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am243x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DPRU1 -DDEBUG_PIN_SHIFT=0 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..d14b6e9ad --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am243x-lp_icss_g0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..3e0e375db --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..411673d10 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,99 @@ +/* + * AM64x_PRU0.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM64x PRU0 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 0; use only the first 4 KB for PRU0 and reserve + * the second 4 KB for RTU0 and Tx_PRU0 */ + PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000 CREGISTER=24 + /* 8 KB PRU Data RAM 1; reserved completely for Slice1 cores - PRU1, + * RTU1 and Tx_PRU1; do not use for any Slice0 cores */ + PRU1_DMEM_1 : org = 0x00002000 len = 0x00001000 CREGISTER=25 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU0_DMEM_0 : org = 0x00001000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00001800 len = 0x00000800 + RTU1_DMEM_1 : org = 0x00003000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* XXX: PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + MII_G_RT : org = 0x00033000 len = 0x00000F44 CREGISTER=9 + TM_CFG_PRU0 : org = 0x0002A000 len = 0x0000004C CREGISTER=10 + PRU0_CTRL : org = 0x00022000 len = 0x00000030 CREGISTER=11 + PA_STATS_QRAM : org = 0x00027000 len = 0x00001000 CREGISTER=12 + PA_STATS_CRAM : org = 0x0002C000 len = 0x00001000 CREGISTER=13 + MII_MDIO : org = 0x00032400 len = 0x00000088 CREGISTER=21 + PRU_RTU_RAT0 : org = 0x00008000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + MII_RT : org = 0x00032000 len = 0x00000070 CREGISTER=27 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD14 : org = 0x00024800 len = 0x00000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x00000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x00000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x00000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x00000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x00000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x00000100 CREGISTER=20 + RSVD23 : org = 0xC0000000 len = 0x00000100 CREGISTER=23 + /* Random length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU0_DMEM_0, PAGE 1 + .bss > PRU0_DMEM_0, PAGE 1 + .cio > PRU0_DMEM_0, PAGE 1 + .data > PRU0_DMEM_0, PAGE 1 + .switch > PRU0_DMEM_0, PAGE 1 + .sysmem > PRU0_DMEM_0, PAGE 1 + .cinit > PRU0_DMEM_0, PAGE 1 + .rodata > PRU0_DMEM_0, PAGE 1 + .rofardata > PRU0_DMEM_0, PAGE 1 + .farbss > PRU0_DMEM_0, PAGE 1 + .fardata > PRU0_DMEM_0, PAGE 1 +} diff --git a/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..b4f706026 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_c_am64x-evm_icss_g0_pru0_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru0_load_bin.h +HEX_ARRAY_PREFIX := PRU0Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock_c/firmware/am64x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am64x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DPRU0 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..8fab0f4e7 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am64x-evm_icss_g0_pru0_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec new file mode 100644 index 000000000..8284d2e66 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd new file mode 100644 index 000000000..009b97e36 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd @@ -0,0 +1,100 @@ +/* + * AM64x_PRU1.cmd + * + * Example Linker command file for linking programs built with the C compiler + * on AM64x PRU1 cores + */ + +-cr /* Link using C conventions */ + +/* Specify the System Memory Map */ +MEMORY +{ + PAGE 0: + /* 12 KB PRU Instruction RAM */ + PRU_IMEM : org = 0x00000000 len = 0x00003000 + + PAGE 1: + /* Data RAMs */ + /* 8 KB PRU Data RAM 1; use only the first 4 KB for PRU1 and reserve + * the second 4 KB for RTU1 and Tx_PRU1 */ + PRU1_DMEM_1 : org = 0x00000000 len = 0x00001000 CREGISTER=24 + /* 8 KB PRU Data RAM 0; reserved completely for Slice0 cores - PRU0, + * RTU0 and Tx_PRU0; do not use for any Slice1 cores */ + PRU0_DMEM_0 : org = 0x00002000 len = 0x00001000 CREGISTER=25 + /* NOTE: Custom split of the second 4 KB of ICSS Data RAMs 0 and 1 + * split equally between the corresponding RTU and Tx_PRU cores in + * each slice */ + RTU1_DMEM_1 : org = 0x00001000 len = 0x00000800 + TX_PRU1_DMEM_1 : org = 0x00001800 len = 0x00000800 + RTU0_DMEM_0 : org = 0x00003000 len = 0x00000800 + TX_PRU0_DMEM_0 : org = 0x00003800 len = 0x00000800 + + PAGE 2: + /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */ + /* 64 KB PRU Shared RAM */ + PRU_SHAREDMEM : org = 0x00010000 len = 0x00010000 CREGISTER=28 + + /* Internal Peripherals */ + /* NOTE: Use full INTC length instead of 0x200 to match the pruIntc + * structure definition in pru_intc.h, ignoring the second Constant + * Register #6 that starts at 0x200 offset within INTC */ + PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 + PRU_IEP1 : org = 0x0002F000 len = 0x00000100 CREGISTER=1 + PRU_IEP1_0x100 : org = 0x0002F100 len = 0x0000021C CREGISTER=2 + PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 + PRU_CFG : org = 0x00026000 len = 0x00000100 CREGISTER=4 + PRU_CFG_0x100 : org = 0x00026100 len = 0x00000098 CREGISTER=5 + /* XXX: PRU_INTC_0x200 is part of INTC space, and is therefore commented + * out as it conflicts with PRU_INTC size above. To use PRU_INTC_0x200, + * split up the pruIntc structure and CT_INTC variable in + * source/include/PROCESSOR/pru_intc.h */ + /*PRU_INTC_0x200: org = 0x00020200 len = 0x00001304 CREGISTER=6*/ + PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 + PRU_IEP0_0x100 : org = 0x0002E100 len = 0x0000021C CREGISTER=8 + MII_G_RT : org = 0x00033000 len = 0x00000F44 CREGISTER=9 + TM_CFG_PRU1 : org = 0x0002A200 len = 0x0000004C CREGISTER=10 + PRU1_CTRL : org = 0x00024000 len = 0x00000030 CREGISTER=11 + + PA_STATS_QRAM : org = 0x00027000 len = 0x00001000 CREGISTER=12 + PA_STATS_CRAM : org = 0x0002C000 len = 0x00001000 CREGISTER=13 + MII_MDIO : org = 0x00032400 len = 0x00000088 CREGISTER=21 + PRU_RTU_RAT1 : org = 0x00009000 len = 0x00000854 CREGISTER=22 + PRU_IEP0 : org = 0x0002E000 len = 0x00000100 CREGISTER=26 + MII_RT : org = 0x00032000 len = 0x00000070 CREGISTER=27 + + /* External Regions */ + /* Random length 0x100 assigned to the below regions */ + RSVD14 : org = 0x00024800 len = 0x00000100 CREGISTER=14 + RSVD15 : org = 0x60000000 len = 0x00000100 CREGISTER=15 + RSVD16 : org = 0x70000000 len = 0x00000100 CREGISTER=16 + RSVD17 : org = 0x80000000 len = 0x00000100 CREGISTER=17 + RSVD18 : org = 0x90000000 len = 0x00000100 CREGISTER=18 + RSVD19 : org = 0xA0000000 len = 0x00000100 CREGISTER=19 + RSVD20 : org = 0xB0000000 len = 0x00000100 CREGISTER=20 + RSVD23 : org = 0xC0000000 len = 0x00000100 CREGISTER=23 + /* Random length 0x10000 (max len value) assigned to programmable C29-31*/ + RSVD29 : org = 0xD0000000 len = 0x00010000 CREGISTER=29 + RSVD30 : org = 0xE0000000 len = 0x00010000 CREGISTER=30 + RSVD31 : org = 0xF0000000 len = 0x00010000 CREGISTER=31 +} + +/* Specify the sections allocation into memory */ +SECTIONS { + /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading + an ELF file, but useful when loading a binary */ + .text:_c_int00* > 0x0, PAGE 0 + + .text > PRU_IMEM, PAGE 0 + .stack > PRU1_DMEM_1, PAGE 1 + .bss > PRU1_DMEM_1, PAGE 1 + .cio > PRU1_DMEM_1, PAGE 1 + .data > PRU1_DMEM_1, PAGE 1 + .switch > PRU1_DMEM_1, PAGE 1 + .sysmem > PRU1_DMEM_1, PAGE 1 + .cinit > PRU1_DMEM_1, PAGE 1 + .rodata > PRU1_DMEM_1, PAGE 1 + .rofardata > PRU1_DMEM_1, PAGE 1 + .farbss > PRU1_DMEM_1, PAGE 1 + .fardata > PRU1_DMEM_1, PAGE 1 +} diff --git a/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile new file mode 100644 index 000000000..5ee2136a2 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile @@ -0,0 +1,48 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +# Define build outputs +OUTPUT_NAME := spinlock_c_am64x-evm_icss_g0_pru1_fw + +# MCU+ projects: rename & move hex array output +MCU_HEX_NAME := pru1_load_bin.h +HEX_ARRAY_PREFIX := PRU1Firmware +MCU_HEX_PATH := $(OPEN_PRU_PATH)/academy/spinlock/spinlock_c/firmware/am64x-evm/$(MCU_HEX_NAME) + +# which directories to search for assembly & C source files? +FILES_PATH := .. ../../.. . + +# Linker command file +COMMAND_FILES := linker.cmd + +# Silicon version (3: PRUSS, PRU-ICSS; 4: PRU_ICSSG) +PRU_VERSION := 4 +EXPECTED_DEVICE := am64x + +# Default values are defined in pru_rules.mak: +# - include paths (INCLUDE) +# - compiler flags (CFLAGS) +# - linker flags (LFLAGS) + +# Optional: +# Pre-define here to override default value +# OPT_LEVEL, STACK_SIZE, HEAP_SIZE, or ENTRY_POINT + +# pru_rules.mak has shared settings for all PRU/RTU/TX_PRU core makefiles +include $(OPEN_PRU_PATH)/pru_rules.mak + +# Optional: +# Append values to INCLUDE, CFLAGS, or LFLAGS here. +# Values can be appended like this: +# INCLUDE += --include_path= + +# Defines (pass instance specific definitions to the program) +# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide' +# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1: +# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1 +DFLAGS := -DPRU1 + +# Libraries +# see --library in 'PRU Optimizing C/C++ Compiler User's Guide' +LIBS := + diff --git a/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec new file mode 100644 index 000000000..b74d09227 --- /dev/null +++ b/academy/spinlock/spinlock_c/firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am64x-evm_icss_g0_pru1_fw_ti-pru-cgt + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/main.c b/academy/spinlock/spinlock_c/firmware/main.c similarity index 86% rename from academy/spinlock/main.c rename to academy/spinlock/spinlock_c/firmware/main.c index 370f6789e..7b1d03dc5 100644 --- a/academy/spinlock/main.c +++ b/academy/spinlock/spinlock_c/firmware/main.c @@ -36,14 +36,16 @@ void spinlock_release(uint8_t flag_id); /* Spinlock flag id (valid range 0-63). Both PRUs must use the same id. */ #define SPINLOCK_FLAG 11 -/* R30 drives the PRU GPO signals; use a debug pin to scope lock ownership. */ -/* Before use: pinmux the debug signals (see the GPIO lab) and update the */ -/* shift to match your board. PRU0 is selected via -DPRU0 in the makefile. */ +/* + * R30 drives the PRU GPO signals; a debug pin shows lock ownership on a scope. + * Each core drives its own GPO4 by default. The AM243x LaunchPad routes PRU1 + * GPO4 to no header, so its PRU1 makefile passes -DDEBUG_PIN_SHIFT=0 (PRU1 + * GPO0). The pinmux is in the R5F project's example.syscfg; see readme.md for + * the header pins. + */ volatile register uint32_t __R30; -#if PRU0 -#define DEBUG_PIN_SHIFT 4 /* PRU0 debug pin */ -#else -#define DEBUG_PIN_SHIFT 5 /* PRU1 debug pin */ +#ifndef DEBUG_PIN_SHIFT +#define DEBUG_PIN_SHIFT 4 #endif /* @@ -87,7 +89,4 @@ void main(void) /* Work outside the lock, so the other core gets a turn. */ __delay_cycles(OUTSIDE_TIME); } - - /* Not reached because of the while(1) loop above. */ - __halt(); } diff --git a/academy/spinlock/spinlock.asm b/academy/spinlock/spinlock_c/firmware/spinlock.asm similarity index 100% rename from academy/spinlock/spinlock.asm rename to academy/spinlock/spinlock_c/firmware/spinlock.asm diff --git a/academy/spinlock/spinlock_c/makefile b/academy/spinlock/spinlock_c/makefile new file mode 100644 index 000000000..1274dc53b --- /dev/null +++ b/academy/spinlock/spinlock_c/makefile @@ -0,0 +1,120 @@ +include ../../../imports.mak + +####################### +# project information # +####################### + +PROJECT_NAME := spinlock_c +SUPPORTED_PROCESSORS := am64x am243x +# Does the PRU code have dependencies outside of the open-pru repo? +PRU_DEPENDENCIES := +# Use NON_PRU_DEPENDENCIES to select which makefiles to call for non-PRU cores +NON_PRU_DEPENDENCIES := mcuplus + +################### +# Prebuild checks # +################### +BUILD_PROJECT := y +DEVICE_NON_PRU := + +# Only build project if $(DEVICE) is in $(SUPPORTED_PROCESSORS) +ifeq (,$(findstring $(DEVICE),$(SUPPORTED_PROCESSORS))) +BUILD_PROJECT := n +MESSAGE := Project $(PROJECT_NAME) does not have a build option for $(DEVICE) +endif + +# Only build project if PRU dependencies exist +ifneq (,$(PRU_DEPENDENCIES)) +# MCU+ SDK dependency? +ifeq (mcuplus,$(findstring mcuplus,$(PRU_DEPENDENCIES))) +ifneq ($(BUILD_MCUPLUS),y) +BUILD_PROJECT := n +MESSAGE ?= Project $(PROJECT_NAME) depends on MCU+ SDK, but BUILD_MCUPLUS != y. +endif +endif +# Additional PRU dependency checks go here. For example: +#ifeq (dependency,$(findstring dependency,$(PRU_DEPENDENCIES))) +#if (dependency check fails) +#BUILD_PROJECT := n +#MESSAGE ?= Project $(PROJECT_NAME) depends on dependency, but dependency does not exist. +#endif +#endif +endif + +# Only build non-PRU code if the non-PRU code is enabled in imports.mak +ifeq ($(BUILD_MCUPLUS),y) +ifeq (mcuplus,$(findstring mcuplus,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_mcuplus +endif +endif +ifeq ($(BUILD_LINUX),y) +ifeq (linux,$(findstring linux,$(NON_PRU_DEPENDENCIES))) +DEVICE_NON_PRU += $(DEVICE)_linux +endif +endif + +########################### +# Make and clean commands # +########################### + +ifeq ($(BUILD_PROJECT),y) +# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak +# "make" builds PRU firmware first, then host (non-PRU) code +all: MESSAGE = "Building $(PROJECT_NAME) for $(DEVICE)" +all: pre_build_message + $(MAKE) pru + $(MAKE) host + +# "make pru" builds only PRU firmware for $(DEVICE) +pru: ARGUMENTS_PRU = all +pru: $(DEVICE) + +# "make host" builds only host (non-PRU) code for $(DEVICE) +host: ARGUMENTS_MCUPLUS = all +host: $(DEVICE_NON_PRU) + +# "make clean" cleans projects that match $(DEVICE) set in imports.mak +clean: ARGUMENTS_PRU = clean +clean: ARGUMENTS_MCUPLUS = scrub +clean: MESSAGE = "Cleaning $(PROJECT_NAME) for $(DEVICE)" +clean: pre_build_message $(DEVICE) $(DEVICE_NON_PRU) + +else +# if a prebuild check failed, print message and exit +all clean pru host: pre_build_message +endif + +pre_build_message: + @echo $(MESSAGE) + +###################### +# Target definitions # +###################### + +# provide target definitions for each supported processor +# PRU firmware should be built before any RTOS code that includes it + +am64x: +# am64x-evm + $(MAKE) -C firmware/am64x-evm/icss_g0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am64x-evm/icss_g0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am64x_mcuplus: +# am64x-evm + $(MAKE) -C mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang $(ARGUMENTS_MCUPLUS) + +am243x: +# am243x-evm + $(MAKE) -C firmware/am243x-evm/icss_g0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-evm/icss_g0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) +# am243x-lp + $(MAKE) -C firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU) + $(MAKE) -C firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU) + +am243x_mcuplus: +# am243x-evm + $(MAKE) -C mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang $(ARGUMENTS_MCUPLUS) +# am243x-lp + $(MAKE) -C mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang $(ARGUMENTS_MCUPLUS) + +.PHONY: all clean pru host pre_build_message $(DEVICE) $(DEVICE_NON_PRU) $(SUPPORTED_PROCESSORS) diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg new file mode 100644 index 000000000..a5ab28b18 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,276 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALV_beta" --part "ALV" --package "ALV" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM243x@12.00.00" --product "OPEN_PRU@2026.02.00" + * @v2CliArgs --device "AM2434" --package "FCBGA (ALV)" --variant "AM2434-D" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM243x@12.00.00" --product "OPEN_PRU@2026.02.00" + * @versions {"tool":"1.27.0+4565"} + */ + +/** + * Import the modules used in this configuration. + */ +const i2c = scripting.addModule("/drivers/i2c/i2c", {}, false); +const i2c1 = i2c.addInstance(); +const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false); +const pruicss1 = pruicss.addInstance(); +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); +const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false); +const default_linker1 = default_linker.addInstance(); +const general = scripting.addModule("/memory_configurator/general", {}, false); +const general1 = general.addInstance(); +const region = scripting.addModule("/memory_configurator/region", {}, false); +const region1 = region.addInstance(); +const section = scripting.addModule("/memory_configurator/section", {}, false); +const section1 = section.addInstance(); +const section2 = section.addInstance(); +const section3 = section.addInstance(); +const section4 = section.addInstance(); +const section5 = section.addInstance(); +const section6 = section.addInstance(); +const section7 = section.addInstance(); +const section8 = section.addInstance(); +const section9 = section.addInstance(); +const section10 = section.addInstance(); +const section11 = section.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +i2c1.$name = "CONFIG_I2C0"; +i2c1.I2C_child.$name = "drivers_i2c_v0_i2c_v0_template0"; + +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO.create(2); +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.$assign = "PRU_ICSSG0_PRU0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPO4.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].$name = "CONFIG_PRU_ICSS_GPIO1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.$assign = "PRU_ICSSG0_PRU1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPO4.$used = true; + +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +const uart_v0_template = scripting.addModule("/drivers/uart/v0/uart_v0_template", {}, false); +const uart_v0_template1 = uart_v0_template.addInstance({}, false); +uart_v0_template1.$name = "drivers_uart_v0_uart_v0_template0"; +debug_log.uartLog.child = uart_v0_template1; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x80000000; +mpu_armv76.size = 31; + +default_linker1.$name = "memory_configurator_default_linker0"; + +general1.$name = "CONFIG_GENERAL0"; +general1.linker.$name = "TIARMCLANG0"; + +region1.$name = "MEMORY_REGION_CONFIGURATION0"; +region1.memory_region.create(9); +region1.memory_region[0].type = "TCMA_R5F"; +region1.memory_region[0].$name = "R5F_VECS"; +region1.memory_region[0].size = 0x40; +region1.memory_region[0].auto = false; +region1.memory_region[1].type = "TCMA_R5F"; +region1.memory_region[1].$name = "R5F_TCMA"; +region1.memory_region[1].size = 0x7FC0; +region1.memory_region[2].type = "TCMB_R5F"; +region1.memory_region[2].$name = "R5F_TCMB0"; +region1.memory_region[2].size = 0x8000; +region1.memory_region[3].$name = "NON_CACHE_MEM"; +region1.memory_region[3].auto = false; +region1.memory_region[3].manualStartAddress = 0x70060000; +region1.memory_region[3].size = 0x8000; +region1.memory_region[4].$name = "MSRAM"; +region1.memory_region[4].auto = false; +region1.memory_region[4].manualStartAddress = 0x70080000; +region1.memory_region[4].size = 0x40000; +region1.memory_region[5].type = "FLASH"; +region1.memory_region[5].$name = "FLASH"; +region1.memory_region[5].auto = false; +region1.memory_region[5].manualStartAddress = 0x60100000; +region1.memory_region[5].size = 0x80000; +region1.memory_region[6].$name = "USER_SHM_MEM"; +region1.memory_region[6].auto = false; +region1.memory_region[6].manualStartAddress = 0x701D0000; +region1.memory_region[6].size = 0x180; +region1.memory_region[6].isShared = true; +region1.memory_region[6].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[7].auto = false; +region1.memory_region[7].manualStartAddress = 0x701D0180; +region1.memory_region[7].size = 0x3E80; +region1.memory_region[7].$name = "LOG_SHM_MEM"; +region1.memory_region[7].isShared = true; +region1.memory_region[7].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[8].auto = false; +region1.memory_region[8].manualStartAddress = 0x701D4000; +region1.memory_region[8].size = 0xC000; +region1.memory_region[8].$name = "RTOS_NORTOS_IPC_SHM_MEM"; +region1.memory_region[8].isShared = true; +region1.memory_region[8].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; + +section1.$name = "Vector Table"; +section1.load_memory = "R5F_VECS"; +section1.group = false; +section1.output_section.create(1); +section1.output_section[0].$name = ".vectors"; +section1.output_section[0].palignment = true; + +section2.$name = "Text Segments"; +section2.load_memory = "MSRAM"; +section2.output_section.create(5); +section2.output_section[0].$name = ".text.hwi"; +section2.output_section[0].palignment = true; +section2.output_section[1].$name = ".text.cache"; +section2.output_section[1].palignment = true; +section2.output_section[2].$name = ".text.mpu"; +section2.output_section[2].palignment = true; +section2.output_section[3].$name = ".text.boot"; +section2.output_section[3].palignment = true; +section2.output_section[4].$name = ".text:abort"; +section2.output_section[4].palignment = true; + +section3.$name = "Code and Read-Only Data"; +section3.load_memory = "MSRAM"; +section3.output_section.create(2); +section3.output_section[0].$name = ".text"; +section3.output_section[0].palignment = true; +section3.output_section[1].$name = ".rodata"; +section3.output_section[1].palignment = true; + +section4.$name = "Data Segment"; +section4.load_memory = "MSRAM"; +section4.output_section.create(1); +section4.output_section[0].$name = ".data"; +section4.output_section[0].palignment = true; + +section5.$name = "Memory Segments"; +section5.load_memory = "MSRAM"; +section5.output_section.create(3); +section5.output_section[0].$name = ".bss"; +section5.output_section[0].palignment = true; +section5.output_section[0].output_sections_start = "__BSS_START"; +section5.output_section[0].output_sections_end = "__BSS_END"; +section5.output_section[1].$name = ".sysmem"; +section5.output_section[1].palignment = true; +section5.output_section[2].$name = ".stack"; +section5.output_section[2].palignment = true; + +section6.$name = "Stack Segments"; +section6.load_memory = "MSRAM"; +section6.output_section.create(5); +section6.output_section[0].$name = ".irqstack"; +section6.output_section[0].output_sections_start = "__IRQ_STACK_START"; +section6.output_section[0].output_sections_end = "__IRQ_STACK_END"; +section6.output_section[0].input_section.create(1); +section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;"; +section6.output_section[1].$name = ".fiqstack"; +section6.output_section[1].output_sections_start = "__FIQ_STACK_START"; +section6.output_section[1].output_sections_end = "__FIQ_STACK_END"; +section6.output_section[1].input_section.create(1); +section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;"; +section6.output_section[2].$name = ".svcstack"; +section6.output_section[2].output_sections_start = "__SVC_STACK_START"; +section6.output_section[2].output_sections_end = "__SVC_STACK_END"; +section6.output_section[2].input_section.create(1); +section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;"; +section6.output_section[3].$name = ".abortstack"; +section6.output_section[3].output_sections_start = "__ABORT_STACK_START"; +section6.output_section[3].output_sections_end = "__ABORT_STACK_END"; +section6.output_section[3].input_section.create(1); +section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;"; +section6.output_section[4].$name = ".undefinedstack"; +section6.output_section[4].output_sections_start = "__UNDEFINED_STACK_START"; +section6.output_section[4].output_sections_end = "__UNDEFINED_STACK_END"; +section6.output_section[4].input_section.create(1); +section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;"; + +section7.$name = "Initialization and Exception Handling"; +section7.load_memory = "MSRAM"; +section7.output_section.create(3); +section7.output_section[0].$name = ".ARM.exidx"; +section7.output_section[0].palignment = true; +section7.output_section[1].$name = ".init_array"; +section7.output_section[1].palignment = true; +section7.output_section[2].$name = ".fini_array"; +section7.output_section[2].palignment = true; + +section8.$name = "User Shared Memory"; +section8.type = "NOLOAD"; +section8.load_memory = "USER_SHM_MEM"; +section8.group = false; +section8.output_section.create(1); +section8.output_section[0].$name = ".bss.user_shared_mem"; +section8.output_section[0].alignment = 0; + +section9.$name = "Log Shared Memory"; +section9.load_memory = "LOG_SHM_MEM"; +section9.type = "NOLOAD"; +section9.group = false; +section9.output_section.create(1); +section9.output_section[0].$name = ".bss.log_shared_mem"; +section9.output_section[0].alignment = 0; + +section10.$name = "IPC Shared Memory"; +section10.type = "NOLOAD"; +section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM"; +section10.group = false; +section10.output_section.create(1); +section10.output_section[0].$name = ".bss.ipc_vring_mem"; +section10.output_section[0].alignment = 0; + +section11.$name = "Non Cacheable Memory"; +section11.load_memory = "NON_CACHE_MEM"; +section11.group = false; +section11.type = "NOLOAD"; +section11.output_section.create(1); +section11.output_section[0].$name = ".bss.nocache"; +section11.output_section[0].alignment = 0; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +i2c1.I2C.$suggestSolution = "I2C1"; +i2c1.I2C.SCL.$suggestSolution = "I2C1_SCL"; +i2c1.I2C.SDA.$suggestSolution = "I2C1_SDA"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPO4.$suggestSolution = "PRG0_PRU0_GPO4"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPO4.$suggestSolution = "PRG0_PRU1_GPO4"; +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/main.c b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/main.c new file mode 100644 index 000000000..30444b5e9 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/main.c @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void spinlock_c_main(void *args); + +void freertos_main(void *args) +{ + spinlock_c_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..d6a64937b --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 000000000..3ceca1e17 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,356 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +COV=$(CG_TOOL_ROOT)/bin/tiarmcov +PROFDATA=$(CG_TOOL_ROOT)/bin/tiarmprofdata +COVERAGE_PATH=$(abspath .) +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=spinlock_c.$(PROFILE).out +COREOUTNAME:=spinlock_c.$(PROFILE).optishare.out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=spinlock_c.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=spinlock_c.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=spinlock_c.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=spinlock_c.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=spinlock_c.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=spinlock_c.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=spinlock_c.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=spinlock_c.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) + + +FILES_common := \ + main.c \ + spinlock_c.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MCU_PLUS_SDK_PATH}/source \ + -I${OPEN_PRU_PATH}/source \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am243x/r5f \ + -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \ + -I${OPEN_PRU_PATH}/academy/spinlock/spinlock_c/firmware/am243x-evm \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + -DOS_FREERTOS \ + -DPRU_GPIO_VIA_IOEXP \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -Wno-vla-cxx-extension \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + generated/linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/board/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ + + +LIBS_NAME = \ + freertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + ${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + ${MCU_PLUS_SDK_PATH}/source/board/lib \ + ${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +ifeq ($(INSTRUMENTATION_MODE), yes) +CFLAGS += -fprofile-instr-generate -fcoverage-mapping +endif +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +SYSTEM_FLAG ?= false + +ifeq ($(SYSTEM_FLAG), false) + SYSTEM_COMMAND := syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) +else + SYSTEM_COMMAND := $(OBJS) $(LNK_FILES) $(LIBS_NAME) +endif + +$(OUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +coreout: $(COREOUTNAME) +$(COREOUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Relinking Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ with OptiShare SSO.. + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml -Wl,--import_sso=$(SSO_PATH) + @echo Relinking with optishare: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:freertos:ti-arm-clang spinlock_c ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin + $(RM) \*.lnkxml + $(RM) \*.ossr +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin + $(RM) *.lnkxml + $(RM) *.ossr +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +ifeq ($(SYSTEM_FLAG), false) +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --context r5fss0-0 --part ALV --package ALV --output generated/ ../example.syscfg +endif + +syscfg-gui: + $(SYSCFG_GUI_SCRIPT) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM243x_ALV_beta --context r5fss0-0 --part ALV --package ALV --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for spinlock_c.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o spinlock_c.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=spinlock_c.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=spinlock_c.$(PROFILE).profdata > coverage/spinlock_c.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/spinlock_c.$(PROFILE).profdata.json --output-json=coverage/spinlock_c.$(PROFILE).analysis.json --output=../spinlock_c.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..5bcdc554e --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,113 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - OPEN_PRU_PATH +# - MCU_PLUS_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs + $(RM) $(BOOTIMAGE_NAME) +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..1dde7e4d7 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am243x-evm_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,12 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "kernel/freertos/rov/FreeRTOS.rov.js", +]; + +var objectViewerFiles = [ + "kernel/freertos/rov_theia/FreeRTOS_Theia.rov.js", +]; diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg new file mode 100644 index 000000000..ebd1168e1 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,268 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM243x_ALX_beta" --part "ALX" --package "ALX" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM243x@12.00.00" --product "OPEN_PRU@2026.02.00" + * @versions {"tool":"1.27.0+4565"} + */ + +/** + * Import the modules used in this configuration. + */ +const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false); +const pruicss1 = pruicss.addInstance(); +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); +const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false); +const default_linker1 = default_linker.addInstance(); +const general = scripting.addModule("/memory_configurator/general", {}, false); +const general1 = general.addInstance(); +const region = scripting.addModule("/memory_configurator/region", {}, false); +const region1 = region.addInstance(); +const section = scripting.addModule("/memory_configurator/section", {}, false); +const section1 = section.addInstance(); +const section2 = section.addInstance(); +const section3 = section.addInstance(); +const section4 = section.addInstance(); +const section5 = section.addInstance(); +const section6 = section.addInstance(); +const section7 = section.addInstance(); +const section8 = section.addInstance(); +const section9 = section.addInstance(); +const section10 = section.addInstance(); +const section11 = section.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ + +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO.create(2); +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.$assign = "PRU_ICSSG0_PRU0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPO4.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].$name = "CONFIG_PRU_ICSS_GPIO1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.$assign = "PRU_ICSSG0_PRU1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPO0.$used = true; + +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +const uart_v0_template = scripting.addModule("/drivers/uart/v0/uart_v0_template", {}, false); +const uart_v0_template1 = uart_v0_template.addInstance({}, false); +uart_v0_template1.$name = "drivers_uart_v0_uart_v0_template0"; +debug_log.uartLog.child = uart_v0_template1; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x80000000; +mpu_armv76.size = 31; + +default_linker1.$name = "memory_configurator_default_linker0"; + +general1.$name = "CONFIG_GENERAL0"; +general1.linker.$name = "TIARMCLANG0"; + +region1.$name = "MEMORY_REGION_CONFIGURATION0"; +region1.memory_region.create(9); +region1.memory_region[0].type = "TCMA_R5F"; +region1.memory_region[0].$name = "R5F_VECS"; +region1.memory_region[0].size = 0x40; +region1.memory_region[0].auto = false; +region1.memory_region[1].type = "TCMA_R5F"; +region1.memory_region[1].$name = "R5F_TCMA"; +region1.memory_region[1].size = 0x7FC0; +region1.memory_region[2].type = "TCMB_R5F"; +region1.memory_region[2].$name = "R5F_TCMB0"; +region1.memory_region[2].size = 0x8000; +region1.memory_region[3].$name = "NON_CACHE_MEM"; +region1.memory_region[3].auto = false; +region1.memory_region[3].manualStartAddress = 0x70060000; +region1.memory_region[3].size = 0x8000; +region1.memory_region[4].$name = "MSRAM"; +region1.memory_region[4].auto = false; +region1.memory_region[4].manualStartAddress = 0x70080000; +region1.memory_region[4].size = 0x40000; +region1.memory_region[5].type = "FLASH"; +region1.memory_region[5].$name = "FLASH"; +region1.memory_region[5].auto = false; +region1.memory_region[5].manualStartAddress = 0x60100000; +region1.memory_region[5].size = 0x80000; +region1.memory_region[6].$name = "USER_SHM_MEM"; +region1.memory_region[6].auto = false; +region1.memory_region[6].manualStartAddress = 0x701D0000; +region1.memory_region[6].size = 0x180; +region1.memory_region[6].isShared = true; +region1.memory_region[6].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[7].auto = false; +region1.memory_region[7].manualStartAddress = 0x701D0180; +region1.memory_region[7].size = 0x3E80; +region1.memory_region[7].$name = "LOG_SHM_MEM"; +region1.memory_region[7].isShared = true; +region1.memory_region[7].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[8].auto = false; +region1.memory_region[8].manualStartAddress = 0x701D4000; +region1.memory_region[8].size = 0xC000; +region1.memory_region[8].$name = "RTOS_NORTOS_IPC_SHM_MEM"; +region1.memory_region[8].isShared = true; +region1.memory_region[8].shared_cores = ["m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; + +section1.$name = "Vector Table"; +section1.load_memory = "R5F_VECS"; +section1.group = false; +section1.output_section.create(1); +section1.output_section[0].$name = ".vectors"; +section1.output_section[0].palignment = true; + +section2.$name = "Text Segments"; +section2.load_memory = "MSRAM"; +section2.output_section.create(5); +section2.output_section[0].$name = ".text.hwi"; +section2.output_section[0].palignment = true; +section2.output_section[1].$name = ".text.cache"; +section2.output_section[1].palignment = true; +section2.output_section[2].$name = ".text.mpu"; +section2.output_section[2].palignment = true; +section2.output_section[3].$name = ".text.boot"; +section2.output_section[3].palignment = true; +section2.output_section[4].$name = ".text:abort"; +section2.output_section[4].palignment = true; + +section3.$name = "Code and Read-Only Data"; +section3.load_memory = "MSRAM"; +section3.output_section.create(2); +section3.output_section[0].$name = ".text"; +section3.output_section[0].palignment = true; +section3.output_section[1].$name = ".rodata"; +section3.output_section[1].palignment = true; + +section4.$name = "Data Segment"; +section4.load_memory = "MSRAM"; +section4.output_section.create(1); +section4.output_section[0].$name = ".data"; +section4.output_section[0].palignment = true; + +section5.$name = "Memory Segments"; +section5.load_memory = "MSRAM"; +section5.output_section.create(3); +section5.output_section[0].$name = ".bss"; +section5.output_section[0].palignment = true; +section5.output_section[0].output_sections_start = "__BSS_START"; +section5.output_section[0].output_sections_end = "__BSS_END"; +section5.output_section[1].$name = ".sysmem"; +section5.output_section[1].palignment = true; +section5.output_section[2].$name = ".stack"; +section5.output_section[2].palignment = true; + +section6.$name = "Stack Segments"; +section6.load_memory = "MSRAM"; +section6.output_section.create(5); +section6.output_section[0].$name = ".irqstack"; +section6.output_section[0].output_sections_start = "__IRQ_STACK_START"; +section6.output_section[0].output_sections_end = "__IRQ_STACK_END"; +section6.output_section[0].input_section.create(1); +section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;"; +section6.output_section[1].$name = ".fiqstack"; +section6.output_section[1].output_sections_start = "__FIQ_STACK_START"; +section6.output_section[1].output_sections_end = "__FIQ_STACK_END"; +section6.output_section[1].input_section.create(1); +section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;"; +section6.output_section[2].$name = ".svcstack"; +section6.output_section[2].output_sections_start = "__SVC_STACK_START"; +section6.output_section[2].output_sections_end = "__SVC_STACK_END"; +section6.output_section[2].input_section.create(1); +section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;"; +section6.output_section[3].$name = ".abortstack"; +section6.output_section[3].output_sections_start = "__ABORT_STACK_START"; +section6.output_section[3].output_sections_end = "__ABORT_STACK_END"; +section6.output_section[3].input_section.create(1); +section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;"; +section6.output_section[4].$name = ".undefinedstack"; +section6.output_section[4].output_sections_start = "__UNDEFINED_STACK_START"; +section6.output_section[4].output_sections_end = "__UNDEFINED_STACK_END"; +section6.output_section[4].input_section.create(1); +section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;"; + +section7.$name = "Initialization and Exception Handling"; +section7.load_memory = "MSRAM"; +section7.output_section.create(3); +section7.output_section[0].$name = ".ARM.exidx"; +section7.output_section[0].palignment = true; +section7.output_section[1].$name = ".init_array"; +section7.output_section[1].palignment = true; +section7.output_section[2].$name = ".fini_array"; +section7.output_section[2].palignment = true; + +section8.$name = "User Shared Memory"; +section8.type = "NOLOAD"; +section8.load_memory = "USER_SHM_MEM"; +section8.group = false; +section8.output_section.create(1); +section8.output_section[0].$name = ".bss.user_shared_mem"; +section8.output_section[0].alignment = 0; + +section9.$name = "Log Shared Memory"; +section9.load_memory = "LOG_SHM_MEM"; +section9.type = "NOLOAD"; +section9.group = false; +section9.output_section.create(1); +section9.output_section[0].$name = ".bss.log_shared_mem"; +section9.output_section[0].alignment = 0; + +section10.$name = "IPC Shared Memory"; +section10.type = "NOLOAD"; +section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM"; +section10.group = false; +section10.output_section.create(1); +section10.output_section[0].$name = ".bss.ipc_vring_mem"; +section10.output_section[0].alignment = 0; + +section11.$name = "Non Cacheable Memory"; +section11.load_memory = "NON_CACHE_MEM"; +section11.group = false; +section11.type = "NOLOAD"; +section11.output_section.create(1); +section11.output_section[0].$name = ".bss.nocache"; +section11.output_section[0].alignment = 0; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPO4.$suggestSolution = "PRG0_PRU0_GPO4"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPO0.$suggestSolution = "PRG0_PRU1_GPO0"; +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/main.c b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/main.c new file mode 100644 index 000000000..30444b5e9 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/main.c @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void spinlock_c_main(void *args); + +void freertos_main(void *args) +{ + spinlock_c_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..c9a3f2f11 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 000000000..93aa1f2e0 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,355 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +COV=$(CG_TOOL_ROOT)/bin/tiarmcov +PROFDATA=$(CG_TOOL_ROOT)/bin/tiarmprofdata +COVERAGE_PATH=$(abspath .) +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=spinlock_c.$(PROFILE).out +COREOUTNAME:=spinlock_c.$(PROFILE).optishare.out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=spinlock_c.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=spinlock_c.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=spinlock_c.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=spinlock_c.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=spinlock_c.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=spinlock_c.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=spinlock_c.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=spinlock_c.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) + + +FILES_common := \ + main.c \ + spinlock_c.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MCU_PLUS_SDK_PATH}/source \ + -I${OPEN_PRU_PATH}/source \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am243x/r5f \ + -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \ + -I${OPEN_PRU_PATH}/academy/spinlock/spinlock_c/firmware/am243x-lp \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM243X \ + -DOS_FREERTOS \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -Wno-vla-cxx-extension \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + generated/linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/board/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ + + +LIBS_NAME = \ + freertos.am243x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am243x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + ${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + ${MCU_PLUS_SDK_PATH}/source/board/lib \ + ${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +ifeq ($(INSTRUMENTATION_MODE), yes) +CFLAGS += -fprofile-instr-generate -fcoverage-mapping +endif +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am243x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +SYSTEM_FLAG ?= false + +ifeq ($(SYSTEM_FLAG), false) + SYSTEM_COMMAND := syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) +else + SYSTEM_COMMAND := $(OBJS) $(LNK_FILES) $(LIBS_NAME) +endif + +$(OUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml + @echo Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +coreout: $(COREOUTNAME) +$(COREOUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Relinking Linking: am243x:r5fss0-0:freertos:ti-arm-clang $@ with OptiShare SSO.. + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml -Wl,--import_sso=$(SSO_PATH) + @echo Relinking with optishare: am243x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am243x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am243x:r5fss0-0:freertos:ti-arm-clang spinlock_c ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin + $(RM) \*.lnkxml + $(RM) \*.ossr +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin + $(RM) *.lnkxml + $(RM) *.ossr +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +ifeq ($(SYSTEM_FLAG), false) +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg +endif + +syscfg-gui: + $(SYSCFG_GUI_SCRIPT) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM243x_ALX_beta --context r5fss0-0 --part ALX --package ALX --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for spinlock_c.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o spinlock_c.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=spinlock_c.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=spinlock_c.$(PROFILE).profdata > coverage/spinlock_c.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/spinlock_c.$(PROFILE).profdata.json --output-json=coverage/spinlock_c.$(PROFILE).analysis.json --output=../spinlock_c.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..5bcdc554e --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,113 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - OPEN_PRU_PATH +# - MCU_PLUS_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs + $(RM) $(BOOTIMAGE_NAME) +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am243x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..1caef46fe --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am243x-lp_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,12 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "kernel/freertos/rov/FreeRTOS.rov.js", +]; + +var objectViewerFiles = [ + "kernel/freertos/rov_theia/FreeRTOS_Theia.rov.js", +]; diff --git a/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg new file mode 100644 index 000000000..c07ba0448 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg @@ -0,0 +1,276 @@ +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --device "AM64x" --part "Default" --package "ALV" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM64x@11.02.00" --product "OPEN_PRU@2026.02.00" + * @v2CliArgs --device "AM6442" --package "FCBGA (ALV)" --variant "AM6442-D" --context "r5fss0-0" --product "MCU_PLUS_SDK_AM64x@11.02.00" --product "OPEN_PRU@2026.02.00" + * @versions {"tool":"1.27.0+4565"} + */ + +/** + * Import the modules used in this configuration. + */ +const i2c = scripting.addModule("/drivers/i2c/i2c", {}, false); +const i2c1 = i2c.addInstance(); +const pruicss = scripting.addModule("/drivers/pruicss/pruicss", {}, false); +const pruicss1 = pruicss.addInstance(); +const debug_log = scripting.addModule("/kernel/dpl/debug_log"); +const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg"); +const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false); +const mpu_armv71 = mpu_armv7.addInstance(); +const mpu_armv72 = mpu_armv7.addInstance(); +const mpu_armv73 = mpu_armv7.addInstance(); +const mpu_armv74 = mpu_armv7.addInstance(); +const mpu_armv75 = mpu_armv7.addInstance(); +const mpu_armv76 = mpu_armv7.addInstance(); +const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false); +const default_linker1 = default_linker.addInstance(); +const general = scripting.addModule("/memory_configurator/general", {}, false); +const general1 = general.addInstance(); +const region = scripting.addModule("/memory_configurator/region", {}, false); +const region1 = region.addInstance(); +const section = scripting.addModule("/memory_configurator/section", {}, false); +const section1 = section.addInstance(); +const section2 = section.addInstance(); +const section3 = section.addInstance(); +const section4 = section.addInstance(); +const section5 = section.addInstance(); +const section6 = section.addInstance(); +const section7 = section.addInstance(); +const section8 = section.addInstance(); +const section9 = section.addInstance(); +const section10 = section.addInstance(); +const section11 = section.addInstance(); + +/** + * Write custom configuration values to the imported modules. + */ +i2c1.$name = "CONFIG_I2C0"; +i2c1.I2C_child.$name = "drivers_i2c_v0_i2c_v0_template0"; + +pruicss1.$name = "CONFIG_PRU_ICSS0"; +pruicss1.AdditionalICSSSettings[0].$name = "CONFIG_PRU_ICSS_IO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO.create(2); +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].$name = "CONFIG_PRU_ICSS_GPIO0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPO4.$used = true; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].$name = "CONFIG_PRU_ICSS_GPIO1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.$assign = "PRU_ICSSG0_PRU1"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPO4.$used = true; + +debug_log.enableUartLog = true; +debug_log.uartLog.$name = "CONFIG_UART_CONSOLE"; +debug_log.uartLog.UART.$assign = "USART0"; + +const uart_v0_template = scripting.addModule("/drivers/uart/v0/uart_v0_template", {}, false); +const uart_v0_template1 = uart_v0_template.addInstance({}, false); +uart_v0_template1.$name = "drivers_uart_v0_uart_v0_template0"; +debug_log.uartLog.child = uart_v0_template1; + +mpu_armv71.$name = "CONFIG_MPU_REGION0"; +mpu_armv71.size = 31; +mpu_armv71.attributes = "Device"; +mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv71.allowExecute = false; + +mpu_armv72.$name = "CONFIG_MPU_REGION1"; +mpu_armv72.size = 15; +mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv73.$name = "CONFIG_MPU_REGION2"; +mpu_armv73.baseAddr = 0x41010000; +mpu_armv73.size = 15; +mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD"; + +mpu_armv74.$name = "CONFIG_MPU_REGION3"; +mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD"; +mpu_armv74.baseAddr = 0x70000000; +mpu_armv74.size = 21; + +mpu_armv75.$name = "CONFIG_MPU_REGION4"; +mpu_armv75.baseAddr = 0x60000000; +mpu_armv75.size = 28; +mpu_armv75.accessPermissions = "Supervisor RD, User RD"; + +mpu_armv76.$name = "CONFIG_MPU_REGION5"; +mpu_armv76.baseAddr = 0x80000000; +mpu_armv76.size = 31; + +default_linker1.$name = "memory_configurator_default_linker0"; + +general1.$name = "CONFIG_GENERAL0"; +general1.linker.$name = "TIARMCLANG0"; + +region1.$name = "MEMORY_REGION_CONFIGURATION0"; +region1.memory_region.create(9); +region1.memory_region[0].type = "TCMA_R5F"; +region1.memory_region[0].$name = "R5F_VECS"; +region1.memory_region[0].size = 0x40; +region1.memory_region[0].auto = false; +region1.memory_region[1].type = "TCMA_R5F"; +region1.memory_region[1].$name = "R5F_TCMA"; +region1.memory_region[1].size = 0x7FC0; +region1.memory_region[2].type = "TCMB_R5F"; +region1.memory_region[2].$name = "R5F_TCMB0"; +region1.memory_region[2].size = 0x8000; +region1.memory_region[3].$name = "NON_CACHE_MEM"; +region1.memory_region[3].auto = false; +region1.memory_region[3].manualStartAddress = 0x70060000; +region1.memory_region[3].size = 0x8000; +region1.memory_region[4].$name = "MSRAM"; +region1.memory_region[4].auto = false; +region1.memory_region[4].manualStartAddress = 0x70080000; +region1.memory_region[4].size = 0x40000; +region1.memory_region[5].type = "FLASH"; +region1.memory_region[5].$name = "FLASH"; +region1.memory_region[5].auto = false; +region1.memory_region[5].manualStartAddress = 0x60100000; +region1.memory_region[5].size = 0x80000; +region1.memory_region[6].$name = "USER_SHM_MEM"; +region1.memory_region[6].auto = false; +region1.memory_region[6].manualStartAddress = 0x701D0000; +region1.memory_region[6].size = 0x80; +region1.memory_region[6].isShared = true; +region1.memory_region[6].shared_cores = ["a53ss0-0","a53ss0-1","m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[7].auto = false; +region1.memory_region[7].manualStartAddress = 0x701D0080; +region1.memory_region[7].size = 0x3F80; +region1.memory_region[7].$name = "LOG_SHM_MEM"; +region1.memory_region[7].isShared = true; +region1.memory_region[7].shared_cores = ["a53ss0-0","a53ss0-1","m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; +region1.memory_region[8].auto = false; +region1.memory_region[8].manualStartAddress = 0x701D4000; +region1.memory_region[8].size = 0xC000; +region1.memory_region[8].$name = "RTOS_NORTOS_IPC_SHM_MEM"; +region1.memory_region[8].isShared = true; +region1.memory_region[8].shared_cores = ["a53ss0-0","a53ss0-1","m4fss0-0","r5fss0-1","r5fss1-0","r5fss1-1"]; + +section1.$name = "Vector Table"; +section1.load_memory = "R5F_VECS"; +section1.group = false; +section1.output_section.create(1); +section1.output_section[0].$name = ".vectors"; +section1.output_section[0].palignment = true; + +section2.$name = "Text Segments"; +section2.load_memory = "MSRAM"; +section2.output_section.create(5); +section2.output_section[0].$name = ".text.hwi"; +section2.output_section[0].palignment = true; +section2.output_section[1].$name = ".text.cache"; +section2.output_section[1].palignment = true; +section2.output_section[2].$name = ".text.mpu"; +section2.output_section[2].palignment = true; +section2.output_section[3].$name = ".text.boot"; +section2.output_section[3].palignment = true; +section2.output_section[4].$name = ".text:abort"; +section2.output_section[4].palignment = true; + +section3.$name = "Code and Read-Only Data"; +section3.load_memory = "MSRAM"; +section3.output_section.create(2); +section3.output_section[0].$name = ".text"; +section3.output_section[0].palignment = true; +section3.output_section[1].$name = ".rodata"; +section3.output_section[1].palignment = true; + +section4.$name = "Data Segment"; +section4.load_memory = "MSRAM"; +section4.output_section.create(1); +section4.output_section[0].$name = ".data"; +section4.output_section[0].palignment = true; + +section5.$name = "Memory Segments"; +section5.load_memory = "MSRAM"; +section5.output_section.create(3); +section5.output_section[0].$name = ".bss"; +section5.output_section[0].palignment = true; +section5.output_section[0].output_sections_start = "__BSS_START"; +section5.output_section[0].output_sections_end = "__BSS_END"; +section5.output_section[1].$name = ".sysmem"; +section5.output_section[1].palignment = true; +section5.output_section[2].$name = ".stack"; +section5.output_section[2].palignment = true; + +section6.$name = "Stack Segments"; +section6.load_memory = "MSRAM"; +section6.output_section.create(5); +section6.output_section[0].$name = ".irqstack"; +section6.output_section[0].output_sections_start = "__IRQ_STACK_START"; +section6.output_section[0].output_sections_end = "__IRQ_STACK_END"; +section6.output_section[0].input_section.create(1); +section6.output_section[0].input_section[0].$name = ". = . + __IRQ_STACK_SIZE;"; +section6.output_section[1].$name = ".fiqstack"; +section6.output_section[1].output_sections_start = "__FIQ_STACK_START"; +section6.output_section[1].output_sections_end = "__FIQ_STACK_END"; +section6.output_section[1].input_section.create(1); +section6.output_section[1].input_section[0].$name = ". = . + __FIQ_STACK_SIZE;"; +section6.output_section[2].$name = ".svcstack"; +section6.output_section[2].output_sections_start = "__SVC_STACK_START"; +section6.output_section[2].output_sections_end = "__SVC_STACK_END"; +section6.output_section[2].input_section.create(1); +section6.output_section[2].input_section[0].$name = ". = . + __SVC_STACK_SIZE;"; +section6.output_section[3].$name = ".abortstack"; +section6.output_section[3].output_sections_start = "__ABORT_STACK_START"; +section6.output_section[3].output_sections_end = "__ABORT_STACK_END"; +section6.output_section[3].input_section.create(1); +section6.output_section[3].input_section[0].$name = ". = . + __ABORT_STACK_SIZE;"; +section6.output_section[4].$name = ".undefinedstack"; +section6.output_section[4].output_sections_start = "__UNDEFINED_STACK_START"; +section6.output_section[4].output_sections_end = "__UNDEFINED_STACK_END"; +section6.output_section[4].input_section.create(1); +section6.output_section[4].input_section[0].$name = ". = . + __UNDEFINED_STACK_SIZE;"; + +section7.$name = "Initialization and Exception Handling"; +section7.load_memory = "MSRAM"; +section7.output_section.create(3); +section7.output_section[0].$name = ".ARM.exidx"; +section7.output_section[0].palignment = true; +section7.output_section[1].$name = ".init_array"; +section7.output_section[1].palignment = true; +section7.output_section[2].$name = ".fini_array"; +section7.output_section[2].palignment = true; + +section8.$name = "User Shared Memory"; +section8.type = "NOLOAD"; +section8.load_memory = "USER_SHM_MEM"; +section8.group = false; +section8.output_section.create(1); +section8.output_section[0].$name = ".bss.user_shared_mem"; +section8.output_section[0].alignment = 0; + +section9.$name = "Log Shared Memory"; +section9.load_memory = "LOG_SHM_MEM"; +section9.type = "NOLOAD"; +section9.group = false; +section9.output_section.create(1); +section9.output_section[0].$name = ".bss.log_shared_mem"; +section9.output_section[0].alignment = 0; + +section10.$name = "IPC Shared Memory"; +section10.type = "NOLOAD"; +section10.load_memory = "RTOS_NORTOS_IPC_SHM_MEM"; +section10.group = false; +section10.output_section.create(1); +section10.output_section[0].$name = ".bss.ipc_vring_mem"; +section10.output_section[0].alignment = 0; + +section11.$name = "Non Cacheable Memory"; +section11.load_memory = "NON_CACHE_MEM"; +section11.group = false; +section11.type = "NOLOAD"; +section11.output_section.create(1); +section11.output_section[0].$name = ".bss.nocache"; +section11.output_section[0].alignment = 0; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +i2c1.I2C.$suggestSolution = "I2C1"; +i2c1.I2C.SCL.$suggestSolution = "I2C1_SCL"; +i2c1.I2C.SDA.$suggestSolution = "I2C1_SDA"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.$suggestSolution = "PRU_ICSSG0_PRU0"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[0].PRU_ICSSG0_PRU.GPO4.$suggestSolution = "PRG0_PRU0_GPO4"; +pruicss1.AdditionalICSSSettings[0].PruGPIO[1].PRU_ICSSG0_PRU.GPO4.$suggestSolution = "PRG0_PRU1_GPO4"; +debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD"; +debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD"; diff --git a/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/main.c b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/main.c new file mode 100644 index 000000000..0f7ab0de6 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/main.c @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2024-2026 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_board_config.h" +#include "FreeRTOS.h" +#include "task.h" + +#define MAIN_TASK_PRI (configMAX_PRIORITIES-1) + +#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE)) +StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32))); + +StaticTask_t gMainTaskObj; +TaskHandle_t gMainTask; + +void spinlock_c_main(void *args); + +void freertos_main(void *args) +{ + spinlock_c_main(NULL); + + vTaskDelete(NULL); +} + + +int main(void) +{ + /* init SOC specific modules */ + System_init(); + Board_init(); + + /* This task is created at highest priority, it should create more tasks and then delete itself */ + gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */ + "freertos_main", /* Text name for the task. This is to facilitate debugging only. */ + MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */ + NULL, /* We are not using the task parameter. */ + MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */ + gMainTaskStack, /* pointer to stack base */ + &gMainTaskObj ); /* pointer to statically allocated task object memory */ + configASSERT(gMainTask != NULL); + + /* Start the scheduler to start the tasks executing. */ + vTaskStartScheduler(); + + /* The following line should never be reached because vTaskStartScheduler() + will only return if there was not enough FreeRTOS heap memory available to + create the Idle and (if configured) Timer tasks. Heap management, and + techniques for trapping heap exhaustion, are described in the book text. */ + DebugP_assertNoLog(0); + + return 0; +} diff --git a/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec new file mode 100644 index 000000000..c95719b14 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/example.projectspec @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile new file mode 100644 index 000000000..be309b6fb --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile @@ -0,0 +1,356 @@ +# +# Auto generated makefile +# + +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + + +CG_TOOL_ROOT=$(CGT_TI_ARM_CLANG_PATH) + +CC=$(CG_TOOL_ROOT)/bin/tiarmclang +LNK=$(CG_TOOL_ROOT)/bin/tiarmclang +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +COV=$(CG_TOOL_ROOT)/bin/tiarmcov +PROFDATA=$(CG_TOOL_ROOT)/bin/tiarmprofdata +COVERAGE_PATH=$(abspath .) +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +PROFILE?=release +ConfigName:=$(PROFILE) + +OUTNAME:=spinlock_c.$(PROFILE).out +COREOUTNAME:=spinlock_c.$(PROFILE).optishare.out + +BOOTIMAGE_PATH=$(abspath .) +BOOTIMAGE_NAME:=spinlock_c.$(PROFILE).appimage +BOOTIMAGE_NAME_XIP:=spinlock_c.$(PROFILE).appimage_xip +BOOTIMAGE_NAME_SIGNED:=spinlock_c.$(PROFILE).appimage.signed +BOOTIMAGE_RPRC_NAME:=spinlock_c.$(PROFILE).rprc +BOOTIMAGE_RPRC_NAME_XIP:=spinlock_c.$(PROFILE).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=spinlock_c.$(PROFILE).rprc_tmp +BOOTIMAGE_NAME_HS:=spinlock_c.$(PROFILE).appimage.hs +BOOTIMAGE_NAME_HS_FS:=spinlock_c.$(PROFILE).appimage.hs_fs +TARGETS := $(BOOTIMAGE_NAME) + + +FILES_common := \ + main.c \ + spinlock_c.c \ + ti_drivers_config.c \ + ti_drivers_open_close.c \ + ti_board_config.c \ + ti_board_open_close.c \ + ti_dpl_config.c \ + ti_pinmux_config.c \ + ti_power_clock_config.c \ + +FILES_PATH_common = \ + .. \ + ../../.. \ + generated \ + +INCLUDES_common := \ + -I${CG_TOOL_ROOT}/include/c \ + -I${MCU_PLUS_SDK_PATH}/source \ + -I${OPEN_PRU_PATH}/source \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \ + -I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am64x/r5f \ + -I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \ + -I${OPEN_PRU_PATH}/academy/spinlock/spinlock_c/firmware/am64x-evm \ + -Igenerated \ + +DEFINES_common := \ + -DSOC_AM64X \ + -DOS_FREERTOS \ + -DPRU_GPIO_VIA_IOEXP \ + +CFLAGS_common := \ + -mcpu=cortex-r5 \ + -mfloat-abi=hard \ + -mfpu=vfpv3-d16 \ + -mthumb \ + -Wall \ + -Werror \ + -g \ + -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-unused-function \ + +CFLAGS_cpp_common := \ + -Wno-c99-designator \ + -Wno-extern-c-compat \ + -Wno-c++11-narrowing \ + -Wno-reorder-init-list \ + -Wno-register \ + -Wno-writable-strings \ + -Wno-enum-compare \ + -Wno-reserved-user-defined-literal \ + -Wno-unused-const-variable \ + -Wno-vla-cxx-extension \ + -x c++ \ + +CFLAGS_debug := \ + -D_DEBUG_=1 \ + +CFLAGS_release := \ + -Os \ + +LNK_FILES_common = \ + generated/linker.cmd \ + +LIBS_PATH_common = \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/board/lib \ + -Wl,-i${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + -Wl,-i${CG_TOOL_ROOT}/lib \ + +LIBS_common = \ + -lfreertos.am64x.r5f.ti-arm-clang.${ConfigName}.lib \ + -ldrivers.am64x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -lboard.am64x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + -llibc.a \ + -llibsysbm.a \ + +LFLAGS_common = \ + -Wl,--diag_suppress=10063 \ + -Wl,--ram_model \ + -Wl,--reread_libs \ + -Wl,--gen_xml_func_hash \ + + +LIBS_NAME = \ + freertos.am64x.r5f.ti-arm-clang.${ConfigName}.lib \ + drivers.am64x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + board.am64x.r5f.ti-arm-clang.freertos.${ConfigName}.lib \ + libc.a \ + libsysbm.a \ + +LIBS_PATH_NAME = \ + ${MCU_PLUS_SDK_PATH}/source/kernel/freertos/lib \ + ${MCU_PLUS_SDK_PATH}/source/drivers/lib \ + ${MCU_PLUS_SDK_PATH}/source/board/lib \ + ${MCU_PLUS_SDK_PATH}/source/pru_io/lib \ + ${CG_TOOL_ROOT}/lib \ + +FILES := $(FILES_common) $(FILES_$(PROFILE)) +ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE)) +FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE)) +CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE)) +ifeq ($(INSTRUMENTATION_MODE), yes) +CFLAGS += -fprofile-instr-generate -fcoverage-mapping +endif +DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE)) +INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE)) +LIBS := $(LIBS_common) $(LIBS_$(PROFILE)) +LIBS_PATH := $(LIBS_PATH_common) $(LIBS_PATH_$(PROFILE)) +LFLAGS := $(LFLAGS_common) $(LFLAGS_$(PROFILE)) +LNKOPTFLAGS := $(LNKOPTFLAGS_common) $(LNKOPTFLAGS_$(PROFILE)) +LNK_FILES := $(LNK_FILES_common) $(LNK_FILES_$(PROFILE)) + +OBJDIR := obj/$(PROFILE)/ +OBJS := $(FILES:%.c=%.obj) +OBJS += $(ASMFILES:%.S=%.obj) +DEPS := $(FILES:%.c=%.d) + +vpath %.obj $(OBJDIR) +vpath %.c $(FILES_PATH) +vpath %.S $(FILES_PATH) +vpath %.lib $(LIBS_PATH_NAME) +vpath %.a $(LIBS_PATH_NAME) + +$(OBJDIR)/%.obj %.obj: %.c + @echo Compiling: am64x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -o $(OBJDIR)/$@ $< + +$(OBJDIR)/%.obj %.obj: %.S + @echo Compiling: am64x:r5fss0-0:freertos:ti-arm-clang $(LIBNAME): $< + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)/$@ $< + +all: $(TARGETS) + +SYSCFG_GEN_FILES=generated/ti_drivers_config.c generated/ti_drivers_config.h +SYSCFG_GEN_FILES+=generated/ti_drivers_open_close.c generated/ti_drivers_open_close.h +SYSCFG_GEN_FILES+=generated/ti_dpl_config.c generated/ti_dpl_config.h +SYSCFG_GEN_FILES+=generated/ti_pinmux_config.c generated/ti_power_clock_config.c +SYSCFG_GEN_FILES+=generated/ti_board_config.c generated/ti_board_config.h +SYSCFG_GEN_FILES+=generated/ti_board_open_close.c generated/ti_board_open_close.h + +SYSTEM_FLAG ?= false + +ifeq ($(SYSTEM_FLAG), false) + SYSTEM_COMMAND := syscfg $(SYSCFG_GEN_FILES) $(OBJS) $(LNK_FILES) $(LIBS_NAME) +else + SYSTEM_COMMAND := $(OBJS) $(LNK_FILES) $(LIBS_NAME) +endif + +$(OUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Linking: am64x:r5fss0-0:freertos:ti-arm-clang $@ ... + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml + @echo Linking: am64x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +coreout: $(COREOUTNAME) +$(COREOUTNAME): $(SYSTEM_COMMAND) + @echo . + @echo Relinking Linking: am64x:r5fss0-0:freertos:ti-arm-clang $@ with OptiShare SSO.. + $(LNK) $(LNKOPTFLAGS) $(LFLAGS) $(LIBS_PATH) -Wl,-m=$(basename $@).map -o $@ $(addprefix $(OBJDIR), $(OBJS)) $(LIBS) $(LNK_FILES) -Wl,--xml_link_info=$(basename $@).lnkxml -Wl,--import_sso=$(SSO_PATH) + @echo Relinking with optishare: am64x:r5fss0-0:freertos:ti-arm-clang $@ Done !!! + @echo . + +clean: + @echo Cleaning: am64x:r5fss0-0:freertos:ti-arm-clang $(OUTNAME) ... + $(RMDIR) $(OBJDIR) + $(RM) $(OUTNAME) + $(RM) $(BOOTIMAGE_NAME) + $(RM) $(BOOTIMAGE_NAME_XIP) + $(RM) $(BOOTIMAGE_NAME_SIGNED) + $(RM) $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(RM) $(BOOTIMAGE_RPRC_NAME_XIP) + $(RMDIR) generated/ + +scrub: + @echo Scrubing: am64x:r5fss0-0:freertos:ti-arm-clang spinlock_c ... + $(RMDIR) obj +ifeq ($(OS),Windows_NT) + $(RM) \*.out + $(RM) \*.map + $(RM) \*.appimage* + $(RM) \*.rprc* + $(RM) \*.tiimage* + $(RM) \*.bin +else + $(RM) *.out + $(RM) *.map + $(RM) *.appimage* + $(RM) *.rprc* + $(RM) *.tiimage* + $(RM) *.bin + $(RM) *.lnkxml + $(RM) *.ossr +endif + $(RMDIR) generated + +$(OBJS): | $(OBJDIR) + +$(OBJDIR): + $(MKDIR) $@ + + +.NOTPARALLEL: + +.INTERMEDIATE: syscfg +$(SYSCFG_GEN_FILES): syscfg + +ifeq ($(SYSTEM_FLAG), false) +syscfg: ../example.syscfg + @echo Generating SysConfig files ... + $(SYSCFG_NODE) $(SYSCFG_CLI_PATH)/dist/cli.js --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --context r5fss0-0 --part Default --package ALV --output generated/ ../example.syscfg +endif + +syscfg-gui: + $(SYSCFG_GUI_SCRIPT) --product $(SYSCFG_SDKPRODUCT) --product $(SYSCFG_MCU_PLUS_SDK_PRODUCT) --device AM64x --context r5fss0-0 --part Default --package ALV --output generated/ ../example.syscfg + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CERT_KEY=$(APP_SIGNING_KEY) + +BOOTIMAGE_CORE_ID_a53ss0-0 = 0 +BOOTIMAGE_CORE_ID_a53ss0-1 = 1 +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(SYSCFG_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +$(BOOTIMAGE_NAME): $(OUTNAME) + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$@ ... +ifneq ($(OS),Windows_NT) + $(CHMOD) a+x $(XIPGEN_CMD) +endif + $(OUTRPRC_CMD) $(OUTNAME) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE), HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS) + $(RM) $(BOOTIMAGE_NAME)-enc +endif + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS) Done !!! + @echo . +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS) + $(RM) $(BOOTIMAGE_NAME) + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!! + @echo . +endif + + + +.PHONY: coverage +coverage: + @echo Creating Coverage Report for spinlock_c.$(PROFILE) ... + $(MKDIR) coverage + $(PROFDATA) merge -sparse -obj-file=$(OUTNAME) $(OUTNAME).cnt -o spinlock_c.$(PROFILE).profdata + $(COV) show --format=html --show-expansions --show-instantiations --show-branches=count --object=$(OUTNAME) -instr-profile=spinlock_c.$(PROFILE).profdata --output-dir=$(COVERAGE_PATH)/coverage --ignore-filename-regex=build_jenkins + $(COV) export --format=text --object=$(OUTNAME) --instr-profile=spinlock_c.$(PROFILE).profdata > coverage/spinlock_c.$(PROFILE).profdata.json + node $(MCU_PLUS_SDK_PATH)/tools/smart_placement/clang_coverage_analyse.js --input=coverage/spinlock_c.$(PROFILE).profdata.json --output-json=coverage/spinlock_c.$(PROFILE).analysis.json --output=../spinlock_c.annotations.$(PROFILE).S --top-function-count=500 + @echo Coverage Report Generated at $(COVERAGE_PATH)/coverage folder !!! + +-include $(addprefix $(OBJDIR)/, $(DEPS)) diff --git a/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen new file mode 100644 index 000000000..8bc8150ba --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen @@ -0,0 +1,114 @@ +# +# Auto generated makefile +# + +# Below variables need to be defined outside this file or via command line +# - OPEN_PRU_PATH +# - MCU_PLUS_SDK_PATH +# - PROFILE +# - CG_TOOL_ROOT +# - OUTNAME +# - CCS_INSTALL_DIR +# - CCS_IDE_MODE + +CCS_PATH=$(CCS_INSTALL_DIR) +include $(OPEN_PRU_PATH)/imports.mak +include $(MCU_PLUS_SDK_PATH)/devconfig/devconfig.mak + +STRIP=$(CG_TOOL_ROOT)/bin/tiarmstrip +OBJCOPY=$(CG_TOOL_ROOT)/bin/tiarmobjcopy +ifeq ($(OS), Windows_NT) + PYTHON=python +else + PYTHON=python3 +endif + +OUTFILE=$(PROFILE)/$(OUTNAME).out +BOOTIMAGE_PATH=$(abspath ${PROFILE}) +BOOTIMAGE_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage +BOOTIMAGE_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage_xip +BOOTIMAGE_NAME_SIGNED:=$(BOOTIMAGE_PATH)/$(OUTNAME).appimage.signed +BOOTIMAGE_RPRC_NAME:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc +BOOTIMAGE_RPRC_NAME_XIP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_xip +BOOTIMAGE_RPRC_NAME_TMP:=$(BOOTIMAGE_PATH)/$(OUTNAME).rprc_tmp + +# +# Generation of boot image which can be loaded by Secondary Boot Loader (SBL) +# +ifeq ($(OS),Windows_NT) +EXE_EXT=.exe +endif +ifeq ($(OS),Windows_NT) + BOOTIMAGE_CERT_GEN_CMD=powershell -executionpolicy unrestricted -command $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.ps1 +else + BOOTIMAGE_CERT_GEN_CMD=$(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/x509CertificateGen.sh +endif +BOOTIMAGE_TEMP_OUT_FILE=$(PROFILE)/temp_stdout_$(PROFILE).txt + +BOOTIMAGE_CORE_ID_a53ss0-0 = 0 +BOOTIMAGE_CORE_ID_r5fss0-0 = 4 +BOOTIMAGE_CORE_ID_r5fss0-1 = 5 +BOOTIMAGE_CORE_ID_r5fss1-0 = 6 +BOOTIMAGE_CORE_ID_r5fss1-1 = 7 +BOOTIMAGE_CORE_ID_m4fss0-0 = 14 +SBL_RUN_ADDRESS=0x70000000 +SBL_DEV_ID=55 + +MULTI_CORE_IMAGE_GEN = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/multicoreImageGen/multicoreImageGen.js +OUTRPRC_CMD = $(CCS_NODE) $(MCU_PLUS_SDK_PATH)/tools/boot/out2rprc/elf2rprc.js +APP_IMAGE_SIGN_CMD = $(MCU_PLUS_SDK_PATH)/source/security/security_common/tools/boot/signing/appimage_x509_cert_gen.py + +ifeq ($(OS),Windows_NT) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.exe +else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out.mac + else + XIPGEN_CMD=$(MCU_PLUS_SDK_PATH)/tools/boot/xipGen/xipGen.out +endif +endif + +MULTI_CORE_IMAGE_PARAMS = \ + $(BOOTIMAGE_RPRC_NAME)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +MULTI_CORE_IMAGE_PARAMS_XIP = \ + $(BOOTIMAGE_RPRC_NAME_XIP)@$(BOOTIMAGE_CORE_ID_r5fss0-0) \ + +all: +ifeq ($(CCS_IDE_MODE),cloud) +# No post build steps +else + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME) ... + $(OUTRPRC_CMD) $(OUTFILE) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(COPY) $(OUTNAME).rprc $(BOOTIMAGE_RPRC_NAME) + $(COPY) $(BOOTIMAGE_RPRC_NAME) $(BOOTIMAGE_RPRC_NAME_TMP) + $(RM) $(BOOTIMAGE_RPRC_NAME) + $(XIPGEN_CMD) -i $(BOOTIMAGE_RPRC_NAME_TMP) -o $(BOOTIMAGE_RPRC_NAME) -x $(BOOTIMAGE_RPRC_NAME_XIP) --flash-start-addr 0x60000000 -v > $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME) $(MULTI_CORE_IMAGE_PARAMS) >> $(BOOTIMAGE_TEMP_OUT_FILE) + $(MULTI_CORE_IMAGE_GEN) --devID $(SBL_DEV_ID) --out $(BOOTIMAGE_NAME_XIP) $(MULTI_CORE_IMAGE_PARAMS_XIP) >> $(BOOTIMAGE_TEMP_OUT_FILE) +ifeq ($(DEVICE_TYPE),HS) +# Sign the appimage using appimage signing script +ifeq ($(ENC_ENABLED),no) + @echo Boot image signing: Encryption is disabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME) +else + @echo Boot image signing: Encryption is enabled. + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME).hs + $(RM) $(BOOTIMAGE_NAME)-enc +endif +else +# Sign the appimage for HS-FS using appimage signing script + $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME).hs_fs + $(RM) $(BOOTIMAGE_NAME) +endif + $(RM) $(BOOTIMAGE_RPRC_NAME_TMP) +ifeq ($(DEVICE_TYPE),HS) + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs Done !!! + @echo . +else + @echo Boot image: am64x:r5fss0-0:freertos:ti-arm-clang $(BOOTIMAGE_NAME).hs_fs Done !!! + @echo . +endif +endif diff --git a/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec new file mode 100644 index 000000000..3b5a202c8 --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec @@ -0,0 +1,16 @@ +export OPEN_PRU_PATH?=$(abspath ../../../../../../..) +include $(OPEN_PRU_PATH)/imports.mak + +PROFILE?=Release + +PROJECT_NAME=spinlock_c_am64x-evm_r5fss0-0_freertos_ti-arm-clang + +all: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) + +clean: + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectBuild -ccs.projects $(PROJECT_NAME) -ccs.configuration $(PROFILE) -ccs.clean + +export: + $(MKDIR) $(OPEN_PRU_PATH)/ccs_projects + $(CCS_ECLIPSE) -noSplash -data $(OPEN_PRU_PATH)/ccs_projects -application com.ti.ccstudio.apps.projectCreate -ccs.projectSpec example.projectspec -ccs.overwrite full diff --git a/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs new file mode 100644 index 000000000..f716f8e9d --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/am64x-evm/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs @@ -0,0 +1,12 @@ +/* + * ======== syscfg_c.rov.xs ======== + * This file contains the information needed by the Runtime Object + * View (ROV) tool. + */ +var crovFiles = [ + "kernel/freertos/rov/FreeRTOS.rov.js", +]; + +var objectViewerFiles = [ + "kernel/freertos/rov_theia/FreeRTOS_Theia.rov.js", +]; diff --git a/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c b/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c new file mode 100644 index 000000000..12e2193cb --- /dev/null +++ b/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c @@ -0,0 +1,98 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2026 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include "ti_drivers_config.h" +#include "ti_drivers_open_close.h" +#include "ti_board_open_close.h" +#include + +#include +#include +#if defined(PRU_GPIO_VIA_IOEXP) +#include +#endif + +/* + * The R5F loads the spinlock firmware onto PRU0 and PRU1 of ICSSG0. Each PRU + * drives a debug GPO while it holds the lock; the pinmux for both pins is in + * example.syscfg, and readme.md lists the header pins. + */ + +PRUICSS_Handle gPruIcss0Handle; + +/* + * On the AM64x and AM243x EVMs the PRU GPIOs only reach the expansion header + * once the TCA6424 I/O expander enables them. Those boards' makefiles define + * PRU_GPIO_VIA_IOEXP. The AM243x LaunchPad has no such switch. + */ +#if defined(PRU_GPIO_VIA_IOEXP) + +static TCA6424_Config gTCA6424_Config; + +static void i2c_io_expander(void *args) +{ + int32_t status = SystemP_SUCCESS; + TCA6424_Params tca6424Params; + TCA6424_Params_init(&tca6424Params); + status = TCA6424_open(&gTCA6424_Config, &tca6424Params); + uint32_t ioIndex; + + if(status == SystemP_SUCCESS) + { + /* set P12 high which controls CPSW_FET_SEL -> enable PRU1 and PRU0 GPIOs */ + ioIndex = 0x0a; + status = TCA6424_setOutput( + &gTCA6424_Config, + ioIndex, + TCA6424_OUT_STATE_HIGH); + + /* Configure as output */ + status += TCA6424_config( + &gTCA6424_Config, + ioIndex, + TCA6424_MODE_OUTPUT); + } + TCA6424_close(&gTCA6424_Config); + DebugP_assert(status == SystemP_SUCCESS); +} + +#endif + +void spinlock_c_main(void *args) +{ + Drivers_open(); // check return status + + int status; + status = Board_driversOpen(); + DebugP_assert(SystemP_SUCCESS == status); + + gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0); + + #if defined(PRU_GPIO_VIA_IOEXP) + /* Configure the IO Expander to connect the PRU IOs */ + i2c_io_expander(NULL); + #endif + + status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU0)); + DebugP_assert(status != 0); + + status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU1)); + DebugP_assert(status != 0); + + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_PRU0, PRU0Firmware_0, sizeof(PRU0Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_PRU1, PRU1Firmware_0, sizeof(PRU1Firmware_0)); + DebugP_assert(SystemP_SUCCESS == status); + + while (1) + { + ClockP_usleep(1); + } + + Board_driversClose(); + Drivers_close(); +} diff --git a/academy/spinlock/spinlock_c/readme.md b/academy/spinlock/spinlock_c/readme.md new file mode 100644 index 000000000..479a2f923 --- /dev/null +++ b/academy/spinlock/spinlock_c/readme.md @@ -0,0 +1,82 @@ +# Spinlock (C) + +## Introduction + +This example shows PRU0 and PRU1 sharing a resource through the PRU_ICSSG local +hardware spinlock. Each core drives a debug pin while it holds the lock, so a +scope or logic analyzer shows the two cores taking turns. The same lock, used +from assembly only, is in `spinlock`. + +## Overview + +The PRU reaches the spinlock accelerator over the broadside interface with +`XIN`/`XOUT` (XID `0x90`, lock id `0`-`63` in `R1.b0`, status in `R1.b3`). + +- `firmware/spinlock.asm` has the C-callable `spinlock_acquire()` (one + non-blocking attempt; returns 1 if this core got the lock) and + `spinlock_release()`. +- `firmware/main.c` spins on `spinlock_acquire()`, drives its debug pin high, + holds the lock (1000 cycles on PRU0, 2000 on PRU1), drives the pin low, + releases the lock, then waits `OUTSIDE_TIME` cycles before trying again. + +The R5F core (running FreeRTOS) sets the pinmux for both debug pins and loads +the firmware onto PRU0 and PRU1 of ICSSG0. On the AM64x and AM243x EVMs it also +sets the board's I/O expander over I2C so that the PRU signals reach the +expansion header. + +For how the spinlock accelerator works, see the PRU Academy page +AM243x/AM64x PRU Academy > Hardware information > PRU Broadside Accelerators > Spinlock: + +- AM64x: https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__AXw28VmX5TFHmSGgvY-0qw__AM64-ACADEMY__WI1KRXP__LATEST +- AM243x: https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__Ac5K7fXpNm5GbT1YWvI-8g__AM24X-ACADEMY__ZPSnq-h__LATEST + +## Debug pins + +| Board | PRU0 | PRU1 | +| ------------------ | ----------------------------------------- | ----------------------------------- | +| AM64x / AM243x EVM | GPO4: J2 pin A13 (TMDS64DC01: J2, pin 9) | GPO4: TMDS64DC01 J4, pin 13 | +| AM243x LaunchPad | GPO4: BoosterPack J2.17 | GPO0: BoosterPack J2.11 | + +On the EVMs, the pins are reached through a J2 High Speed Expansion Connector +such as the TMDS64DC01 expansion board, as in `gpio/gpio_toggle`. + +The LaunchPad does not route PRU1 GPO4 to a header, so its PRU1 build passes +`-DDEBUG_PIN_SHIFT=0`. + +## Usage notes + +Measured on LP-AM243 (ICSSG0 PRU0 and PRU1): + +- The lock is not fair. A core that tries to re-acquire straight after releasing wins + every time, because the other core's retry loop is longer than that gap. In a test + version of `main.c` with no gap, PRU1 never got the lock. Do some work outside the lock before trying + again, as `main.c` does with `OUTSIDE_TIME`. +- An acquire by the core that already holds the lock also returns 1. The status means + "this core holds the lock"; it is not a nesting count, so do not take the lock + recursively. +- An acquire is one attempt. Waiting for the lock has no upper bound: it lasts as long + as the other core holds it, so keep critical sections short. + +## Supported Combinations + +Refer to open-pru/academy/readme.md > Supported processors per-project +for the list of processors that support building this project, and information +about porting this project to other processors. + +## Validated HW & SW + +This project was tested on hardware with these software versions: + +| Processor | Hardware | Software | +| --------- | -------- | ------------------------------------------------- | +| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am64x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | + +## Steps to Run the Example + +1. Build the project from the top-level make (`make` in `academy`, or in this + folder), with `DEVICE` set to `am243x` or `am64x` in `imports.mak`. +2. Load and run the R5F image. It sets the pinmux and loads the firmware onto + PRU0 and PRU1. +3. Probe the two debug pins in the table above. Each pin goes high only while + its core holds the lock, and the two pins are never high at the same time. From c69b3b06768c3ce70e1fb224f28e49a1625d7b49 Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Sat, 21 Nov 2026 16:16:31 +0530 Subject: [PATCH 09/11] academy/spinlock: follow best_practices.md assembly conventions Address the Qodo review findings on the spinlock sources: - Use lowercase instruction mnemonics, padded to the operand column (five spaces after three-letter ops, four after four-letter ops). - Name the assembly macros m_spinlock_acquire and m_spinlock_release, and use a ?-suffixed macro-local label for the acquire retry loop. - Mark the C-callable spinlock_acquire/spinlock_release with .asmfunc/.endasmfunc. - Mark the acquire busy-wait as INTENTIONALLY_UNBOUNDED_LOOP. - Document the flag_id range (0-63) at each function, and say how the peak cycle counts were obtained (hand-counted, one cycle per instruction). - Add pseudocode comments to the R5F loader functions. The PRU machine code is unchanged: spinlock.asm and spinlock_example.asm assemble to the same instruction words as before. Signed-off-by: Pratheesh Gangadhar --- .../spinlock/firmware/spinlock_example.asm | 37 +++++++++++-------- academy/spinlock/spinlock/readme.md | 4 +- .../spinlock/spinlock_c/firmware/spinlock.asm | 37 +++++++++++++------ .../spinlock/spinlock_c/mcuplus/spinlock_c.c | 24 ++++++++++++ 4 files changed, 73 insertions(+), 29 deletions(-) diff --git a/academy/spinlock/spinlock/firmware/spinlock_example.asm b/academy/spinlock/spinlock/firmware/spinlock_example.asm index d76fe9b1b..b01749611 100644 --- a/academy/spinlock/spinlock/firmware/spinlock_example.asm +++ b/academy/spinlock/spinlock/firmware/spinlock_example.asm @@ -27,7 +27,7 @@ INT_SPIN_XID .set 144 ; XID 0x90 - local PRU spinlock accelerator SPINLOCK_ID .set 0 ; lock id 0-63, fixed in PRU firmware ;****************************************************************************** -; Macro: M_SPINLOCK_ACQUIRE +; Macro: m_spinlock_acquire ; Acquire the spinlock and busy-wait until successful. ; ; Pseudocode: @@ -36,28 +36,33 @@ SPINLOCK_ID .set 0 ; lock id 0-63, fixed in PRU firmware ; ; Registers modified : R1.b0 (lock id), R1.b3 (status, bit 0 = 1 on exit) ; Peak Cycles : 3 if the lock is free; unbounded while another core holds it -; (2 cycles per retry) +; (2 cycles per retry). Hand-counted at one cycle per +; instruction, assuming the broadside xin completes in one +; cycle; not measured separately on hardware. ;****************************************************************************** -M_SPINLOCK_ACQUIRE .macro - LDI R1.b0, SPINLOCK_ID ; lock id (0-63) -$1: - XIN INT_SPIN_XID, &R1.b3, 1 ; attempt acquire; status in R1.b3 - QBBC $1, R1.b3, 0 ; bit 0 clear -> not acquired, retry +m_spinlock_acquire .macro + ldi r1.b0, SPINLOCK_ID ; lock id (0-63) + ; INTENTIONALLY_UNBOUNDED_LOOP: waits as long as another core holds the + ; lock. A holder that never releases stalls this core here. +acquire_retry?: + xin INT_SPIN_XID, &r1.b3, 1 ; attempt acquire; status in R1.b3 + qbbc acquire_retry?, r1.b3, 0 ; bit 0 clear -> not acquired, retry .endm ;****************************************************************************** -; Macro: M_SPINLOCK_RELEASE -; Release the spinlock. Must follow M_SPINLOCK_ACQUIRE (lock id is still +; Macro: m_spinlock_release +; Release the spinlock. Must follow m_spinlock_acquire (lock id is still ; in R1.b0). ; ; Pseudocode: ; XOUT(XID 0x90) with lock id R1.b0 ; frees the lock ; ; Registers modified : none -; Peak Cycles : 1 (one XOUT) +; Peak Cycles : 1 (one xout), hand-counted; not measured separately on +; hardware. ;****************************************************************************** -M_SPINLOCK_RELEASE .macro - XOUT INT_SPIN_XID, &R1.b3, 1 ; release lock held in R1.b0 +m_spinlock_release .macro + xout INT_SPIN_XID, &r1.b3, 1 ; release lock held in R1.b0 .endm ;******** @@ -69,14 +74,14 @@ main: ; Clear the register space before starting. zero &r0, 120 - M_SPINLOCK_ACQUIRE + m_spinlock_acquire ;-------------------------------------------------------------------------- ; Critical section: we now own SPINLOCK_ID. Access the shared resource here. ;-------------------------------------------------------------------------- - ; M_SPINLOCK_RELEASE uses the lock id in R1.b0. If the critical section - ; overwrites R1.b0, reload it (LDI R1.b0, SPINLOCK_ID) before releasing. - M_SPINLOCK_RELEASE + ; m_spinlock_release uses the lock id in R1.b0. If the critical section + ; overwrites R1.b0, reload it (ldi r1.b0, SPINLOCK_ID) before releasing. + m_spinlock_release halt diff --git a/academy/spinlock/spinlock/readme.md b/academy/spinlock/spinlock/readme.md index 954f20484..c41162a4f 100644 --- a/academy/spinlock/spinlock/readme.md +++ b/academy/spinlock/spinlock/readme.md @@ -14,9 +14,9 @@ acquire returns its status in `R1.b3`. `firmware/spinlock_example.asm` defines two macros: -- `M_SPINLOCK_ACQUIRE` busy-waits until bit 0 of the status is set, which +- `m_spinlock_acquire` busy-waits until bit 0 of the status is set, which means this core now owns the lock. -- `M_SPINLOCK_RELEASE` frees the lock. +- `m_spinlock_release` frees the lock. `main` takes the lock once, leaves room for a critical section, releases the lock and halts. The R5F core (running FreeRTOS) loads the firmware onto PRU0 and diff --git a/academy/spinlock/spinlock_c/firmware/spinlock.asm b/academy/spinlock/spinlock_c/firmware/spinlock.asm index 7de23ef40..e86a99c8f 100644 --- a/academy/spinlock/spinlock_c/firmware/spinlock.asm +++ b/academy/spinlock/spinlock_c/firmware/spinlock.asm @@ -34,6 +34,10 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock ; One non-blocking attempt to acquire spinlock 'flag_id'. ; Returns 1 if the lock was acquired, 0 if it is held by someone else. ; +; Parameters: +; flag_id : lock id, valid range 0-63. Not range-checked here; the +; caller must pass a valid id. +; ; Calling convention (PRU C/C++ compiler): the uint8_t argument arrives in ; R14.b0 and the uint8_t return value is passed back in R14.b0. The return ; address is in r3.w2. @@ -44,16 +48,20 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock ; return R1.b3 & 1 ; 1 = acquired, 0 = held by another ; ; Registers modified : R1 (R1.b0, R1.b3), R14.b0 (return value) -; Peak Cycles : 4 (one acquire attempt; excludes any C-side retry spin) +; Peak Cycles : 4, hand-counted at one cycle per instruction (mov, xin, and, +; jmp), for one acquire attempt; excludes any C-side retry +; spin. Assumes the broadside xin completes in one cycle; not +; measured separately on hardware. ;****************************************************************************** .sect ".text:spinlock_acquire" .clink .global spinlock_acquire -spinlock_acquire: - MOV R1.b0, R14.b0 ; lock id -> R1.b0 (presented to accel) - XIN INT_SPIN_XID, &R1.b3, 1 ; status returned in R1.b3 (bit0=acquired) - AND R14.b0, R1.b3, 1 ; return bit 0 only: 1 = acquired - JMP r3.w2 +spinlock_acquire: .asmfunc + mov r1.b0, r14.b0 ; lock id -> R1.b0 (presented to accel) + xin INT_SPIN_XID, &r1.b3, 1 ; status returned in R1.b3 (bit0=acquired) + and r14.b0, r1.b3, 1 ; return bit 0 only: 1 = acquired + jmp r3.w2 + .endasmfunc ;****************************************************************************** ; void spinlock_release(uint8_t flag_id); @@ -61,6 +69,10 @@ spinlock_acquire: ; Release spinlock 'flag_id'. Only the owner should release, and it must do ; so promptly. ; +; Parameters: +; flag_id : lock id, valid range 0-63, the same id passed to +; spinlock_acquire(). Not range-checked here. +; ; Calling convention (PRU C/C++ compiler): the uint8_t argument arrives in ; R14.b0. The return address is in r3.w2. ; @@ -69,12 +81,15 @@ spinlock_acquire: ; XOUT(XID 0x90) ; free the lock ; ; Registers modified : R1.b0 -; Peak Cycles : 3 +; Peak Cycles : 3, hand-counted at one cycle per instruction (mov, xout, +; jmp). Assumes the broadside xout completes in one cycle; not +; measured separately on hardware. ;****************************************************************************** .sect ".text:spinlock_release" .clink .global spinlock_release -spinlock_release: - MOV R1.b0, R14.b0 ; lock id -> R1.b0 - XOUT INT_SPIN_XID, &R1.b3, 1 ; release the lock - JMP r3.w2 +spinlock_release: .asmfunc + mov r1.b0, r14.b0 ; lock id -> R1.b0 + xout INT_SPIN_XID, &r1.b3, 1 ; release the lock + jmp r3.w2 + .endasmfunc diff --git a/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c b/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c index 12e2193cb..2d7827a55 100644 --- a/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c +++ b/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c @@ -33,6 +33,18 @@ PRUICSS_Handle gPruIcss0Handle; static TCA6424_Config gTCA6424_Config; +/* + * i2c_io_expander: route the PRU GPIOs to the expansion header. + * + * Pseudocode: + * open the TCA6424 + * if open succeeded: + * drive P12 (CPSW_FET_SEL) high, then make it an output + * close the TCA6424 + * assert that every step succeeded + * + * args is unused. + */ static void i2c_io_expander(void *args) { int32_t status = SystemP_SUCCESS; @@ -62,6 +74,18 @@ static void i2c_io_expander(void *args) #endif +/* + * spinlock_c_main: start the spinlock_c firmware on both PRUs. + * + * Pseudocode: + * open the drivers and board drivers, then ICSSG0 + * if PRU_GPIO_VIA_IOEXP: enable the PRU GPIOs through the I/O expander + * clear PRU0 and PRU1 data RAM + * load and start the PRU0 and PRU1 firmware + * idle forever; the PRUs run on their own from here + * + * Any failed step stops at a DebugP_assert. args is unused. + */ void spinlock_c_main(void *args) { Drivers_open(); // check return status From 70e9b28880c5ad73161779fc4a430478876cf1ac Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Mon, 23 Nov 2026 13:02:24 +0530 Subject: [PATCH 10/11] academy/spinlock: check the PRUICSS handle and document preserved registers Address the remaining Qodo review findings on c69b3b06: - Assert that PRUICSS_open() returned a handle before it is used, in both R5F examples. Drivers_open() returns void, so replace the misleading "check return status" comment. - State the preserved registers in the register-usage block of each acquire/release routine and macro. - Say explicitly that the release XOUT uses R1.b3 as its operand while the lock id is taken from R1.b0, so R1.b0 must still hold the id. Signed-off-by: Pratheesh Gangadhar --- academy/spinlock/spinlock/firmware/spinlock_example.asm | 6 +++++- academy/spinlock/spinlock/mcuplus/spinlock.c | 3 ++- academy/spinlock/spinlock_c/firmware/spinlock.asm | 6 +++++- academy/spinlock/spinlock_c/mcuplus/spinlock_c.c | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/academy/spinlock/spinlock/firmware/spinlock_example.asm b/academy/spinlock/spinlock/firmware/spinlock_example.asm index b01749611..ab909aa4e 100644 --- a/academy/spinlock/spinlock/firmware/spinlock_example.asm +++ b/academy/spinlock/spinlock/firmware/spinlock_example.asm @@ -13,7 +13,9 @@ ; - The lock id (0..63) is presented in R1.b0. ; - ACQUIRE: XIN returns acquisition status in R1.b3; bit 0 set means the ; lock is now owned by this core. Busy-wait until bit 0 is set. -; - RELEASE: XOUT with the same lock id in R1.b0 frees the lock. +; - RELEASE: XOUT with the same lock id in R1.b0 frees the lock. The +; XOUT operand is R1.b3, as for the acquire; the lock id is still +; taken from R1.b0, so R1.b0 must hold the id when the XOUT runs. ; ; Steps to build: ; clpru --silicon_version=4 spinlock_example.asm @@ -35,6 +37,7 @@ SPINLOCK_ID .set 0 ; lock id 0-63, fixed in PRU firmware ; do { XIN(XID 0x90) -> R1.b3 } while (R1.b3 bit 0 == 0) ; ; Registers modified : R1.b0 (lock id), R1.b3 (status, bit 0 = 1 on exit) +; Registers preserved: all others ; Peak Cycles : 3 if the lock is free; unbounded while another core holds it ; (2 cycles per retry). Hand-counted at one cycle per ; instruction, assuming the broadside xin completes in one @@ -58,6 +61,7 @@ acquire_retry?: ; XOUT(XID 0x90) with lock id R1.b0 ; frees the lock ; ; Registers modified : none +; Registers preserved: all ; Peak Cycles : 1 (one xout), hand-counted; not measured separately on ; hardware. ;****************************************************************************** diff --git a/academy/spinlock/spinlock/mcuplus/spinlock.c b/academy/spinlock/spinlock/mcuplus/spinlock.c index b457ac6dd..97ff64247 100644 --- a/academy/spinlock/spinlock/mcuplus/spinlock.c +++ b/academy/spinlock/spinlock/mcuplus/spinlock.c @@ -23,13 +23,14 @@ PRUICSS_Handle gPruIcss0Handle; void spinlock_main(void *args) { - Drivers_open(); // check return status + Drivers_open(); /* returns void, so there is no status to check */ int status; status = Board_driversOpen(); DebugP_assert(SystemP_SUCCESS == status); gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0); + DebugP_assert(gPruIcss0Handle != NULL); status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU0)); DebugP_assert(status != 0); diff --git a/academy/spinlock/spinlock_c/firmware/spinlock.asm b/academy/spinlock/spinlock_c/firmware/spinlock.asm index e86a99c8f..5c4913831 100644 --- a/academy/spinlock/spinlock_c/firmware/spinlock.asm +++ b/academy/spinlock/spinlock_c/firmware/spinlock.asm @@ -19,7 +19,9 @@ ; * bit0 == 0 -> the lock is held by someone else; retry ; The acquire is non-blocking - one XIN is one attempt. The caller ; (here, C) spins until it gets a 1. -; - RELEASE: an XOUT with the same lock id in R1.b0 frees the lock. +; - RELEASE: an XOUT with the same lock id in R1.b0 frees the lock. The +; XOUT operand is R1.b3, as for the acquire; the lock id is still +; taken from R1.b0, so R1.b0 must hold the id when the XOUT runs. ;****************************************************************************** ; Required for building .out with an assembly file @@ -48,6 +50,7 @@ INT_SPIN_XID .set 0x90 ; broadside XID for the local PRU spinlock ; return R1.b3 & 1 ; 1 = acquired, 0 = held by another ; ; Registers modified : R1 (R1.b0, R1.b3), R14.b0 (return value) +; Registers preserved: all others ; Peak Cycles : 4, hand-counted at one cycle per instruction (mov, xin, and, ; jmp), for one acquire attempt; excludes any C-side retry ; spin. Assumes the broadside xin completes in one cycle; not @@ -81,6 +84,7 @@ spinlock_acquire: .asmfunc ; XOUT(XID 0x90) ; free the lock ; ; Registers modified : R1.b0 +; Registers preserved: all others ; Peak Cycles : 3, hand-counted at one cycle per instruction (mov, xout, ; jmp). Assumes the broadside xout completes in one cycle; not ; measured separately on hardware. diff --git a/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c b/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c index 2d7827a55..c7606ae5c 100644 --- a/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c +++ b/academy/spinlock/spinlock_c/mcuplus/spinlock_c.c @@ -88,13 +88,14 @@ static void i2c_io_expander(void *args) */ void spinlock_c_main(void *args) { - Drivers_open(); // check return status + Drivers_open(); /* returns void, so there is no status to check */ int status; status = Board_driversOpen(); DebugP_assert(SystemP_SUCCESS == status); gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0); + DebugP_assert(gPruIcss0Handle != NULL); #if defined(PRU_GPIO_VIA_IOEXP) /* Configure the IO Expander to connect the PRU IOs */ From 6db3234cd8f9c24e701310cd79682e6fa331ac1a Mon Sep 17 00:00:00 2001 From: Pratheesh Gangadhar Date: Sat, 28 Nov 2026 14:51:55 +0530 Subject: [PATCH 11/11] academy/spinlock: fill the Validated HW & SW rows Both projects were tested on an LP-AM243 with MCU+ SDK 12.01.00.33 and OpenPRU v2026.02.00. The am64x row is removed because no AM64x hardware was tested. --- academy/spinlock/spinlock/readme.md | 3 +-- academy/spinlock/spinlock_c/readme.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/academy/spinlock/spinlock/readme.md b/academy/spinlock/spinlock/readme.md index c41162a4f..c5ae256a2 100644 --- a/academy/spinlock/spinlock/readme.md +++ b/academy/spinlock/spinlock/readme.md @@ -40,8 +40,7 @@ This project was tested on hardware with these software versions: | Processor | Hardware | Software | | --------- | -------- | ------------------------------------------------- | -| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | -| am64x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am243x | LP-AM243 | MCU PLUS SDK 12.01.00.33, OpenPRU v2026.02.00 | ## Steps to Run the Example diff --git a/academy/spinlock/spinlock_c/readme.md b/academy/spinlock/spinlock_c/readme.md index 479a2f923..d74ba137d 100644 --- a/academy/spinlock/spinlock_c/readme.md +++ b/academy/spinlock/spinlock_c/readme.md @@ -69,8 +69,7 @@ This project was tested on hardware with these software versions: | Processor | Hardware | Software | | --------- | -------- | ------------------------------------------------- | -| am243x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | -| am64x | FIXME | MCU PLUS SDK FIXME, OpenPRU FIXME | +| am243x | LP-AM243 | MCU PLUS SDK 12.01.00.33, OpenPRU v2026.02.00 | ## Steps to Run the Example