looking for linux bug

This commit is contained in:
2025-11-18 12:43:15 +01:00
parent 81ce1e927a
commit c482185ffd
5 changed files with 26 additions and 16 deletions
+7 -5
View File
@@ -17,6 +17,12 @@ set(ROMEO_WARNING_FLAGS
-Wpedantic
-Werror) # TODO so far, this only affects mission code, not bsp
option(ROMEO_LOW_LEVEL_TESTS "enable semihosting for emulation" OFF)
if(${ROMEO_LOW_LEVEL_TESTS})
add_compile_definitions(LOW_LEVEL_TESTS)
endif()
# CMake options which are only available when crosscompiling
if (${CMAKE_CROSSCOMPILING})
set(ZYNQ_UART UART1 CACHE STRING "Which PS UART to use for stdout")
@@ -32,11 +38,7 @@ if (${CMAKE_CROSSCOMPILING})
add_compile_definitions(ARM_SEMIHOSTING)
endif()
option(ROMEO_LOW_LEVEL_TESTS "enable semihosting for emulation" OFF)
if(${ROMEO_LOW_LEVEL_TESTS})
add_compile_definitions(LOW_LEVEL_TESTS)
endif()
else()
unset(ZYNQ_UART)
unset(ZYNQ_UART CACHE)
+1 -1
View File
@@ -46,7 +46,7 @@
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) PTHREAD_STACK_MIN ) /* The stack size being passed is equal to the minimum stack size needed by pthread_create(). */
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 200 * 1024 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 12 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
+10 -4
View File
@@ -206,7 +206,8 @@ impl<const STACKSIZE: usize> StaticThreadInner<STACKSIZE> {
panic!("StaticThread(\"{}\")::spawn: priority {} is larger than maximum ({})", self.name, self.priority, unsafe{super::ffi::freertos_task_priority_max()});
}
let stack = self.stack.take_no_init().unwrap();
// let stack = self.stack.take_no_init().unwrap();
let stack : &mut Box<[core::ffi::c_char;STACKSIZE]> = &mut Box::new([0;STACKSIZE]);
let closure_space = core::mem::size_of::<F>();
// Will be checked later on, but this way we get a more precise output instead of a generic panic
@@ -246,7 +247,8 @@ impl<const STACKSIZE: usize> StaticThreadInner<STACKSIZE> {
);
}
let thread_data = self.thread_data.take_no_init().unwrap();
// let thread_data = self.thread_data.take_no_init().unwrap();
let thread_data: &mut Box<[core::ffi::c_char;ffi::Sizes::TASK_DATA_SIZE]> = &mut Box::new([0;ffi::Sizes::TASK_DATA_SIZE]);
// SAFE: We only pass pointers derived from &'static references to the OS, so the pointers will
// be valid for the complete runtime. This includes values borrowed by the closure
@@ -265,7 +267,11 @@ impl<const STACKSIZE: usize> StaticThreadInner<STACKSIZE> {
panic!("could not create thread");
}
let handle = self.handle.take_no_init().unwrap();
// let handle = self.handle.take_no_init().unwrap();
let handle = &mut Box::new(ThreadHandle {
name: "todo",
freertos_handle: None,
});
handle.freertos_handle = Some(freertos_handle);
// Store the Handle in task local storage, so we can use the rust types later on
@@ -278,7 +284,7 @@ impl<const STACKSIZE: usize> StaticThreadInner<STACKSIZE> {
)
};
// this creates a copy of handle, as it impls Copy
*handle
**handle
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ mod dh;
pub mod fsrc;
mod panic;
#[cfg(feature = "low_level_tests")]
//#[cfg(feature = "low_level_tests")]
mod low_level_tests;
use core::fmt::Write;
+7 -5
View File
@@ -41,7 +41,7 @@ pub static mut CONTROLLER_TASK_HANDLE: *const core::ffi::c_void = 0 as *const co
/// Stack for test threads, is reused as tests are run one after another
///
/// assumes we run in qemu, so memory is no consideration
static TEST_RUNNER_STACK: StaticReadOnceLock<[u8; 1024000]> = StaticReadOnceLock::new([0; 1024000]);
static TEST_RUNNER_STACK: StaticReadOnceLock<[core::ffi::c_char; 1024000]> = StaticReadOnceLock::new([0; 1024000]);
static TEST_RUNNER_THREAD_DATA: StaticReadOnceLock<
[core::ffi::c_char; osal::ffi::Sizes::TASK_DATA_SIZE],
> = StaticReadOnceLock::new([0; osal::ffi::Sizes::TASK_DATA_SIZE]);
@@ -56,15 +56,15 @@ extern "C" fn rust_low_level_tests() {
unsafe { CONTROLLER_TASK_HANDLE = osal::ffi::freertos_task_current() };
run_tests(&mut [function_with_name!(mutex), function_with_name!(fail), function_with_name!(mutex)]);
}
use std::sync::{Arc, Mutex};
/// Runner for low level tests, will attempt to look a bit like std rust tests.
/// expects a function and its name, to print it
/// use the function_with_name! macro to generate the tuple
fn run_tests(tests: &mut [(fn(), &'static str)]) -> ! {
let stack = TEST_RUNNER_STACK.take_no_init().unwrap();
let stack = Arc::new(Mutex::new([0i8;102400]));
let thread_data = TEST_RUNNER_THREAD_DATA.take_no_init().unwrap();
panic!("oh noes");
let thread_data = Arc::new(Mutex::new([0i8;osal::ffi::Sizes::TASK_DATA_SIZE]));
let number_of_tests = tests.len();
@@ -86,11 +86,13 @@ fn run_tests(tests: &mut [(fn(), &'static str)]) -> ! {
// and stack. But as the suspended task will not be restarted, it does work
// in this (testing!) context.
let test_function = test.0 as *const core::ffi::c_void;
let stack = &mut stack.lock().unwrap();
let thread_data = &mut thread_data.lock().unwrap();
unsafe {
osal::ffi::freertos_create_task_static(
run_one_test,
test_function,
0,
2,
thread_data.as_mut_ptr(),
thread_data.len().try_into().unwrap(),
stack.as_mut_ptr(),