71typedef enum : uint32_t {
81typedef enum : uint32_t {
116typedef enum : uintptr_t {
144 uintptr_t addr = (uintptr_t)flash_address;
146 return (uint32_t)(addr - base);
180 if ((flash_address == LX_NULL) || (destination == LX_NULL) || (words == 0U)) {
181 return (
UINT)LX_ERROR;
188 return (
UINT)LX_ERROR;
190 return (
UINT)LX_SUCCESS;
225 if ((flash_address == LX_NULL) || (source == LX_NULL) || (words == 0U)) {
226 return (
UINT)LX_ERROR;
233 return (
UINT)LX_ERROR;
235 return (
UINT)LX_SUCCESS;
269 LX_PARAMETER_NOT_USED(erase_count);
271 return (
UINT)LX_ERROR;
276 return (
UINT)LX_ERROR;
278 return (
UINT)LX_SUCCESS;
311 return (
UINT)LX_ERROR;
315 while (remain_words > 0U) {
316 uint32_t chunk_words = remain_words;
317 if (chunk_words > (uint32_t)LX_NOR_SECTOR_SIZE) {
318 chunk_words = (uint32_t)LX_NOR_SECTOR_SIZE;
326 return (
UINT)LX_ERROR;
328 for (uint32_t i = 0U; i < chunk_words; i++) {
330 return (
UINT)LX_ERROR;
333 offset += chunk_bytes;
334 remain_words -= chunk_words;
336 return (
UINT)LX_SUCCESS;
395typedef enum : uint32_t {
414typedef enum : uint32_t {
459typedef enum : uint8_t {
564typedef enum : uint8_t {
602 if (pfs ==
nullptr) {
605 const uint32_t raw = *pfs;
638typedef enum : uint32_t {
652typedef enum : uint8_t {
723 return (
UINT)LX_ERROR;
733 return (
UINT)LX_SUCCESS;
764 return (
UINT)LX_ERROR;
771 return (
UINT)LX_SUCCESS;
802 uint32_t jedec_id = 0U;
808 return (
UINT)LX_ERROR;
813 return (
UINT)LX_ERROR;
815 return (
UINT)LX_SUCCESS;
847 return (
UINT)LX_SUCCESS;
860 return (
UINT)LX_ERROR;
868 if (phase_a != (
UINT)LX_SUCCESS) {
872 if (phase_b != (
UINT)LX_SUCCESS) {
876 if (probe != (
UINT)LX_SUCCESS) {
882 return (
UINT)LX_SUCCESS;
888 if (nor_flash == LX_NULL) {
889 return (
UINT)LX_ERROR;
896 if (bus != (
UINT)LX_SUCCESS) {
918 return (
UINT)LX_SUCCESS;
ra8_xspi_rdid_magic_t
Sentinel value distinguishing a written observation from cold-boot zero / stale RAM.
@ k_ra8_xspi_rdid_magic
'R','D','I','D' little-endian.
static const ra8_xspi_pin_ref_t s_ra8_xspi_pin_refs[k_ra8_xspi_pin_count]
Static reference list of OCTA (port, pin) pairs.
ra8_lx_nor_base_t
Synthetic flash base address handed to LevelX.
@ k_ra8_lx_nor_base_addr
Synthetic base for LevelX-managed window inside the flash.
static UINT internal_reset_phase_1s(void)
Phase B – switch the controller to 1S-1S-1S and reset again.
static UINT internal_nor_write(ULONG *flash_address, ULONG *source, ULONG words)
LevelX write callback: program words ULONGs from RAM to flash.
static UINT internal_nor_read(ULONG *flash_address, ULONG *destination, ULONG words)
LevelX read callback: copy words ULONGs from flash to RAM.
ra8_xspi_reset_timing_t
Post-software-reset settle time required by the IS25LX512M.
@ k_ra8_xspi_reset_settle_ms
>= tRPH (50 us).
ra8_lx_nor_constants_t
Compile-time constants for the xSPI <-> LevelX bridge.
@ k_ra8_lx_nor_word_bytes
Bytes per ULONG word (LevelX uses 4-byte ULONGs on this target).
@ k_ra8_lx_xspi_instance
xSPI instance routed to the EK-RA8D2 IS25LX512M flash chip.
@ k_ra8_lx_nor_words_per_block
LevelX words per block (= block_bytes / sizeof(ULONG)).
@ k_ra8_lx_nor_block_bytes
IS25LX512M erase-sector size (opcode 0x20 / sector erase).
@ k_ra8_lx_nor_total_blocks
Number of LevelX blocks exposed to wear-levelling.
static UINT internal_nor_block_erased_verify(ULONG block)
LevelX block-erased-verify callback: confirm a sector is 0xFF.
ra8_xspi_rdid_observation_t g_ra8_xspi_rdid_observed
JLink-readable observation of the last RDID probe.
ra8_xspi_reset_form_t
Width of the opcode pair shipped to ra8_xspi_software_reset.
@ k_ra8_xspi_reset_form_8d
Opcode + complement for 8D-8D-8D.
@ k_ra8_xspi_reset_form_1s
1-byte opcode for 1S-1S-1S.
static UINT internal_bus_init_once(void)
Bring the OCTA bus up (pins + controller) on first call.
static uint32_t internal_flash_offset_bytes(ULONG *flash_address)
ra8_xspi_pin_observation_t g_ra8_xspi_pin_observed[k_ra8_xspi_pin_count]
JLink-readable PSEL readback for the 12 OCTA pin slots.
ra8_lx_jedec_id_t
Expected JEDEC ID triplet for the EK-RA8D2 IS25LX512M-JHLE chip.
@ k_ra8_lx_jedec_type
IS25LX memory-type code.
@ k_ra8_lx_jedec_mfr
ISSI manufacturer ID.
@ k_ra8_lx_jedec_expected
Packed RDID expected.
@ k_ra8_lx_jedec_capacity
512 Mbit capacity code.
ra8_xspi_pin_count_t
Number of OCTA bus pin slots in g_ra8_xspi_pin_observed.
@ k_ra8_xspi_pin_count
CS + CK + DQS + DQ0..DQ7 + 1 spare.
static UINT internal_reset_phase_8d(void)
Phase A – punch the IS25LX512M out of any 8D-OPI mode.
UINT lx_nor_driver_ra8_xspi_initialize(LX_NOR_FLASH *nor_flash)
LevelX NOR driver-initialise entry point bridging onto ra8_xspi.
ra8_lx_pin_diag_t
Constants for the diagnostic xSPI pin-state capture.
@ k_ra8_lx_pin_unobserved
Sentinel before PFS is read.
@ k_ra8_lx_pfs_psel_mask
PSEL is the low 5 bits of the PFS.
ra8_xspi_stage_t
Bring-up stage markers stamped into g_ra8_xspi_rdid_observed.stage.
@ k_ra8_xspi_stage_init_1s
xSPI init in 1S mode.
@ k_ra8_xspi_stage_done
Bring-up succeeded.
@ k_ra8_xspi_stage_pins
Pin routing in progress.
@ k_ra8_xspi_stage_reset_1s
Software reset in 1S.
@ k_ra8_xspi_stage_reset_8d
Software reset in 8D.
@ k_ra8_xspi_stage_init_8d
xSPI init in 8D mode.
@ k_ra8_xspi_stage_rdid
RDID probe in flight.
static void internal_stamp_observed_start(void)
Stamp the observation breadcrumb at the start of a bring-up call.
static void internal_capture_xspi_pin_state(void)
Capture the post-init PFS state of every OCTA pin.
static ULONG s_ra8_lx_nor_sector_buffer[LX_NOR_SECTOR_SIZE]
Per-driver scratch buffer LevelX uses for sector mapping reads.
static UINT internal_nor_block_erase(ULONG block, ULONG erase_count)
LevelX block-erase callback: erase one 4 KiB sector by index.
static bool s_xspi_bus_ready
One-shot guard so we only run the bus bring-up once.
static const char * s_lx_xspi_tag
Logging tag for the LevelX <-> ra8_xspi bridge.
static UINT internal_probe_rdid(void)
Probe RDID and confirm the IS25LX512M is responsive.
LevelX NOR-flash driver shim that bridges LevelX onto the RA8 ra8_xspi HAL (EK-RA8D2 ISSI IS25LX512M ...
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_board_eth_pin_t pin
Pin.
ra8_err_t ra8_board_xspi_pins_init(void)
Route the 12 OCTA bus pins to the xSPI peripheral and pulse RESET_L.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
#define ra8_log_error(tag, message)
RA8 log error.
@ k_ra8_xspi_lio_1s1s1s
1S-1S-1S extended SPI.
@ k_ra8_xspi_lio_8d8d8d
8D-8D-8D octal DDR (OPI).
Pin Function Select (PFS) register layout for the Renesas RA8D2.
@ k_ra8_pfs_mask_pmr
RA8 PFS mask pmr.
@ k_ra8_pfs_bit_psel0
Peripheral select bit 0.
static volatile uint32_t * ra8_pfs_pmn(ra8_port_t port, ra8_pin_t pin)
Get pointer to the PmnPFS register for a single pin.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_t
Port indices for the RA8D2 IOPORT module.
@ k_ra8_port_max
Highest valid port index.
@ k_ra8_port_8
RA8 port 8.
@ k_ra8_port_1
RA8 port 1.
ra8_pin_t
Pin indices within an IOPORT port (0..15).
@ k_ra8_pin_max
Highest valid pin index.
SysTick-based tick counter, delay and timestamp helpers.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
xSPI / Octo-SPI driver (flash read/program/erase + ID/status)
ra8_err_t ra8_xspi_flash_program(uint8_t instance, uint32_t flash_addr, const uint8_t *data, uint32_t len)
Program (write) len bytes at flash_addr.
ra8_err_t ra8_xspi_software_reset(uint8_t instance, uint8_t cmd_bytes)
Issue the JEDEC software-reset pair (RSTEN 0x66 + RST 0x99).
ra8_err_t ra8_xspi_init(uint8_t instance, ra8_xspi_lio_mode_t mode)
Initialise an xSPI instance in the chosen link-layer IO mode.
ra8_err_t ra8_xspi_flash_read(uint8_t instance, uint32_t flash_addr, uint8_t *buf, uint32_t len)
Read len bytes from external flash into buf.
ra8_err_t ra8_xspi_flash_erase_sector(uint8_t instance, uint32_t flash_addr)
Erase the 4 KiB sector containing flash_addr.
ra8_err_t ra8_xspi_flash_read_id(uint8_t instance, uint32_t *out_id)
Read the JEDEC ID (opcode 0x9F), returning 24 bits in a uint32_t.
One row per OCTA pin captured AFTER ra8_board_xspi_pins_init.
uint8_t pmr_observed
1 if PFS.PMR == 1 after init.
uint8_t psel_observed
PFS PSEL[28..24] >> 24.
uint8_t pin
Pin index within the port.
uint32_t pfs_raw
Full 32-bit PmnPFS readback.
uint8_t port
Port index from ra8_port_t.
Board-side reference (port, pin) for the 12 OCTA pad slots.
JLink-readable snapshot of the most recent RDID probe.
uint32_t jedec_id
Last raw RDID triplet from the HAL.
uint32_t magic
k_ra8_xspi_rdid_magic once written.
uint32_t call_count
Number of probe attempts since reset.
uint32_t reset_8d_err
ra8_err_t from 8D-form software reset.
uint32_t rid_err
Last ra8_err_t from read_id (uint).
uint32_t stage
Last stage reached (see ra8_xspi_stage_t).
uint32_t reset_1s_err
ra8_err_t from 1S-form software reset.
uint32_t reserved
Reserved for future diagnostics.