75 for (uint32_t i = 0U; i < len; i++) {
101 return (uint8_t)((uint8_t)
'0' + (uint8_t)nibble);
122 if (text[len] ==
'\0') {
181 uint8_t width = digits;
185 for (uint8_t i = 0U; i < width; i++) {
211 out[0] = (uint8_t)
'0';
218 scratch[count] = (uint8_t)((uint8_t)
'0' + (uint8_t)(v %
k_dfu_dec_radix));
222 for (uint8_t i = 0U; i < count; i++) {
223 out[i] = scratch[count - 1U - i];
324 for (uint8_t attempt = 0U; attempt < (uint8_t)
k_dfu_enum_tries; attempt++) {
450 if (state == want_state) {
507 for (uint16_t b = 0U; b < (uint16_t)
k_dfu_blocks; b++) {
548 for (uint16_t b = 0U; b < (uint16_t)
k_dfu_blocks; b++) {
619 err =
dfu_print(
"ra8d2 dfu: enumerated pid=0x");
670 err =
dfu_print(
" blocks downloaded + verified -- USB SELFTEST DFU PASS\r\n");
@ k_dfu_print_cap
Bound for console-string scans.
@ k_dfu_breq_dnload
DFU_DNLOAD.
@ k_dfu_breq_getstatus
DFU_GETSTATUS.
@ k_dfu_breq_get_desc
GET_DESCRIPTOR.
@ k_dfu_byte_bits
Bits per byte.
@ k_dfu_bm_std_dev_in
bmRequestType: Std | Device | In.
@ k_dfu_getstatus_len
DFU_GETSTATUS payload len.
@ k_dfu_breq_set_config
SET_CONFIGURATION.
@ k_dfu_breq_set_addr
SET_ADDRESS.
@ k_dfu_desc_device
DEVICE descriptor type.
@ k_dfu_off_dev_pid
idProduct LSB byte offset.
@ k_dfu_state_dnload_idle
dfuDNLOAD-IDLE.
@ k_dfu_bm_class_if_in
bmRequestType: Class | Interface | In.
@ k_dfu_breq_abort
DFU_ABORT (-> dfuIDLE).
@ k_dfu_dev_desc_len
DEVICE descriptor length.
@ k_dfu_breq_upload
DFU_UPLOAD.
@ k_dfu_bm_class_if_out
bmRequestType: Class | Interface | Out.
@ k_dfu_state_idle
dfuIDLE.
@ k_dfu_bm_std_dev_out
bmRequestType: Std | Device | Out.
@ k_dfu_off_status_state
bState offset in GETSTATUS.
@ k_dfu_reset_hold_ms
USB bus-reset hold (>=10 ms).
@ k_dfu_attach_to_ms
Wait for the D+ pull-up.
@ k_dfu_enum_tries
Reset+probe attempts.
@ k_dfu_attach_spin
Attach spin cap (frozen-tick guard).
@ k_dfu_recovery_ms
Post-reset recovery (TRSTRCY).
@ k_dfu_status_poll_ms
Pause between GETSTATUS polls.
@ k_dfu_addr_settle_ms
Post-SET_ADDRESS recovery.
@ k_dfu_vbus_settle_ms
VBUS settle before probing.
@ k_dfu_debounce_ms
Post-attach debounce (>=100 ms).
@ k_dfu_status_tries
GETSTATUS polls before giving up.
static volatile uint32_t s_dbg_pid
Device-reported product id captured at enumeration.
@ k_dfu_phase_init
Host controller init.
@ k_dfu_phase_pass
Image verified byte-equal.
@ k_dfu_phase_upload
Running DFU_UPLOAD.
@ k_dfu_phase_download
Running DFU_DNLOAD.
@ k_dfu_phase_enum
Enumerating.
@ k_dfu_hex_chars_u32
32-bit value -> "ABCDEF01".
@ k_dfu_hex_digit_split
Threshold between '0-9'/'A-F'.
@ k_dfu_nibble_bits
Bits per hex nibble.
@ k_dfu_nibble_mask
4-bit nibble mask.
static volatile uint32_t s_dbg_blocks_ok
Blocks the host confirmed byte-equal on upload (expect k_dfu_blocks).
@ k_dfu_xfer_size
wTransferSize: bytes per DFU block.
@ k_dfu_byte_mask
Byte mask.
@ k_dfu_dev_addr
Address the host assigns.
@ k_dfu_pat_idx_mul
Per-index pattern multiplier.
@ k_dfu_no_mismatch
Probe: no mismatch.
@ k_dfu_pat_blk_mul
Per-block pattern multiplier.
@ k_dfu_intf
DFU interface number.
@ k_dfu_config_val
bConfigurationValue.
@ k_dfu_pat_bias
Pattern constant bias.
@ k_dfu_blocks
Blocks in the rehearsal image.
@ k_dfu_dec_chars_u32
Max digits for a 32-bit count.
@ k_dfu_hex_chars_u16
16-bit value -> "ABCD".
@ k_dfu_dec_radix
Base for decimal conversion.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_on(ra8_board_led_id_t led)
Drive led HIGH (light it).
@ k_ra8_board_led2
LED2, GREEN, P303 (jumper E26).
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
SysTick-based tick counter, delay and timestamp helpers.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
uint32_t ra8_time_ms(void)
Get the current 1 kHz tick count.
Native USB controller driver public API (device + host modes).
@ k_ra8_usb_speed_hs
High-Speed controller (USBHS @ 0x40351000).
ra8_err_t ra8_usb_host_bus_reset(ra8_usb_speed_t speed, bool assert_reset)
Drive (or release) the bus reset line.
uint16_t ra8_usb_host_line_state(ra8_usb_speed_t speed)
Read the host port's D+/D- line state (SYSSTS0.LNST).
ra8_err_t ra8_usb_host_init(ra8_usb_speed_t speed)
Bring up a USB controller in HOST mode.
ra8_err_t ra8_usb_host_deinit(ra8_usb_speed_t speed)
Tear down a host-mode controller and drop its MSTP reference.
ra8_err_t ra8_usb_host_control_xfer(ra8_usb_speed_t speed, const ra8_usb_setup_t *setup, uint8_t *data, uint16_t data_len, uint16_t *out_received)
Run a complete host control transfer (SETUP, optional DATA, STATUS).
ra8_err_t ra8_usb_host_set_uact(ra8_usb_speed_t speed, bool enable)
Enable / disable SOF (Start-of-Frame) generation on the bus.
ra8_err_t ra8_usb_host_set_target(ra8_usb_speed_t speed, uint8_t dev_addr)
Retarget the host's default control pipe at a device address.
Decoded 8-byte USB SETUP packet.
static void dfu_pattern_fill(uint32_t block, uint8_t *out, uint32_t len)
Fill a firmware block with this block's deterministic bytes.
static ra8_err_t dfu_print_fail(const char *what, ra8_err_t err)
Print "FAIL <what> err=0xNNNNNNNN" on its own line.
static ra8_err_t dfu_wait_state(uint8_t want_state)
Poll DFU_GETSTATUS until the device reports want_state.
static ra8_err_t dfu_host_enumerate(void)
Enumerate the looped-back device: descriptor hunt, address, config.
static ra8_err_t dfu_download_all(void)
Download the whole rehearsal image, then DFU_ABORT back to dfuIDLE.
static ra8_err_t dfu_sci_write(const uint8_t *data, uint32_t len)
Push a literal block over the J-Link OB CDC console (SCI8) polled.
static ra8_err_t dfu_getstatus(uint8_t *out_state)
DFU_GETSTATUS: read the 6-byte status and return the bState field.
static ra8_err_t dfu_dnload_block(uint16_t block, uint8_t *data, uint16_t len)
DFU_DNLOAD one block, then poll to dfuDNLOAD-IDLE.
static ra8_err_t dfu_enum_set_config(void)
SET_CONFIGURATION(::k_dfu_config_val) on the addressed device.
static ra8_err_t dfu_ctrl_get_dev_desc(uint8_t *desc)
GET_DESCRIPTOR(DEVICE) over the polled control engine.
ra8_err_t dfu_host_pass(void)
Run the full host pass: enumerate, download, upload-verify.
static ra8_err_t dfu_enum_set_address(void)
SET_ADDRESS to k_dfu_dev_addr, then retarget the DCP.
static uint8_t dfu_nibble_to_hex(uint32_t nibble)
Format one nibble (0..15) into an uppercase hex character.
static ra8_err_t dfu_enum_hunt(uint8_t *desc)
Wait for attach, then bus-reset + read the device descriptor.
static ra8_err_t dfu_print_hex(uint32_t value, uint8_t digits)
Print a value as fixed-width uppercase hex.
static uint32_t dfu_str_len(const char *text)
Bounded ASCII string length (cap k_dfu_print_cap).
static ra8_err_t dfu_print_dec(uint32_t value)
Print a uint32_t as ASCII decimal.
static ra8_err_t dfu_print(const char *text)
Print a NUL-terminated ASCII string over the console.
static ra8_err_t dfu_upload_verify(void)
DFU_UPLOAD the image back block by block and byte-check each.
Shared constants + host-side DFU ladder interface for usb_selftest_dfu.
static volatile uint32_t s_dbg_phase
Host-ladder phase marker (wlun_phase_t).
static volatile uint32_t s_dbg_pass_count
Completed full passes (sticky success counter).
static volatile uint32_t s_dbg_mismatch
First mismatching sector, or k_wlun_no_mismatch.