diff --git a/.gitignore b/.gitignore index 5f6b1e6..9da9820 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,11 @@ target/ itm.fifo # when gdb crashes /core +debug/ +target/ + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index d8b5c1d..a3352fd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,64 +4,17 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - { - "type": "lldb", - "request": "custom", - "name": "LLDB - Release", - "targetCreateCommands": [ - "command source ${workspaceFolder}/openocd.lldb" - ], - "sourceLanguages": [ - "rust" - ] - }, - { - "type": "gdb", - "request": "launch", - "name": "Debug", - "target": "./target/thumbv7em-none-eabi/debug/mwatch_kernel", - // "gdbpath": "arm-none-eabi-gdb", - "gdbpath": "/home/mabez/programs/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gdb", - "cwd": "${workspaceRoot}", - "autorun": [ - "source openocd.gdb" - ] - }, - { - "type": "gdb", - "request": "launch", - "name": "Debug - ITM", - "target": "./target/thumbv7em-none-eabi/debug/mwatch_kernel", - // "gdbpath": "arm-none-eabi-gdb", - "gdbpath": "/home/mabez/programs/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gdb", - "cwd": "${workspaceRoot}", - "autorun": [ - "source openocd_itm.gdb" - ] - }, - { - "type": "gdb", - "request": "launch", - "name": "Release", - "target": "./target/thumbv7em-none-eabi/release/mwatch_kernel", - // "gdbpath": "arm-none-eabi-gdb", - "gdbpath": "/home/mabez/programs/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gdb", - "cwd": "${workspaceRoot}", - "autorun": [ - "source openocd.gdb" - ] - }, { "type": "gdb", - "request": "launch", - "name": "Release - ITM", - "target": "./target/thumbv7em-none-eabi/release/mwatch_kernel", - // "gdbpath": "arm-none-eabi-gdb", - "gdbpath": "/home/mabez/programs/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gdb", + "request": "attach", + "name": "VsCode: Wokwi Debug S3", + "executable": "${workspaceFolder}/target/xtensa-esp32s3-none-elf/release/kernel-esp32s3", + "target": "127.0.0.1:9333", + "remote": true, + "gdbpath": "${userHome}/.espressif/tools/xtensa-esp-elf-gdb/11.2_20220823/xtensa-esp-elf-gdb/bin/xtensa-esp32s3-elf-gdb", "cwd": "${workspaceRoot}", - "autorun": [ - "source openocd_itm.gdb" - ] - }, + "stopAtConnect": true, + "valuesFormatting": "parseText" + } ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 474c58f..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu" -} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 65915c8..d92b7ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +dependencies = [ + "memchr", +] + [[package]] name = "aligned" version = "0.2.0" @@ -17,6 +26,12 @@ dependencies = [ "as-slice", ] +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + [[package]] name = "as-slice" version = "0.1.5" @@ -25,7 +40,7 @@ checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" dependencies = [ "generic-array 0.12.4", "generic-array 0.13.3", - "generic-array 0.14.6", + "generic-array 0.14.7", "stable_deref_trait", ] @@ -38,6 +53,15 @@ dependencies = [ "critical-section", ] +[[package]] +name = "atomic-polyfill" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" +dependencies = [ + "critical-section", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -59,12 +83,39 @@ dependencies = [ "rustc_version 0.2.3", ] +[[package]] +name = "bare-metal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" + +[[package]] +name = "basic-toml" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6" +dependencies = [ + "serde", +] + [[package]] name = "bitfield" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" +[[package]] +name = "bitfield" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "build_const" version = "0.2.2" @@ -92,6 +143,19 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "core-isa-parser" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ec98e54b735872e54b2335c2e5a5c7fa7d9c3bfd45500f75280f84089a0083" +dependencies = [ + "anyhow", + "enum-as-inner", + "regex", + "strum 0.24.1", + "strum_macros 0.24.3", +] + [[package]] name = "cortex-m" version = "0.5.11" @@ -99,7 +163,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59971a5cf4dacacaf738dd9d8660875118fce790f800f661893eb20894c1d622" dependencies = [ "aligned 0.2.0", - "bare-metal", + "bare-metal 0.2.5", "cortex-m 0.6.7", "volatile-register", ] @@ -111,21 +175,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9075300b07c6a56263b9b582c214d0ff037b00d45ec9fde1cc711490c56f1bb9" dependencies = [ "aligned 0.3.5", - "bare-metal", - "bitfield", - "cortex-m 0.7.6", + "bare-metal 0.2.5", + "bitfield 0.13.2", + "cortex-m 0.7.7", "volatile-register", ] [[package]] name = "cortex-m" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70858629a458fdfd39f9675c4dc309411f2a3f83bede76988d81bf1a0ecee9e0" +checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" dependencies = [ - "bare-metal", - "bitfield", - "embedded-hal", + "bare-metal 0.2.5", + "bitfield 0.13.2", + "embedded-hal 0.2.7", "volatile-register", ] @@ -146,7 +210,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "454f278bf469e2de0a4d22ea019d169d8944f86957c8207a39e3f66c32be2fc6" dependencies = [ "cortex-m-rt-macros", - "r0", + "r0 0.2.2", ] [[package]] @@ -157,7 +221,7 @@ checksum = "c8e3aa52243e26f5922fa522b0814019e0c98fc567e2756d715dce7ad7a81f49" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -182,7 +246,7 @@ dependencies = [ "proc-macro2", "quote", "rtic-syntax", - "syn", + "syn 1.0.109", ] [[package]] @@ -191,7 +255,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc" dependencies = [ - "cortex-m 0.7.6", + "cortex-m 0.7.7", ] [[package]] @@ -205,9 +269,164 @@ dependencies = [ [[package]] name = "critical-section" -version = "1.1.1" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" + +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core 0.13.4", + "darling_macro 0.13.4", +] + +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core 0.20.3", + "darling_macro 0.20.3", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.37", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core 0.13.4", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core 0.20.3", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" + +[[package]] +name = "embassy-executor" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4f2f7687ed60a799909eca1bf68b41e9f2ad03d740f0956a945ddabccc6aedb" +dependencies = [ + "atomic-polyfill 1.0.3", + "cfg-if", + "critical-section", + "embassy-macros", + "embassy-time", + "futures-util", + "static_cell", +] + +[[package]] +name = "embassy-futures" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e5367165d347c039360f784812f493b001583ab6a3dd8622f4ce9c30374ec3" + +[[package]] +name = "embassy-macros" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" +checksum = "c8f57fb96af50e126bb4ae0826604ac5b9f9ac1d32fb3576d552f7285bf68e67" +dependencies = [ + "darling 0.13.4", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "embassy-sync" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0dad296a6f70bfdc32ef52442a31f98c28e1608893c1cecc9b6f419bab005a0" +dependencies = [ + "cfg-if", + "critical-section", + "embedded-io 0.4.0", + "futures-util", + "heapless 0.7.16", +] + +[[package]] +name = "embassy-time" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94a9532d29ec2949c49079d85fd77422e3f4cdc133a71674743cd3b8d5a56a20" +dependencies = [ + "atomic-polyfill 1.0.3", + "cfg-if", + "critical-section", + "embedded-hal 0.2.7", + "embedded-hal-async", + "futures-util", + "heapless 0.7.16", +] + +[[package]] +name = "embedded-can" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" +dependencies = [ + "nb 1.1.0", +] + +[[package]] +name = "embedded-dma" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "994f7e5b5cb23521c22304927195f236813053eb9c065dd2226a32ba64695446" +dependencies = [ + "stable_deref_trait", +] [[package]] name = "embedded-graphics" @@ -242,6 +461,173 @@ dependencies = [ "void", ] +[[package]] +name = "embedded-hal" +version = "1.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2894bc2f0457b8ca3d6b8ab8aad64d9337583672494013457f86c5a9146c0e22" + +[[package]] +name = "embedded-hal-async" +version = "1.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a8a3517745342155b3b00895a0f78417a453fb800d97a8bf4777d5720acde9" +dependencies = [ + "embedded-hal 1.0.0-rc.1", +] + +[[package]] +name = "embedded-hal-nb" +version = "1.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257e3bb0163c69195acb0ebe0083b017b963235861d5ea9741626abdc55f39c9" +dependencies = [ + "embedded-hal 1.0.0-rc.1", + "nb 1.1.0", +] + +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bbadc628dc286b9ae02f0cb0f5411c056eb7487b72f0083203f115de94060" + +[[package]] +name = "embedded-io-async" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1394754ad749a560b25a0c70dcd2b66a450824a1311fc475bb2ccbfabe7f8414" +dependencies = [ + "embedded-io 0.5.0", +] + +[[package]] +name = "enum-as-inner" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "esp-backtrace" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7d3ecccb0df809cb6ca79b08f863271c0aa24f586df96272988a85d34dfa62" +dependencies = [ + "esp-println", +] + +[[package]] +name = "esp-hal-common" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29b785e4195e1e1e6fae5b8c7fc44a1a71efa94e0b69527a38cce64815bfe7a6" +dependencies = [ + "basic-toml", + "bitfield 0.14.0", + "bitflags", + "cfg-if", + "critical-section", + "embassy-futures", + "embassy-sync", + "embassy-time", + "embedded-can", + "embedded-dma", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0-rc.1", + "embedded-hal-async", + "embedded-hal-nb", + "embedded-io 0.5.0", + "embedded-io-async", + "esp-hal-procmacros", + "esp-synopsys-usb-otg", + "esp32s3", + "fugit", + "lock_api", + "nb 1.1.0", + "paste", + "serde", + "strum 0.25.0", + "usb-device", + "void", + "xtensa-lx", + "xtensa-lx-rt", +] + +[[package]] +name = "esp-hal-procmacros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4cdf19581f9b0bb2b57b1549a2e639342825344b52f34048ddb29c46efa30de" +dependencies = [ + "darling 0.20.3", + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "esp-println" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b429ea925356d60c10d7214cf0e1777d9578c1287cd50aad09df3c22c4c2f1" +dependencies = [ + "critical-section", + "log", +] + +[[package]] +name = "esp-synopsys-usb-otg" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc6734e87e7b86858f7884649deae6bf634d1e6f5b2d078e457cf4d72c541ec" +dependencies = [ + "critical-section", + "embedded-hal 0.2.7", + "usb-device", + "vcell", +] + +[[package]] +name = "esp32s3" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6991fd4a8ac00e7be2646a09c3da992b69e57a0b1da2570c4cd5a58c613a3a11" +dependencies = [ + "critical-section", + "vcell", + "xtensa-lx", +] + +[[package]] +name = "esp32s3-hal" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f64ce29b9649d2ab4778525362388831f8fa7653052a7ad15ec970048bb9b49" +dependencies = [ + "embassy-time", + "esp-hal-common", +] + [[package]] name = "float-cmp" version = "0.8.0" @@ -251,6 +637,51 @@ dependencies = [ "num-traits", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fugit" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17186ad64927d5ac8f02c1e77ccefa08ccd9eaa314d5a4772278aa204a22f7e7" +dependencies = [ + "gcd", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "gcd" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" + [[package]] name = "generic-array" version = "0.11.2" @@ -280,9 +711,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -312,6 +743,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heapless" version = "0.4.4" @@ -330,7 +767,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634bd4d29cbf24424d0a4bfcbf80c6960129dc24424752a7d1d1390607023422" dependencies = [ "as-slice", - "generic-array 0.14.6", + "generic-array 0.14.7", "hash32 0.1.1", "stable_deref_trait", ] @@ -341,39 +778,78 @@ version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" dependencies = [ - "atomic-polyfill", + "atomic-polyfill 0.1.11", "hash32 0.2.1", "rustc_version 0.4.0", "spin", "stable_deref_trait", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hm11" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfabb682fcb7cf6e15c57bd9beda42c0aaa11ca1db1466f56dbf41a161cf1bbf" dependencies = [ - "embedded-hal", + "embedded-hal 0.2.7", "heapless 0.4.4", "nb 0.1.3", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[package]] +name = "kernel-esp32s3" +version = "0.1.0" +dependencies = [ + "embassy-executor", + "embassy-futures", + "embassy-time", + "embedded-hal-async", + "esp-backtrace", + "esp-println", + "esp32s3-hal", + "log", + "mwatch_kernel", + "static_cell", + "xtensa-lx-rt", ] [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -381,12 +857,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "max17048" @@ -394,15 +867,36 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98c522e4c30912075a931cef0ede9d43e3ae0d60ffe27d5aa04f4b108521f3a4" dependencies = [ - "embedded-hal", + "embedded-hal 0.2.7", ] +[[package]] +name = "memchr" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" + [[package]] name = "micromath" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc4010833aea396656c2f91ee704d51a6f1329ec2ab56ffd00bfd56f7481ea94" +[[package]] +name = "minijinja" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80084fa3099f58b7afab51e5f92e24c2c2c68dcad26e96ad104bd6011570461d" +dependencies = [ + "serde", +] + +[[package]] +name = "mutex-trait" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4bb1638d419e12f8b1c43d9e639abd0d1424285bdea2f76aa231e233c63cd3a" + [[package]] name = "mwatch-kernel-stm32l4" version = "2.0.0" @@ -414,7 +908,7 @@ dependencies = [ "cortex-m-rtic", "crc", "embedded-graphics", - "embedded-hal", + "embedded-hal 0.2.7", "heapless 0.7.16", "hm11", "log", @@ -436,7 +930,7 @@ version = "2.0.0" dependencies = [ "crc", "embedded-graphics", - "embedded-hal", + "embedded-hal 0.2.7", "heapless 0.7.16", "log", "simple-hex", @@ -449,31 +943,37 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" dependencies = [ - "nb 1.0.0", + "nb 1.1.0", ] [[package]] name = "nb" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + [[package]] name = "panic-itm" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d577d97d1b31268087b6dddf2470e6794ef5eee87d9dca7fcd0481695391a4c" dependencies = [ - "cortex-m 0.7.6", + "cortex-m 0.7.7", ] [[package]] @@ -482,7 +982,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ab67bc881453e4c90f958c657c1303670ea87bc1a16e87fd71a40f656dce9" dependencies = [ - "cortex-m 0.7.6", + "cortex-m 0.7.7", "rtt-target", ] @@ -492,24 +992,76 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec" dependencies = [ - "cortex-m 0.7.6", + "cortex-m 0.7.7", "cortex-m-semihosting", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -520,6 +1072,41 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" +[[package]] +name = "r0" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7a31eed1591dcbc95d92ad7161908e72f4677f8fabf2a32ca49b4237cbf211" + +[[package]] +name = "regex" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + [[package]] name = "rtic-core" version = "0.3.1" @@ -532,9 +1119,9 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8152fcaa845720d61e6cc570548b89144c2c307f18a480bbd97e55e9f6eeff04" dependencies = [ - "indexmap", + "indexmap 1.9.3", "proc-macro2", - "syn", + "syn 1.0.109", ] [[package]] @@ -543,7 +1130,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "065d6058bb1204f51a562a67209e1817cf714759d5cf845aa45c75fa7b0b9d9b" dependencies = [ - "cortex-m 0.7.6", + "cortex-m 0.7.7", "ufmt-write", ] @@ -562,14 +1149,20 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.16", + "semver 1.0.19", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" @@ -582,9 +1175,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" [[package]] name = "semver-parser" @@ -592,6 +1185,26 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "serde" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + [[package]] name = "simple-hex" version = "0.1.0" @@ -600,9 +1213,9 @@ checksum = "b581d48c218869658cf5e61f33835dd69ef4722e1cad6f43157afa9f72c2d46e" [[package]] name = "spin" -version = "0.9.4" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ "lock_api", ] @@ -614,7 +1227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "791086e9ee362d1c22c7fc1b59aaf78500ed72f4b4fad1942d72d89815aff143" dependencies = [ "embedded-graphics-core", - "embedded-hal", + "embedded-hal 0.2.7", ] [[package]] @@ -623,13 +1236,22 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_cell" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49cd323fc21eb534f903ee78d781d622099f9716c5b408ed23bcf39f8f1651c0" +dependencies = [ + "atomic-polyfill 1.0.3", +] + [[package]] name = "stm32l4" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "769f6c1c26a76d1554473b21039e1233dd1d02a0262f23f5161150c2dcf2f538" dependencies = [ - "bare-metal", + "bare-metal 0.2.5", "cortex-m 0.6.7", "cortex-m-rt", "vcell", @@ -644,18 +1266,76 @@ dependencies = [ "as-slice", "cast", "cortex-m 0.6.7", - "embedded-hal", + "embedded-hal 0.2.7", "nb 0.1.3", "stable_deref_trait", "stm32l4", "void", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros 0.25.2", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "strum_macros" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.37", +] + [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -664,24 +1344,42 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ + "deranged", "time-core", ] [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.0.0", + "toml_datetime", + "winnow", +] [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ufmt-write" @@ -691,9 +1389,15 @@ checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "usb-device" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508" [[package]] name = "vcell" @@ -721,3 +1425,48 @@ checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" dependencies = [ "vcell", ] + +[[package]] +name = "winnow" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +dependencies = [ + "memchr", +] + +[[package]] +name = "xtensa-lx" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9490addc0a1edd86e571a9ed8063f33d8224f981e61bbf72279671ed0cb4bb7c" +dependencies = [ + "bare-metal 1.0.0", + "mutex-trait", + "spin", +] + +[[package]] +name = "xtensa-lx-rt" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904102108b780c9a5e3275c5f3c63dc348ec43ae5da5237868515498b447d51a" +dependencies = [ + "bare-metal 1.0.0", + "core-isa-parser", + "minijinja", + "r0 1.0.0", + "xtensa-lx-rt-proc-macros", +] + +[[package]] +name = "xtensa-lx-rt-proc-macros" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "082cdede098bbec9af15b0e74085e5f3d16f2923597de7aed7b8112003af2da7" +dependencies = [ + "darling 0.20.3", + "proc-macro2", + "quote", + "syn 2.0.37", +] diff --git a/Cargo.toml b/Cargo.toml index 27278ac..fb65d1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] -members = ["kernel", "kernel-stm32l4"] +members = ["kernel", "kernel-stm32l4", "kernel-esp32s3"] +resolver = "2" [profile.dev] codegen-units = 1 @@ -9,5 +10,5 @@ opt-level = 'z' # 0 or 1 for debug [profile.release] codegen-units = 1 -lto = true +lto = 'fat' debug = true diff --git a/kernel-esp32s3/.cargo/config.toml b/kernel-esp32s3/.cargo/config.toml new file mode 100644 index 0000000..605231a --- /dev/null +++ b/kernel-esp32s3/.cargo/config.toml @@ -0,0 +1,12 @@ +[target.xtensa-esp32s3-none-elf] +runner = "espflash flash --monitor" + +[build] +rustflags = [ + "-C", "link-arg=-nostartfiles", + "-C", "link-arg=-Wl,-Tlinkall.x", +] +target = "xtensa-esp32s3-none-elf" + +[unstable] +build-std = ["core"] diff --git a/kernel-esp32s3/Cargo.toml b/kernel-esp32s3/Cargo.toml new file mode 100644 index 0000000..58d55cc --- /dev/null +++ b/kernel-esp32s3/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "kernel-esp32s3" +version = "0.1.0" +authors = ["Scott Mabin "] +edition = "2021" +license = "MIT OR Apache-2.0" + +[dependencies] +esp32s3-hal = { version = "0.12.0", features = ["async", "embassy", "embassy-time-systick"] } +esp-backtrace = { version = "0.8.0", features = ["esp32s3", "panic-handler", "print-uart"] } +esp-println = { version = "0.6", features = ["esp32s3", "log"] } +xtensa-lx-rt = { version = "0.16.0", features = ["esp32s3"], optional = true } +mwatch-kernel = { version = "2.0", package = "mwatch_kernel", path = "../kernel" } +embassy-executor = { version = "0.1.1", features = ["nightly", "integrated-timers"] } +embassy-time = "0.1.0" +embassy-futures = "0.1.0" +static-cell = { version = "1", package = "static_cell" } +embedded-hal-async = "1.0.0-rc.1" +log = "0.4" + +[features] +default = ["rt"] +rt = ["xtensa-lx-rt"] diff --git a/kernel-esp32s3/LICENSE-APACHE b/kernel-esp32s3/LICENSE-APACHE new file mode 100644 index 0000000..d2c040e --- /dev/null +++ b/kernel-esp32s3/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/kernel-esp32s3/LICENSE-MIT b/kernel-esp32s3/LICENSE-MIT new file mode 100644 index 0000000..3d3dcba --- /dev/null +++ b/kernel-esp32s3/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright [year] [fullname] + +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: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +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. diff --git a/kernel-esp32s3/diagram.json b/kernel-esp32s3/diagram.json new file mode 100644 index 0000000..e9fd2b7 --- /dev/null +++ b/kernel-esp32s3/diagram.json @@ -0,0 +1,112 @@ +{ + "version": 1, + "author": "Scott Mabin", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-s3-devkitc-1", + "id": "esp", + "top": 0, + "left": 0, + "attrs": { + "builder": "rust-nostd-esp" + } + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": 45, + "left": -250.27, + "attrs": { + "color": "green" + } + }, + { + "type": "wokwi-pushbutton", + "id": "btn2", + "top": 103.94, + "left": -247.33, + "attrs": { + "color": "green" + } + }, + { + "type": "wokwi-pushbutton", + "id": "btn3", + "top": 170.6, + "left": -248.01, + "attrs": { + "color": "green" + } + } + ], + "connections": [ + [ + "esp:TX", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp:RX", + "$serialMonitor:TX", + "", + [] + ], + [ + "btn1:1.l", + "esp:GND.1", + "green", + [ + "h-43.3", + "v12.88" + ] + ], + [ + "btn2:1.l", + "esp:GND.1", + "green", + [ + "h-29.57", + "v111.28" + ] + ], + [ + "btn3:1.l", + "esp:GND.1", + "green", + [ + "h-14.23", + "v45.95" + ] + ], + [ + "esp:4", + "btn1:2.r", + "green", + [ + "h-173.51", + "v19" + ] + ], + [ + "esp:5", + "btn2:2.r", + "green", + [ + "h-163.58", + "v1.03" + ] + ], + [ + "esp:6", + "btn3:2.r", + "green", + [ + "h-153.65", + "v126.79" + ] + ] + ], + "dependencies": {} +} \ No newline at end of file diff --git a/kernel-esp32s3/rust-toolchain.toml b/kernel-esp32s3/rust-toolchain.toml new file mode 100644 index 0000000..a2f5ab5 --- /dev/null +++ b/kernel-esp32s3/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "esp" diff --git a/kernel-esp32s3/src/main.rs b/kernel-esp32s3/src/main.rs new file mode 100644 index 0000000..f541797 --- /dev/null +++ b/kernel-esp32s3/src/main.rs @@ -0,0 +1,66 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use embassy_executor::Executor; +use embassy_futures::select::{select3, Either3}; +use embassy_time::{Timer, Duration}; +use esp32s3_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, embassy, gpio::{PullUp, Input, Gpio4, Gpio5, Gpio6}, IO}; +use esp_backtrace as _; +use esp_println; +use static_cell::StaticCell; +use embedded_hal_async::digital::Wait; + +static EXECUTOR: StaticCell = StaticCell::new(); + +#[xtensa_lx_rt::entry] +fn main() -> ! { + let peripherals = Peripherals::take(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); + + esp_println::logger::init_logger(log::LevelFilter::Info); + + log::info!("\r\n\r\n /\\/\\/ / /\\ \\ \\__ _| |_ ___| |__ \r\n / \\ \\/ \\/ / _` | __/ __| '_ \\ \r\n/ /\\/\\ \\ /\\ / (_| | || (__| | | |\r\n\\/ \\/\\/ \\/ \\__,_|\\__\\___|_| |_|\r\n \r\n"); + log::info!("Copyright Scott Mabin 2022"); + + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + + // Async requires the GPIO interrupt to wake futures + esp32s3_hal::interrupt::enable( + esp32s3_hal::peripherals::Interrupt::GPIO, + esp32s3_hal::interrupt::Priority::Priority1, + ) + .unwrap(); + + embassy::init( + &clocks, + esp32s3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER), + ); + + let executor = EXECUTOR.init(Executor::new()); + executor.run(|spawner| { + spawner.spawn(idle()).ok(); + spawner.spawn(input(io.pins.gpio4.into_pull_up_input(), io.pins.gpio5.into_pull_up_input(), io.pins.gpio6.into_pull_up_input())).ok(); + }) +} + +#[embassy_executor::task] +async fn idle() { + loop { + log::info!("Bing!"); + Timer::after(Duration::from_millis(3_000)).await; + } +} + +#[embassy_executor::task] +async fn input(mut left: Gpio4>, mut middle: Gpio5>, mut right: Gpio6>) { + log::info!("Waiting for Inputs"); + loop { + match select3(left.wait_for_falling_edge(), middle.wait_for_falling_edge(), right.wait_for_falling_edge()).await { + Either3::First(_) => log::info!("LEFT!"), + Either3::Second(_) => log::info!("MIDDLE!"), + Either3::Third(_) => log::info!("RIGHT!"), + }; + } +} \ No newline at end of file diff --git a/kernel-esp32s3/wokwi.toml b/kernel-esp32s3/wokwi.toml new file mode 100644 index 0000000..adada60 --- /dev/null +++ b/kernel-esp32s3/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1 +elf = "../target/xtensa-esp32s3-none-elf/release/kernel-esp32s3" +firmware = "../target/xtensa-esp32s3-none-elf/release/kernel-esp32s3" \ No newline at end of file diff --git a/kernel/src/application/application_manager.rs b/kernel/src/application/application_manager.rs index cd70c6c..5997465 100644 --- a/kernel/src/application/application_manager.rs +++ b/kernel/src/application/application_manager.rs @@ -66,7 +66,7 @@ impl ApplicationManager { /// Create a new application manager from a chunk of ram pub fn new(ram: Ram, os_table_ptr: &'static mut Table) -> Self { Self { - ram: ram, + ram, target_cs: [0u8; 4], target_cs_idx: 0, service_fn: None, @@ -111,11 +111,11 @@ impl ApplicationManager { fn digest_from_bytes(bytes: &[u8]) -> u32 { assert_eq!(bytes.len(), 4); // bytes arrive in reversed order - let digest = ((u32::from(bytes[0])) << 24) + + ((u32::from(bytes[0])) << 24) | ((u32::from(bytes[1])) << 16) | ((u32::from(bytes[2])) << 8) - | (u32::from(bytes[3])); - digest + | (u32::from(bytes[3])) } /// Run the application @@ -123,9 +123,9 @@ impl ApplicationManager { if !self.status.is_loaded { return Err(Error::NoApplication); } - let setup_ptr = Self::fn_ptr_from_slice(&self.ram.as_ref()[..4]); - let service_ptr = Self::fn_ptr_from_slice(&self.ram.as_ref()[4..8]); - let input_ptr = Self::fn_ptr_from_slice(&self.ram.as_ref()[8..12]); + let setup_ptr = Self::fn_ptr_from_slice(&self.ram.bytes()[..4]); + let service_ptr = Self::fn_ptr_from_slice(&self.ram.bytes()[4..8]); + let input_ptr = Self::fn_ptr_from_slice(&self.ram.bytes()[8..12]); let _result = unsafe { let setup: SetupFn = ::core::mem::transmute(setup_ptr); let service: ServiceFn = ::core::mem::transmute(service_ptr); @@ -250,8 +250,8 @@ impl Ram { } /// Get an immutable reference to the internal ram buffer - pub fn as_ref(&self) -> &[u8] { - &self.ram + pub fn bytes(&self) -> &[u8] { + self.ram } pub fn as_slice(&self) -> &[u8] { diff --git a/kernel/src/application/mod.rs b/kernel/src/application/mod.rs index 7659bdf..377bae2 100644 --- a/kernel/src/application/mod.rs +++ b/kernel/src/application/mod.rs @@ -35,6 +35,10 @@ pub struct FrameBuffer { impl FrameBuffer { /// Create a frame buffer from a pointer + /// + /// # Safety + /// + /// The pointer passed **must** but a unique pointer and not shared or aliased. pub unsafe fn new(ptr: *mut u8, len: usize, width: u8, height: u8) -> Self { Self { ptr, @@ -65,7 +69,7 @@ impl embedded_graphics::draw_target::DrawTarget for FrameBuffer { let y = pos.y; let color: u16 = RawU16::from(color).into_inner(); let slice = unsafe { core::slice::from_raw_parts_mut(self.ptr, self.len) }; - slice[((x + (y * self.width as i32)) as usize * 2)] = (color >> 8) as u8; + slice[(x + (y * self.width as i32)) as usize * 2] = (color >> 8) as u8; slice[(((x + (y * self.width as i32)) as usize) * 2) + 1] = color as u8; }); diff --git a/kernel/src/application/states/clock.rs b/kernel/src/application/states/clock.rs index aa7b77c..abf671a 100644 --- a/kernel/src/application/states/clock.rs +++ b/kernel/src/application/states/clock.rs @@ -72,7 +72,7 @@ impl State for ClockState { .ok(); self.buffer.clear(); - write!(self.buffer, "{:02}%", soc).unwrap(); + write!(self.buffer, "{soc:02}%").unwrap(); Text::new(self.buffer.as_str(), Point::new(110, 12), style) .draw(display) .ok(); diff --git a/kernel/src/application/states/mwatch.rs b/kernel/src/application/states/mwatch.rs index 92a6147..583ca26 100644 --- a/kernel/src/application/states/mwatch.rs +++ b/kernel/src/application/states/mwatch.rs @@ -11,13 +11,10 @@ use embedded_graphics::pixelcolor::Rgb565; use embedded_graphics::prelude::*; use embedded_graphics::text::{Alignment, Text}; +#[derive(Default)] pub struct MWState {} -impl Default for MWState { - fn default() -> Self { - Self {} - } -} + impl State for MWState { fn render(&mut self, _system: &mut System, display: &mut FrameBuffer) -> Option { diff --git a/kernel/src/application/states/notifications.rs b/kernel/src/application/states/notifications.rs index 661ca50..584c08d 100644 --- a/kernel/src/application/states/notifications.rs +++ b/kernel/src/application/states/notifications.rs @@ -78,7 +78,7 @@ impl State for NotificationState { system .nm .peek_notification(self.menu.selected() as usize, |notification| { - self.body.render(display, ¬ification); + self.body.render(display, notification); }); } } diff --git a/kernel/src/application/states/uop.rs b/kernel/src/application/states/uop.rs index d2510c1..9a02267 100644 --- a/kernel/src/application/states/uop.rs +++ b/kernel/src/application/states/uop.rs @@ -4,15 +4,10 @@ use crate::{application::{states::prelude::*, FrameBuffer}, system::{System, inp use embedded_graphics::{image::{Image, ImageRaw}, pixelcolor::{Rgb565, raw::LittleEndian}, prelude::{Point, OriginDimensions, Dimensions}, Drawable}; +#[derive(Default)] pub struct UopState {} -impl Default for UopState { - fn default() -> Self { - Self { - - } - } -} + impl State for UopState { fn render(&mut self, _system: &mut System, display: &mut FrameBuffer) -> Option { diff --git a/kernel/src/ingress/ingress_manager.rs b/kernel/src/ingress/ingress_manager.rs index 226d49f..93cc26b 100644 --- a/kernel/src/ingress/ingress_manager.rs +++ b/kernel/src/ingress/ingress_manager.rs @@ -53,7 +53,7 @@ pub struct IngressManager { impl IngressManager { /// Constructs a new IngressManager pub fn new() -> Self { - IngressManager { + Self { rb: Queue::new(), state: State::Init, hex_chars: [0u8; 2], @@ -253,6 +253,12 @@ impl IngressManager { } } +impl Default for IngressManager { + fn default() -> Self { + Self::new() + } +} + #[cfg(test)] mod test { use super::*; diff --git a/kernel/src/system/input.rs b/kernel/src/system/input.rs index b399e74..55902c7 100644 --- a/kernel/src/system/input.rs +++ b/kernel/src/system/input.rs @@ -43,7 +43,7 @@ pub struct InputManager { impl InputManager { /// Creates a new instance of the InputManager - pub fn new() -> Self { + pub const fn new() -> Self { Self { raw_vector: 0, last_vector: 0, diff --git a/kernel/src/system/notification.rs b/kernel/src/system/notification.rs index 00a0c09..5e6a83d 100644 --- a/kernel/src/system/notification.rs +++ b/kernel/src/system/notification.rs @@ -31,8 +31,8 @@ impl Notification { pub fn from_buffer(buffer: &Buffer, idxs: &[usize; 3]) -> Result { Ok(Notification { - section_indexes: idxs.clone(), - inner: buffer.clone() + section_indexes: *idxs, + inner: *buffer }) } @@ -60,7 +60,7 @@ pub struct NotificationManager { } impl NotificationManager { - pub fn new() -> NotificationManager { + pub const fn new() -> NotificationManager { NotificationManager { pool: [Notification::default(); BUFF_COUNT], idx: 0, @@ -73,7 +73,7 @@ impl NotificationManager { F: FnOnce(&Notification), { let notification = &self.pool[index]; - f(¬ification); + f(notification); } pub fn idx(&self) -> usize { diff --git a/kernel/src/system/syscall.rs b/kernel/src/system/syscall.rs index 119cb9a..13c4af9 100644 --- a/kernel/src/system/syscall.rs +++ b/kernel/src/system/syscall.rs @@ -74,7 +74,7 @@ impl Syscall { } } // vals[0] // TODO day in week - Ok(Date::from_calendar_date(vals[3], (vals[2] as u8).try_into().map_err(|_| Error::ParseError)?, vals[1] as u8).map_err(|_| Error::ParseError)?) + Date::from_calendar_date(vals[3], (vals[2] as u8).try_into().map_err(|_| Error::ParseError)?, vals[1] as u8).map_err(|_| Error::ParseError) } pub fn time_from_str(s: &str) -> Result { @@ -88,7 +88,7 @@ impl Syscall { } } } - Ok(Time::from_hms(vals[0], vals[1], vals[2]).map_err(|_| Error::ParseError)?) + Time::from_hms(vals[0], vals[1], vals[2]).map_err(|_| Error::ParseError) } }