├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── bin ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── lib ├── Cargo.toml └── src │ └── lib.rs └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | **/*.rs.bk 3 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "ansi_term" 5 | version = "0.11.0" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | dependencies = [ 8 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 9 | ] 10 | 11 | [[package]] 12 | name = "atty" 13 | version = "0.2.13" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | dependencies = [ 16 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 17 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 18 | ] 19 | 20 | [[package]] 21 | name = "bitflags" 22 | version = "1.2.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | 25 | [[package]] 26 | name = "byteorder" 27 | version = "1.3.2" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | 30 | [[package]] 31 | name = "clap" 32 | version = "2.33.0" 33 | source = "registry+https://github.com/rust-lang/crates.io-index" 34 | dependencies = [ 35 | "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 36 | "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", 37 | "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 38 | "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 39 | "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 40 | "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 41 | "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", 42 | ] 43 | 44 | [[package]] 45 | name = "libc" 46 | version = "0.2.62" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | 49 | [[package]] 50 | name = "strsim" 51 | version = "0.8.0" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | 54 | [[package]] 55 | name = "textwrap" 56 | version = "0.11.0" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | dependencies = [ 59 | "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 60 | ] 61 | 62 | [[package]] 63 | name = "uf2" 64 | version = "0.1.0" 65 | dependencies = [ 66 | "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 67 | ] 68 | 69 | [[package]] 70 | name = "uf2conv-rs" 71 | version = "0.1.0" 72 | dependencies = [ 73 | "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 74 | "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", 75 | "uf2 0.1.0", 76 | ] 77 | 78 | [[package]] 79 | name = "unicode-width" 80 | version = "0.1.6" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | 83 | [[package]] 84 | name = "vec_map" 85 | version = "0.8.1" 86 | source = "registry+https://github.com/rust-lang/crates.io-index" 87 | 88 | [[package]] 89 | name = "winapi" 90 | version = "0.3.8" 91 | source = "registry+https://github.com/rust-lang/crates.io-index" 92 | dependencies = [ 93 | "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 94 | "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 95 | ] 96 | 97 | [[package]] 98 | name = "winapi-i686-pc-windows-gnu" 99 | version = "0.4.0" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | 102 | [[package]] 103 | name = "winapi-x86_64-pc-windows-gnu" 104 | version = "0.4.0" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | 107 | [metadata] 108 | "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" 109 | "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" 110 | "checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" 111 | "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" 112 | "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" 113 | "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" 114 | "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 115 | "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 116 | "checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" 117 | "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" 118 | "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" 119 | "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 120 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 121 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | members = [ 4 | "bin", 5 | "lib" 6 | ] 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 Paul Sajna 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /bin/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "ansi_term" 3 | version = "0.11.0" 4 | source = "registry+https://github.com/rust-lang/crates.io-index" 5 | dependencies = [ 6 | "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 7 | ] 8 | 9 | [[package]] 10 | name = "atty" 11 | version = "0.2.11" 12 | source = "registry+https://github.com/rust-lang/crates.io-index" 13 | dependencies = [ 14 | "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", 15 | "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 16 | "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 17 | ] 18 | 19 | [[package]] 20 | name = "bitflags" 21 | version = "1.0.4" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | 24 | [[package]] 25 | name = "byteorder" 26 | version = "1.2.6" 27 | source = "registry+https://github.com/rust-lang/crates.io-index" 28 | 29 | [[package]] 30 | name = "clap" 31 | version = "2.32.0" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | dependencies = [ 34 | "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 35 | "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", 36 | "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 37 | "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 38 | "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 39 | "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 40 | "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", 41 | ] 42 | 43 | [[package]] 44 | name = "libc" 45 | version = "0.2.43" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | 48 | [[package]] 49 | name = "redox_syscall" 50 | version = "0.1.40" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | 53 | [[package]] 54 | name = "redox_termios" 55 | version = "0.1.1" 56 | source = "registry+https://github.com/rust-lang/crates.io-index" 57 | dependencies = [ 58 | "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", 59 | ] 60 | 61 | [[package]] 62 | name = "strsim" 63 | version = "0.7.0" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | 66 | [[package]] 67 | name = "termion" 68 | version = "1.5.1" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | dependencies = [ 71 | "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", 72 | "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 74 | ] 75 | 76 | [[package]] 77 | name = "textwrap" 78 | version = "0.10.0" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | dependencies = [ 81 | "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 82 | ] 83 | 84 | [[package]] 85 | name = "uf2conv-rs" 86 | version = "0.1.0" 87 | dependencies = [ 88 | "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 89 | "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", 90 | ] 91 | 92 | [[package]] 93 | name = "unicode-width" 94 | version = "0.1.5" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | 97 | [[package]] 98 | name = "vec_map" 99 | version = "0.8.1" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | 102 | [[package]] 103 | name = "winapi" 104 | version = "0.3.6" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | dependencies = [ 107 | "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 108 | "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 109 | ] 110 | 111 | [[package]] 112 | name = "winapi-i686-pc-windows-gnu" 113 | version = "0.4.0" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | 116 | [[package]] 117 | name = "winapi-x86_64-pc-windows-gnu" 118 | version = "0.4.0" 119 | source = "registry+https://github.com/rust-lang/crates.io-index" 120 | 121 | [metadata] 122 | "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" 123 | "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" 124 | "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" 125 | "checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781" 126 | "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" 127 | "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" 128 | "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" 129 | "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" 130 | "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" 131 | "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" 132 | "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" 133 | "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" 134 | "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" 135 | "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" 136 | "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 137 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 138 | -------------------------------------------------------------------------------- /bin/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uf2conv" 3 | version = "0.1.0" 4 | authors = ["Paul Sajna "] 5 | license = "MIT" 6 | description = "Tool for converting a binary file to a uf2 file" 7 | 8 | [dependencies] 9 | clap = "2.32" 10 | byteorder = "1.2" 11 | 12 | [dependencies.uf2] 13 | path = "../lib" 14 | version = "0.1.0" 15 | -------------------------------------------------------------------------------- /bin/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate byteorder; 2 | extern crate clap; 3 | extern crate uf2; 4 | 5 | use std::error::Error as ErrorTrait; 6 | use std::fs::File; 7 | use std::io::prelude::*; 8 | use std::path::Path; 9 | 10 | use clap::{App, Arg}; 11 | use uf2::bin_to_uf2; 12 | 13 | fn main() -> Result<(), std::io::Error> { 14 | let matches = App::new("UF2Conv") 15 | .version("0.1") 16 | .author("Paul Sajna ") 17 | .about("Converts binary files to Microsoft's UF2 format https://github.com/Microsoft/uf2") 18 | .arg( 19 | Arg::with_name("base") 20 | .short("b") 21 | .long("base") 22 | .help("Sets base address of application for BIN format") 23 | .default_value("0x2000") 24 | .takes_value(true), 25 | ) 26 | .arg( 27 | Arg::with_name("INPUT") 28 | .help("Sets the input file to use") 29 | .required(true) 30 | .index(1), 31 | ) 32 | .arg( 33 | Arg::with_name("output") 34 | .short("o") 35 | .long("output") 36 | .help("Write output to named file") 37 | .default_value("flash.uf2"), 38 | ) 39 | .arg( 40 | Arg::with_name("family") 41 | .short("f") 42 | .long("family") 43 | .default_value("0x0") 44 | .help("specify familyID number") 45 | .takes_value(true), 46 | ) 47 | .get_matches(); 48 | 49 | let path = Path::new(matches.value_of("INPUT").unwrap()); 50 | let display = path.display(); 51 | let mut file = match File::open(&path) { 52 | Err(why) => panic!("couldn't open {}: {}", display, why.description()), 53 | Ok(file) => file, 54 | }; 55 | let mut buffer = Vec::new(); 56 | file.read_to_end(&mut buffer)?; 57 | 58 | let family_id = 59 | u32::from_str_radix(&matches.value_of("family").unwrap()[2..], 16).unwrap_or(0x0); 60 | let base = u32::from_str_radix(&matches.value_of("base").unwrap()[2..], 16).unwrap_or(0x2000); 61 | 62 | let uf2 = bin_to_uf2(&buffer, family_id, base); 63 | 64 | let outpath = Path::new(matches.value_of("output").unwrap()); 65 | let display = outpath.display(); 66 | let mut outfile = match File::create(&outpath) { 67 | Err(why) => panic!("couldn't create {}: {}", display, why.description()), 68 | Ok(outfile) => outfile, 69 | }; 70 | outfile.write(&uf2?)?; 71 | Ok(()) 72 | } 73 | -------------------------------------------------------------------------------- /lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uf2" 3 | description = "Library for working with the Microsoft's UF2 file format" 4 | version = "0.1.0" 5 | authors = ["Paul Sajna "] 6 | edition = "2018" 7 | license = "MIT" 8 | 9 | [dependencies] 10 | byteorder = "1.2" 11 | -------------------------------------------------------------------------------- /lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate byteorder; 2 | 3 | use std::io::prelude::*; 4 | 5 | use byteorder::{LittleEndian, WriteBytesExt}; 6 | 7 | const UF2_MAGIC_START0: u32 = 0x0A324655; // "UF2\n" 8 | const UF2_MAGIC_START1: u32 = 0x9E5D5157; // Randomly selected 9 | const UF2_MAGIC_END: u32 = 0x0AB16F30; // Ditto 10 | 11 | pub fn bin_to_uf2( 12 | bytes: &Vec, 13 | family_id: u32, 14 | app_start_addr: u32, 15 | ) -> Result, std::io::Error> { 16 | let datapadding = [0u8; 512 - 256 - 32 - 4]; 17 | let nblocks: u32 = ((bytes.len() + 255) / 256) as u32; 18 | let mut outp: Vec = Vec::new(); 19 | for blockno in 0..nblocks { 20 | let ptr = 256 * blockno; 21 | let chunk = match bytes.get(ptr as usize..ptr as usize + 256) { 22 | Some(bytes) => bytes.to_vec(), 23 | None => { 24 | let mut chunk = bytes[ptr as usize..bytes.len()].to_vec(); 25 | while chunk.len() < 256 { 26 | chunk.push(0); 27 | } 28 | chunk 29 | } 30 | }; 31 | let mut flags: u32 = 0; 32 | if family_id != 0 { 33 | flags |= 0x2000 34 | } 35 | 36 | // header 37 | outp.write_u32::(UF2_MAGIC_START0)?; 38 | outp.write_u32::(UF2_MAGIC_START1)?; 39 | outp.write_u32::(flags)?; 40 | outp.write_u32::(ptr + app_start_addr)?; 41 | outp.write_u32::(256)?; 42 | outp.write_u32::(blockno)?; 43 | outp.write_u32::(nblocks)?; 44 | outp.write_u32::(family_id)?; 45 | 46 | // data 47 | outp.write(&chunk)?; 48 | outp.write(&datapadding)?; 49 | 50 | // footer 51 | outp.write_u32::(UF2_MAGIC_END)?; 52 | } 53 | Ok(outp) 54 | } 55 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # uf2conv 2 | 3 | Adds a uf2 header [Microsofts HID Flashing Format (UF2)](https://github.com/microsoft/uf2/blob/86e101e3a282553756161fe12206c7a609975e70/README.md) for copying over to UF2 bootloader mass storage devices. UF2 is factory programmed extensively by [Microsoft MakeCode](https://www.microsoft.com/en-us/makecode) and [Adafruit](https://www.adafruit.com/) hardware. 4 | 5 | ## Install 6 | `cargo install uf2conv` 7 | 8 | ## Usage 9 | ```bash 10 | $ uf2conv 11 | error: The following required arguments were not provided: 12 | 13 | 14 | USAGE: 15 | uf2conv --base --family --output 16 | 17 | For more information try --help 18 | ``` 19 | 20 | Base usage you'll want to give the --base memory address for your chip. This is where the code starts after the bootloader. In the case of embedded rust, thats found in your memory.x where you'll find `FLASH (rx) : ORIGIN = 0x00000000+0x4000` or `FLASH (rx) : ORIGIN = 0x00000000 + 16K` Where 16K in bytes is 16384 decimal or 0x4000 hex base. 21 | 22 | ```bash 23 | $ uf2conv pygamer_blinky_basic.bin --base 0x4000 --output pygamer_blinky_basic.uf2 24 | ``` 25 | 26 | And you can copy that uf2 file to your embedded device's drive that appears when you enter bootloader mode. 27 | 28 | ## Rust: How to get a bin file 29 | 30 | Use [cargo-binutils](https://github.com/rust-embedded/cargo-binutils) which replaces the `cargo build` command to find and convert elf files into binary. 31 | 32 | Install the dependencies 33 | ```bash 34 | $ rustup component add llvm-tools-preview 35 | $ cargo install uf2conv cargo-binutils 36 | ``` 37 | 38 | Then in your embedded project, say [PyGamer](https://github.com/atsamd-rs/atsamd/tree/master/boards/pygamer) 39 | ```bash 40 | $ cargo objcopy --example blinky_basic --features unproven --release -- -O binary pygamer_blinky_basic.bin 41 | $ uf2conv pygamer_blinky_basic.bin --base 0x4000 --output pygamer_blinky_basic.uf2 42 | ``` 43 | --------------------------------------------------------------------------------