Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flasher_stub: pass -mabi=ilp32, add EXTRA_CFLAGS, to allow building with a stock compiler (ESPTOOL-643) #856

Merged
merged 2 commits into from
Mar 16, 2023

Conversation

paravoid
Copy link
Contributor

@paravoid paravoid commented Mar 9, 2023

Description of the change

I'm trying to resume work that I started a few years ago (see #499, #500, #501, Debian bug #948096) to try to have Debian ship the esptool flasher stubs.

The TL;DR is that packages in Debian need to build from source and cannot ship binary blobs, and that includes both the stub binaries, as well as precompiled toolchains. Therefore the current Debian maintainer has opted into removing the stubs entirely. (The package is also a bit stagnated, currently at v2.8, and I'm trying to fix that).

For the RISC-V chips, there is no riscv32-esp-elf-gcc compiler in Debian (obviously :), but riscv64-unknown-elf-gcc (riscv64-unknown-elf-gcc (12.1.0-7+11) 12.1.0) exists, and picolibc supports RISC-V as well. What is required on a recent Debian system is:

apt install gcc-riscv64-unknown-elf picolibc-riscv64-unknown-elf

...plus the two commits in this PR, and then:

CROSS_ESPRISCV32=riscv64-unknown-elf- EXTRA_CFLAGS_ESPRISCV32=-specs=picolibc.specs make

After this, the resulting stub for a ESP32-C3 that I have in my disposal seemed to work fine for me. I don't have any other RISCV hardware to test this with.

Yes, I realize this will be entirely unsupported by Espressif. The two changes here are miniscule and no-ops for the Espressif toolchain -- the in-tree precompiled blobs remain unchanged.

Side note

The ESP8266 stub also builds and works on another test board that I have. No modifications are necessary. All that's needed is to:

apt install gcc-xtensa-lx106 picolibc-xtensa-lx106-elf

For the record, these are xtensa-lx106-elf-gcc (12.2.0-9+12) 12.2.0 and picolibc 1.8.

Sadly, there is no compiler for the ESP32/ESP32-S2/ESP32-S3 in Debian, nor there is support for them in picolibc. Currently I have local patches to remove $(STUB_ELF_32) $(STUB_ELF_32S2) $(STUB_ELF_32S3_BETA_2) $(STUB_ELF_32S3) from all and embed. It'd be nice to have some generalized way to build for specific chips.

@github-actions github-actions bot changed the title flasher_stub: pass -mabi=ilp32, add EXTRA_CFLAGS, to allow building with a stock compiler flasher_stub: pass -mabi=ilp32, add EXTRA_CFLAGS, to allow building with a stock compiler (ESPTOOL-643) Mar 9, 2023
@peterdragun
Copy link
Collaborator

Hi @paravoid, thanks for the PR. We have decided that we will accept it.

Can you please rebase the PR? It will help us to merge it using our internal process without losing the credits.
Thanks!

This is a no-op change for the upstream toolchain (compiled stubs are
binary identical), but is required when building with Debian's
riscv64-unknown-elf-gcc compiler.
The flasher_stub Makefile allows for some system-local configuration,
either through local.mk, or through environment variables.

For example, the compiler prefix can be overridden, by defining e.g.
CROSS_ESPRISCV32. However, passing additional flags to the compiler
isn't possible right now. Add EXTRA_CFLAGS and EXTRA_CFLAGS_ESPRISCV32
to allow for that option.
@paravoid
Copy link
Contributor Author

Hi @paravoid, thanks for the PR. We have decided that we will accept it.

Thanks!

Can you please rebase the PR? It will help us to merge it using our internal process without losing the credits. Thanks!

Done.

(I'll soon prepare another PR with some general flasher_stub Makefile fixes.)

@espressif-bot espressif-bot merged commit c10af95 into espressif:master Mar 16, 2023
@paravoid paravoid deleted the debian-riscv64-gcc branch March 16, 2023 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants