Raspberry Pi Bare Bones Rust: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
No edit summary |
mNo edit summary |
||
Line 1:
{{FirstPerson}}
{{BeginnersWarning}}
{{Rating|3}}
In this tutorial we will directly follow [[Raspberry_Pi_Bare_Bones]] to accomplish the same task using Rust, instead of C.
Line 13 ⟶ 15:
In the C tutorial, you created a reference to a symbol "kernel_main" in boot.S.
<source lang="asm">
// Call kernel_main
ldr r3, =kernel_main
</
At the end of that tutorial, the compiled kernel.c object file kernel.o provided a definition for this symbol using its function "kernel_main" to the linker when creating kernel.elf.
Line 38 ⟶ 40:
We will use [https://github.com/japaric/xargo xargo] to build our project, which works just like a drop-in replacement for Cargo. xargo automatically handles the significant task of compiling and linking in components of the Rust language we will need (such as libcore.rs) for our target.
<source lang="bash">
xargo new kernel
cd kernel
rustup override set nightly
</
This creates our crate and tells rustup to use the nightly Rust toolchain for it. We will need features of Rust that are not available in stable.
Line 48 ⟶ 50:
In this directory create a file called arm-none-eabihf.json with this content:
<source lang="python">
{
"llvm-target": "arm-none-eabihf",
Line 64 ⟶ 66:
"no-compiler-rt": true
}
</
Rust uses LLVM as a backend, which expects this kind of specification file for non-standard (has no triple) compilation targets. Filling out the values of this is beyond the scope of this tutorial; more information can be found in [https://github.com/japaric/rust-cross rust-cross] which covers cross compiling Rust in detail.
Line 90 ⟶ 92:
Now, revisit the command which built kernel.elf in the C tutorial, but instead of kernel.o, provide the libkernel.rlib xargo just built in the target directory.
<source lang="bash">
This is it! You've built Rust code for bare metal arm that will run on the Raspberry Pi!
Line 180 ⟶ 182:
<source lang="bash">
</source>
|