|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
External SDRAM bring-up + 64 KB write/read benchmark on EK-RA8D2. More...
#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_sdramc.h"#include "ra8_sdramc_regs.h"#include "ra8_time.h"Go to the source code of this file.
Data Structures | |
| struct | sdram_demo_diag_t |
| First-mismatch diagnostic captured by sdram_demo_read_check. More... | |
Enumerations | |
| enum | sdram_demo_const_t : uint32_t { k_sdram_demo_baud = 115200U , k_sdram_demo_period_ms = 1000U , k_sdram_demo_block_bytes = 65536U , k_sdram_demo_block_words = 16384U , k_sdram_demo_us_per_ms = 1000U } |
| App-wide tunables. More... | |
| enum | sdram_demo_byte_t : uint8_t { k_sdram_demo_ascii_zero = '0' , k_sdram_demo_ascii_a = 'a' , k_sdram_demo_dec_base = 10U , k_sdram_demo_uint_dec_max = 10U , k_sdram_demo_print_buf = 64U , k_sdram_demo_fail_buf = 96U , k_sdram_demo_hex_digits = 8U , k_sdram_demo_nyb_bits = 4U , k_sdram_demo_nyb_mask = 0x0FU } |
| Single-byte ASCII conversion constants. More... | |
| enum | sdram_demo_seed_t : uint32_t { k_sdram_demo_pattern_seed = 0xC0FFEE00UL } |
| Pattern seed – recognisable hex word for SWD inspection. More... | |
Functions | |
| static void | sdram_demo_panic_halt (void) |
| Park forever after a fatal init failure. | |
| static void | sdram_demo_setup_or_halt (void) |
| Bring CGC + SysTick + console + SDRAM up. | |
| static uint32_t | sdram_demo_mbps (uint32_t bytes, uint32_t ms) |
| Compute throughput in MB/s given a byte count and millisecond span. | |
| static uint32_t | sdram_demo_write_pass (uint32_t base) |
| Write base + i into every word of the SDRAM block. | |
| static bool | sdram_demo_read_check (uint32_t base, uint32_t *elapsed, sdram_demo_diag_t *diag) |
| Read every word back and check it matches base + i. | |
| static uint8_t | sdram_demo_uint_to_hex (uint8_t *buf, uint32_t v) |
Render v as exactly 8 lowercase hex digits into buf. | |
| static uint8_t | sdram_demo_uint_to_dec (uint8_t *buf, uint32_t v) |
| Write a decimal uint32 into buf; returns bytes written. | |
| static uint32_t | sdram_demo_format_line (uint8_t *out, uint32_t w_mbps, uint32_t r_mbps) |
Format the per-cycle MB/s line into out, return its length. | |
| static uint32_t | sdram_demo_format_fail (uint8_t *out, const sdram_demo_diag_t *diag) |
Format the read-back FAIL diagnostic line into out. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static const uint8_t | k_sdram_demo_pass_msg [] = "sdram: bench OK\r\n" |
| Verdict line emitted only when a read-back pass matched every word (never on a "sdram: FAIL idx=" path); the HIL scrape keys on this success-only string. | |
External SDRAM bring-up + 64 KB write/read benchmark on EK-RA8D2.
Standalone EVM-tier app that exercises the external SDRAM controller driver (libs/ra8_hal/inc/ra8_sdramc.h). The EK-RA8D2 carries a 64 MB ISSI IS42S32160F SDRAM (16M x 32) wired to the BUS pins with the controller-mapped window starting at k_ra8_sdram_base_addr (0x68000000). The flow:
Bare EK-RA8D2 only – the SDRAM is on-board.
Definition in file main.c.
| enum sdram_demo_byte_t : uint8_t |
Single-byte ASCII conversion constants.
| enum sdram_demo_const_t : uint32_t |
| enum sdram_demo_seed_t : uint32_t |
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Bench-tests SDRAM and prints MB/s.
Definition at line 365 of file main.c.
References k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, k_sdram_demo_block_bytes, k_sdram_demo_fail_buf, k_sdram_demo_pass_msg, k_sdram_demo_pattern_seed, k_sdram_demo_period_ms, k_sdram_demo_print_buf, ra8_board_led_on(), ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_delay_ms(), ra8_isr_globals_enable(), sdram_demo_format_fail(), sdram_demo_format_line(), sdram_demo_mbps(), sdram_demo_panic_halt(), sdram_demo_read_check(), sdram_demo_setup_or_halt(), and sdram_demo_write_pass().
|
static |
Format the read-back FAIL diagnostic line into out.
Emits sdram: FAIL idx=<dec> exp=<hex> got=<hex> n=<dec> so a HIL log shows the corruption signature. The literal sdram: FAIL prefix is what the HIL negative-match regex keys on.
| [out] | out | Destination buffer (>= k_sdram_demo_fail_buf bytes). |
| [in] | diag | First-mismatch diagnostic from sdram_demo_read_check. |
Definition at line 324 of file main.c.
References sdram_demo_diag_t::count, sdram_demo_diag_t::expected, sdram_demo_diag_t::first_idx, sdram_demo_diag_t::got, sdram_demo_uint_to_dec(), and sdram_demo_uint_to_hex().
Referenced by main().
|
static |
Format the per-cycle MB/s line into out, return its length.
| [out] | out | Destination buffer (>= k_sdram_demo_print_buf bytes). |
| [in] | w_mbps | Write throughput in MB/s. |
| [in] | r_mbps | Read throughput in MB/s. |
Definition at line 288 of file main.c.
References sdram_demo_uint_to_dec().
Referenced by main().
|
static |
Compute throughput in MB/s given a byte count and millisecond span.
Returns (bytes / 1e6) / (ms / 1000) = bytes / (ms * 1000). The function clamps ms to 1 to avoid divide-by-zero when the benchmark loop is too fast to register on the millisecond tick.
| [in] | bytes | Total bytes transferred. |
| [in] | ms | Elapsed time in milliseconds. |
Definition at line 159 of file main.c.
References k_sdram_demo_us_per_ms.
Referenced by main().
|
static |
Park forever after a fatal init failure.
Definition at line 100 of file main.c.
Referenced by main(), and sdram_demo_setup_or_halt().
|
static |
Read every word back and check it matches base + i.
| [in] | base | Seed used by the matching write pass. |
| [out] | elapsed | Receives the elapsed milliseconds. |
| [out] | diag | Receives the first-mismatch diagnostic. |
Definition at line 198 of file main.c.
References sdram_demo_diag_t::count, sdram_demo_diag_t::expected, sdram_demo_diag_t::first_idx, sdram_demo_diag_t::got, k_ra8_sdram_base_addr, k_sdram_demo_block_words, and ra8_time_ms().
Referenced by main().
|
static |
Bring CGC + SysTick + console + SDRAM up.
Panic-halts on fail.
Definition at line 112 of file main.c.
References k_ra8_board_led1, k_ra8_board_led2, k_ra8_clock_id_cpuclk0, k_ra8_ok, k_sdram_demo_baud, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_sdramc_init(), ra8_time_init(), and sdram_demo_panic_halt().
Referenced by main().
|
static |
Write a decimal uint32 into buf; returns bytes written.
| [out] | buf | Destination buffer (must hold at least 10 chars). |
| [in] | v | Value to render. |
Definition at line 254 of file main.c.
References k_sdram_demo_ascii_zero, k_sdram_demo_dec_base, and k_sdram_demo_uint_dec_max.
Referenced by sdram_demo_format_fail(), and sdram_demo_format_line().
|
static |
Render v as exactly 8 lowercase hex digits into buf.
| [out] | buf | Destination (must hold >= k_sdram_demo_hex_digits). |
| [in] | v | Value to render. |
Definition at line 229 of file main.c.
References k_sdram_demo_ascii_a, k_sdram_demo_ascii_zero, k_sdram_demo_dec_base, k_sdram_demo_hex_digits, k_sdram_demo_nyb_bits, and k_sdram_demo_nyb_mask.
Referenced by sdram_demo_format_fail().
|
static |
Write base + i into every word of the SDRAM block.
| [in] | base | Seed value mixed into the pattern. |
Definition at line 175 of file main.c.
References k_ra8_sdram_base_addr, k_sdram_demo_block_words, and ra8_time_ms().
Referenced by main().