booting/
booting.rs

1//! Minimal example of setting up program booting without the `#[vexide::main]` attribute macro.
2
3#![no_main]
4#![no_std]
5
6extern crate alloc;
7use alloc::boxed::Box;
8
9use vex_sdk::vexTasksRun;
10use vexide_core::println;
11use vexide_startup::{
12    banner::themes::THEME_DEFAULT, CodeSignature, ProgramFlags, ProgramOwner, ProgramType,
13};
14
15// SAFETY: This symbol is unique and is being used to start the vexide runtime.
16#[unsafe(no_mangle)]
17unsafe extern "C" fn _start() -> ! {
18    unsafe {
19        vexide_startup::startup::<true>(THEME_DEFAULT);
20
21        // Write something to the screen to test if the program is running
22        let test_box = Box::new(100);
23        vex_sdk::vexDisplayRectFill(0, 0, *test_box, 200);
24        println!("Hello, world!");
25        vexTasksRun(); // Flush serial
26    }
27
28    // Exit once we're done.
29    vexide_core::program::exit();
30}
31
32// SAFETY: The code signature needs to be in this section so it may be found by VEXos.
33#[unsafe(link_section = ".code_signature")]
34#[used] // This is needed to prevent the linker from removing this object in release builds
35static CODE_SIG: CodeSignature = CodeSignature::new(
36    ProgramType::User,
37    ProgramOwner::Partner,
38    ProgramFlags::empty(),
39);
40
41#[panic_handler]
42const fn panic(_info: &core::panic::PanicInfo<'_>) -> ! {
43    loop {}
44}