Skip to content

Commit

Permalink
Add support for ESP32-P4 (#408)
Browse files Browse the repository at this point in the history
* feat: Add support for ESP32-P4

* docs: Update changelog
  • Loading branch information
SergioGasquez authored Jan 15, 2024
1 parent 4e4ff03 commit 36e055c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Added support for specifying the location of the export file via `ESPUP_EXPORT_FILE` (#403)
- Added support for ESP32-P4 (#408)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Options:
With this option, espup will skip GCC installation (it will be handled by esp-idf-sys), hence you won't be able to build no_std applications.

-t, --targets <TARGETS>
Comma or space separated list of targets [esp32,esp32c2,esp32c3,esp32c6,esp32h2,esp32s2,esp32s3,all]
Comma or space separated list of targets [esp32,esp32c2,esp32c3,esp32c6,esp32h2,esp32s2,esp32s3,esp32p4,all]

[default: all]

Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct InstallOpts {
/// With this option, espup will skip GCC installation (it will be handled by esp-idf-sys), hence you won't be able to build no_std applications.
#[arg(short = 's', long)]
pub std: bool,
/// Comma or space separated list of targets [esp32,esp32c2,esp32c3,esp32c6,esp32h2,esp32s2,esp32s3,all].
/// Comma or space separated list of targets [esp32,esp32c2,esp32c3,esp32c6,esp32h2,esp32s2,esp32s3,esp32p4,all].
#[arg(short = 't', long, default_value = "all", value_parser = parse_targets)]
pub targets: HashSet<Target>,
/// Xtensa Rust toolchain version.
Expand Down
3 changes: 3 additions & 0 deletions src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub enum Target {
ESP32S2,
/// Xtensa LX7 based dual core
ESP32S3,
/// RISC-V based dual core
ESP32P4,
}

impl Target {
Expand Down Expand Up @@ -90,6 +92,7 @@ mod tests {
Target::ESP32H2,
Target::ESP32S2,
Target::ESP32S3,
Target::ESP32P4,
]
.into_iter()
.collect();
Expand Down
5 changes: 4 additions & 1 deletion src/toolchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ pub async fn install(args: InstallOpts, install_mode: InstallMode) -> Result<()>
to_install.push(Box::new(xtensa_rust.to_owned()));
}

to_install.push(Box::new(llvm));
// Check if ther is any Xtensa target
if targets.iter().any(|t| t.is_xtensa()) {
to_install.push(Box::new(llvm.to_owned()));
}

if targets.iter().any(|t| t.is_riscv()) {
let riscv_target = RiscVTarget::new(&args.nightly_version);
Expand Down
4 changes: 3 additions & 1 deletion src/toolchain/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ impl RiscVTarget {
nightly_version,
"riscv32imc-unknown-none-elf",
"riscv32imac-unknown-none-elf",
"riscv32imafc-unknown-none-elf",
])
.stdout(Stdio::null())
.status()?
Expand All @@ -350,7 +351,7 @@ impl RiscVTarget {
impl Installable for RiscVTarget {
async fn install(&self) -> Result<Vec<String>, Error> {
info!(
"Installing RISC-V Rust targets ('riscv32imc-unknown-none-elf' and 'riscv32imac-unknown-none-elf') for '{}' toolchain", &self.nightly_version
"Installing RISC-V Rust targets ('riscv32imc-unknown-none-elf', 'riscv32imac-unknown-none-elf' and 'riscv32imafc-unknown-none-elf') for '{}' toolchain", &self.nightly_version
);

if !Command::new("rustup")
Expand All @@ -365,6 +366,7 @@ impl Installable for RiscVTarget {
"--target",
"riscv32imc-unknown-none-elf",
"riscv32imac-unknown-none-elf",
"riscv32imafc-unknown-none-elf",
])
.stdout(Stdio::null())
.stderr(Stdio::null())
Expand Down

0 comments on commit 36e055c

Please sign in to comment.