You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pull in the ATDF file from Microchip and add all the necessary plumbing
around the code-base to make it compile.
It hasn't been tested much yet. So far, I've tested some accesses to the
PORTx register on hardware. The common patches for the xmega series seem
reasonable, so I've applied them. Additionally, VPORTA.DIR was patched
out for 2 series devices because it doesn't work. VPORTA.DIR is mapped
to memory address 0x0. This address is commonly used as NULL pointer and
it looks like rust isn't able to handle accesses to that address [1]. To
check that, I've created a short example programm accessing VPORTA.DIR
[2] and checking the resulting binary with avr-objdump [3]. The produced
binary panics as soon as I'm trying to access VPORTA.DIR [4]. By
changing the code to access a different register of VPORTA like OUT, the
code produces a sane binary [5].
[1] https://users.rust-lang.org/t/reading-from-physical-address-0x0/117408/2
[2]
```
#![no_std]
#![no_main]
use panic_halt as _;
pub extern "C" fn main() -> ! {
let dp = unsafe { avr_device::attiny1626::Peripherals::steal() };
dp.vporta.dir().write(|w| w.set(1 << 7));
loop {}
}
```
[3] `avr-objdump -D -m tinyavr2 target/avr-none/debug/test.elf`
[4]
```
000000a0 <main>:
a0: 81 e0 ldi r24, 0x01 ; 1
a2: 80 93 00 38 sts 0x3800, r24 ; 0x803800 <DEVICE_PERIPHERALS>
a6: 0e 94 59 00 call 0xb2 ; 0xb2 <_ZN4core9panicking14panic_nounwind17h63d81beb9bde1088E>
```
[5]
```
000000a0 <main>:
a0: 81 e0 ldi r24, 0x01 ; 1
a2: 80 93 00 38 sts 0x3800, r24 ; 0x803800 <DEVICE_PERIPHERALS>
a6: 80 e8 ldi r24, 0x80 ; 128
a8: 81 b9 out 0x01, r24 ; 1
aa: ff cf rjmp .-2 ; 0xaa <.Luint32_t_name+0x3>
```
Signed-off-by: Corvin Köhne <c.koehne@beckhoff.com>
0 commit comments