STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
emmc_stm32.c File Reference
#include "emmc_stm32.h"
#include <string.h>
#include "board.h"
#include "cmsis_os2.h"
#include "main.h"
Include dependency graph for emmc_stm32.c:

Go to the source code of this file.

Macros

#define LEGACY_MAX_HZ   26000000UL
#define AXI_SRAM_START   0x24000000UL
#define AXI_SRAM_END   0x24050000UL /* 320 KB with the default TCM split */
#define LOG_CHUNKS   4U /* 64 KB: ~1 s of card stall at ~60 kB/s */

Functions

static bool dma_reachable (const void *p, uint32_t bytes)
static bool dcache_on (void)
static uint32_t divider_for (uint32_t kernel_hz, uint32_t max_hz)
static void clamp_clock (void)
static emmc_status_t wait_transfer_state (uint32_t deadline)
static emmc_status_t finish (uint32_t budget_ms)
static emmc_status_t port_start (void *context, uint32_t *block_count)
static emmc_status_t port_read (void *context, uint32_t lba, void *buffer, uint32_t count, uint32_t budget_ms)
static emmc_status_t port_write (void *context, uint32_t lba, const void *buffer, uint32_t count, uint32_t budget_ms)
static void port_lock (void *context)
static void port_unlock (void *context)
void HAL_MMC_TxCpltCallback (MMC_HandleTypeDef *hmmc)
void HAL_MMC_RxCpltCallback (MMC_HandleTypeDef *hmmc)
void HAL_MMC_ErrorCallback (MMC_HandleTypeDef *hmmc)
emmc_status_t emmc_stm32_init (void)
emmc_log_t * emmc_stm32_log (void)
const emmc_card_info_t * emmc_stm32_card (uint32_t *issues)
void emmc_stm32_writer_task (void *argument)

Variables

MMC_HandleTypeDef hmmc1
static emmc_log_chunk_t chunks[LOG_CHUNKS] BOARD_DMA_BUFFER
static emmc_log_t flight_log
static osMutexId_t queue_mutex
static osSemaphoreId_t transfer_done
static volatile bool transfer_ok
static emmc_card_info_t card
static uint32_t card_issues
static bool card_known
static const emmc_port_t port

Macro Definition Documentation

◆ AXI_SRAM_END

#define AXI_SRAM_END   0x24050000UL /* 320 KB with the default TCM split */

Definition at line 39 of file emmc_stm32.c.

Referenced by dma_reachable().

◆ AXI_SRAM_START

#define AXI_SRAM_START   0x24000000UL

Definition at line 38 of file emmc_stm32.c.

Referenced by dma_reachable().

◆ LEGACY_MAX_HZ

#define LEGACY_MAX_HZ   26000000UL

Definition at line 37 of file emmc_stm32.c.

Referenced by clamp_clock(), and port_start().

◆ LOG_CHUNKS

#define LOG_CHUNKS   4U /* 64 KB: ~1 s of card stall at ~60 kB/s */

Definition at line 40 of file emmc_stm32.c.

Referenced by emmc_stm32_init().

Function Documentation

◆ clamp_clock()

void clamp_clock ( void )
static

◆ dcache_on()

bool dcache_on ( void )
static

Definition at line 69 of file emmc_stm32.c.

References SCB, and SCB_CCR_DC_Msk.

Referenced by port_read(), and port_write().

◆ divider_for()

uint32_t divider_for ( uint32_t kernel_hz,
uint32_t max_hz )
static

Definition at line 73 of file emmc_stm32.c.

Referenced by clamp_clock(), and port_start().

◆ dma_reachable()

bool dma_reachable ( const void * p,
uint32_t bytes )
static

Definition at line 61 of file emmc_stm32.c.

References a, AXI_SRAM_END, AXI_SRAM_START, and p.

Referenced by port_read(), port_start(), and port_write().

◆ emmc_stm32_card()

const emmc_card_info_t * emmc_stm32_card ( uint32_t * issues)

Definition at line 250 of file emmc_stm32.c.

References card, card_issues, card_known, and NULL.

◆ emmc_stm32_init()

◆ emmc_stm32_log()

emmc_log_t * emmc_stm32_log ( void )

Definition at line 246 of file emmc_stm32.c.

References flight_log.

Referenced by app_set_state(), to_emmc(), and to_emmc().

◆ emmc_stm32_writer_task()

void emmc_stm32_writer_task ( void * argument)

Definition at line 260 of file emmc_stm32.c.

References emmc_log_backlog(), emmc_log_service(), flight_log, osDelay(), and osKernelGetTickCount().

Referenced by start_emmc().

◆ finish()

◆ HAL_MMC_ErrorCallback()

void HAL_MMC_ErrorCallback ( MMC_HandleTypeDef * hmmc)

Definition at line 226 of file emmc_stm32.c.

References hmmc1, osSemaphoreRelease(), transfer_done, and transfer_ok.

◆ HAL_MMC_RxCpltCallback()

void HAL_MMC_RxCpltCallback ( MMC_HandleTypeDef * hmmc)

Definition at line 222 of file emmc_stm32.c.

References HAL_MMC_TxCpltCallback().

◆ HAL_MMC_TxCpltCallback()

void HAL_MMC_TxCpltCallback ( MMC_HandleTypeDef * hmmc)

Definition at line 215 of file emmc_stm32.c.

References hmmc1, osSemaphoreRelease(), transfer_done, and transfer_ok.

Referenced by HAL_MMC_RxCpltCallback().

◆ port_lock()

void port_lock ( void * context)
static

Definition at line 200 of file emmc_stm32.c.

References osMutexAcquire(), osWaitForever, and queue_mutex.

◆ port_read()

emmc_status_t port_read ( void * context,
uint32_t lba,
void * buffer,
uint32_t count,
uint32_t budget_ms )
static

◆ port_start()

◆ port_unlock()

void port_unlock ( void * context)
static

Definition at line 205 of file emmc_stm32.c.

References osMutexRelease(), and queue_mutex.

◆ port_write()

emmc_status_t port_write ( void * context,
uint32_t lba,
const void * buffer,
uint32_t count,
uint32_t budget_ms )
static

◆ wait_transfer_state()

emmc_status_t wait_transfer_state ( uint32_t deadline)
static

Definition at line 90 of file emmc_stm32.c.

References EMMC_ERR_TIMEOUT, EMMC_OK, hmmc1, osDelay(), and osKernelGetTickCount().

Referenced by finish().

Variable Documentation

◆ BOARD_DMA_BUFFER

uint32_t ext_csd [EMMC_BLOCK_SIZE / 4U] BOARD_DMA_BUFFER
static

Definition at line 47 of file emmc_stm32.c.

◆ card

emmc_card_info_t card
static

Definition at line 55 of file emmc_stm32.c.

Referenced by emmc_stm32_card(), port_start(), and read_image().

◆ card_issues

uint32_t card_issues
static

Definition at line 56 of file emmc_stm32.c.

Referenced by emmc_stm32_card(), and port_start().

◆ card_known

bool card_known
static

Definition at line 57 of file emmc_stm32.c.

Referenced by emmc_stm32_card(), and port_start().

◆ flight_log

emmc_log_t flight_log
static

Definition at line 51 of file emmc_stm32.c.

Referenced by emmc_stm32_init(), emmc_stm32_log(), and emmc_stm32_writer_task().

◆ hmmc1

◆ port

const emmc_port_t port
static
Initial value:
static emmc_status_t port_read(void *context, uint32_t lba, void *buffer, uint32_t count, uint32_t budget_ms)
Definition emmc_stm32.c:164
static emmc_status_t port_write(void *context, uint32_t lba, const void *buffer, uint32_t count, uint32_t budget_ms)
Definition emmc_stm32.c:182
static void port_lock(void *context)
Definition emmc_stm32.c:200
static void port_unlock(void *context)
Definition emmc_stm32.c:205
static emmc_status_t port_start(void *context, uint32_t *block_count)
Definition emmc_stm32.c:115

Definition at line 210 of file emmc_stm32.c.

Referenced by sequencer::AbortBroadcaster::AbortBroadcaster(), anonymous_namespace{daq_bridge_main.cpp}::BackendLogForwarder::BackendLogForwarder(), StarOTA::PortableServer::begin(), daqtest::BoardListener::BoardListener(), bringup_task(), sequencer::AbortBroadcaster::configure(), daq_comms::transport::TCPClient::connect(), fsw::elodin::ElodinClient::connect(), fsw::elodin::ElodinClient::connect_locked(), anonymous_namespace{heartbeat_service_main.cpp}::elodinThread(), anonymous_namespace{stacklight_service_main.cpp}::elodinThread(), emmc_log_init(), emmc_stm32_init(), idle_init(), idle_task(), led(), log_new(), main(), main(), main(), sequencer::PressureFeed::operator=(), StarOTA::PortableServer::PortableServer(), runControlServer(), sequencer::PressureFeed::runLoop(), self_test_init(), StarOTA::Server::Server(), setup(), setup(), sequencer::PressureFeed::start(), test_init_rejects_bad_input(), test_invalid_init(), test_invalid_inputs(), test_request_id_is_on_the_wire(), test_reset_and_copied_dependencies(), test_injector_layout.TestIgniter::test_the_section_says_why_the_port_is_red(), test_wake_before_enter_is_error(), anonymous_namespace{idle_e2e.cpp}::world_init(), world_init(), writeFixture(), writeFixture(), and writeFixture().

◆ queue_mutex

osMutexId_t queue_mutex
static

Definition at line 52 of file emmc_stm32.c.

Referenced by emmc_stm32_init(), port_lock(), and port_unlock().

◆ transfer_done

osSemaphoreId_t transfer_done
static

◆ transfer_ok

volatile bool transfer_ok
static

Definition at line 54 of file emmc_stm32.c.

Referenced by finish(), HAL_MMC_ErrorCallback(), and HAL_MMC_TxCpltCallback().