Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RISC-VボードでRustを動かす話

Daniel
July 03, 2019

 RISC-VボードでRustを動かす話

最近買ったRISC-VボードHifive1 RevBの上でRustを動かす話です。(時間の関係ではなせなかった部分が少し増えてます)

Daniel

July 03, 2019
Tweet

More Decks by Daniel

Other Decks in Technology

Transcript

  1. ⾃⼰紹介 Self Self { { name name: : " ダニエル"

    " ダニエル", , school school: : " 東京農⼯⼤学" " 東京農⼯⼤学", , twitter twitter: : "@daniel_program" "@daniel_program", , } }
  2. rustから使いやすいようにCを書く freedom-e-sdk void void led_on led_on( () ) { {.

    .. .. .} } void void led_off led_off( () ) { {. .. .. .} } int int main main( () ) { { . .. .. . blink_rs blink_rs( () ); ; } }
  3. rustを書く extern extern { { fn fn led_on led_on( ()

    ); ; fn fn led_off led_off( () ); ; } } #[no_mangle] #[no_mangle] pub pub extern extern fn fn blink_rs blink_rs( () ) { { loop loop { { unsafe unsafe{ { led_on led_on( () ); ; } } delay delay( () ); ; unsafe unsafe{ { led_off led_off( () ); ; } } delay delay( () ); ; } } } }
  4. staticlib Cargo.toml [ [package package] ] name name = =

    "blink" "blink" version version = = "0.1.0" "0.1.0" authors authors = = [ ["Daniel" "Daniel"] ] edition edition = = "2018" "2018" [ [lib lib] ] crate-type crate-type= =[ ["staticlib" "staticlib"] ] [ [dependencies dependencies] ]
  5. cbindgen $ cargo $ cargo install install cbindgen cbindgen $

    cbindgen $ cbindgen . . .. .... .. void blink_rs void blink_rs( (void void) ); ;