diff options
| author | Prashanth Mundkur | 2018-07-10 16:27:03 -0700 |
|---|---|---|
| committer | Prashanth Mundkur | 2018-07-10 17:02:37 -0700 |
| commit | a480edc06d0a803c7ec133fe462005155d163bf7 (patch) | |
| tree | b11fbd7ad7fe4ae8035aadf37ff00031ec584fa0 /riscv/platform_impl.ml | |
| parent | 585c1b81c8e6efd3d7a84f317e1f3e18b84cbe89 (diff) | |
Add an option to specify the dtc to use for the riscv platform.
Diffstat (limited to 'riscv/platform_impl.ml')
| -rw-r--r-- | riscv/platform_impl.ml | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/riscv/platform_impl.ml b/riscv/platform_impl.ml index 5c238a1e..e593dce9 100644 --- a/riscv/platform_impl.ml +++ b/riscv/platform_impl.ml @@ -113,10 +113,23 @@ let dts = spike_dts "rv64imac" cpu_hz insns_per_tick mems;; let bytes_to_string bytes = String.init (List.length bytes) (fun i -> Char.chr (List.nth bytes i)) +let dtc_path = ref "/usr/bin/dtc" + +let set_dtc path = + try let st = Unix.stat path in + if st.Unix.st_kind = Unix.S_REG && st.Unix.st_perm != 0 + then dtc_path := path + else ( Printf.eprintf "%s doesn't seem like a valid executable.\n%!" path; + exit 1) + with Unix.Unix_error (e, _, _) -> + ( Printf.eprintf "Error accessing %s: %s\n%!" path (Unix.error_message e); + exit 1) + let make_dtb dts = (* Call the dtc compiler, assumed to be at /usr/bin/dtc *) try + let cmd = Printf.sprintf "%s -I dts" !dtc_path in let (cfrom, cto, cerr) = - Unix.open_process_full "/usr/bin/dtc -I dts" [||] + Unix.open_process_full cmd [||] in ( output_string cto dts; (* print_endline " sent dts to dtc ..."; *) @@ -136,7 +149,7 @@ let make_dtb dts = (* Call the dtc compiler, assumed to be at /usr/bin/dtc *) let emsg = bytes_to_string (accum_bytes cerr []) in match Unix.close_process_full (cfrom, cto, cerr) with | Unix.WEXITED 0 -> dtb - | _ -> (Printf.printf "%s\n" ("Error executing dtc: " ^ emsg); + | _ -> (Printf.printf "%s\n%!" ("Error executing dtc: " ^ emsg); exit 1) ) with Unix.Unix_error (e, fn, _) -> |
