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

OSPI-flash bring-up + write-window pre-erase for the writable-OSPI self-loop. More...

#include <stdint.h>
#include "ra8_board_ek_ra8d2.h"
#include "ra8_err.h"
#include "ra8_xspi.h"
#include "usb_selftest_ospi_rw_steps.h"
Include dependency graph for usb_selftest_ospi_rw_device.c:

Go to the source code of this file.

Functions

ra8_err_t ospirw_ospi_provision (void)
 Bring the OSPI flash up and erase the writable window.

Variables

static volatile uint32_t s_dbg_ospi_prov = (uint32_t)k_ospirw_no_mismatch
 OSPI bring-up + window pre-erase result (0 = ready, else error).
static volatile uint32_t s_dbg_ospi_id
 OSPI JEDEC id read back at boot (sanity probe).

Detailed Description

OSPI-flash bring-up + write-window pre-erase for the writable-OSPI self-loop.

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

The OSPI provisioning step of the usb_selftest_ospi_rw application, split out of main.c so each translation unit stays below the 1000-line file-size cap. The device-side ThreadX worker (in main.c) calls ospirw_ospi_provision once, before USB attach, to bring the onboard IS25LX512M up in 1S-1S-1S mode and erase the 32 KiB scratch window that the host's WRITE(10) data-OUT phase later programs.

The two J-Link debug probes that record this step's outcome (s_dbg_ospi_prov / s_dbg_ospi_id) live here, beside their only writer.

Author
Brighton Sikarskie
Date
2026-06-13
Since
0.1.0

Definition in file usb_selftest_ospi_rw_device.c.

Function Documentation

◆ ospirw_ospi_provision()

ra8_err_t ospirw_ospi_provision ( void )
nodiscard

Bring the OSPI flash up and erase the writable window.

Mirrors the read-only OSPI self-loop's bring-up: U15 expander courtesy write, ra8_board_xspi_pins_init (OCTA pins + RESET pulse), ra8_xspi_init 1S-1S-1S, JEDEC-id readback, then a one-shot erase of the k_ospirw_sectors window at k_ospirw_offset so the per-write path is fast program-only. The host owns the data. The body lives in usb_selftest_ospi_rw_device.c; ospirw_device_worker in main.c calls it once before USB attach.

Returns
First failing step's error, or k_ra8_ok.
Return values
k_ra8_okOSPI is up and the write window is erased.
(other)A pins / init / erase step failed.
Precondition
CGC is initialized (main ran ra8_cgc_init).
Single caller (the device worker, before USB attach).
Postcondition
The OSPI bring-up / id J-Link probes reflect the outcome.
The 32 KiB OSPI window is erased (0xFF) on success.
Note
Blocking; runs once at boot before USB attach.
Since
0.1.0

Definition at line 45 of file usb_selftest_ospi_rw_device.c.

References k_ospirw_block_size, k_ospirw_erase_sector, k_ospirw_instance, k_ospirw_offset, k_ospirw_sectors, k_ra8_ok, k_ra8_xspi_lio_1s1s1s, ra8_board_io_expander_set_octospi_active(), ra8_board_xspi_pins_init(), ra8_xspi_flash_erase_sector(), ra8_xspi_flash_read_id(), ra8_xspi_init(), s_dbg_ospi_id, and s_dbg_ospi_prov.

Referenced by ospirw_device_worker().

Variable Documentation

◆ s_dbg_ospi_id

volatile uint32_t s_dbg_ospi_id
static

OSPI JEDEC id read back at boot (sanity probe).

Definition at line 43 of file usb_selftest_ospi_rw_device.c.

◆ s_dbg_ospi_prov

volatile uint32_t s_dbg_ospi_prov = (uint32_t)k_ospirw_no_mismatch
static

OSPI bring-up + window pre-erase result (0 = ready, else error).

Definition at line 41 of file usb_selftest_ospi_rw_device.c.