#startup #vex-v5 #vex-robotics #v5 #vex

no-std vexide-startup

Support code for V5 Brain user program booting

20 unstable releases (3 breaking)

new 0.4.3-rc.1 Apr 9, 2025
0.4.2 Mar 6, 2025
0.4.2-beta.3 Feb 22, 2025
0.4.1 Jan 31, 2025
0.1.2 May 20, 2024

#262 in Robotics

Download history 21/week @ 2024-12-17 9/week @ 2025-01-07 4/week @ 2025-01-14 94/week @ 2025-01-21 304/week @ 2025-01-28 55/week @ 2025-02-04 34/week @ 2025-02-11 371/week @ 2025-02-18 206/week @ 2025-02-25 278/week @ 2025-03-04 85/week @ 2025-03-11 50/week @ 2025-03-18 53/week @ 2025-03-25 42/week @ 2025-04-01

241 downloads per month
Used in 2 crates (via vexide)

MIT license

755KB
4.5K SLoC

Contains (static library, 505KB) link/libm.a

User program startup routines.

This crate provides runtime infrastructure for booting VEX user programs from Rust code.

  • User code begins at an assembly routine called _boot, which sets up the stack section before jumping to a user-provided _start symbol, which should be your rust entrypoint. This routine can be found in boot.S.

  • From there, the Rust _start entrypoint may call the startup function to finish the startup process by clearing the .bss section (which stores uninitialized data) and initializing vexide's heap allocator.

This crate does NOT provide a libc crt0 implementation. No libc-style global constructors are called. This means that the __libc_init_array function must be explicitly called if you wish to link to C libraries.

Example

This is an example of a minimal user program that boots without using the main vexide runtime or the #[vexide::main] macro.

#![no_main]
#![no_std]

use vexide_startup::{CodeSignature, ProgramFlags, ProgramOwner, ProgramType};

// SAFETY: This symbol is unique and is being used to start the runtime.
#[unsafe(no_mangle)]
unsafe extern "C" fn _start() -> ! {
    // Setup the heap, zero bss, apply patches, etc...
    unsafe {
        vexide_startup::startup();
    }

    // Rust code goes here!

    // Exit the program once we're done.
    vexide_core::program::exit();
}

// Program header (placed at the first 20 bytes on the binary).
#[unsafe(link_section = ".code_signature")]
#[used] // This is needed to prevent the linker from removing this object in release builds
static CODE_SIG: CodeSignature = CodeSignature::new(
    ProgramType::User,
    ProgramOwner::Partner,
    ProgramFlags::empty(),
);

// Panic handler (this would normally be provided by `veixde_panic`).
#[panic_handler]
const fn panic(_info: &core::panic::PanicInfo<'_>) -> ! {
    loop {}
}

vexide-startup

Startup primitives for the vexide runtime. This project provides a bare-metal entrypoint that freestanding Rust binaries can leverage to run on the VEX V5 Brain.

This includes:

  • Stack setup
  • Code signature/program header types
  • BSS section handling
  • Global allocator setup for vexide_core.

Dependencies

~1.7–2.6MB
~47K SLoC