|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
HAL-based ESWM/COMA Ethernet media bring-up demo (issue #581). 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_eth_coma.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_mstp_regs.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | ehb_const_t : uint32_t { k_ehb_baud = 115200U } |
| Console + demo knobs (no magic numbers). More... | |
| enum | ehb_fmt_t : uint8_t { k_ehb_radix = 10U , k_ehb_dec_u32_max = 10U } |
| Decimal-serialiser fields. More... | |
Functions | |
| static void | ehb_write (const uint8_t *data, uint32_t len) |
| Write a byte span to the SCI8 console, discarding the status. | |
| static void | ehb_write_u32_line (uint32_t val) |
| Log one unsigned 32-bit value as decimal ASCII plus CRLF. | |
| static void | ehb_panic_halt (void) |
| Print the negative banner and park the CPU. | |
| static void | ehb_setup_or_halt (void) |
| Bring up clocks, MSTP, SysTick and the SCI8 console; halt on failure. | |
| static ra8_err_t | ehb_run_once (void) |
| Drive the ESWCLK + ESWM prerequisites, then the two ETH HAL primitives. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | k_ehb_msg_boot [] = "eth-hal: boot\r\n" |
| static const uint8_t | k_ehb_msg_eswclk [] = "eth-hal: eswclk_init rc=" |
| static const uint8_t | k_ehb_msg_mstp [] = "eth-hal: mstp_eswm rc=" |
| static const uint8_t | k_ehb_msg_coma [] = "eth-hal: coma_bringup rc=" |
| static const uint8_t | k_ehb_msg_rgmii [] = "eth-hal: rgmii_select rc=" |
| static const uint8_t | k_ehb_msg_pass [] = "eth-hal: bringup PASS\r\n" |
| static const uint8_t | k_ehb_msg_fail [] = "eth-hal: bringup FAIL\r\n" |
| static const uint8_t | k_ehb_msg_hw_fail [] = "eth-hal: hw_init_failed\r\n" |
| static const uint8_t | k_ehb_msg_crlf [] = "\r\n" |
HAL-based ESWM/COMA Ethernet media bring-up demo (issue #581).
Demonstrates the two chip-generic ETH HAL primitives extracted from the EK-RA8D2 board Ethernet bring-up (issue #581), driven directly instead of through ra8_board_ethernet_init:
The prerequisites the primitives document – ESWCLK up and the ESWM module-stop gate released – are established first via ra8_cgc_eswclk_init and ra8_mstp_enable(k_ra8_mstp_eswm). Each step's status code is narrated on the SCI8 J-Link VCOM console; the fixed verdict eth-hal: bringup PASS prints only when every call returned k_ra8_ok.
Kept ALONGSIDE examples/.../hil/eth_open_probe (which drives the full board bring-up + ra8_eth_open): this app is the minimal witness that the two extracted primitives compose on their own.
Definition in file main.c.
| enum ehb_const_t : uint32_t |
| enum ehb_fmt_t : uint8_t |
|
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 146 of file main.c.
References ehb_write(), and k_ehb_msg_hw_fail.
Referenced by ehb_setup_or_halt().
|
staticnodiscard |
Drive the ESWCLK + ESWM prerequisites, then the two ETH HAL primitives.
Narrates every status code so a transcript distinguishes which step refused: ESWCLK bring-up, the ESWM module-stop release, the COMA bring-up, or the RGMII media-select. Port 1 is selected because the EK-RA8D2 RJ45 is wired to RMAC1 / ETHA1.
| k_ra8_ok | Every step succeeded. |
| k_ra8_err_hw_timeout | ESWCLK, MSTP readback, or CABPIRM.BPR timed out. |
| k_ra8_err_invalid_arg | ra8_eth_rgmii_select rejected the port. |
Definition at line 218 of file main.c.
References ehb_write(), ehb_write_u32_line(), k_ehb_msg_coma, k_ehb_msg_eswclk, k_ehb_msg_mstp, k_ehb_msg_rgmii, k_ra8_eth_mii_port_1, k_ra8_mstp_eswm, k_ra8_ok, ra8_cgc_eswclk_init(), ra8_eth_coma_bringup(), ra8_eth_rgmii_select(), and ra8_mstp_enable().
Referenced by main().
|
static |
Bring up clocks, MSTP, SysTick and the SCI8 console; halt on failure.
The minimum the media bring-up below depends on: a running MSTP controller (ra8_mstp_init) so the ESWM gate can be released, and the console for narration.
Definition at line 169 of file main.c.
References ehb_panic_halt(), k_ehb_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().
|
static |
Write a byte span to the SCI8 console, discarding the status.
| [in] | data | Non-NULL byte span to transmit. |
| [in] | len | Byte count (0 is a no-op). |
Definition at line 92 of file main.c.
References ra8_board_uart_console_write().
Referenced by ehb_panic_halt(), ehb_run_once(), ehb_write_u32_line(), and main().
|
static |
Log one unsigned 32-bit value as decimal ASCII plus CRLF.
Serialises LSB-first into a local buffer then emits MSB-first; zero prints as a single 0. Used to narrate ra8_err_t codes.
| [in] | val | Value to print. |
Definition at line 113 of file main.c.
References ehb_write(), k_ehb_dec_u32_max, k_ehb_msg_crlf, and k_ehb_radix.
Referenced by ehb_run_once().
| 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.
Definition at line 247 of file main.c.
References ehb_run_once(), ehb_setup_or_halt(), ehb_write(), k_ehb_msg_boot, k_ehb_msg_fail, k_ehb_msg_pass, k_ra8_ok, and ra8_isr_globals_enable().
|
static |
|
static |
Definition at line 71 of file main.c.
Referenced by ehb_run_once().
|
static |
Definition at line 76 of file main.c.
Referenced by ehb_write_u32_line().
|
static |
Definition at line 69 of file main.c.
Referenced by ehb_run_once().
|
static |
|
static |
Definition at line 75 of file main.c.
Referenced by ehb_panic_halt().
|
static |
Definition at line 70 of file main.c.
Referenced by ehb_run_once().
|
static |
|
static |
Definition at line 72 of file main.c.
Referenced by ehb_run_once().