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

Shared constants + host-side DFU ladder interface for usb_selftest_dfu. More...

#include <stdint.h>
#include "ra8_err.h"
Include dependency graph for usb_selftest_dfu_steps.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  dfu_config_t : uint32_t {
  k_dfu_thread_stack = 4096U ,
  k_dfu_host_stack = 8192U ,
  k_dfu_usbx_pool_bytes = 32768U ,
  k_dfu_idle_ticks = 50U ,
  k_dfu_boot_wait_ticks = 500U ,
  k_dfu_retry_ticks = 3000U ,
  k_dfu_baud = 115200U ,
  k_dfu_print_cap = 160U ,
  k_dfu_dev_priority = 8U ,
  k_dfu_host_priority = 24U
}
 Compile-time settings: threads, pool, console, cadence. More...
enum  dfu_hex_t : uint8_t {
  k_dfu_hex_chars_u16 = 4U ,
  k_dfu_hex_chars_u32 = 8U ,
  k_dfu_dec_chars_u32 = 10U ,
  k_dfu_nibble_bits = 4U ,
  k_dfu_hex_digit_split = 10U
}
 Hex/decimal text-formatter sizing constants. More...
enum  dfu_mask_t : uint32_t {
  k_dfu_nibble_mask = 0xFU ,
  k_dfu_dec_radix = 10U
}
 Bit-mask constants used by the text formatters. More...
enum  dfu_geom_t : uint32_t {
  k_dfu_xfer_size = 64U ,
  k_dfu_blocks = 8U ,
  k_dfu_image_bytes = 512U ,
  k_dfu_no_mismatch = 0xFFFFFFFFU ,
  k_dfu_pat_blk_mul = 131U ,
  k_dfu_pat_idx_mul = 7U ,
  k_dfu_pat_bias = 0xA5U ,
  k_dfu_byte_mask = 0xFFU ,
  k_dfu_dev_addr = 1U ,
  k_dfu_intf = 0U ,
  k_dfu_config_val = 1U
}
 Firmware-image geometry + pattern constants. More...
enum  dfu_phase_t : uint32_t {
  k_dfu_phase_boot = 0U ,
  k_dfu_phase_init = 1U ,
  k_dfu_phase_enum = 2U ,
  k_dfu_phase_download = 3U ,
  k_dfu_phase_upload = 4U ,
  k_dfu_phase_pass = 5U
}
 J-Link probe values marking host-ladder progress. More...
enum  dfu_req_t : uint16_t {
  k_dfu_bm_std_dev_in = 0x80U ,
  k_dfu_bm_std_dev_out = 0x00U ,
  k_dfu_bm_class_if_out = 0x21U ,
  k_dfu_bm_class_if_in = 0xA1U ,
  k_dfu_breq_get_desc = 0x06U ,
  k_dfu_breq_set_addr = 0x05U ,
  k_dfu_breq_set_config = 0x09U ,
  k_dfu_breq_dnload = 0x01U ,
  k_dfu_breq_upload = 0x02U ,
  k_dfu_breq_getstatus = 0x03U ,
  k_dfu_breq_abort = 0x06U ,
  k_dfu_desc_device = 0x01U ,
  k_dfu_dev_desc_len = 18U ,
  k_dfu_off_dev_pid = 10U ,
  k_dfu_byte_bits = 8U ,
  k_dfu_getstatus_len = 6U ,
  k_dfu_off_status_state = 4U ,
  k_dfu_state_dnload_idle = 5U ,
  k_dfu_state_idle = 2U
}
 Chapter-9 + DFU class request / descriptor constants. More...
enum  dfu_enum_tune_t : uint32_t {
  k_dfu_vbus_settle_ms = 200U ,
  k_dfu_attach_to_ms = 2000U ,
  k_dfu_debounce_ms = 500U ,
  k_dfu_reset_hold_ms = 50U ,
  k_dfu_recovery_ms = 20U ,
  k_dfu_addr_settle_ms = 5U ,
  k_dfu_status_poll_ms = 2U ,
  k_dfu_status_tries = 50U ,
  k_dfu_enum_tries = 8U ,
  k_dfu_attach_spin = 50000000U
}
 Timing / retry tunables for the polled enumeration + status polling. More...

Functions

ra8_err_t dfu_host_pass (void)
 Run the full host pass: enumerate, download, upload-verify.

Detailed Description

Shared constants + host-side DFU ladder interface for usb_selftest_dfu.

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

Declares the compile-time tunables, image geometry, text-formatter sizing, Chapter-9 + DFU class request constants, and the polled host-ladder entry point that main.c shares with usb_selftest_dfu_steps.c. The host worker thread (in main.c) calls dfu_host_pass; everything else in the sibling translation unit stays static.

Author
Brighton Sikarskie
Date
2026-06-15
Since
0.1.0

Definition in file usb_selftest_dfu_steps.h.

Enumeration Type Documentation

◆ dfu_config_t

enum dfu_config_t : uint32_t

Compile-time settings: threads, pool, console, cadence.

Enumerator
k_dfu_thread_stack 

Device worker stack (bytes).

k_dfu_host_stack 

Host worker stack (bytes).

k_dfu_usbx_pool_bytes 

USBX memory pool (bytes).

k_dfu_idle_ticks 

Parked-loop back-off (ticks).

k_dfu_boot_wait_ticks 

Host start delay (1 ms ticks).

k_dfu_retry_ticks 

Pause between ladder retries.

k_dfu_baud 

J-Link OB CDC log baud.

k_dfu_print_cap 

Bound for console-string scans.

k_dfu_dev_priority 

Device bring-up worker priority.

k_dfu_host_priority 

Host worker priority (below USBX).

Definition at line 32 of file usb_selftest_dfu_steps.h.

◆ dfu_enum_tune_t

enum dfu_enum_tune_t : uint32_t

Timing / retry tunables for the polled enumeration + status polling.

Enumerator
k_dfu_vbus_settle_ms 

VBUS settle before probing.

k_dfu_attach_to_ms 

Wait for the D+ pull-up.

k_dfu_debounce_ms 

Post-attach debounce (>=100 ms).

k_dfu_reset_hold_ms 

USB bus-reset hold (>=10 ms).

k_dfu_recovery_ms 

Post-reset recovery (TRSTRCY).

k_dfu_addr_settle_ms 

Post-SET_ADDRESS recovery.

k_dfu_status_poll_ms 

Pause between GETSTATUS polls.

k_dfu_status_tries 

GETSTATUS polls before giving up.

k_dfu_enum_tries 

Reset+probe attempts.

k_dfu_attach_spin 

Attach spin cap (frozen-tick guard).

Definition at line 127 of file usb_selftest_dfu_steps.h.

◆ dfu_geom_t

enum dfu_geom_t : uint32_t

Firmware-image geometry + pattern constants.

Enumerator
k_dfu_xfer_size 

wTransferSize: bytes per DFU block.

k_dfu_blocks 

Blocks in the rehearsal image.

k_dfu_image_bytes 

k_dfu_blocks * k_dfu_xfer_size.

k_dfu_no_mismatch 

Probe: no mismatch.

k_dfu_pat_blk_mul 

Per-block pattern multiplier.

k_dfu_pat_idx_mul 

Per-index pattern multiplier.

k_dfu_pat_bias 

Pattern constant bias.

k_dfu_byte_mask 

Byte mask.

k_dfu_dev_addr 

Address the host assigns.

k_dfu_intf 

DFU interface number.

k_dfu_config_val 

bConfigurationValue.

Definition at line 70 of file usb_selftest_dfu_steps.h.

◆ dfu_hex_t

enum dfu_hex_t : uint8_t

Hex/decimal text-formatter sizing constants.

Enumerator
k_dfu_hex_chars_u16 

16-bit value -> "ABCD".

k_dfu_hex_chars_u32 

32-bit value -> "ABCDEF01".

k_dfu_dec_chars_u32 

Max digits for a 32-bit count.

k_dfu_nibble_bits 

Bits per hex nibble.

k_dfu_hex_digit_split 

Threshold between '0-9'/'A-F'.

Definition at line 49 of file usb_selftest_dfu_steps.h.

◆ dfu_mask_t

enum dfu_mask_t : uint32_t

Bit-mask constants used by the text formatters.

Enumerator
k_dfu_nibble_mask 

4-bit nibble mask.

k_dfu_dec_radix 

Base for decimal conversion.

Definition at line 61 of file usb_selftest_dfu_steps.h.

◆ dfu_phase_t

enum dfu_phase_t : uint32_t

J-Link probe values marking host-ladder progress.

Enumerator
k_dfu_phase_boot 

Host thread not started.

k_dfu_phase_init 

Host controller init.

k_dfu_phase_enum 

Enumerating.

k_dfu_phase_download 

Running DFU_DNLOAD.

k_dfu_phase_upload 

Running DFU_UPLOAD.

k_dfu_phase_pass 

Image verified byte-equal.

Definition at line 88 of file usb_selftest_dfu_steps.h.

◆ dfu_req_t

enum dfu_req_t : uint16_t

Chapter-9 + DFU class request / descriptor constants.

Enumerator
k_dfu_bm_std_dev_in 

bmRequestType: Std | Device | In.

k_dfu_bm_std_dev_out 

bmRequestType: Std | Device | Out.

k_dfu_bm_class_if_out 

bmRequestType: Class | Interface | Out.

k_dfu_bm_class_if_in 

bmRequestType: Class | Interface | In.

k_dfu_breq_get_desc 

GET_DESCRIPTOR.

k_dfu_breq_set_addr 

SET_ADDRESS.

k_dfu_breq_set_config 

SET_CONFIGURATION.

k_dfu_breq_dnload 

DFU_DNLOAD.

k_dfu_breq_upload 

DFU_UPLOAD.

k_dfu_breq_getstatus 

DFU_GETSTATUS.

k_dfu_breq_abort 

DFU_ABORT (-> dfuIDLE).

k_dfu_desc_device 

DEVICE descriptor type.

k_dfu_dev_desc_len 

DEVICE descriptor length.

k_dfu_off_dev_pid 

idProduct LSB byte offset.

k_dfu_byte_bits 

Bits per byte.

k_dfu_getstatus_len 

DFU_GETSTATUS payload len.

k_dfu_off_status_state 

bState offset in GETSTATUS.

k_dfu_state_dnload_idle 

dfuDNLOAD-IDLE.

k_dfu_state_idle 

dfuIDLE.

Definition at line 101 of file usb_selftest_dfu_steps.h.

Function Documentation

◆ dfu_host_pass()

ra8_err_t dfu_host_pass ( void )
nodiscard

Run the full host pass: enumerate, download, upload-verify.

Returns
First failing step's error, or k_ra8_ok.
Return values
k_ra8_okThe pass printed DFU PASS.
Precondition
Device-side DFU class is registered (other thread).
The self-loop cable connects J7 to J11.
Postcondition
On success the host pass counter advanced and LED2 is on.
On failure the host controller is deinitialized for a clean retry.
Note
Blocking; runs on the low-priority host thread.
Since
0.1.0

Definition at line 629 of file usb_selftest_dfu_steps.c.

References dfu_download_all(), dfu_host_enumerate(), dfu_print(), dfu_print_dec(), dfu_print_fail(), dfu_upload_verify(), k_dfu_blocks, k_dfu_phase_download, k_dfu_phase_init, k_dfu_phase_pass, k_dfu_phase_upload, k_ra8_board_led2, k_ra8_ok, k_ra8_usb_speed_hs, ra8_board_led_on(), ra8_usb_host_deinit(), ra8_usb_host_init(), s_dbg_pass_count, and s_dbg_phase.