From 67078f6242baaa2cffbd6a60e52f4e66e71da50c Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sun, 31 May 2020 16:37:44 +0000 Subject: [PATCH] rust: Fixes for newer dependencies --- rust/Cargo.toml | 6 ++++ rust/accelerometer/Cargo.toml | 2 +- rust/accelerometer/src/main.rs | 4 +-- rust/buffered-uart/.cargo/config | 4 --- rust/buffered-uart/Cargo.toml | 2 +- rust/buffered-uart/build.rs | 13 ------- rust/buffered-uart/src/lib.rs | 58 +++++++++++++------------------ rust/buffered-uart/trap.x | 2 -- rust/cryptest/Cargo.toml | 2 +- rust/cryptest/src/main.rs | 4 +-- rust/dvp-ov/Cargo.toml | 2 +- rust/dvp-ov/src/main.rs | 4 +-- rust/embgfx/Cargo.toml | 2 +- rust/embgfx/src/main.rs | 4 +-- rust/game-of-life/Cargo.toml | 2 +- rust/game-of-life/src/main.rs | 4 +-- rust/glyph-mapping/Cargo.toml | 2 +- rust/glyph-mapping/src/main.rs | 4 +-- rust/interrupt/.cargo/config | 4 --- rust/interrupt/Cargo.toml | 2 +- rust/interrupt/build.rs | 13 ------- rust/interrupt/src/main.rs | 8 ++--- rust/interrupt/trap.x | 2 -- rust/k210-console/Cargo.toml | 2 +- rust/k210-console/src/main.rs | 4 +-- rust/k210-shared/Cargo.toml | 2 +- rust/k210-shared/src/panic.rs | 4 +-- rust/k210-shared/src/soc/i2c.rs | 2 +- rust/mandelbrot/Cargo.toml | 2 +- rust/mandelbrot/src/main.rs | 4 +-- rust/rgbcontrol/Cargo.toml | 2 +- rust/rgbcontrol/src/main.rs | 4 +-- rust/sdlcd/Cargo.toml | 2 +- rust/sdlcd/src/main.rs | 4 +-- rust/sdtest/Cargo.toml | 2 +- rust/sdtest/src/main.rs | 4 +-- rust/secp256k1-test/Cargo.toml | 2 +- rust/secp256k1-test/src/main.rs | 4 +-- rust/term-server/.cargo/config | 4 --- rust/term-server/Cargo.toml | 2 +- rust/term-server/src/main.rs | 4 +-- rust/uart-passthrough/Cargo.toml | 2 +- rust/uart-passthrough/src/main.rs | 20 ++++++----- rust/voxel/Cargo.toml | 2 +- rust/voxel/src/main.rs | 4 +-- rust/weather/.cargo/config | 4 --- rust/weather/Cargo.toml | 2 +- rust/weather/src/main.rs | 6 ++-- 48 files changed, 99 insertions(+), 145 deletions(-) delete mode 100644 rust/buffered-uart/.cargo/config delete mode 100644 rust/buffered-uart/build.rs delete mode 100644 rust/buffered-uart/trap.x delete mode 100644 rust/interrupt/.cargo/config delete mode 100644 rust/interrupt/build.rs delete mode 100644 rust/interrupt/trap.x delete mode 100644 rust/term-server/.cargo/config delete mode 100644 rust/weather/.cargo/config diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 93c91ed..3dd8c0d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -21,6 +21,12 @@ members = [ [patch.crates-io] +k210-hal = { git = "https://github.com/riscv-rust/k210-hal.git", rev = "fdf1ad61af8f756765a65133bb2d08cda686be6f" } +riscv = { git = "https://github.com/rust-embedded/riscv.git", rev = "422a1625cfd666f927eae485629fa7f96be5ebd0" } + +# Remove this after https://github.com/ilya-epifanov/riscv-target/pull/1 or similar merged +riscv-target = { git = "https://github.com/laanwj/riscv-target.git", rev = "189b5261ecdd40f18eb1b82614d6876aa88bd744" } + # This patch was merged upstream, unfortunately, rust-secp256k1 puts a restriction on # cc_rs <= 1.0.41 so we can't actually use the newer version yet. cc = { git = "https://github.com/laanwj/cc-rs.git", rev = "83e66a79a25b55d0aa84db42257a8edbb0095cf8" } diff --git a/rust/accelerometer/Cargo.toml b/rust/accelerometer/Cargo.toml index 5063b78..33ddfab 100644 --- a/rust/accelerometer/Cargo.toml +++ b/rust/accelerometer/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" libm = "0.1" diff --git a/rust/accelerometer/src/main.rs b/rust/accelerometer/src/main.rs index 2b091d8..9aa1cd1 100644 --- a/rust/accelerometer/src/main.rs +++ b/rust/accelerometer/src/main.rs @@ -4,7 +4,7 @@ #![no_std] #![no_main] -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT,MSA300_SLV_ADDR,MSA300_ADDR_BITS,MSA300_CLK}; @@ -63,7 +63,7 @@ fn main() -> ! { usleep(200000); // Configure UART - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/buffered-uart/.cargo/config b/rust/buffered-uart/.cargo/config deleted file mode 100644 index 27904bc..0000000 --- a/rust/buffered-uart/.cargo/config +++ /dev/null @@ -1,4 +0,0 @@ -[target.riscv64gc-unknown-none-elf] -rustflags = [ - "-C", "link-arg=-Ttrap.x", -] diff --git a/rust/buffered-uart/Cargo.toml b/rust/buffered-uart/Cargo.toml index 31fc8c9..d8d972e 100644 --- a/rust/buffered-uart/Cargo.toml +++ b/rust/buffered-uart/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] bare-metal = "0.2.0" -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = { version = "0.5", features = ["inline-asm"] } k210-shared = { path = "../k210-shared" } diff --git a/rust/buffered-uart/build.rs b/rust/buffered-uart/build.rs deleted file mode 100644 index 0d3e283..0000000 --- a/rust/buffered-uart/build.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::{env, fs}; -use std::path::PathBuf; -use std::io::Write; - -fn main() { - // Put the linker script somewhere the linker can find it - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - println!("cargo:rustc-link-search={}", out_dir.display()); - - fs::File::create(out_dir.join("trap.x")).unwrap() - .write_all(include_bytes!("trap.x")).unwrap(); - println!("cargo:rerun-if-changed=trap.x"); -} diff --git a/rust/buffered-uart/src/lib.rs b/rust/buffered-uart/src/lib.rs index b7bc09b..7858016 100644 --- a/rust/buffered-uart/src/lib.rs +++ b/rust/buffered-uart/src/lib.rs @@ -11,7 +11,7 @@ use k210_hal::pac; use k210_shared::soc::sysctl; use pac::interrupt::Interrupt; use riscv::asm; -use riscv::register::{mcause, mhartid, mie, mip, mstatus}; +use riscv::register::{mhartid, mie, mip, mstatus}; const UART_BUFSIZE: usize = 8192; /** UART ring buffer */ @@ -80,42 +80,34 @@ fn interrupt_uart1() { } } -/** Global trap handler */ +/** PLIC interrupts */ +#[allow(non_snake_case)] #[no_mangle] -fn my_trap_handler() { - let hartid = mhartid::read(); - let cause = mcause::read().cause(); - match cause { - // PLIC interrupts - mcause::Trap::Interrupt(mcause::Interrupt::MachineExternal) => { - if mip::read().mext() { - unsafe { - let plic = pac::PLIC::ptr(); - let target = &(*plic).targets[hartid * 2]; - let int_num = target.claim.read().bits(); - let int = Interrupt::try_from(int_num as u8).unwrap(); +fn MachineExternal() { + if mip::read().mext() { + unsafe { + let hartid = mhartid::read(); + let plic = pac::PLIC::ptr(); + let target = &(*plic).targets[hartid * 2]; + let int_num = target.claim.read().bits(); + let int = Interrupt::try_from(int_num as u8).unwrap(); - // Does this really need the 'disable other interrupts, change threshold' dance - // as done in handle_irq_m_ext in plic.c? - match int { - Interrupt::UART1 => interrupt_uart1(), - // We'll get a spurious UARTHS interrupt, ignore it - Interrupt::UARTHS => {} - _ => { - panic!( - "unknown machineexternal {:?} on {}, int {:?}", - cause, hartid, int - ); - } - } - - // Perform IRQ complete - target.claim.write(|w| w.bits(int_num)); + // Does this really need the 'disable other interrupts, change threshold' dance + // as done in handle_irq_m_ext in plic.c? + match int { + Interrupt::UART1 => interrupt_uart1(), + // We'll get a spurious UARTHS interrupt, ignore it + Interrupt::UARTHS => {} + _ => { + panic!( + "unknown machineexternal hart {}, int {:?}", + hartid, int + ); } } - } - _ => { - panic!("unknown trap {:?}", cause); + + // Perform IRQ complete + target.claim.write(|w| w.bits(int_num)); } } } diff --git a/rust/buffered-uart/trap.x b/rust/buffered-uart/trap.x deleted file mode 100644 index d58bc44..0000000 --- a/rust/buffered-uart/trap.x +++ /dev/null @@ -1,2 +0,0 @@ -/* set our own trap handler */ -trap_handler = my_trap_handler; diff --git a/rust/cryptest/Cargo.toml b/rust/cryptest/Cargo.toml index bf328e8..1dcebf5 100644 --- a/rust/cryptest/Cargo.toml +++ b/rust/cryptest/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" k210-hal = "0.2.0" k210-shared = { path = "../k210-shared" } riscv = "0.5" -riscv-rt = "0.6" +riscv-rt = "0.7" hex-literal = "0.2" sha2 = { version = "0.8", default-features = false } aes-soft = { version = "0.3" } diff --git a/rust/cryptest/src/main.rs b/rust/cryptest/src/main.rs index a2adccd..d8d05ca 100644 --- a/rust/cryptest/src/main.rs +++ b/rust/cryptest/src/main.rs @@ -8,7 +8,7 @@ use core::iter; use hex_literal::hex; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_shared::soc::sleep::usleep; use k210_shared::soc::sysctl; use k210_shared::soc::aes::{self, cipher_mode, encrypt_sel}; @@ -50,7 +50,7 @@ fn main() -> ! { // Configure UART let serial = p .UARTHS - .configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + .configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/dvp-ov/Cargo.toml b/rust/dvp-ov/Cargo.toml index 2bb3fc3..9a33250 100644 --- a/rust/dvp-ov/Cargo.toml +++ b/rust/dvp-ov/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/dvp-ov/src/main.rs b/rust/dvp-ov/src/main.rs index 299131a..7a15b04 100644 --- a/rust/dvp-ov/src/main.rs +++ b/rust/dvp-ov/src/main.rs @@ -4,7 +4,7 @@ #![no_std] #![no_main] -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT,DISP_PIXELS}; @@ -68,7 +68,7 @@ fn main() -> ! { usleep(200000); // Configure UART - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/embgfx/Cargo.toml b/rust/embgfx/Cargo.toml index 0b1ced1..b768fb3 100644 --- a/rust/embgfx/Cargo.toml +++ b/rust/embgfx/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" libm = "0.1" diff --git a/rust/embgfx/src/main.rs b/rust/embgfx/src/main.rs index db7d5cb..b7f9d88 100644 --- a/rust/embgfx/src/main.rs +++ b/rust/embgfx/src/main.rs @@ -13,7 +13,7 @@ use embedded_graphics::primitives::{Circle, Rectangle}; use embedded_graphics::{text_6x8, Drawing}; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_shared::board::def::{io, DISP_HEIGHT, DISP_PIXELS, DISP_WIDTH}; use k210_shared::board::lcd::{self, LCD, LCDHL}; use k210_shared::board::lcd_render::ScreenImage; @@ -96,7 +96,7 @@ fn main() -> ! { // Configure UART let serial = p .UARTHS - .configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + .configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/game-of-life/Cargo.toml b/rust/game-of-life/Cargo.toml index 199d830..6bebceb 100644 --- a/rust/game-of-life/Cargo.toml +++ b/rust/game-of-life/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/game-of-life/src/main.rs b/rust/game-of-life/src/main.rs index 97bfebe..5e7ad8d 100644 --- a/rust/game-of-life/src/main.rs +++ b/rust/game-of-life/src/main.rs @@ -4,7 +4,7 @@ #![no_std] #![no_main] -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT,DISP_PIXELS,NS2009_SLV_ADDR,NS2009_CAL,NS2009_ADDR_BITS,NS2009_CLK}; @@ -150,7 +150,7 @@ fn main() -> ! { usleep(200000); // Configure UART - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/glyph-mapping/Cargo.toml b/rust/glyph-mapping/Cargo.toml index 6b8d3e1..99af6da 100644 --- a/rust/glyph-mapping/Cargo.toml +++ b/rust/glyph-mapping/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/glyph-mapping/src/main.rs b/rust/glyph-mapping/src/main.rs index 3a3ea9c..4390779 100644 --- a/rust/glyph-mapping/src/main.rs +++ b/rust/glyph-mapping/src/main.rs @@ -7,7 +7,7 @@ use k210_console::console::{Console, ScreenImage}; use k210_console::cp437; use k210_console::cp437_8x8::{FONT, GLYPH_BY_FILL}; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT,DISP_PIXELS}; @@ -79,7 +79,7 @@ fn main() -> ! { usleep(200000); // Configure UART - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/interrupt/.cargo/config b/rust/interrupt/.cargo/config deleted file mode 100644 index 27904bc..0000000 --- a/rust/interrupt/.cargo/config +++ /dev/null @@ -1,4 +0,0 @@ -[target.riscv64gc-unknown-none-elf] -rustflags = [ - "-C", "link-arg=-Ttrap.x", -] diff --git a/rust/interrupt/Cargo.toml b/rust/interrupt/Cargo.toml index 4897b39..df4f759 100644 --- a/rust/interrupt/Cargo.toml +++ b/rust/interrupt/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = { version = "0.5", features = ["inline-asm"] } k210-shared = { path = "../k210-shared" } diff --git a/rust/interrupt/build.rs b/rust/interrupt/build.rs deleted file mode 100644 index 0d3e283..0000000 --- a/rust/interrupt/build.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::{env, fs}; -use std::path::PathBuf; -use std::io::Write; - -fn main() { - // Put the linker script somewhere the linker can find it - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - println!("cargo:rustc-link-search={}", out_dir.display()); - - fs::File::create(out_dir.join("trap.x")).unwrap() - .write_all(include_bytes!("trap.x")).unwrap(); - println!("cargo:rerun-if-changed=trap.x"); -} diff --git a/rust/interrupt/src/main.rs b/rust/interrupt/src/main.rs index d94d98f..093e8af 100644 --- a/rust/interrupt/src/main.rs +++ b/rust/interrupt/src/main.rs @@ -4,7 +4,6 @@ #![no_std] #![no_main] -use k210_hal::Peripherals; use k210_hal::pac; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; @@ -29,8 +28,9 @@ struct IntrInfo { static mut INTR_INFO: Option = None; +#[allow(non_snake_case)] #[no_mangle] -fn my_trap_handler() { +fn MachineSoft() { let hartid = mhartid::read(); let cause = mcause::read().cause(); @@ -44,7 +44,7 @@ fn my_trap_handler() { #[entry] fn main() -> ! { - let p = Peripherals::take().unwrap(); + let p = pac::Peripherals::take().unwrap(); sysctl::pll_set_freq(sysctl::pll::PLL0, 800_000_000).unwrap(); sysctl::pll_set_freq(sysctl::pll::PLL1, 300_000_000).unwrap(); sysctl::pll_set_freq(sysctl::pll::PLL2, 45_158_400).unwrap(); @@ -53,7 +53,7 @@ fn main() -> ! { usleep(200000); // Configure UART - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/interrupt/trap.x b/rust/interrupt/trap.x deleted file mode 100644 index d58bc44..0000000 --- a/rust/interrupt/trap.x +++ /dev/null @@ -1,2 +0,0 @@ -/* set our own trap handler */ -trap_handler = my_trap_handler; diff --git a/rust/k210-console/Cargo.toml b/rust/k210-console/Cargo.toml index 551fc1d..fc31947 100644 --- a/rust/k210-console/Cargo.toml +++ b/rust/k210-console/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/k210-console/src/main.rs b/rust/k210-console/src/main.rs index e8bcae7..44a7ebf 100644 --- a/rust/k210-console/src/main.rs +++ b/rust/k210-console/src/main.rs @@ -9,7 +9,7 @@ mod lfsr; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_shared::board::def::io; use k210_shared::board::lcd::{self, LCD, LCDHL}; use k210_shared::board::lcd_colors; @@ -62,7 +62,7 @@ fn main() -> ! { // Configure UART let serial = p .UARTHS - .configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + .configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/k210-shared/Cargo.toml b/rust/k210-shared/Cargo.toml index 16cab16..ca69300 100644 --- a/rust/k210-shared/Cargo.toml +++ b/rust/k210-shared/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" k210-hal = "0.2.0" libm = "0.1" riscv = "0.5" -riscv-rt = "0.6" +riscv-rt = "0.7" diff --git a/rust/k210-shared/src/panic.rs b/rust/k210-shared/src/panic.rs index b38915d..23c175b 100644 --- a/rust/k210-shared/src/panic.rs +++ b/rust/k210-shared/src/panic.rs @@ -1,5 +1,5 @@ /** Panic handler: based on ARM panic-itm */ -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use core::panic::PanicInfo; @@ -12,7 +12,7 @@ fn panic(info: &PanicInfo) -> ! { // also, can we really know the state? let p = unsafe { Peripherals::steal() }; let clocks = k210_hal::clock::Clocks::new(); - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); writeln!(stdout, "{}", info).unwrap(); diff --git a/rust/k210-shared/src/soc/i2c.rs b/rust/k210-shared/src/soc/i2c.rs index 8edd8b8..618318d 100644 --- a/rust/k210-shared/src/soc/i2c.rs +++ b/rust/k210-shared/src/soc/i2c.rs @@ -59,7 +59,7 @@ impl I2C for I2CImpl { sysctl::clock_set_threshold(IF::DIV, 3); sysctl::reset(IF::RESET); - let v_i2c_freq = sysctl::clock_get_freq(sysctl::clock::I2C0); + let v_i2c_freq = sysctl::clock_get_freq(IF::CLK); let v_period_clk_cnt = v_i2c_freq / i2c_clk / 2; let v_period_clk_cnt: u16 = v_period_clk_cnt.try_into().unwrap(); let v_period_clk_cnt = cmp::max(v_period_clk_cnt, 1); diff --git a/rust/mandelbrot/Cargo.toml b/rust/mandelbrot/Cargo.toml index 6666e4b..8311102 100644 --- a/rust/mandelbrot/Cargo.toml +++ b/rust/mandelbrot/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/mandelbrot/src/main.rs b/rust/mandelbrot/src/main.rs index 3beee29..e5f23db 100644 --- a/rust/mandelbrot/src/main.rs +++ b/rust/mandelbrot/src/main.rs @@ -6,7 +6,7 @@ mod palette; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT}; @@ -65,7 +65,7 @@ fn main() -> ! { usleep(200000); // Configure UART - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/rgbcontrol/Cargo.toml b/rust/rgbcontrol/Cargo.toml index 72e4aa8..4acd9d7 100644 --- a/rust/rgbcontrol/Cargo.toml +++ b/rust/rgbcontrol/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" k210-hal = "0.2.0" k210-shared = { path = "../k210-shared" } riscv = "0.5" -riscv-rt = "0.6" +riscv-rt = "0.7" diff --git a/rust/rgbcontrol/src/main.rs b/rust/rgbcontrol/src/main.rs index e95edcd..6e1936e 100644 --- a/rust/rgbcontrol/src/main.rs +++ b/rust/rgbcontrol/src/main.rs @@ -5,7 +5,7 @@ #![no_main] use core::cmp::{min,max}; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use k210_shared::board::def::{ @@ -76,7 +76,7 @@ fn main() -> ! { usleep(200000); - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/sdlcd/Cargo.toml b/rust/sdlcd/Cargo.toml index 1d40fa5..e6f2be5 100644 --- a/rust/sdlcd/Cargo.toml +++ b/rust/sdlcd/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] nb = "0.1.1" -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/sdlcd/src/main.rs b/rust/sdlcd/src/main.rs index bddd88b..0b960f9 100644 --- a/rust/sdlcd/src/main.rs +++ b/rust/sdlcd/src/main.rs @@ -10,7 +10,7 @@ use core::convert::TryInto; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_shared::board::def::{io, DISP_HEIGHT, DISP_PIXELS, DISP_WIDTH}; use k210_shared::board::lcd::{self, LCD, LCDHL}; use k210_shared::board::lcd_colors; @@ -67,7 +67,7 @@ fn main() -> ! { // Configure UART let serial = p .UARTHS - .configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + .configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/sdtest/Cargo.toml b/rust/sdtest/Cargo.toml index b605656..1f91cb9 100644 --- a/rust/sdtest/Cargo.toml +++ b/rust/sdtest/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] nb = "0.1.1" -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/sdtest/src/main.rs b/rust/sdtest/src/main.rs index ff38762..18231d3 100644 --- a/rust/sdtest/src/main.rs +++ b/rust/sdtest/src/main.rs @@ -7,7 +7,7 @@ use core::convert::TryInto; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_shared::board::def::io; use k210_shared::board::sdcard; use k210_shared::soc::dmac::{dma_channel, DMACExt}; @@ -69,7 +69,7 @@ fn main() -> ! { // Configure UART let serial = p .UARTHS - .configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + .configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/secp256k1-test/Cargo.toml b/rust/secp256k1-test/Cargo.toml index 8e2af2a..589deca 100644 --- a/rust/secp256k1-test/Cargo.toml +++ b/rust/secp256k1-test/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/secp256k1-test/src/main.rs b/rust/secp256k1-test/src/main.rs index 12361df..1a74237 100644 --- a/rust/secp256k1-test/src/main.rs +++ b/rust/secp256k1-test/src/main.rs @@ -6,7 +6,7 @@ #![no_std] #![no_main] -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use riscv_rt::entry; @@ -30,7 +30,7 @@ fn main() -> ! { usleep(200000); - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + let serial = p.UARTHS.configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/term-server/.cargo/config b/rust/term-server/.cargo/config deleted file mode 100644 index 27904bc..0000000 --- a/rust/term-server/.cargo/config +++ /dev/null @@ -1,4 +0,0 @@ -[target.riscv64gc-unknown-none-elf] -rustflags = [ - "-C", "link-arg=-Ttrap.x", -] diff --git a/rust/term-server/Cargo.toml b/rust/term-server/Cargo.toml index 702c3f1..6f40bf8 100644 --- a/rust/term-server/Cargo.toml +++ b/rust/term-server/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] embedded-hal = { version = "0.2.1", features = ["unproven"] } nb = "0.1.1" -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/term-server/src/main.rs b/rust/term-server/src/main.rs index 9f1b22d..a960a80 100644 --- a/rust/term-server/src/main.rs +++ b/rust/term-server/src/main.rs @@ -8,7 +8,7 @@ use core::str; use esp8266at::handler::{NetworkEvent, SerialNetworkHandler}; use esp8266at::response::{parse, ParseResult}; use esp8266at::traits; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use k210_shared::board::def::io; @@ -77,7 +77,7 @@ fn main() -> ! { io_init(); // Configure UARTHS (→host) - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), DEFAULT_BAUD.bps(), &clocks); + let serial = p.UARTHS.configure(DEFAULT_BAUD.bps(), &clocks); let (mut tx, mut _rx) = serial.split(); let mut debug = Stdout(&mut tx); diff --git a/rust/uart-passthrough/Cargo.toml b/rust/uart-passthrough/Cargo.toml index e19e444..21540b1 100644 --- a/rust/uart-passthrough/Cargo.toml +++ b/rust/uart-passthrough/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] nb = "0.1.1" -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/uart-passthrough/src/main.rs b/rust/uart-passthrough/src/main.rs index 19e962f..f8b8b4e 100644 --- a/rust/uart-passthrough/src/main.rs +++ b/rust/uart-passthrough/src/main.rs @@ -4,7 +4,7 @@ #![no_std] #![no_main] -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_hal::prelude::*; use k210_hal::serial::Serial; use k210_shared::board::def::io; @@ -27,17 +27,19 @@ fn main() -> ! { let clocks = k210_hal::clock::Clocks::new(); // Configure UARTHS (→host) - let mut serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), DEFAULT_BAUD.bps(), &clocks); + let mut serial = p.UARTHS.configure( DEFAULT_BAUD.bps(), &clocks); let (mut tx, mut rx) = serial.split(); // Configure UART1 (→WIFI) sysctl::clock_enable(sysctl::clock::UART1); sysctl::reset(sysctl::reset::UART1); + fpioa::set_function(io::WIFI_RX, fpioa::function::UART1_TX); + fpioa::set_function(io::WIFI_TX, fpioa::function::UART1_RX); fpioa::set_function(io::WIFI_EN, fpioa::function::GPIOHS8); fpioa::set_io_pull(io::WIFI_EN, fpioa::pull::DOWN); gpiohs::set_pin(8, true); gpiohs::set_direction(8, gpio::direction::OUTPUT); - let mut wifi_serial = p.UART1.configure((p.pins.pin7, p.pins.pin6), DEFAULT_BAUD.bps(), &clocks); + let mut wifi_serial = p.UART1.configure(DEFAULT_BAUD.bps(), &clocks); let (mut wtx, mut wrx) = wifi_serial.split(); // Relay characters between UARTs @@ -46,8 +48,8 @@ fn main() -> ! { // OOB restores safe baudrate for UARTHS, to be sure we're able to recover from // sync failures let mut rate = DEFAULT_BAUD; - let (userial, pins) = Serial::join(tx, rx).free(); - serial = userial.configure(pins, rate.bps(), &clocks); + let userial = Serial::join(tx, rx).free(); + serial = userial.configure(rate.bps(), &clocks); let s = serial.split(); tx = s.0; rx = s.1; @@ -59,8 +61,8 @@ fn main() -> ! { rate = u32::from(d[0]) | (u32::from(d[1]) << 8) | (u32::from(d[2]) << 16) | (u32::from(d[3]) << 24); // re-configure UARTHS at new rate - let (userial, pins) = Serial::join(tx, rx).free(); - serial = userial.configure(pins, rate.bps(), &clocks); + let userial = Serial::join(tx, rx).free(); + serial = userial.configure(rate.bps(), &clocks); let s = serial.split(); tx = s.0; rx = s.1; @@ -73,8 +75,8 @@ fn main() -> ! { _ => {} } // re-configure UART1 - let (wifi_userial, wifi_pins) = Serial::join(wtx, wrx).free(); - wifi_serial = wifi_userial.configure(wifi_pins, rate.bps(), &clocks); + let wifi_userial = Serial::join(wtx, wrx).free(); + wifi_serial = wifi_userial.configure(rate.bps(), &clocks); let s = wifi_serial.split(); wtx = s.0; wrx = s.1; diff --git a/rust/voxel/Cargo.toml b/rust/voxel/Cargo.toml index 33a3002..cf40ff0 100644 --- a/rust/voxel/Cargo.toml +++ b/rust/voxel/Cargo.toml @@ -5,7 +5,7 @@ authors = ["W.J. van der Laan "] edition = "2018" [dependencies] -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/voxel/src/main.rs b/rust/voxel/src/main.rs index 67e19dd..30819b9 100644 --- a/rust/voxel/src/main.rs +++ b/rust/voxel/src/main.rs @@ -7,7 +7,7 @@ use libm::F32Ext; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; -use k210_hal::Peripherals; +use k210_hal::pac::Peripherals; use k210_shared::board::def::{io, DISP_HEIGHT, DISP_PIXELS, DISP_WIDTH, MSA300_SLV_ADDR,MSA300_ADDR_BITS,MSA300_CLK}; use k210_shared::board::lcd::{self, LCD, LCDHL}; use k210_shared::board::lcd_colors; @@ -178,7 +178,7 @@ fn main() -> ! { // Configure UART let serial = p .UARTHS - .configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks); + .configure(115_200.bps(), &clocks); let (mut tx, _) = serial.split(); let mut stdout = Stdout(&mut tx); diff --git a/rust/weather/.cargo/config b/rust/weather/.cargo/config deleted file mode 100644 index 27904bc..0000000 --- a/rust/weather/.cargo/config +++ /dev/null @@ -1,4 +0,0 @@ -[target.riscv64gc-unknown-none-elf] -rustflags = [ - "-C", "link-arg=-Ttrap.x", -] diff --git a/rust/weather/Cargo.toml b/rust/weather/Cargo.toml index 82fe12d..e20095a 100644 --- a/rust/weather/Cargo.toml +++ b/rust/weather/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] embedded-hal = { version = "0.2.1", features = ["unproven"] } nb = "0.1.1" -riscv-rt = "0.6" +riscv-rt = "0.7" k210-hal = "0.2.0" riscv = "0.5" k210-shared = { path = "../k210-shared" } diff --git a/rust/weather/src/main.rs b/rust/weather/src/main.rs index dd93b86..e0ae80a 100644 --- a/rust/weather/src/main.rs +++ b/rust/weather/src/main.rs @@ -8,7 +8,7 @@ use core::str; use esp8266at::handler::{NetworkEvent, SerialNetworkHandler}; use esp8266at::response::{parse, ConnectionType, ParseResult}; use esp8266at::traits::{self, Write}; -use k210_hal::{Peripherals, pac}; +use k210_hal::pac; use k210_hal::prelude::*; use k210_hal::stdout::Stdout; use k210_shared::board::def::io; @@ -106,7 +106,7 @@ fn show_uart_info(debug: &mut dyn core::fmt::Write, uart: *const pac::uart1::Reg #[entry] fn main() -> ! { - let p = Peripherals::take().unwrap(); + let p = pac::Peripherals::take().unwrap(); sysctl::pll_set_freq(sysctl::pll::PLL0, 800_000_000).unwrap(); sysctl::pll_set_freq(sysctl::pll::PLL1, 300_000_000).unwrap(); sysctl::pll_set_freq(sysctl::pll::PLL2, 45_158_400).unwrap(); @@ -116,7 +116,7 @@ fn main() -> ! { io_init(); // Configure UARTHS (→host) - let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), DEFAULT_BAUD.bps(), &clocks); + let serial = p.UARTHS.configure(DEFAULT_BAUD.bps(), &clocks); let (mut tx, mut _rx) = serial.split(); let mut debug = Stdout(&mut tx);