|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Bare-metal ra8_eth_open() bring-up probe (tracker issue #524). More...
#include <stddef.h>#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_eth.h"#include "ra8_isr.h"#include "ra8_log.h"#include "ra8_mstp.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | eop_consts_t : uint32_t { k_eop_uart_baud = 115200U , k_eop_channel = 1U , k_eop_hex_chars = 8U , k_eop_hex_shift = 4U , k_eop_hex_mask = 0xFU , k_eop_dec_base = 10U , k_eop_dec_max = 10U } |
| Console + probe knobs (no magic numbers). More... | |
| enum | eop_pad_t : uint32_t { k_eop_pad_bytes = RA8_ETH_PROBE_PAD_BYTES } |
| Size of the leading .bss pad that steers where the HAL's Ethernet statics land in SRAM. More... | |
| enum | eop_mac_t : uint8_t { k_eop_mac_0 = 0x02U , k_eop_mac_1 = 0x00U , k_eop_mac_2 = 0x00U , k_eop_mac_3 = 0x00U , k_eop_mac_4 = 0x00U , k_eop_mac_5 = 0x01U } |
| Locally-administered MAC the probe opens with. More... | |
Functions | |
| static void | eop_print (const uint8_t *msg, uint32_t len) |
| Push bytes at the SCI8 console, discarding the write status. | |
| static void | eop_log_sink (void *ctx, uint8_t byte) |
| ra8_log byte sink forwarding every log byte to the console. | |
| static void | eop_print_hex (uint32_t value) |
| Print a 32-bit value as 0x + eight upper-case hex digits. | |
| static void | eop_print_uint (uint32_t value) |
| Print an unsigned 32-bit value in decimal. | |
| static uint32_t | eop_bss_pad_anchor (void) |
| Touch s_eop_bss_pad and report where it starts. | |
| static void | eop_panic_halt (void) |
| Print the negative banner and park the CPU. | |
| static void | eop_setup_or_halt (uint32_t *out_cpuclk_hz) |
| Bring up clocks, MSTP, SysTick and the SCI8 console; halt on failure. | |
| static ra8_err_t | eop_run_once (void) |
| Run the board Ethernet bring-up and the one ra8_eth_open call. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static volatile uint8_t | s_eop_bss_pad [k_eop_pad_bytes] |
| Leading .bss filler that positions every library static behind it. | |
| static const uint8_t | k_eop_msg_boot [] = "eth-open-probe: boot\r\n" |
| static const uint8_t | k_eop_msg_clock [] = "eth-open-probe: cpuclk0=" |
| static const uint8_t | k_eop_msg_pad [] = " bss_pad=" |
| static const uint8_t | k_eop_msg_padlen [] = " pad_bytes=" |
| static const uint8_t | k_eop_msg_board [] = "eth-open-probe: board_eth rc=" |
| static const uint8_t | k_eop_msg_opening [] = "eth-open-probe: calling ra8_eth_open ch=1\r\n" |
| static const uint8_t | k_eop_msg_open_rc [] = "eth-open-probe: eth_open rc=" |
| static const uint8_t | k_eop_msg_pass [] = "eth-open-probe: PASS\r\n" |
| static const uint8_t | k_eop_msg_fail [] = "eth-open-probe: FAIL\r\n" |
| static const uint8_t | k_eop_msg_hw_fail [] = "eth-open-probe: hw_init_failed\r\n" |
| static const uint8_t | k_eop_msg_newline [] = "\r\n" |
| static const uint8_t | k_eop_hex_digits [] = "0123456789ABCDEF" |
| static const uint8_t | k_eop_msg_hex_lead [] = "0x" |
Bare-metal ra8_eth_open() bring-up probe (tracker issue #524).
The smallest program that reaches ra8_eth_open() on real silicon: clocks, module-stop, SysTick, the SCI8 J-Link VCOM console, the board Ethernet pin/PHY bring-up, then one ra8_eth_open() on channel 1 – exactly the sequence port/netxduo/src/nx_ether_driver_ra8_eth.c performs from NX_LINK_INITIALIZE, with no RTOS, no IP stack and no packet pool in between.
It exists because that sequence has been reported to take a HardFault inside the GWCA TX-ring init, with the descriptor-chain pointer the caller loaded out of the HAL's GWCA state block arriving with address bit 25 clear (0x220664B0 -> 0x200664B0), while the SRAM word itself reads back correct over J-Link. Bit 25 is the bit that separates the Cortex-M85 DTCM window at 0x20000000 from system SRAM at 0x22000000 (HUM Ch 5 "Address Space" pp 236-243), so a cleared bit 25 turns an SRAM pointer into an address just above the 64 KiB DTCM – unimplemented, and therefore a precise BusFault.
The app narrates every step and registers the console as the ra8_log byte sink, so if the fault does occur the shared decoder in libs/ra8_core/src/ra8_exception.c prints the stacked frame (pc, r0..r3) plus cfsr / bfar on the bench UART instead of dropping them into ITM. Those are the numbers the report turns on: r0 is the descriptor-chain pointer as the CPU actually loaded it.
Sequence:
Reaching the verdict line proves the open path completed; a HardFault dump instead of it is the #524 signature.
Definition in file main.c.
| enum eop_consts_t : uint32_t |
Console + probe knobs (no magic numbers).
| enum eop_mac_t : uint8_t |
| enum eop_pad_t : uint32_t |
Size of the leading .bss pad that steers where the HAL's Ethernet statics land in SRAM.
RA8_ETH_PROBE_PAD_BYTES is a build-time knob (-D... from CMake, see this app's CMakeLists.txt) and the whole point of the app as an instrument. libs/ra8_board_ek_ra8d2/ld/linker_script.ld emits *(.bss) before *(.bss.*), and -fdata-sections puts every ordinary variable in its own .bss.<name>; so a pad forced into the plain .bss section lands ahead of every library static, and growing it slides the whole GWCA block – s_gwca_state, the descriptor chains and the buffer pools – up SRAM by exactly that many bytes with no other change to the program.
That makes "where the Ethernet DMA structures live" a single build-time variable, which is what tracker issue #499 needs and could not get by growing an application array (that moves the rings and every unrelated static, and pulling the rings out of .bss into a placed section moves everything that followed them instead).
| Enumerator | |
|---|---|
| k_eop_pad_bytes | Leading .bss pad, bytes. |
|
static |
Touch s_eop_bss_pad and report where it starts.
Two jobs in one place. The write keeps --gc-sections from dropping the pad, which would silently turn the address sweep into a no-op; and the returned address anchors the transcript to the link map, so a run log says which layout produced it without anyone having to guess which build it came from. Every library static sits at a fixed offset from this address, so it identifies the layout completely.
| 0x22000030..0x2219FFFF | Somewhere in the .bss output section. |
< Byte written to defeat –gc-sections.
< Arbitrary non-zero witness value.
Definition at line 287 of file main.c.
References s_eop_bss_pad.
Referenced by main().
|
static |
ra8_log byte sink forwarding every log byte to the console.
ra8_exception_report() narrates the decoded fault through ra8_log, whose default ITM backend deliberately drops every byte in fault context. A registered byte sink bypasses that gate, so the dump (pc, r0..r3, cfsr, bfar) lands on the bench UART where the transcript can be read without a debugger attached.
| [in] | ctx | Unused opaque cookie (sink ABI). |
| [in] | byte | Log byte to emit. |
Definition at line 199 of file main.c.
References ra8_board_uart_console_write().
Referenced by main().
|
static |
Print the negative banner and park the CPU.
Mirrors the sibling apps' panic idiom: one banner the HIL gate can match, then a debugger-visible stop.
Definition at line 311 of file main.c.
References eop_print(), and k_eop_msg_hw_fail.
Referenced by eop_setup_or_halt().
|
static |
Push bytes at the SCI8 console, discarding the write status.
Console loss is acceptable for a narration helper – the HIL gate re-checks the transcript it actually received.
| [in] | msg | Bytes to send (not NUL-inspected). |
| [in] | len | Number of bytes to send. |
Definition at line 173 of file main.c.
References ra8_board_uart_console_write().
Referenced by eop_panic_halt(), eop_print_hex(), eop_print_uint(), eop_run_once(), and main().
|
static |
Print a 32-bit value as 0x + eight upper-case hex digits.
Fixed width so a transcript diff lines up column-wise; the addresses this probe reports are only legible in hex.
| [in] | value | Value to print. |
Definition at line 221 of file main.c.
References eop_print(), k_eop_hex_chars, k_eop_hex_digits, k_eop_hex_mask, k_eop_hex_shift, and k_eop_msg_hex_lead.
Referenced by main().
|
static |
Print an unsigned 32-bit value in decimal.
Digits are pushed LSB-first into a local buffer then emitted MSB-first; zero prints as a single 0.
| [in] | value | Value to print. |
Definition at line 247 of file main.c.
References eop_print(), k_eop_dec_base, and k_eop_dec_max.
Referenced by eop_run_once().
|
staticnodiscard |
Run the board Ethernet bring-up and the one ra8_eth_open call.
Narrates both status codes so a transcript distinguishes "the board layer refused" from "the HAL open path refused" from "the CPU faulted inside the open path and never returned a code at all" – the last of which is the #524 signature and is why every line is flushed before the call rather than after it.
| k_ra8_ok | Both the board layer and ra8_eth_open succeeded. |
| k_ra8_err_invalid_arg | ra8_eth_open rejected the channel or sizes. |
| k_ra8_err_timeout | GWCA / RMAC mode change did not complete. |
Definition at line 391 of file main.c.
References eop_print(), eop_print_uint(), k_eop_channel, k_eop_mac_0, k_eop_mac_1, k_eop_mac_2, k_eop_mac_3, k_eop_mac_4, k_eop_mac_5, k_eop_msg_board, k_eop_msg_newline, k_eop_msg_open_rc, k_eop_msg_opening, k_ra8_ok, ra8_board_ethernet_init(), and ra8_eth_open().
Referenced by main().
|
static |
Bring up clocks, MSTP, SysTick and the SCI8 console; halt on failure.
The minimum the Ethernet bring-up below depends on: ra8_board_ethernet_init needs a running SysTick for its PHY reset delays, and ra8_eth_open needs the ESWM module clock ra8_mstp_init releases.
| [out] | out_cpuclk_hz | Receives the measured CPUCLK0 frequency in Hz. |
Definition at line 338 of file main.c.
References eop_panic_halt(), k_eop_uart_baud, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().
Referenced by main().
| void main | ( | void | ) |
The application entry point Reset_Handler hands control to.
Returns void, not int. This is a freestanding image: there is no hosted C environment, no process and nothing to report an exit status to. ISO C fixes main at int only for a hosted implementation; for a freestanding one (C23 5.1.2.1) the startup function's name and type are implementation-defined, and this is that definition. Reset_Handler discards no value because there is none to discard, and if main ever does return, startup halts the CPU rather than resuming anything.
The firmware lane is compiled -ffreestanding (see cmake/ra8_add_app.cmake) and the flag and this signature travel together: without it both GCC and clang reject a non-int main (-Wmain / -Wmain-return-type). Do not remove one without the other.
That coupling is why the declaration sits behind __STDC_HOSTED__ == 0, which -ffreestanding sets and a hosted build does not. The guard is not defensive dressing: this header is reachable from host builds (the unit tests compile ra8_core natively), and an unguarded void main(void); makes every hosted translation unit that includes it fail with conflicting types for 'main' against its own ISO int main. The declaration therefore exists exactly where its contract does.
Hosted first-party code – everything under tests/ and tools/ – uses the ISO int main(...) contract instead, because it genuinely does run under an OS that reads the exit status. scripts/checks/check_entry_points.py holds each domain to its own contract (#707).
Declared here, once, for the same reason SystemInit is: every vector_table.c used to restate it as a local extern int32_t main(void);, sixteen copies that no compiler ever compared against the definition – and roughly thirty of them had silently drifted out of agreement with the main they called.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
The application entry point Reset_Handler hands control to.
Brings up CGC + GPT triple, runs sweep.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Profiles power modes once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, SPI, and SD card, then runs the shared ra8_io VFS round-trip over the SD-over-SPI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Both USB controllers' clocks and pins come up before the kernel so the workers only deal with stack bring-up.
The application entry point Reset_Handler hands control to.
Brings up logging and the clock tree, releases the Cortex-M33 (which then blinks LED1 via ra8_pcntr_set_output()), and idles. See the file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the cacheable-SRAM round-trip with the D-cache that SystemInit() enabled through ra8_cache_dcache_enable(), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU + RA8_BOOT_CACHE_VIA_HAL).
The application entry point Reset_Handler hands control to.
Publishes the mailbox, releases the Cortex-M33 into the emitter, yields until it signals done, validates the blob the M33 built, then logs the PASS/FAIL verdict and the chapter count read back from the blob. See the file header for the offload narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Publishes the mailbox, arms the IPC0 wake and configures the LPM block, releases the Cortex-M33 into the reader, waits for the first held page, logs the page-0 verdict, then runs the #150 mode-switch cycle – parking in low-power WFI and waking on the M33's page-turn pokes – before logging the handoff verdict and parking for good. See the file header for the narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the timebase then measures forever.
The application entry point Reset_Handler hands control to.
Arms the RIIC1 target and polls the dispatcher.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the LIN commander then drives frames.
The application entry point Reset_Handler hands control to.
Brings up logging, "renders" page 0 into the shared mailbox, releases the Cortex-M33 into its hold loop, and parks the M85 in low-power WFI sleep. See the file header for the power-saving narrative.
The application entry point Reset_Handler hands control to.
The USB clock, pins, console, and the SD card all come up before the kernel so the worker only deals with USB stack bring-up.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (MPU enabled, canonical boot map, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the wear-levelling + power-cycle-survival flow, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the program/erase round-trip, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then runs the full ra8_io VFS round-trip over the native-SDHI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Brings up the console and both stdio sinks, retargets the engine's stdio to the in-RAM capture sink, runs the two-backend swap, replays the RAM capture out of the UART, and prints a single PASS/FAIL verdict per abstraction before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then writes + reads + compares one raw 512-byte block straight against ra8_sdcard. On success it prints the exact PASS banner; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII + RSIP, then ThreadX.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initializes and arms ADC_B, formats each successful channel sample without variadic I/O, emits the verdict, toggles LED1, and delays.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, releases the Cortex-M33 (which then blinks LED1), and idles. See the file header for the teaching narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See the file header for the full behaviour summary.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (cacheable SRAM, RO MRAM const, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches and MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU).
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Lights HOCO + PLL, then runs a 1 Hz blink.
The application entry point Reset_Handler hands control to.
See file header for behaviour summary.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initializes the demo, executes one comparison per period, increments the exported match or mismatch counter, and toggles the matching LED.
The application entry point Reset_Handler hands control to.
Brings up the clock tree, MSTP, ISR/ELC, and the VCOM console, programs a software-triggered DTC block copy, runs it with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI.
The application entry point Reset_Handler hands control to.
Brings up logging, zeros the shared control block, releases the Cortex-M33, waits for its boot signature, then yields while the M33 counts autonomously to k_bg_target_count. After the M33 sets done, the M85 reads the counter and logs the PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Brings up logging, releases the Cortex-M33, confirms it booted, runs k_m85_demo_rounds narrated mailbox rounds, then drops into the idle heartbeat. See the file header for the teaching narrative.
The application entry point Reset_Handler hands control to.
Fires ELC software events once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Definition at line 422 of file main.c.
References eop_bss_pad_anchor(), eop_log_sink(), eop_print(), eop_print_hex(), eop_run_once(), eop_setup_or_halt(), k_eop_msg_boot, k_eop_msg_clock, k_eop_msg_fail, k_eop_msg_newline, k_eop_msg_pad, k_eop_msg_padlen, k_eop_msg_pass, k_eop_pad_bytes, k_ra8_ok, ra8_isr_globals_enable(), and ra8_log_set_byte_sink().
|
static |
Definition at line 153 of file main.c.
Referenced by eop_print_hex().
|
static |
Definition at line 146 of file main.c.
Referenced by eop_run_once().
|
static |
|
static |
|
static |
|
static |
Definition at line 154 of file main.c.
Referenced by eop_print_hex().
|
static |
Definition at line 151 of file main.c.
Referenced by eop_panic_halt().
|
static |
Definition at line 152 of file main.c.
Referenced by eop_run_once(), and main().
|
static |
Definition at line 148 of file main.c.
Referenced by eop_run_once().
|
static |
Definition at line 147 of file main.c.
Referenced by eop_run_once().
|
static |
|
static |
|
static |
|
static |
Leading .bss filler that positions every library static behind it.
Forced into the plain .bss input section (not the -fdata-sections .bss.s_eop_bss_pad it would otherwise get) so the linker emits it in the *(.bss) group, ahead of every *(.bss.*). volatile plus the single write in eop_bss_pad_anchor keeps --gc-sections from discarding it.
Definition at line 130 of file main.c.
Referenced by eop_bss_pad_anchor().