ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
tz_secure_only_usb_hs_steps.c File Reference

examples/ek_ra8d2/hw_validated/manual/tz_secure_only_usb_hs/src/tz_secure_only_usb_hs_steps.c More...

#include "tz_secure_only_usb_hs_steps.h"
#include <stdint.h>
#include <string.h>
#include "ra8_board_ek_ra8d2.h"
#include "ra8_err.h"
#include "ra8_isr.h"
#include "ra8_usb.h"
#include "ra8_usb_regs.h"
#include "tx_api.h"
#include "ux_api.h"
#include "ux_dcd_ra8_usb.h"
#include "ux_device_class_cdc_acm.h"
#include "ux_device_stack.h"
#include "ux_system.h"
Include dependency graph for tz_secure_only_usb_hs_steps.c:

Go to the source code of this file.

Data Structures

struct  demo_diag_t
 Demo-loop counters; read via JLink to localise stalls. More...

Enumerations

enum  usbhs_sec_reg_addr_t : uintptr_t {
  k_usbhs_psarb_addr = 0x40204004UL ,
  k_usbhs_pparb_addr = 0x4020401CUL
}
 USBHS security/privilege attribution register addresses. More...
enum  demo_config_t : uint32_t {
  k_demo_thread_stack = 8192U ,
  k_demo_usbx_pool_bytes = 16384U ,
  k_demo_echo_buf_bytes = 512U ,
  k_demo_idle_ticks = 1U
}
enum  boot_probe_step_t : uint32_t {
  k_boot_probe_thread_entry = 1U ,
  k_boot_probe_pre_sys_init = 2U ,
  k_boot_probe_pre_dev_stack_init = 3U ,
  k_boot_probe_pre_class_register = 4U ,
  k_boot_probe_pre_board_usbhs_init = 5U ,
  k_boot_probe_post_board_usbhs_init = 7U ,
  k_boot_probe_pre_ux_dcd_init = 8U ,
  k_boot_probe_post_ux_dcd_init = 9U ,
  k_boot_probe_pre_dev_attach = 10U ,
  k_boot_probe_post_dev_attach = 11U ,
  k_boot_probe_enter_echo_loop = 12U
}
 Bisect-probe step values for s_boot_probe. More...

Functions

static VOID intenb0_watchdog_entry (ULONG arg)
 Watchdog entry: re-asserts USBHS INTENB0 = 0xFF00 if cleared.
static VOID demo_cdc_activate (VOID *cdc_instance)
 CDC-ACM activate callback.
static VOID demo_cdc_deactivate (VOID *cdc_instance)
 CDC-ACM deactivate callback.
static bool demo_worker_usbx_init (void)
 Bring up USBX system + device stack with HS+FS frameworks.
static bool demo_worker_register_cdc (void)
 Register the CDC-ACM class against configuration 1, interface 0.
static bool demo_worker_start_dcd (void)
 Plug the DCD bridge into the device stack and attach the bus.
static void demo_worker_spawn_intenb0_watchdog (void)
 Spawn the INTENB0 re-arm watchdog thread.
static void demo_worker_capture_echo_probes (void)
 Capture bisect probes ONCE on entry to the echo loop.
static void demo_worker_echo_loop (void)
 Run the CDC-ACM echo loop forever.
static VOID demo_worker (ULONG arg)
 Worker thread entry.
VOID tx_application_define (VOID *first_unused_memory)

Variables

static TX_THREAD s_demo_thread
 ThreadX TCB for the USBX worker thread.
static UCHAR s_demo_stack [k_demo_thread_stack]
 Stack backing storage for s_demo_thread.
static TX_THREAD s_intenb0_watchdog_thread
 ThreadX TCB for the INTENB0 re-arm watchdog.
static UCHAR s_intenb0_watchdog_stack [1024U]
 Stack backing storage for the INTENB0 watchdog thread.
volatile uint32_t s_intenb0_rearm_count = 0U
 Number of times the watchdog has re-asserted INTENB0 = 0xFF00.
volatile uint32_t s_intenb0_watchdog_started = 0U
 Set to 1 once the watchdog thread has begun polling.
volatile uint32_t s_host_kick_done = 0U
 Set to 1 once the host-mode PHY analog kick has been applied.
static UCHAR s_usbx_pool [k_demo_usbx_pool_bytes]
 USBX memory pool (USBX uses tx_byte_pool internally).
static UX_SLAVE_CLASS_CDC_ACM *volatile s_cdc_acm = UX_NULL
 Active CDC-ACM class instance, captured by activate callback.
volatile uint32_t s_cdc_activate_count = 0U
volatile uint32_t s_cdc_activate_post_put = 0U
volatile uint32_t s_cdc_deactivate_count = 0U
volatile uint32_t s_pendsv_observed_run_count = 0U
volatile demo_diag_t s_demo_diag = {}
static volatile uint32_t s_boot_probe = 0U
 Temporary bisect probe for USBHS bring-up HardFault.
volatile uint16_t s_syscfg_in_echo_loop = 0U
 SYSCFG snapshot taken on the FIRST iteration of the echo loop.
volatile uint16_t s_lpsts_in_echo_loop = 0U
 LPSTS snapshot on first echo-loop iteration.
volatile uint32_t s_psar_state = 0U
 Snapshot of R_PSCU->PSARB on entry to the echo loop.
volatile uint32_t s_ppar_state = 0U
 Snapshot of R_PSCU->PPARB on entry to the echo loop.
static TX_SEMAPHORE s_cdc_active_sem
 Posted by demo_cdc_activate; demo thread blocks on it instead of polling s_cdc_acm with tx_thread_sleep.

Detailed Description

examples/ek_ra8d2/hw_validated/manual/tz_secure_only_usb_hs/src/tz_secure_only_usb_hs_steps.c

ThreadX + USBX worker machinery for the secure-only USB-HS echo app.

Tag
[Ring 6 / APP] {World: S}

Sibling translation unit for examples/ek_ra8d2/hw_validated/manual/tz_secure_only_usb_hs/src/main.c. Holds the CDC-ACM activate/deactivate callbacks, the USBX bring-up step routines, the INTENB0 re-arm watchdog and the ThreadX tx_application_define kernel hook. These were moved here verbatim from main.c (a pure, behaviour-preserving code move) so that every translation unit stays under the 1000-line check_file_size.py cap. The four USBX descriptor byte arrays consumed by demo_worker_usbx_init live in the companion tz_secure_only_usb_hs_descriptors.c.

Author
Brighton Sikarskie
Date
2026-05-03
Since
0.1.0

Definition in file tz_secure_only_usb_hs_steps.c.

Enumeration Type Documentation

◆ boot_probe_step_t

enum boot_probe_step_t : uint32_t

Bisect-probe step values for s_boot_probe.

Enumerator
k_boot_probe_thread_entry 

worker entry.

k_boot_probe_pre_sys_init 

before _ux_system_initialize.

k_boot_probe_pre_dev_stack_init 

before _ux_device_stack_init.

k_boot_probe_pre_class_register 

before _ux_device_stack_class_register.

k_boot_probe_pre_board_usbhs_init 

before ra8_board_usbhs_device_init.

k_boot_probe_post_board_usbhs_init 

after ra8_board_usbhs_device_init.

k_boot_probe_pre_ux_dcd_init 

before ux_dcd_ra8_usb_initialize.

k_boot_probe_post_ux_dcd_init 

after ux_dcd_ra8_usb_initialize.

k_boot_probe_pre_dev_attach 

before ra8_usb_device_attach.

k_boot_probe_post_dev_attach 

after ra8_usb_device_attach.

k_boot_probe_enter_echo_loop 

entering echo while(1).

Definition at line 288 of file tz_secure_only_usb_hs_steps.c.

◆ demo_config_t

enum demo_config_t : uint32_t
Enumerator
k_demo_thread_stack 

Worker thread stack (bytes).

k_demo_usbx_pool_bytes 

USBX memory pool (bytes).

k_demo_echo_buf_bytes 

HS bulk MPS.

k_demo_idle_ticks 

Idle back-off when no class active.

Definition at line 44 of file tz_secure_only_usb_hs_steps.c.

◆ usbhs_sec_reg_addr_t

enum usbhs_sec_reg_addr_t : uintptr_t

USBHS security/privilege attribution register addresses.

Enumerator
k_usbhs_psarb_addr 

Peripheral Security Attribution B.

k_usbhs_pparb_addr 

Peripheral Privilege Attribution B.

Definition at line 39 of file tz_secure_only_usb_hs_steps.c.

Function Documentation

◆ demo_cdc_activate()

VOID demo_cdc_activate ( VOID * cdc_instance)
static

CDC-ACM activate callback.

Captures the live class instance.

Parameters
[in]cdc_instancePointer to UX_SLAVE_CLASS_CDC_ACM.
Precondition
Called from the USBX class thread.
Postcondition
s_cdc_acm points at the live CDC-ACM class.
Note
USBX guarantees serialization with the deactivate callback.
Since
0.1.0

Definition at line 330 of file tz_secure_only_usb_hs_steps.c.

References s_cdc_acm, s_cdc_activate_count, s_cdc_activate_post_put, s_cdc_active_sem, and ux_dcd_ra8_usb_auto_echo_enable().

◆ demo_cdc_deactivate()

VOID demo_cdc_deactivate ( VOID * cdc_instance)
static

CDC-ACM deactivate callback.

Drops the live class pointer.

Parameters
[in]cdc_instanceUnused.
Precondition
Called from the USBX class thread.
Postcondition
s_cdc_acm is UX_NULL.
Note
USBX guarantees serialization with the activate callback.
Since
0.1.0

Definition at line 363 of file tz_secure_only_usb_hs_steps.c.

References s_cdc_acm, and s_cdc_deactivate_count.

◆ demo_worker()

VOID demo_worker ( ULONG arg)
static

Worker thread entry.

Brings USBX + CDC up, then echoes forever.

Parameters
[in]argUnused (ThreadX entry signature).
Precondition
tx_application_define started this thread auto-start.
Postcondition
Thread loops forever; never returns.
Note
Single-instance worker; not designed for re-entry.
Since
0.1.0

Definition at line 628 of file tz_secure_only_usb_hs_steps.c.

References demo_worker_capture_echo_probes(), demo_worker_echo_loop(), demo_worker_register_cdc(), demo_worker_spawn_intenb0_watchdog(), demo_worker_start_dcd(), demo_worker_usbx_init(), k_boot_probe_enter_echo_loop, k_boot_probe_thread_entry, and s_boot_probe.

◆ demo_worker_capture_echo_probes()

void demo_worker_capture_echo_probes ( void )
static

Capture bisect probes ONCE on entry to the echo loop.

Reads SYSCFG / LPSTS / PSARB / PPARB into JLink-visible globals so post-mortem analysis can confirm the controller state at the moment the echo loop starts spinning.

HUM Ch 37.2.1 SYSCFG p 2060, HUM Ch 37.2.43 LPSTS p 2111, HUM Ch 51.8.1 PSARB p 3284, HUM Ch 51.8.6 PPARB p 3292.

Precondition
USBHS MSTP ungated; SYSCFG.USBE=1.
Postcondition
Four s_*_in_echo_loop / s_*_state globals are set.
Note
Not thread-safe; called only from demo_worker.
Since
0.1.0

Definition at line 547 of file tz_secure_only_usb_hs_steps.c.

References k_usbhs_pparb_addr, k_usbhs_psarb_addr, ra8_usb_hs(), ra8_usbhs_lpsts(), s_lpsts_in_echo_loop, s_ppar_state, s_psar_state, s_syscfg_in_echo_loop, and r_usb_regs_t::SYSCFG.

Referenced by demo_worker().

◆ demo_worker_echo_loop()

void demo_worker_echo_loop ( void )
static

Run the CDC-ACM echo loop forever.

Read up to k_demo_echo_buf_bytes bytes from the host, echo them straight back, and toggle LED1 once per byte echoed. s_demo_diag counters track each branch for JLink-side instrumentation.

Precondition
demo_worker_start_dcd returned true.
Postcondition
Never returns.
Note
Single-instance; not designed for re-entry.
Since
0.1.0

Definition at line 571 of file tz_secure_only_usb_hs_steps.c.

References k_demo_echo_buf_bytes, k_demo_idle_ticks, k_ra8_board_led1, ra8_board_led_toggle(), s_cdc_acm, s_demo_diag, and tx_thread_sleep.

Referenced by demo_worker().

◆ demo_worker_register_cdc()

bool demo_worker_register_cdc ( void )
static

Register the CDC-ACM class against configuration 1, interface 0.

Wires the activate/deactivate callbacks so s_cdc_acm tracks the live class instance. Must be called after the device stack has been initialized and before ux_dcd_ra8_usb_initialize.

Returns
true on success, false on USBX failure.
Return values
trueCDC-ACM class registered.
false_ux_device_stack_class_register failed.
Precondition
demo_worker_usbx_init returned true.
Postcondition
CDC-ACM class is bound to configuration 1, interface 0.
Note
Not thread-safe; called only from demo_worker.
Since
0.1.0

Definition at line 431 of file tz_secure_only_usb_hs_steps.c.

References demo_cdc_activate(), demo_cdc_deactivate(), k_boot_probe_pre_class_register, and s_boot_probe.

Referenced by demo_worker().

◆ demo_worker_spawn_intenb0_watchdog()

void demo_worker_spawn_intenb0_watchdog ( void )
static

Spawn the INTENB0 re-arm watchdog thread.

USB Bus Reset on the RA8D2 HS controller auto-clears INTENB0 to 0 (verified live via JLink: a manual write of INTENB0 = 0xFF00 immediately resumed ISR firing after a host bus reset). The driver's busreset_rearm is supposed to do this from the DVST(=Default) ISR path, but the ISR cannot run while INTENB0 is zero. This polled watchdog breaks the chicken-and-egg by re-writing INTENB0 outside the ISR.

Precondition
demo_worker_start_dcd returned true.
Postcondition
A ThreadX thread named usbhs_intenb0_wdog is auto-started.
Note
Not thread-safe; called only from demo_worker.
Since
0.1.0

Definition at line 514 of file tz_secure_only_usb_hs_steps.c.

References intenb0_watchdog_entry(), s_intenb0_watchdog_stack, s_intenb0_watchdog_thread, s_thread_name, TX_AUTO_START, TX_NO_TIME_SLICE, and tx_thread_create.

Referenced by demo_worker().

◆ demo_worker_start_dcd()

bool demo_worker_start_dcd ( void )
static

Plug the DCD bridge into the device stack and attach the bus.

USBHS controller bring-up is performed exactly once, inside ux_dcd_ra8_usb_initialize (which itself calls ra8_usb_device_init). The PHY clock was armed in main() via ra8_cgc_usbhs_pll_enable; PD07 role-select is owned by demo_pins_init. MSTPB12 ungate happens inside ra8_usb_device_init via ra8_mstp_enable.

Previously this site called ra8_board_usbhs_device_init() which also invoked ra8_usb_device_init(hs) and ux_dcd_ra8_usb_initialize then invoked it AGAIN. The duplicate PHY bring-up cleared INTENB0 and left the controller in a state where chirp completed but the host never issued SETUP – exactly the failure signature observed on J7.

The "host-mode kick" / SYSCFG reset block previously sitting between the two probes was compile-time disabled (#if 0) and has been removed; s_host_kick_done is left at 0 so JLink scripts that read it still link.

Returns
true on success, false on any HAL failure.
Return values
trueDCD initialized and bus attached at HS.
falseux_dcd_ra8_usb_initialize or ra8_usb_device_attach failed.
Precondition
demo_worker_register_cdc returned true.
Postcondition
Bus is attached at HS speed; controller is enumerating.
Note
Not thread-safe; called only from demo_worker.
Since
0.1.0

Definition at line 479 of file tz_secure_only_usb_hs_steps.c.

References k_boot_probe_post_board_usbhs_init, k_boot_probe_post_dev_attach, k_boot_probe_post_ux_dcd_init, k_boot_probe_pre_dev_attach, k_boot_probe_pre_ux_dcd_init, k_ra8_ok, k_ra8_usb_speed_hs, ra8_usb_device_attach(), s_boot_probe, s_host_kick_done, and ux_dcd_ra8_usb_initialize().

Referenced by demo_worker().

◆ demo_worker_usbx_init()

bool demo_worker_usbx_init ( void )
static

Bring up USBX system + device stack with HS+FS frameworks.

Initializes the USBX memory pool, then registers both HS and FS device frameworks. With the PHY CLKSEL=24 fix landed (see ra8_usb.c::internal_usbhs_phy_bringup), the HS chirp completes correctly and the host expects HS-conformant descriptors with 512-byte bulk MPS. USBX picks the framework matching the negotiated bus speed (RHST=011 -> HS framework, RHST=010 -> FS framework).

Returns
true on success, false on any USBX failure.
Return values
trueBoth system and device stacks initialized.
false_ux_system_initialize or _ux_device_stack_initialize failed.
Precondition
USBX pool storage exists and is sized k_demo_usbx_pool_bytes.
Postcondition
On success, the USBX stack is ready for class registration.
Note
Not thread-safe; called only from demo_worker.
Since
0.1.0

Definition at line 395 of file tz_secure_only_usb_hs_steps.c.

References k_boot_probe_pre_dev_stack_init, k_boot_probe_pre_sys_init, k_demo_usbx_pool_bytes, s_boot_probe, s_tz_secure_only_usb_hs_device_framework_fs, s_tz_secure_only_usb_hs_device_framework_hs, s_tz_secure_only_usb_hs_language_id_framework, s_tz_secure_only_usb_hs_string_framework, and s_usbx_pool.

Referenced by demo_worker().

◆ intenb0_watchdog_entry()

VOID intenb0_watchdog_entry ( ULONG arg)
static

Watchdog entry: re-asserts USBHS INTENB0 = 0xFF00 if cleared.

Parameters
[in]argUnused (ThreadX entry signature).
Precondition
USBHS MSTP ungated and SYSCFG.USBE=1 (otherwise reads return 0).
Postcondition
Loops forever; never returns.
Note
Single-instance; reads/writes a single 16-bit MMIO register which is naturally atomic on Cortex-M.
Since
0.1.0

Definition at line 665 of file tz_secure_only_usb_hs_steps.c.

References r_usb_regs_t::INTENB0, k_ra8_int0_full_mask, ra8_usb_hs(), s_intenb0_rearm_count, s_intenb0_watchdog_started, and tx_thread_sleep.

Referenced by demo_worker_spawn_intenb0_watchdog().

◆ tx_application_define()

VOID tx_application_define ( VOID * first_unused_memory)

Variable Documentation

◆ s_boot_probe

volatile uint32_t s_boot_probe = 0U
static

Temporary bisect probe for USBHS bring-up HardFault.

Stepped through every major call in demo_worker so a JLink session can read the last value reached and localise which call faulted. Values: 1=thread entry, 2=pre _ux_system_initialize, 3=pre _ux_device_stack_initialize, 4=pre _ux_device_stack_class_register, 5=pre ra8_board_usbhs_device_init, 7=post that, 8=pre ux_dcd_ra8_usb_initialize, 9=post, 10=pre ra8_usb_device_attach, 11=post, 12=entering echo while(1). Remove once the offending call is identified.

Note
File-scope, single-writer (worker thread).
Since
0.1.0

Definition at line 219 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_worker(), demo_worker_register_cdc(), demo_worker_start_dcd(), and demo_worker_usbx_init().

◆ s_cdc_acm

UX_SLAVE_CLASS_CDC_ACM* volatile s_cdc_acm = UX_NULL
static

Active CDC-ACM class instance, captured by activate callback.

Note
Read by worker; written by USBX class thread (ISR context). Must be volatile so the worker's tight polling loop re-reads memory each iteration and sees the ISR-side write.
Since
0.1.0

Definition at line 171 of file tz_secure_only_usb_hs_steps.c.

◆ s_cdc_activate_count

volatile uint32_t s_cdc_activate_count = 0U

Definition at line 174 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_cdc_activate().

◆ s_cdc_activate_post_put

volatile uint32_t s_cdc_activate_post_put = 0U

Definition at line 175 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_cdc_activate().

◆ s_cdc_active_sem

TX_SEMAPHORE s_cdc_active_sem
static

Posted by demo_cdc_activate; demo thread blocks on it instead of polling s_cdc_acm with tx_thread_sleep.

Note
Single-producer (USBX class thread), single-consumer (demo).
Since
0.1.0

Definition at line 309 of file tz_secure_only_usb_hs_steps.c.

◆ s_cdc_deactivate_count

volatile uint32_t s_cdc_deactivate_count = 0U

Definition at line 176 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_cdc_deactivate().

◆ s_demo_diag

volatile demo_diag_t s_demo_diag = {}

Definition at line 200 of file tz_secure_only_usb_hs_steps.c.

◆ s_demo_stack

UCHAR s_demo_stack[k_demo_thread_stack]
static

Stack backing storage for s_demo_thread.

Since
0.1.0

Definition at line 82 of file tz_secure_only_usb_hs_steps.c.

◆ s_demo_thread

TX_THREAD s_demo_thread
static

ThreadX TCB for the USBX worker thread.

Note
Single-writer (worker only).
Since
0.1.0

Definition at line 75 of file tz_secure_only_usb_hs_steps.c.

◆ s_host_kick_done

volatile uint32_t s_host_kick_done = 0U

Set to 1 once the host-mode PHY analog kick has been applied.

Some Renesas USB-OTG PHYs latch into a stuck analog state after power-on if the controller never enters host mode. The mitigation is to briefly assert SYSCFG.DCFM + SYSCFG.DRPD (host + bus pull-down), wait, then clear them again before completing the device-mode bring-up. s_host_kick_done is incremented after the kick sequence completes so a JLink session can confirm the path was taken: mem32 &s_host_kick_done should read 1 after boot.

Note
Single-writer (worker thread); read-only elsewhere.
Since
0.1.0

Definition at line 148 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_worker_start_dcd().

◆ s_intenb0_rearm_count

volatile uint32_t s_intenb0_rearm_count = 0U

Number of times the watchdog has re-asserted INTENB0 = 0xFF00.

Increments once per polling tick where INTENB0 != 0xFF00 was observed. A non-zero value here proves the watchdog is firing and that the IP is clearing INTENB0 (typically across a USB Bus Reset). Read via JLink: mem32 &s_intenb0_rearm_count.

Note
Single-writer (watchdog thread); read-only elsewhere.
Since
0.1.0

Definition at line 122 of file tz_secure_only_usb_hs_steps.c.

Referenced by intenb0_watchdog_entry().

◆ s_intenb0_watchdog_stack

UCHAR s_intenb0_watchdog_stack[1024U]
static

Stack backing storage for the INTENB0 watchdog thread.

Since
0.1.0

Definition at line 107 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_worker_spawn_intenb0_watchdog().

◆ s_intenb0_watchdog_started

volatile uint32_t s_intenb0_watchdog_started = 0U

Set to 1 once the watchdog thread has begun polling.

Note
Single-writer (watchdog thread).
Since
0.1.0

Definition at line 130 of file tz_secure_only_usb_hs_steps.c.

Referenced by intenb0_watchdog_entry().

◆ s_intenb0_watchdog_thread

TX_THREAD s_intenb0_watchdog_thread
static

ThreadX TCB for the INTENB0 re-arm watchdog.

USB Bus Reset on the HS controller auto-clears INTENB0 to 0. The driver's busreset_rearm is supposed to re-set INTENB0 = 0xFF00 from the ISR's DVST(=Default) handler, but the ISR cannot fire while INTENB0 is zero (chicken-and-egg). This dedicated low-priority thread polls INTENB0 every ThreadX tick and re-asserts the device- mode interrupt mask whenever the IP has cleared it. With the mask back in place, the next bus event raises USBI0 and the ISR fires.

Note
Single-writer (this thread); read via JLink for diagnostics.
Since
0.1.0

Definition at line 100 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_worker_spawn_intenb0_watchdog().

◆ s_lpsts_in_echo_loop

volatile uint16_t s_lpsts_in_echo_loop = 0U

LPSTS snapshot on first echo-loop iteration.

Companion to s_syscfg_in_echo_loop; HUM Ch 37.2.43 LPSTS p 2111. Expected SUSPENDM=1 (0x4000).

Since
0.1.0

Definition at line 244 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_worker_capture_echo_probes().

◆ s_pendsv_observed_run_count

volatile uint32_t s_pendsv_observed_run_count = 0U

Definition at line 177 of file tz_secure_only_usb_hs_steps.c.

◆ s_ppar_state

volatile uint32_t s_ppar_state = 0U

Snapshot of R_PSCU->PPARB on entry to the echo loop.

PSCU base = 0x40204000, PPARB offset 0x1C (HUM Ch 51.8.6 "PPARB : Peripheral Privilege Attribution Register B" p 3292). Bit 12 (PPARB12) is the USBHS Type1 privileged/unprivileged bit: 0 = Privileged-only access, 1 = Unprivileged access permitted. Reset value = 0xFFFFFFFF – USBHS defaults to "unprivileged access permitted", which means both privileged-secure and unprivileged- secure register accesses are allowed by the TrustZone Filter.

Note
Single-writer (worker thread); read via JLink only.
Since
0.1.0

Definition at line 282 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_worker_capture_echo_probes().

◆ s_psar_state

volatile uint32_t s_psar_state = 0U

Snapshot of R_PSCU->PSARB on entry to the echo loop.

PSCU base = 0x40204000, PSARB offset 0x04 (HUM Ch 51.8.1 "PSARB : Peripheral Security Attribution Register B" p 3284). Bit 12 (PSARB12) is the USBHS Type1 secure/non-secure bit; bit 11 (PSARB11) is the USBFS0 equivalent. 0 = Secure, 1 = Non-secure. Reset value = 0x00000000 – both modules default to Secure, which is what this no-op-TrustZone build wants. We capture it once at the echo-loop entry so a JLink session can verify nothing else (e.g. ThreadX init or the USBX class layer) flipped PSARB12 to NS out from under us.

Note
Single-writer (worker thread); read via JLink only.
Since
0.1.0

Definition at line 264 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_worker_capture_echo_probes().

◆ s_syscfg_in_echo_loop

volatile uint16_t s_syscfg_in_echo_loop = 0U

SYSCFG snapshot taken on the FIRST iteration of the echo loop.

Bisect probe (HUM Ch 37.2.1 SYSCFG p 2060) for the "USBE clears between phy bring-up and echo loop" regression. Captured exactly once – before the loop body has had a chance to do any USBX work – so a JLink session can compare it against ::s_syscfg_after_attach to localise whether anything between ra8_usb_device_attach and the echo-loop entry clears USBE.

Note
File-scope, single-writer (worker thread).
Since
0.1.0

Definition at line 235 of file tz_secure_only_usb_hs_steps.c.

Referenced by demo_worker_capture_echo_probes().

◆ s_usbx_pool

UCHAR s_usbx_pool[k_demo_usbx_pool_bytes]
static

USBX memory pool (USBX uses tx_byte_pool internally).

Since
0.1.0

Definition at line 155 of file tz_secure_only_usb_hs_steps.c.