Hello!
I'm compiling some rust code for the avr attiny85 and have a big problem: it seems that code for interrupt handlers is not created! I've tried to create a minimal program to reproduce this:
#![allow(dead_code)]
#![allow(non_snake_case)] // for ISRs
#![feature(abi_avr_interrupt)]
#![feature(core_intrinsics)]
#![no_main]
#![no_std]
use attiny_hal::{clock, delay, prelude::*};
use avr_device;
use avr_device::interrupt;
static mut A: u8 = 7;
#[no_mangle]
pub extern "C" fn main() {
let mut delay = delay::Delay::<clock::MHz1>::new();
loop {
delay.delay_ms(1u16);
}
}
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
// __vector_15
#[interrupt(attiny85)]
fn USI_OVF() {
unsafe {
A += 1;
}
}
// __vector_3
#[interrupt(attiny85)]
fn PCINT0() {
unsafe {
A += 1;
}
}
According to the attiny documentation, USI_OVF
is vector 15, but using nm
, that is not generated at all:
00000054 W __vector_1
00000054 W __vector_10
00000054 W __vector_11
00000054 W __vector_12
00000054 W __vector_13
00000086 T __vector_14
00000086 T __vector_2
00000054 W __vector_3
00000054 W __vector_4
00000054 W __vector_5
00000054 W __vector_6
00000054 W __vector_7
00000054 W __vector_8
00000054 W __vector_9
00000000 W __vector_default
That result is completely unexpected for me. No __vector_15
at all, __vector_3
(i.e. PCINT0
) is there, but doesn't use my code. Therefore, vectors 2 and 14 have an implementation (the same?)...
Do I have something completely misconfigured?
That's the cargo.toml:
[package]
name = "rust-attiny85-missing-interrupt"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[profile.dev]
panic = "abort"
lto = true
opt-level = "s"
debug-assertions = false
[profile.release]
debug=true
panic = "abort"
lto = false
codegen-units = 1
opt-level = "s"
debug-assertions = true
strip = false
[dependencies]
avr-device = "0.5.1"
[dependencies.attiny-hal]
git = "https://github.com/rahix/avr-hal"
version = "0.1.0"
features = ["attiny85", "rt"]
.cargo/config:
[build]
target = "avr-attiny85.json"
[unstable]
build-std = ["core", "panic_abort"]
build-std-features = [ "panic_immediate_abort" ]
avr-attiny85.json:
{
"arch": "avr",
"atomic-cas": false,
"cpu": "attiny85",
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
"eh-frame-header": false,
"exe-suffix": ".elf",
"executables": true,
"late-link-args": {
"gcc": [
"-lgcc"
]
},
"linker": "avr-gcc",
"llvm-target": "avr-unknown-unknown",
"max-atomic-width": 8,
"no-default-libraries": false,
"pre-link-args": {
"gcc": [
"-mmcu=attiny85"
]
},
"target-c-int-width": "16",
"target-pointer-width": "16"
}
I completely don't understand this result and hope someone can help me...
cu
Markus