{"id":13423263,"url":"https://github.com/rust-embedded/msp430-quickstart","last_synced_at":"2025-04-13T00:45:13.710Z","repository":{"id":53718563,"uuid":"236834291","full_name":"rust-embedded/msp430-quickstart","owner":"rust-embedded","description":"Template to develop bare metal applications for MSP430 microcontrollers","archived":false,"fork":false,"pushed_at":"2022-09-11T22:19:26.000Z","size":72,"stargazers_count":40,"open_issues_count":0,"forks_count":6,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-26T18:51:53.772Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-embedded.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-28T20:28:05.000Z","updated_at":"2025-03-13T18:55:30.000Z","dependencies_parsed_at":"2023-01-18T04:15:30.667Z","dependency_job_id":null,"html_url":"https://github.com/rust-embedded/msp430-quickstart","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/rust-embedded%2Fmsp430-quickstart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Fmsp430-quickstart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Fmsp430-quickstart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Fmsp430-quickstart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-embedded","download_url":"https://codeload.github.com/rust-embedded/msp430-quickstart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650420,"owners_count":21139672,"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":[],"created_at":"2024-07-31T00:00:26.822Z","updated_at":"2025-04-13T00:45:13.689Z","avatar_url":"https://github.com/rust-embedded.png","language":"Rust","readme":"# `msp430-quickstart`\n\n\u003e A template for building applications for TI MSP430 microcontrollers.\n\nThis project is developed and maintained by the [MSP430 team][team].\n\n## Dependencies\n\n- Rust nightly-2022-01-24 or a newer toolchain. _Only nightly compilers work\n  for now._\n\n  The [`rust-toolchain.toml`](./rust-toolchain.toml) file makes sure this step\n  is done for you. This file tells [`rustup`](https://rustup.rs/) to download\n  and use nightly compiler for this crate, as well as download the compiler\n  source to build `libcore`.\n\n  You can manually set up a nightly compiler as the default for all MSP430\n  projects by running:\n\n  ``` console\n  $ rustup default nightly\n  $ rustup component add rust-src\n  ```\n\n  Alternatively, you can manually set up overrides on a project basis using:\n\n  ```console\n  $ rustup override set --path /path/to/crate nightly-YYYY-MM-DD`.\n  $ rustup component add --toolchain nightly-YYYY-MM-DD rust-src\n  ```\n\n- The `cargo generate` subcommand ([Installation instructions](https://github.com/ashleygwilliams/cargo-generate#installation)).\n\n- TI's [MSP430 GCC Compiler](http://www.ti.com/tool/MSP430-GCC-OPENSOURCE),\n  version 8.3.0 or greater. `msp430-elf-gcc` should be visible on the path.\n\nThe following dependencies are required in order to generate a peripheral access crate (see *Using this template* below)\n\n- [`svd2rust`](https://github.com/rust-embedded/svd2rust), version 0.20.0 or\n  a newer commit.\n\n- [`msp430_svd`](https://github.com/pftbest/msp430_svd), version 0.3.0 or a\n  newer commit. Cloning the repo and following the directions in README.md is\n  sufficient.\n\n## Using this template\n\n0. Before instantiating a project, you need to know some characteristics about\n   your specific MSP430 device that will be used to fill in the template. In\n   particular:\n\n   - What is the exact part number of your device? Which MSP430 family does\n     your part belong to?\n\n   - Does your part have an already-existing [peripheral access crate](https://rust-embedded.github.io/book/start/registers.html) (PAC)?\n\n   - How much flash memory, RAM, and how many interrupt vectors does your\n     device have?\n\n   - Where does flash memory, RAM, and interrupt vectors begin in the address\n     space?\n\n   `msp430g2553` is used for the examples in this crate. Answering the first\n   question above:\n\n   - `msp430g2553` belongs to the [`MSP430x2xx` family](https://www.ti.com/lit/ug/slau144j/slau144j.pdf).\n\n   The linked family manual and [datasheet](http://www.ti.com/lit/ds/slas735j/slas735j.pdf)\n   can be used to answer the remaining questions:\n\n   - The `msp430g2553` PAC exists already and can be found on [crates.io](https://crates.io/crates/msp430g2553).\n\n   - `msp430g2553` has 16kB of flash memory, 512 bytes of RAM, and 16 vectors.\n\n   - Flash memory begins at address 0xC000. RAM begins at address 0x0200.\n     The interrupt vectors begin at 0xFFE0.\n\n1. If your particular device does not have a PAC crate, you will need to\n   generate one using `svd2rust` and possibly [publish](https://doc.rust-lang.org/cargo/reference/publishing.html)\n   the crate to https://crates.io. To generate an SVD file, follow the directions\n   in the `msp430_svd` [README.md](https://github.com/pftbest/msp430_svd#msp430_svd)\n   for your device.\n\n   In some cases like [`msp430fr2355`](https://github.com/YuhanLiin/msp430fr2355-quickstart/issues/4#issuecomment-569178043),\n   TI's linker files are not consistent with datasheets on where interrupt\n   vectors begin and how many interrupt vectors there are for a given device.\n   In case of a conflict, _[examine](https://github.com/YuhanLiin/msp430fr2355-quickstart#issuecomment-569320608)\n   the linker script to determine where to start the `VECTORS` section in\n   `memory.x`._ Copies of many linker scripts are kept in the\n   [`msp430_svd`](https://github.com/pftbest/msp430_svd/tree/master/msp430-gcc-support-files)\n   repository.\n\n2. Instantiate the template and follow the prompts.\n\n   ``` console\n   $ cargo generate --git https://github.com/rust-embedded/msp430-quickstart\n   Project Name: app\n   Creating project called `app`...\n   Done! New project created /tmp/app\n\n   $ cd app\n   ```\n\n3. If not targeting `msp430g2553`, replace the PAC entry for `msp430g2553` in\n   `Cargo.toml` with that of your device, e.g.:\n\n   ``` toml\n   # [dependencies.msp430g2553]\n   # version = \"0.3.0\"\n   # features = [\"rt\"]\n   [dependencies.msp430fr2355]\n   version = \"0.4.0\"\n   features = [\"rt\"]\n   ```\n\n4. Populate the `memory.x` file with address space layout information of your\n   device. _Note: As mentioned above, in case of a conflict between the\n   datasheet and linker script on where interrupt vectors begin, use the\n   linker script!_\n\n   ``` console\n   $ cat memory.x\n   MEMORY\n   {\n     /* These values are correct for the msp430g2553 device. You will need to\n        modify these values if using a different device. Room must be reserved\n        for interrupt vectors plus reset vector and the end of the first 64kB\n        of address space. */\n     RAM : ORIGIN = 0x0200, LENGTH = 0x0200\n     ROM : ORIGIN = 0xC000, LENGTH = 0x3FE0\n     VECTORS : ORIGIN = 0xFFE0, LENGTH = 0x20\n   }\n   ```\n\n5. Build the template application or one of the examples. Some examples\n   (such as `timer` or `temp-hal`) may not compile due to size\n   constraints when building using the `dev` profile (the default). Pass the\n   `--release` option to `cargo build` in these cases.\n\n   ``` console\n   $ cargo build\n   $ cargo build --examples\n   ```\n\n   Note that due to [`.cargo/config`](.cargo/config) and [`rust-toolchain.toml`](./rust-toolchain.toml),\n   the above is shorthand for:\n\n   ``` console\n   $ cargo +nightly build --target=msp430-none-elf -Zbuild-std=core\n   $ cargo +nightly build --target=msp430-none-elf -Zbuild-std=core --examples\n   ```\n\n   You may wish to experiment with other commented options in `.cargo/config`.\n\n6. Once you have an ELF binary built, flash it to your microcontroller. Use [`mspdebug`](https://github.com/dlbeer/mspdebug) to launch a debug session and `msp430-elf-gdb` with the linked gdb script. For the msp430g2553 and the MSP-EXP430G2 launchpad board this looks like the following:\n\n   In one terminal session\n   ```console\n   $ mspdebug -C mspdebug.cfg rf2500\n   ```\n\n   In another terminal session\n   ```console\n   $ msp430-elf-gdb -x mspdebug.gdb target/msp430-none-elf/debug/app\n   ```\n\n   This will flash your Rust code to the microcontroller and open a gdb debugging session to step through it.\n\n# License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  http://www.apache.org/licenses/LICENSE-2.0)\n\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n  at your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n[team]: https://github.com/rust-embedded/wg#the-msp430-team\n","funding_links":[],"categories":["Peripheral Access Crates","Recently Updated"],"sub_categories":["MSP430","[Feb 24, 2025](/content/2025/02/24/README.md)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-embedded%2Fmsp430-quickstart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-embedded%2Fmsp430-quickstart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-embedded%2Fmsp430-quickstart/lists"}