Hi all !
Posting my issue because I'm stuck now...
Here is the thing. I'm working on some bare metal rust project for Raspberry Pi B+. I followed some tutorials to get a led blinking and it worked. Now i'm on my way to have the UART working.
My problem is the following, this piece of code :
pub fn register_write(reg: usize, offset: usize, mask: usize, val: usize)
{
unsafe {
let register = reg as *mut usize;
*(register) &= !mask;
*(register) |= val << offset;
}
}
Is leading to this linker error :
undefined reference to 'core::panicking::panic_misaligned_pointer_dereference'
So here is how I compile :
#!/bin/bash
cargo build \
--target arm-none-eabihf.json \
-Z build-std=core,compiler_builtins
sleep 1
arm-none-eabi-gcc -g -mcpu=arm1176jzf-s -fpic -ffreestanding -c boot.S -o boot.o
arm-none-eabi-gcc -g -T linker.ld -o myos.elf -ffreestanding -O2 -nostdlib boot.o $1
where $1 is the .rlib issued by cargo.
my cargo.toml
[package]
name = "rust-kernel"
version = "0.1.0"
edition = "2021"
[dependencies]
[profile.dev]
panic = "abort"
debug-assertions = true # !
incremental = false
codegen-units = 1
opt-level = 'z' # !
debug = 2
overflow-checks = false
debug-assertions=false
And my arm-none-eabihf.json
{
"llvm-target": "arm-none-eabihf",
"target-endian": "little",
"target-pointer-width": "32",
"target-c-int-width": "32",
"os": "none",
"env": "eabi",
"vendor": "unknown",
"arch": "arm",
"linker-flavor": "gcc",
"linker": "arm-none-eabihf-gcc",
"pre-link-args": {
"gcc": [
"-Wall",
"-nostdlib",
"-nostartfiles",
"-ffreestanding",
"-march=armv6"
]
},
"data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
"executables": "true",
"relocation-model": "static",
"no-compiler-rt": "true"
}
So my understanding is that, for some reason, gcc does not find this function anywhere. Which is understandable according to core::panicking - Rust because this function seems to be private ?
Anyway. I'm about to rede things using llvm as it may be more relevant but I'm afraid to face the same issue without understanding what's going on.
Can someone enlight me ?