RefCell
when you need a &mut T
reference, Cell
if you just need a copy of T
atmega_hal
crate? I can only find examples which use arduino_hal
. When I try to use it with atmega_hal
the compiler tells me that I should explicitely set a concrete type for CLOCK
. How hasatmega_hal::I2c::new(...)
to be called to successfully return I2c
?
memcmp
return i16
on AVR, it includes dylanmckay's patch to get around the "unrecognized instruction" issue, and it un-reverts the llvm_asm!
removal, since none of the AVR libs have switched over to asm!
yet. You can find it here, there are some very basic compilation instructions at the top of the README: https://github.com/drmorr0/rust/tree/drmorr-custom-rustc
Hi!
Can't compile blank project or blink.
Windows 7 x64
nightly-x86_64-pc-windows-msvc
and
nightly-2021-01-07-x86_64-pc-windows-msvc
main.rs
#![no_std] // from the previous step
#![no_main]
#[no_mangle]
pub extern fn main() {
//let x=1+1;
}
C:!Electro!RUST\projects\avr168>cargo build -Z build-std=core --target avr-atm
ega328p.json --release
Compiling core v0.0.0 (C:!Electro!RUST.rustup\toolchains\nightly-2021-01-0
7-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core)
Compiling compiler_builtins v0.1.36
Compiling rustc-std-workspace-core v1.99.0 (C:!Electro!RUST.rustup\toolcha
ins\nightly-2021-01-07-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\rustc
-std-workspace-core)
Compiling avr168 v0.1.0 (C:!Electro!RUST\projects\avr168)
error: language item required, but not found: eh_personality
error: #[panic_handler]
function required, but not found
error: aborting due to 2 previous errors
error: could not compile avr168
To learn more, run the command again with --verbose.
How to compile blank project for AVR?
Tnx.
with other toolchain :
C:!Electro!RUST\projects\avr168>cargo build -Z build-std=core --target avr-atm
ega328p.json --release
Compiling core v0.0.0 (C:!Electro!RUST.rustup\toolchains\nightly-x86_64-pc
-windows-msvc\lib\rustlib\src\rust\library\core)
Compiling compiler_builtins v0.1.71
warning: target json file contains unused fields: no-compiler-rt
Compiling rustc-std-workspace-core v1.99.0 (C:!Electro!RUST.rustup\toolcha
ins\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\rustc-std-worksp
ace-core)
warning: rustc-std-workspace-core
(lib) generated 1 warning (1 duplicate)
LLVM ERROR: Not supported instr: <MCInst 323 <MCOperand Reg:1> <MCOperand Imm:13
<MCOperand Reg:43>>
warning:compiler_builtins
(lib) generated 1 warning (1 duplicate)
error: could not compilecompiler_builtins
; 1 warning emitted
warning: build failed, waiting for other jobs to finish...
warning:core
(lib) generated 1 warning
I haven't Arduino (some atmega48 and 168 chips).
Set to 2021-01-07
Get some parts from template (cargo.toml):
[package]
name = "avr168"
version = "0.1.0"
authors = [""]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
panic-halt = "0.2.0"
ufmt = "0.1.0"
nb = "0.1.2"
embedded-hal = "0.2.3"
# Configure the build for minimal size - AVRs have very little program memory
[profile.dev]
panic = "abort"
lto = true
opt-level = "s"
[profile.release]
panic = "abort"
codegen-units = 1
debug = false
lto = true
opt-level = "s"
main.rs
#![no_std] // from the previous step
#![no_main]
#![feature(llvm_asm)]
use panic_halt as _;
#[no_mangle]
pub extern fn main() {
loop {
unsafe {
llvm_asm!("NOP"); }
}
}
Now it's ok, but minimum size 500 byte :(
#![no_std] // from the previous step
#![no_main]
#![feature(llvm_asm)]
use panic_halt as _;
extern crate avrd;
use avrd::current::*; // Import constants for the target MCU
//use core::intrinsics::volatile_store;
//#[no_mangle]
fn main() {
unsafe {
llvm_asm!("NOP");
}
let mut number: u8 = 12;
number-=1;
match number {
11 => number-=3,
12 => unsafe {llvm_asm!("NOP;
NOP;
NOP;")},
_ => unsafe {llvm_asm!("NOP")},
}
}
Can't understand how to use.nightly-2022-06-13
, so maybe that's been resolved?