diff options
author | Evan Lojewski <github@meklort.com> | 2020-02-17 20:47:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-17 20:47:13 -0700 |
commit | 23b478f335cd622049ad17f1f7ca4f0641200705 (patch) | |
tree | 2243e00ad65259233171f3fbc97eb898c806af3e /ape | |
parent | d2419a287fc52929c351fb7fed54bae323fedc54 (diff) | |
download | bcm5719-ortega-23b478f335cd622049ad17f1f7ca4f0641200705.tar.gz bcm5719-ortega-23b478f335cd622049ad17f1f7ca4f0641200705.zip |
printf: Remove nvm access from the ape as it triggers a race condition when the rx cpu is restarted. (#35)
Rather than print directly, the APE now using the host debug console only for printf.
The RX cpu (function 0 only) uses the debug console and forwards it over SPI when new data is available.
Diffstat (limited to 'ape')
-rw-r--r-- | ape/main.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -47,7 +47,6 @@ #include <APE.h> #include <APE_APE.h> #include <APE_APE_PERI.h> -#include <APE_DEBUG.h> #include <APE_DEVICE1.h> #include <APE_DEVICE2.h> #include <APE_DEVICE3.h> @@ -233,7 +232,7 @@ void wait_for_rx(volatile DEVICE_t *device, volatile SHM_t *shm) } while (waiting); } -void handle_reset(void) +bool handle_reset(void) { uint32_t chip_id = DEVICE.ChipId.r32; if (!chip_id) @@ -279,17 +278,27 @@ void handle_reset(void) wait_for_rx(&DEVICE1, &SHM1); wait_for_rx(&DEVICE2, &SHM2); wait_for_rx(&DEVICE3, &SHM3); + + return true; + } + else + { + // No reset + return false; } } void __attribute__((noreturn)) __start() { - handle_reset(); - - if (DEBUG.WritePointer.r32 >= sizeof(DEBUG.Buffer) || DEBUG.ReadPointer.r32 >= sizeof(DEBUG.Buffer)) + if (handle_reset() || + SHM.RcpuWritePointer.r32 > sizeof(SHM.RcpuPrintfBuffer) || + SHM.RcpuReadPointer.r32 > sizeof(SHM.RcpuPrintfBuffer) || + SHM.RcpuHostReadPointer.r32 > sizeof(SHM.RcpuPrintfBuffer) + ) { - DEBUG.WritePointer.r32 = 0; - DEBUG.ReadPointer.r32 = 0; + SHM.RcpuWritePointer.r32 = 0; + SHM.RcpuReadPointer.r32 = 0; + SHM.RcpuHostReadPointer.r32 = 0; printf("Chip Reset.\n"); } else @@ -297,6 +306,7 @@ void __attribute__((noreturn)) __start() printf("APE Reload.\n"); } + checkSupply(true); printf("Begin APE.\n"); |