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
241 downloads per month
Used in 2 crates
(via vexide)
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 inboot.S
. -
From there, the Rust
_start
entrypoint may call thestartup
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