27#include <zephyr/drivers/disk.h>
28#include <zephyr/kernel.h>
29#include <zephyr/random/random.h>
30#include <zephyr/storage/disk_access.h>
31#include <zephyr/task_wdt/task_wdt.h>
38#define EMMC_VOLUME_NAME "SD"
40#ifdef CONFIG_TEST_ENABLED
41static uint8_t buffer[512];
42static uint8_t read_buff[512];
43static struct k_work_q test_workq;
50#ifdef CONFIG_TEST_ENABLED
51 const k_work_queue_config cfg = {.name =
"test_workq", .no_yield = 0};
52 k_work_queue_start(&test_workq, test_workq_stack,
53 K_THREAD_STACK_SIZEOF(test_workq_stack),
54 CONFIG_TEST_WORKQUEUE_PRIO, &cfg);
56 k_work_init(&m_test_internal_params.work, &test::exec);
66#ifdef CONFIG_TEST_ENABLED
69 m_test_internal_params.test_id =
static_cast<int>(id);
70 m_test_internal_params.param0 = params.begin()[0];
71 m_test_internal_params.param1 = params.begin()[1];
72 m_test_internal_params.param2 = params.begin()[2];
75 m_test_internal_params.test_id =
static_cast<int>(id);
76 m_test_internal_params.param0 = params.begin()[0];
77 m_test_internal_params.param1 = params.begin()[1];
78 m_test_internal_params.param2 = params.begin()[2];
81 m_test_internal_params.test_id =
static_cast<int>(id);
82 m_test_internal_params.param0 = params.begin()[0];
87 k_work_submit_to_queue(&test_workq, &m_test_internal_params.work);
92test::uhf_tx_simple(uint32_t nframes, uint32_t delay_us, uint32_t len)
98test::sband_tx_simple(uint32_t nframes, uint32_t delay_us, uint32_t len)
103static auto radio_msg = msg_arbiter::msg();
107 uint32_t delay_us, uint32_t len)
126 telemetry::ccsds_tm_header tm_header;
137 tm_header.length = len;
138 for (uint32_t i = 0; i < nframes && m_stop ==
false; i++) {
140 etl::bit_stream_writer bit_stream(
143 tm_header.serialize(bit_stream);
148 radio_msg.data[j] = j;
151 arb.fwd(0, 0, radio_msg, radio_msg.iface, K_FOREVER);
152 k_usleep(std::max(1U, delay_us));
159 return m_emmc_success;
163test::emmc_simple(uint32_t nbytes)
165#ifdef CONFIG_TEST_ENABLED
174 uint32_t sec_size = 512;
176 if (nbytes % sec_size != 0) {
180 int num_of_sectors = nbytes / sec_size;
183 for (uint32_t i = 0; i < sec_size; i++) {
190 for (i = 0; i < num_of_sectors; i++) {
202 if (memcmp(read_buff, buffer, sec_size)) {
205 memset(read_buff, 0xff, sec_size);
207 m_emmc_success =
true;
233 uhf_tx_simple(4, 100000, 512);
234 k_sleep(K_SECONDS(30));
235 sband_tx_simple(10, 100000, 512);
236 k_sleep(K_SECONDS(10));
237 emmc_simple(512 * 1000);
242test::exec(k_work *item)
244#ifdef CONFIG_TEST_ENABLED
247 while (t.m_running) {
254 struct params_work_container *params =
255 CONTAINER_OF(item,
struct params_work_container, work);
256 switch (
static_cast<test_id>(params->test_id)) {
258 t.uhf_tx_simple(params->param0, params->param1, params->param2);
262 t.sband_tx_simple(params->param0, params->param1, params->param2);
266 t.emmc_simple(params->param0);
293test::test() : m_emmc_success(false), m_running(false), m_stop(false)
comms::lib::emmc & emmc()
Returns a reference to the eMMC subsystem.
comms::lib::fpga & fpga()
Returns a reference to the FPGA subsystem.
static board & get_instance()
Gets a reference to the single instance of the Board interface class.
void enable(bool set=false)
void enable(bool en=true)
Enable/disable the FPGA subsystem.
interface
Radio interface identifier.
static constexpr size_t mtu
static msg_arbiter & get_instance()
Singleton access to a unique and global msg_arbiter instance.
bool emmc_success() const
test(test const &)=delete
void exec_test(test_id id, std::initializer_list< uint32_t > params)
static test & get_instance()
void emc_routine()
A simple routine for EMC testing.
K_THREAD_STACK_DEFINE(radio_rx_thread_stack, CONFIG_RADIO_RX_THREAD_STACK_SIZE)