diff --git a/.cargo/config.toml b/.cargo/config.toml index 9b886b5..0b32db2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,12 +1,14 @@ -[build] -target = "thumbv8m.main-none-eabihf" +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +runner = "picotool load -u -v -x -t elf" -[target.thumbv8m.main-none-eabihf] rustflags = [ - "-C", "link-arg=--nmagic", - "-C", "link-arg=-Tlink.x", - "-C", "link-arg=-Tdefmt.x", - "-C", "target-cpu=cortex-m33", + "-C", "linker=flip-link", + "-C", "link-arg=--nmagic", + "-C", "link-arg=-Tlink.x", + "-C", "link-arg=-Tdefmt.x", + "-Z", "trap-unreachable=no", + "-C", "no-vectorize-loops", ] -runner = "picotool load -u -v -x -t elf" +[build] +target = "thumbv6m-none-eabi" diff --git a/Cargo.lock b/Cargo.lock index 56ed097..6dadf0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,7 +70,16 @@ checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.106", +] + +[[package]] +name = "crc-any" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62ec9ff5f7965e4d7280bd5482acd20aadb50d632cf6c1d74493856b011fa73" +dependencies = [ + "debug-helper", ] [[package]] @@ -80,10 +89,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" [[package]] -name = "defmt" -version = "0.3.10" +name = "debug-helper" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f6162c53f659f65d00619fe31f14556a6e9f8752ccc4a41bd177ffcf3d6130" +checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e" + +[[package]] +name = "defmt" +version = "0.3.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0963443817029b2024136fc4dd07a5107eb8f977eaf18fcd1fdeb11306b64ad" +dependencies = [ + "defmt 1.0.1", +] + +[[package]] +name = "defmt" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "548d977b6da32fa1d1fda2876453da1e7df63ad0304c8b3dae4dbe7b96f39b78" dependencies = [ "bitflags", "defmt-macros", @@ -91,34 +115,34 @@ dependencies = [ [[package]] name = "defmt-macros" -version = "0.4.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d135dd939bad62d7490b0002602d35b358dce5fd9233a709d3c1ef467d4bde6" +checksum = "3d4fc12a85bcf441cfe44344c4b72d58493178ce635338a3f3b78943aceb258e" dependencies = [ "defmt-parser", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.106", ] [[package]] name = "defmt-parser" -version = "0.4.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3983b127f13995e68c1e29071e5d115cd96f215ccb5e6812e3728cd6f92653b3" +checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" dependencies = [ "thiserror", ] [[package]] name = "defmt-rtt" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab697b3dbbc1750b7c8b821aa6f6e7f2480b47a99bc057a2ed7b170ebef0c51" +checksum = "c6eca0aae8aa2cf8333200ecbd236274697bc0a394765c858b3d9372eb1abcfa" dependencies = [ "critical-section", - "defmt", + "defmt 0.3.100", ] [[package]] @@ -179,9 +203,9 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" [[package]] name = "frunk" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874b6a17738fc273ec753618bac60ddaeac48cb1d7684c3e7bd472e57a28b817" +checksum = "28aef0f9aa070bce60767c12ba9cb41efeaf1a2bc6427f87b7d83f11239a16d7" dependencies = [ "frunk_core", "frunk_derives", @@ -189,31 +213,31 @@ dependencies = [ [[package]] name = "frunk_core" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3529a07095650187788833d585c219761114005d5976185760cf794d265b6a5c" +checksum = "476eeaa382e3462b84da5d6ba3da97b5786823c2d0d3a0d04ef088d073da225c" [[package]] name = "frunk_derives" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e99b8b3c28ae0e84b604c75f721c21dc77afb3706076af5e8216d15fd1deaae3" +checksum = "a0b4095fc99e1d858e5b8c7125d2638372ec85aa0fe6c807105cf10b0265ca6c" dependencies = [ "frunk_proc_macro_helpers", "quote", - "syn 2.0.100", + "syn 2.0.106", ] [[package]] name = "frunk_proc_macro_helpers" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a956ef36c377977e512e227dcad20f68c2786ac7a54dacece3746046fea5ce" +checksum = "1952b802269f2db12ab7c0bd328d0ae8feaabf19f352a7b0af7bb0c5693abfce" dependencies = [ "frunk_core", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.106", ] [[package]] @@ -252,9 +276,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.13.0" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] @@ -311,15 +335,9 @@ checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.106", ] -[[package]] -name = "panic-halt" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a513e167849a384b7f9b746e517604398518590a9142f4846a32e3c2a4de7b11" - [[package]] name = "panic-probe" version = "0.3.2" @@ -327,6 +345,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4047d9235d1423d66cc97da7d07eddb54d4f154d6c13805c6d0793956f4f25b0" dependencies = [ "cortex-m", + "defmt 0.3.100", ] [[package]] @@ -348,9 +367,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" [[package]] name = "proc-macro-error-attr2" @@ -371,23 +390,23 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.106", ] [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -399,79 +418,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] -name = "riscv" -version = "0.11.1" +name = "rp-pico" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5c1b8bf41ea746266cdee443d1d1e9125c86ce1447e1a2615abd34330d33a9" +checksum = "b9342d3ac7011ac688300979e9b52a81f0add1d05feb02868cf94bfee0705b28" dependencies = [ - "critical-section", - "embedded-hal 1.0.0", -] - -[[package]] -name = "riscv-rt" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0d35e32cf1383183e8885d8a9aa4402a087fd094dc34c2cb6df6687d0229dfe" -dependencies = [ - "riscv", - "riscv-rt-macros", -] - -[[package]] -name = "riscv-rt-macros" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30f19a85fe107b65031e0ba8ec60c34c2494069fe910d6c297f5e7cb5a6f76d0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", -] - -[[package]] -name = "rp-binary-info" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534e2a451671116f5b9391cb15fae43b9abdc56817bcaca9a95ed32c3e4c6b38" - -[[package]] -name = "rp-hal-common" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8288358786b1458fb2caac8c4b40fb529ef4200d6c46467e2695b7a8ba573ae8" -dependencies = [ - "fugit", -] - -[[package]] -name = "rp2350-usb-ramdisk" -version = "0.1.0" -dependencies = [ - "cortex-m", "cortex-m-rt", - "critical-section", - "defmt", - "defmt-rtt", - "embedded-hal 1.0.0", - "panic-halt", - "panic-probe", - "rp235x-hal", + "fugit", + "rp2040-boot2", + "rp2040-hal", "usb-device", - "usbd-storage", ] [[package]] -name = "rp235x-hal" +name = "rp2040-boot2" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2939c82776b0b4ae110168b4298b5adf831e6cff249b057bf2a2187453b959c" +checksum = "7c92f344f63f950ee36cf4080050e4dce850839b9175da38f9d2ffb69b4dbb21" +dependencies = [ + "crc-any", +] + +[[package]] +name = "rp2040-hal" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d11e711940087f2cdff8aeae9f4b902e2014c06a00b39a1092686b81ec973d6f" dependencies = [ "bitfield 0.14.0", "cortex-m", - "cortex-m-rt", "critical-section", - "defmt", "embedded-dma", "embedded-hal 0.2.7", "embedded-hal 1.0.0", @@ -480,40 +456,35 @@ dependencies = [ "embedded-io", "frunk", "fugit", - "gcd", "itertools", "nb 1.1.0", "paste", "pio", "rand_core", - "riscv", - "riscv-rt", - "rp-binary-info", - "rp-hal-common", - "rp235x-hal-macros", - "rp235x-pac", - "sha2-const-stable", + "rp2040-hal-macros", + "rp2040-pac", "usb-device", "vcell", "void", ] [[package]] -name = "rp235x-hal-macros" +name = "rp2040-hal-macros" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74edd7a5979e9763bbb98e9746e711bac7464ee3397af7288e6c288ff0d3c764" +checksum = "86479063e497efe1ae81995ef9071f54fd1c7427e04d6c5b84cde545ff672a5e" dependencies = [ + "cortex-m-rt", "proc-macro2", "quote", - "syn 2.0.100", + "syn 1.0.109", ] [[package]] -name = "rp235x-pac" -version = "0.1.0" +name = "rp2040-pac" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffcb6931deee4242886b5a1df62db5e2555b0eb6ae1e8be101f3ea3e58e65c6" +checksum = "83cbcd3f7a0ca7bbe61dc4eb7e202842bee4e27b769a7bf3a4a72fa399d6e404" dependencies = [ "cortex-m", "cortex-m-rt", @@ -521,6 +492,23 @@ dependencies = [ "vcell", ] +[[package]] +name = "rp2040-usb-ramdisk" +version = "0.1.0" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "defmt 0.3.100", + "defmt-rtt", + "embedded-hal 1.0.0", + "panic-probe", + "rp-pico", + "rp2040-boot2", + "rp2040-hal", + "usb-device", + "usbd-storage", +] + [[package]] name = "rustc_version" version = "0.2.3" @@ -545,12 +533,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "sha2-const-stable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f179d4e11094a893b82fff208f74d448a7512f99f5a0acbd5c679b705f83ed9" - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -570,9 +552,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.100" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -581,29 +563,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.12" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.106", ] [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" [[package]] name = "usb-device" @@ -611,7 +593,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6" dependencies = [ - "defmt", + "defmt 0.3.100", "heapless", "portable-atomic", ] @@ -622,7 +604,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee23ab04c7d76b63c417cf2fa672d720477d2e71c6822ac6e5ceaf526f48f394" dependencies = [ - "defmt", + "defmt 0.3.100", "num_enum 0.6.1", "usb-device", ] diff --git a/Cargo.toml b/Cargo.toml index 9f4b78e..0799c3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,17 +1,30 @@ [package] -name = "rp2350-usb-ramdisk" +name = "rp2040-usb-ramdisk" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] cortex-m = "0.7.7" -cortex-m-rt = "0.7.5" -critical-section = "1.2.0" +cortex-m-rt = { version = "0.7.5", optional = true } defmt = "0.3.10" defmt-rtt = "0.4.1" embedded-hal = "1.0.0" -panic-halt = "1.0.0" -panic-probe = "0.3.2" -rp235x-hal = { version = "0.3.0", features = ["binary-info", "critical-section-impl", "rt", "defmt"] } +panic-probe = { version = "0.3.2", features = ["print-defmt"] } +rp-pico = "0.9.0" +rp2040-boot2 = { version = "0.3.0", optional = true } +rp2040-hal = "0.10.2" usb-device = "0.3.2" -usbd-storage = { version = "1.0.0", features = ["bbb", "defmt", "scsi"] } +usbd-storage = { version = "1.0.0", features = ["scsi", "bbb", "defmt"] } + +[features] +default = ["boot2", "rt", "critical-section-impl"] +boot2 = ["rp2040-boot2"] +rt = ["cortex-m-rt","rp2040-hal/rt"] +critical-section-impl = ["rp2040-hal/critical-section-impl"] +cortex-m-rt = ["dep:cortex-m-rt"] + +[profile.dev] +panic = "abort" + +[profile.release] +panic = "abort" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..de09fbc --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +BIN=rp2040-usb-ramdisk + +.PHONY: flash +flash: target/thumbv6m-none-eabi/release/$(BIN) + elf2uf2-rs --deploy $< + +target/thumbv6m-none-eabi/release/$(BIN): src/main.rs src/serial_number.rs Cargo.toml + cargo build --target thumbv6m-none-eabi --release + +target/thumbv6m-none-eabi/release/$(BIN).uf2: target/thumbv6m-none-eabi/release/$(BIN) + elf2uf2-rs $< $@ + diff --git a/build.rs b/build.rs deleted file mode 100644 index 90bade9..0000000 --- a/build.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::{fs::File, io::Write, path::PathBuf}; - -fn main() { - let out = PathBuf::from(std::env::var("OUT_DIR").unwrap()); - println!("cargo:rustc-link-search={}", out.display()); - - let memory_x = include_bytes!("memory.x"); - let mut f = File::create(out.join("memory.x")).unwrap(); - f.write_all(memory_x).unwrap(); - println!("cargo:rerun-if-changed=memory.x"); - - println!("cargo:rerun-if-changed=build.rs"); -} diff --git a/memory.x b/memory.x index 7d409ba..070eac7 100644 --- a/memory.x +++ b/memory.x @@ -1,77 +1,15 @@ MEMORY { - /* - * The RP2350 has either external or internal flash. - * - * 2 MiB is a safe default here, although a Pico 2 has 4 MiB. - */ - FLASH : ORIGIN = 0x10000000, LENGTH = 2048K - /* - * RAM consists of 8 banks, SRAM0-SRAM7, with a striped mapping. - * This is usually good for performance, as it distributes load on - * those banks evenly. - */ - RAM : ORIGIN = 0x20000000, LENGTH = 512K - /* - * RAM banks 8 and 9 use a direct mapping. They can be used to have - * memory areas dedicated for some specific job, improving predictability - * of access times. - * Example: Separate stacks for core0 and core1. - */ - SRAM4 : ORIGIN = 0x20080000, LENGTH = 4K - SRAM5 : ORIGIN = 0x20081000, LENGTH = 4K + BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100 + FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100 + RAM : ORIGIN = 0x20000000, LENGTH = 256K } -SECTIONS { - /* ### Boot ROM info - * - * Goes after .vector_table, to keep it in the first 4K of flash - * where the Boot ROM (and picotool) can find it - */ - .start_block : ALIGN(4) - { - __start_block_addr = .; - KEEP(*(.start_block)); - KEEP(*(.boot_info)); - } > FLASH - -} INSERT AFTER .vector_table; - -/* move .text to start /after/ the boot info */ -_stext = ADDR(.start_block) + SIZEOF(.start_block); +EXTERN(BOOT2_FIRMWARE) SECTIONS { - /* ### Picotool 'Binary Info' Entries - * - * Picotool looks through this block (as we have pointers to it in our - * header) to find interesting information. - */ - .bi_entries : ALIGN(4) + /* ### Boot loader */ + .boot2 ORIGIN(BOOT2) : { - /* We put this in the header */ - __bi_entries_start = .; - /* Here are the entries */ - KEEP(*(.bi_entries)); - /* Keep this block a nice round size */ - . = ALIGN(4); - /* We put this in the header */ - __bi_entries_end = .; - } > FLASH -} INSERT AFTER .text; - -SECTIONS { - /* ### Boot ROM extra info - * - * Goes after everything in our program, so it can contain a signature. - */ - .end_block : ALIGN(4) - { - __end_block_addr = .; - KEEP(*(.end_block)); - } > FLASH - -} INSERT AFTER .uninit; - -PROVIDE(start_to_end = __end_block_addr - __start_block_addr); -PROVIDE(end_to_start = __start_block_addr - __end_block_addr); - - + KEEP(*(.boot2)); + } > BOOT2 +} INSERT BEFORE .text; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 91e7c2a..0136bce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,18 @@ #![no_std] #![no_main] +use rp_pico::entry; + use defmt as _; use defmt_rtt as _; use panic_probe as _; -use rp235x_hal as hal; - use embedded_hal::digital::StatefulOutputPin; +use rp_pico::hal::pac; + +use rp_pico::hal; + use usb_device::{class_prelude::*, prelude::*}; use usbd_storage::subclass::scsi::{Scsi, ScsiCommand}; @@ -16,15 +20,8 @@ use usbd_storage::subclass::Command; use usbd_storage::transport::bbb::{BulkOnly, BulkOnlyError}; use usbd_storage::transport::TransportError; - -#[link_section = ".start_block"] -#[used] -pub static IMAGE_DEF: hal::block::ImageDef = hal::block::ImageDef::secure_exe(); - -const XTAL_FREQ_HZ: u32 = 12_000_000u32; - const DISK_BLOCK_SIZE: u32 = 512; -const DISK_BLOCK_NUM: u32 = 1000; +const DISK_BLOCK_NUM: u32 = 256; const USB_PACKET_SIZE: u16 = 64; // 8,16,32,64 const MAX_LUN: u8 = 0; // max 0x0F @@ -69,14 +66,14 @@ impl State { } } -#[hal::entry] +#[entry] fn main() -> ! { - let mut pac = hal::pac::Peripherals::take().unwrap(); + let mut pac = pac::Peripherals::take().unwrap(); let mut watchdog = hal::Watchdog::new(pac.WATCHDOG); let clocks = hal::clocks::init_clocks_and_plls( - XTAL_FREQ_HZ, + rp_pico::XOSC_CRYSTAL_FREQ, pac.XOSC, pac.CLOCKS, pac.PLL_SYS, @@ -84,23 +81,24 @@ fn main() -> ! { &mut pac.RESETS, &mut watchdog, ) + .ok() .unwrap(); - let timer = hal::Timer::new_timer0(pac.TIMER0, &mut pac.RESETS, &clocks); + let timer = hal::timer::Timer::new(pac.TIMER, &mut pac.RESETS, &clocks); let sio = hal::Sio::new(pac.SIO); - let pins = hal::gpio::Pins::new( + let pins = rp_pico::Pins::new( pac.IO_BANK0, pac.PADS_BANK0, sio.gpio_bank0, &mut pac.RESETS, ); - let mut led_pin = pins.gpio12.into_push_pull_output(); + let mut led_pin = pins.led.into_push_pull_output(); let usb_bus = UsbBusAllocator::new(hal::usb::UsbBus::new( - pac.USB, - pac.USB_DPRAM, + pac.USBCTRL_REGS, + pac.USBCTRL_DPRAM, clocks.usb_clock, true, &mut pac.RESETS, @@ -191,10 +189,10 @@ fn main() -> ! { (UsbDeviceState::Addressed, true) => 250_000, (UsbDeviceState::Addressed, false) => 250_000, // The USB device has been configured and is fully functional. - (UsbDeviceState::Configured, true) => 8, - (UsbDeviceState::Configured, false) => 16, + (UsbDeviceState::Configured, true) => 1_000_000, + (UsbDeviceState::Configured, false) => 0, // The USB device has been suspended by the host or it has been unplugged from the USB bus. - (UsbDeviceState::Suspend, true) => 10_000, + (UsbDeviceState::Suspend, true) => 25_000, (UsbDeviceState::Suspend, false) => 2_000_000, } }; @@ -348,11 +346,3 @@ fn process_command( Ok(()) } - -#[link_section = ".bi_entries"] -#[used] -pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 3] = [ - hal::binary_info::rp_program_name!(c"rp2350-usb-ramdisk"), - hal::binary_info::rp_cargo_version!(), - hal::binary_info::rp_program_build_attribute!(), -];