{"id":13815621,"url":"https://github.com/hemashushu/practice-mcu-bare-metal-rust","last_synced_at":"2025-05-15T09:32:50.193Z","repository":{"id":63045690,"uuid":"562296915","full_name":"hemashushu/practice-mcu-bare-metal-rust","owner":"hemashushu","description":"A bare metal (register level) STM32F103C8T6/STM32F103 MCU program written in pure Rust without any IDE, SDK, HAL or library, and no assembly code, the only tool required is the Rust compiler.","archived":false,"fork":false,"pushed_at":"2023-01-19T03:22:49.000Z","size":4186,"stargazers_count":120,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-19T11:52:54.579Z","etag":null,"topics":["arm","bare-metal","cortex-m3","mcu","rust","stm32","stm32f103c8t6"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hemashushu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-05T22:28:15.000Z","updated_at":"2024-10-30T19:21:08.000Z","dependencies_parsed_at":"2023-01-26T14:01:39.907Z","dependency_job_id":null,"html_url":"https://github.com/hemashushu/practice-mcu-bare-metal-rust","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemashushu%2Fpractice-mcu-bare-metal-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemashushu%2Fpractice-mcu-bare-metal-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemashushu%2Fpractice-mcu-bare-metal-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemashushu%2Fpractice-mcu-bare-metal-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hemashushu","download_url":"https://codeload.github.com/hemashushu/practice-mcu-bare-metal-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254313973,"owners_count":22050148,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arm","bare-metal","cortex-m3","mcu","rust","stm32","stm32f103c8t6"],"created_at":"2024-08-04T04:03:41.444Z","updated_at":"2025-05-15T09:32:49.395Z","avatar_url":"https://github.com/hemashushu.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# MCU STM32F103C8T6 Bare-metal in Rust\n\n[EN](README.md) | [中文](README.zh-Hans.md)\n\nA bare metal (register level) STM32F103C8T6/STM32F103 MCU program written in pure Rust without any IDE, SDK, HAL or library, and no assembly code, the only tool required is the Rust compiler. Implemented the basic input and output, timer, serial communication, etc. by directly reading and writing registers of hardware.\n\n![stm32f103 rust bare-metal](images/stm32f103-title-v2.jpg)\n\n## Implemented Features\n\n- GPIO read and write\n- Set system clock\n- SysTick and interrupt\n- UART read and write\n\n[Demo video](https://user-images.githubusercontent.com/394223/206145763-c068ce9e-dcf1-4c87-a6ef-062fdc21162d.mp4)\n\n[Demo video](images/stm32f103-v2.mp4)\n\n\u003cvideo width=\"480\" height=\"270\" controls\u003e\n  \u003csource src=\"images/stm32f103-v2.mp4\" type=\"video/mp4\"\u003e\n\u003c/video\u003e\n\n## Source Code Structure\n\n- `src/register_*.rs` Definition of register structures and values\n- `src/startup.rs` startup and vector array\n- `src/main.rs` main program\n- `.vscode/launch.json` configuration file for VSCode debug\n- `svd/` `System View Description` file for displaying various register names and address values during GDB debugging\n- `build.sh` script for compiling\n- `flash.sh` script for compiling and downloading firmware\n\n## Wires\n\n- PC13: builtin LED -\n- PB5: external LED +\n- PA0: button (the another button pin connect to GND)\n- PA9: USART1_TX -\u003e CP2012 RX\n- PA10: USART1_RX -\u003e CP2012 TX\n\n## Compile\n\nInstall `Rust` on your platform first, then run:\n\n`$ ./build.sh`\n\n## Flash\n\nConnect the MCU to your computer using the `CMSIS_DAP debugger` (hardware) and then run:\n\n`$ ./flash.sh`\n\n## Debug\n\n`$ ./server-gdb-server.sh`\n\nthen open another terminal, and run:\n\n`$ ./start-gdb-client-with-svd.sh`\n\n## Reference Documents\n\nHardware description and register structure and value description documentations:\n\n- STM32F103c8 Datasheet\n  https://www.st.com/resource/en/datasheet/cd00161566.pdf\n\n- RM0008 Reference manual\n  https://www.st.com/resource/en/reference_manual/cd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf\n\n- PM0214 Programming manual\n  https://www.st.com/resource/en/programming_manual/pm0214-stm32-cortexm4-mcus-and-mpus-programming-manual-stmicroelectronics.pdf\n\nFor those who want to know how it works and who want to go further and implement more features, check out these:\n\n- Bare metal programming guide (C lang on STM32F429)\n  https://github.com/cpq/bare-metal-programming-guide\n\n- The Embedonomicon\n  https://docs.rust-embedded.org/embedonomicon/\n\n- libopencm3 project\n  https://github.com/libopencm3/libopencm3\n\n## C language version\n\nThis project is also implemented in C by the author, for those interested please check out [MCU STM32F030C8T6 Bare-metal in C](https://github.com/hemashushu/practice-mcu-bare-metal-stm32f030)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemashushu%2Fpractice-mcu-bare-metal-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhemashushu%2Fpractice-mcu-bare-metal-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemashushu%2Fpractice-mcu-bare-metal-rust/lists"}