Compare commits

..

5 commits
rp2040 ... main

Author SHA1 Message Date
Jakob Lechner
43bec436eb Rework fast blinking after reset 2025-09-24 10:46:11 +02:00
Jakob Lechner
eb4921afce Change LED Pin and flash timing 2025-09-23 20:19:22 +02:00
Jakob Lechner
8dd4913dba Fix partition table 2025-04-11 02:47:38 +02:00
Jakob Lechner
b9a37ff54d Remove serial number
It doesn't work with windows. It seems that the USB device goes into low
power state and then the serial number string descriptor cannot be read.
2025-04-11 02:47:29 +02:00
Jakob Lechner
cd44e736db Use RP2350 2025-03-10 21:59:58 +01:00
7 changed files with 259 additions and 183 deletions

View file

@ -1,14 +1,12 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "picotool load -u -v -x -t elf"
[build]
target = "thumbv8m.main-none-eabihf"
[target.thumbv8m.main-none-eabihf]
rustflags = [
"-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",
"-C", "link-arg=--nmagic",
"-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Tdefmt.x",
"-C", "target-cpu=cortex-m33",
]
[build]
target = "thumbv6m-none-eabi"
runner = "picotool load -u -v -x -t elf"

242
Cargo.lock generated
View file

@ -70,16 +70,7 @@ checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472"
dependencies = [
"proc-macro2",
"quote",
"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",
"syn 2.0.100",
]
[[package]]
@ -88,26 +79,11 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
[[package]]
name = "debug-helper"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e"
[[package]]
name = "defmt"
version = "0.3.100"
version = "0.3.10"
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"
checksum = "86f6162c53f659f65d00619fe31f14556a6e9f8752ccc4a41bd177ffcf3d6130"
dependencies = [
"bitflags",
"defmt-macros",
@ -115,34 +91,34 @@ dependencies = [
[[package]]
name = "defmt-macros"
version = "1.0.1"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d4fc12a85bcf441cfe44344c4b72d58493178ce635338a3f3b78943aceb258e"
checksum = "9d135dd939bad62d7490b0002602d35b358dce5fd9233a709d3c1ef467d4bde6"
dependencies = [
"defmt-parser",
"proc-macro-error2",
"proc-macro2",
"quote",
"syn 2.0.106",
"syn 2.0.100",
]
[[package]]
name = "defmt-parser"
version = "1.0.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
checksum = "3983b127f13995e68c1e29071e5d115cd96f215ccb5e6812e3728cd6f92653b3"
dependencies = [
"thiserror",
]
[[package]]
name = "defmt-rtt"
version = "0.4.2"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6eca0aae8aa2cf8333200ecbd236274697bc0a394765c858b3d9372eb1abcfa"
checksum = "bab697b3dbbc1750b7c8b821aa6f6e7f2480b47a99bc057a2ed7b170ebef0c51"
dependencies = [
"critical-section",
"defmt 0.3.100",
"defmt",
]
[[package]]
@ -203,9 +179,9 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
[[package]]
name = "frunk"
version = "0.4.4"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28aef0f9aa070bce60767c12ba9cb41efeaf1a2bc6427f87b7d83f11239a16d7"
checksum = "874b6a17738fc273ec753618bac60ddaeac48cb1d7684c3e7bd472e57a28b817"
dependencies = [
"frunk_core",
"frunk_derives",
@ -213,31 +189,31 @@ dependencies = [
[[package]]
name = "frunk_core"
version = "0.4.4"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "476eeaa382e3462b84da5d6ba3da97b5786823c2d0d3a0d04ef088d073da225c"
checksum = "3529a07095650187788833d585c219761114005d5976185760cf794d265b6a5c"
[[package]]
name = "frunk_derives"
version = "0.4.4"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0b4095fc99e1d858e5b8c7125d2638372ec85aa0fe6c807105cf10b0265ca6c"
checksum = "e99b8b3c28ae0e84b604c75f721c21dc77afb3706076af5e8216d15fd1deaae3"
dependencies = [
"frunk_proc_macro_helpers",
"quote",
"syn 2.0.106",
"syn 2.0.100",
]
[[package]]
name = "frunk_proc_macro_helpers"
version = "0.1.4"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1952b802269f2db12ab7c0bd328d0ae8feaabf19f352a7b0af7bb0c5693abfce"
checksum = "05a956ef36c377977e512e227dcad20f68c2786ac7a54dacece3746046fea5ce"
dependencies = [
"frunk_core",
"proc-macro2",
"quote",
"syn 2.0.106",
"syn 2.0.100",
]
[[package]]
@ -276,9 +252,9 @@ dependencies = [
[[package]]
name = "itertools"
version = "0.10.5"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
dependencies = [
"either",
]
@ -335,9 +311,15 @@ checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.106",
"syn 2.0.100",
]
[[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"
@ -345,7 +327,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4047d9235d1423d66cc97da7d07eddb54d4f154d6c13805c6d0793956f4f25b0"
dependencies = [
"cortex-m",
"defmt 0.3.100",
]
[[package]]
@ -367,9 +348,9 @@ dependencies = [
[[package]]
name = "portable-atomic"
version = "1.11.1"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
[[package]]
name = "proc-macro-error-attr2"
@ -390,23 +371,23 @@ dependencies = [
"proc-macro-error-attr2",
"proc-macro2",
"quote",
"syn 2.0.106",
"syn 2.0.100",
]
[[package]]
name = "proc-macro2"
version = "1.0.101"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.40"
version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801"
dependencies = [
"proc-macro2",
]
@ -418,36 +399,79 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]]
name = "rp-pico"
version = "0.9.0"
name = "riscv"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9342d3ac7011ac688300979e9b52a81f0add1d05feb02868cf94bfee0705b28"
checksum = "2f5c1b8bf41ea746266cdee443d1d1e9125c86ce1447e1a2615abd34330d33a9"
dependencies = [
"cortex-m-rt",
"fugit",
"rp2040-boot2",
"rp2040-hal",
"usb-device",
"critical-section",
"embedded-hal 1.0.0",
]
[[package]]
name = "rp2040-boot2"
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",
"usb-device",
"usbd-storage",
]
[[package]]
name = "rp235x-hal"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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"
checksum = "e2939c82776b0b4ae110168b4298b5adf831e6cff249b057bf2a2187453b959c"
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",
@ -456,35 +480,40 @@ dependencies = [
"embedded-io",
"frunk",
"fugit",
"gcd",
"itertools",
"nb 1.1.0",
"paste",
"pio",
"rand_core",
"rp2040-hal-macros",
"rp2040-pac",
"riscv",
"riscv-rt",
"rp-binary-info",
"rp-hal-common",
"rp235x-hal-macros",
"rp235x-pac",
"sha2-const-stable",
"usb-device",
"vcell",
"void",
]
[[package]]
name = "rp2040-hal-macros"
name = "rp235x-hal-macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86479063e497efe1ae81995ef9071f54fd1c7427e04d6c5b84cde545ff672a5e"
checksum = "74edd7a5979e9763bbb98e9746e711bac7464ee3397af7288e6c288ff0d3c764"
dependencies = [
"cortex-m-rt",
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.100",
]
[[package]]
name = "rp2040-pac"
version = "0.6.0"
name = "rp235x-pac"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83cbcd3f7a0ca7bbe61dc4eb7e202842bee4e27b769a7bf3a4a72fa399d6e404"
checksum = "5ffcb6931deee4242886b5a1df62db5e2555b0eb6ae1e8be101f3ea3e58e65c6"
dependencies = [
"cortex-m",
"cortex-m-rt",
@ -492,23 +521,6 @@ 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"
@ -533,6 +545,12 @@ 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"
@ -552,9 +570,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.106"
version = "2.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
dependencies = [
"proc-macro2",
"quote",
@ -563,29 +581,29 @@ dependencies = [
[[package]]
name = "thiserror"
version = "2.0.16"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0"
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.16"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960"
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.106",
"syn 2.0.100",
]
[[package]]
name = "unicode-ident"
version = "1.0.19"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "usb-device"
@ -593,7 +611,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6"
dependencies = [
"defmt 0.3.100",
"defmt",
"heapless",
"portable-atomic",
]
@ -604,7 +622,7 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee23ab04c7d76b63c417cf2fa672d720477d2e71c6822ac6e5ceaf526f48f394"
dependencies = [
"defmt 0.3.100",
"defmt",
"num_enum 0.6.1",
"usb-device",
]

View file

@ -1,30 +1,17 @@
[package]
name = "rp2040-usb-ramdisk"
name = "rp2350-usb-ramdisk"
version = "0.1.0"
edition = "2024"
edition = "2021"
[dependencies]
cortex-m = "0.7.7"
cortex-m-rt = { version = "0.7.5", optional = true }
cortex-m-rt = "0.7.5"
critical-section = "1.2.0"
defmt = "0.3.10"
defmt-rtt = "0.4.1"
embedded-hal = "1.0.0"
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"
panic-halt = "1.0.0"
panic-probe = "0.3.2"
rp235x-hal = { version = "0.3.0", features = ["binary-info", "critical-section-impl", "rt", "defmt"] }
usb-device = "0.3.2"
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"
usbd-storage = { version = "1.0.0", features = ["bbb", "defmt", "scsi"] }

View file

@ -1,12 +0,0 @@
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 $< $@

13
build.rs Normal file
View file

@ -0,0 +1,13 @@
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");
}

View file

@ -1,15 +1,77 @@
MEMORY {
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
RAM : ORIGIN = 0x20000000, LENGTH = 256K
/*
* 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
}
EXTERN(BOOT2_FIRMWARE)
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);
SECTIONS {
/* ### Boot loader */
.boot2 ORIGIN(BOOT2) :
/* ### 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)
{
KEEP(*(.boot2));
} > BOOT2
} INSERT BEFORE .text;
/* 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);

View file

@ -1,18 +1,14 @@
#![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};
@ -20,8 +16,15 @@ 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 = 256;
const DISK_BLOCK_NUM: u32 = 1000;
const USB_PACKET_SIZE: u16 = 64; // 8,16,32,64
const MAX_LUN: u8 = 0; // max 0x0F
@ -66,14 +69,14 @@ impl State {
}
}
#[entry]
#[hal::entry]
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let mut pac = hal::pac::Peripherals::take().unwrap();
let mut watchdog = hal::Watchdog::new(pac.WATCHDOG);
let clocks = hal::clocks::init_clocks_and_plls(
rp_pico::XOSC_CRYSTAL_FREQ,
XTAL_FREQ_HZ,
pac.XOSC,
pac.CLOCKS,
pac.PLL_SYS,
@ -81,24 +84,23 @@ fn main() -> ! {
&mut pac.RESETS,
&mut watchdog,
)
.ok()
.unwrap();
let timer = hal::timer::Timer::new(pac.TIMER, &mut pac.RESETS, &clocks);
let timer = hal::Timer::new_timer0(pac.TIMER0, &mut pac.RESETS, &clocks);
let sio = hal::Sio::new(pac.SIO);
let pins = rp_pico::Pins::new(
let pins = hal::gpio::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let mut led_pin = pins.led.into_push_pull_output();
let mut led_pin = pins.gpio12.into_push_pull_output();
let usb_bus = UsbBusAllocator::new(hal::usb::UsbBus::new(
pac.USBCTRL_REGS,
pac.USBCTRL_DPRAM,
pac.USB,
pac.USB_DPRAM,
clocks.usb_clock,
true,
&mut pac.RESETS,
@ -189,10 +191,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) => 1_000_000,
(UsbDeviceState::Configured, false) => 0,
(UsbDeviceState::Configured, true) => 8,
(UsbDeviceState::Configured, false) => 16,
// The USB device has been suspended by the host or it has been unplugged from the USB bus.
(UsbDeviceState::Suspend, true) => 25_000,
(UsbDeviceState::Suspend, true) => 10_000,
(UsbDeviceState::Suspend, false) => 2_000_000,
}
};
@ -346,3 +348,11 @@ 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!(),
];