Skip to content

Use Linux i386/AMD64 binaries on FreeBSD. (IDFGH-5492) #7226

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

Merged
merged 1 commit into from
Jul 25, 2021

Conversation

cederom
Copy link
Contributor

@cederom cederom commented Jul 2, 2021

FreeBSD can natively emulate Linux ELF binaries.
This commit allows automated Linux tools deployment on FreeBSD.

Signed-off-by: Tomasz 'CeDeROM' CEDRO tomek@cedro.info

FreeBSD can natively emulate Linux ELF binaries.
This commit allows automated Linux tools deployment on FreeBSD.

Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
@CLAassistant
Copy link

CLAassistant commented Jul 2, 2021

CLA assistant check
All committers have signed the CLA.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 2, 2021
@github-actions github-actions bot changed the title Use Linux i386/AMD64 binaries on FreeBSD. Use Linux i386/AMD64 binaries on FreeBSD. (IDFGH-5492) Jul 2, 2021
@Alvin1Zhang
Copy link
Collaborator

Thanks for your contribution.

@cederom
Copy link
Contributor Author

cederom commented Jul 6, 2021

I can confirm that this commit allows build Zephyr for ESP32 on FreeBSD using Linux toolchain when following instructions provided in the official Zephyr HandBook are met: https://docs.zephyrproject.org/latest/boards/xtensa/esp32/doc/index.html. It is very important to setup environmental variables as instructed :-)

It may be really nice to add west espressif sdk_path command that would quickly return full path to the xtensa toolchain location on the filesystem (installed with west espressif install), so that could be passed to set up the environment scripts before build :-)

Also west espressif info would be nice to have with all necessary version information etc :-)

If you are the authors of the west espressif part please consider such option :-)

@igrr
Copy link
Member

igrr commented Jul 9, 2021

cc @sylvioalves for west espressif part

@espressif-bot espressif-bot added Status: In Progress Work is in progress Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new Status: In Progress Work is in progress labels Jul 20, 2021
@espressif-bot espressif-bot merged commit e1c978a into espressif:master Jul 25, 2021
@cederom
Copy link
Contributor Author

cederom commented Oct 8, 2021

Hello. Was this patch updated to Zephyr upstream? On a new project calling west espressif update; west espressif install returns:

(venv38zephyr) west espressif update
=== updating ESP-IDF submodules..
=== updating ESP-IDF submodules completed

(venv38zephyr) west espressif install
=== downloading ESP-IDF tools..
ERROR: Platform FreeBSD-amd64 appears to be unsupported
FATAL ERROR: command exited with status 1: ./tools/idf_tools.py --tools-json=tools/zephyr_tools.json install

(venv38zephyr) git branch
* main

(venv38zephyr) git remote -v
origin  https://github.com/zephyrproject-rtos/zephyr.git (fetch)
origin  https://github.com/zephyrproject-rtos/zephyr.git (push)

(venv38zephyr) git log -1
commit 39c535fef8347aa1850338e2ea8b3861b5203eef (HEAD -> main, origin/main, master)
Author: Piotr Pryga <piotr.pryga@nordicsemi.no>
Date:   Thu Oct 7 14:59:08 2021 +0200

    Bluetooth: controller: Make per adv filtering by CTE cond compilable

    The filtering of periodic advertisements by scanner may be not needed
    in certain situations e.g. while use of periodic advertising by BT ISO.
    To make the code smaller and avoid execution of not needed code the
    functionality will be conditionally compilable. It may be enabled
    or disabled by use of CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING
    Kconfig option.

    Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>

@sylvioalves
Copy link

sylvioalves commented Oct 8, 2021

@cederom yes, it was: zephyrproject-rtos/hal_espressif#44
The error you are facing is related to platform definition as in:
CURRENT_PLATFORM = PLATFORM_FROM_NAME.get(PYTHON_PLATFORM, UNKNOWN_PLATFORM).

In your environment, CURRENT_PLATFORM is being set to UNKNOWN_PLATFORM, which causes the error ERROR: Platform FreeBSD-amd64 appears to be unsupported.

Can you post what is the value of PYTHON_PLATFORM as in:
PYTHON_PLATFORM = platform.system() + '-' + platform.machine()

I guess there might be a typo error in there, let's see.

Thanks!

@cederom
Copy link
Contributor Author

cederom commented Oct 8, 2021

System default Python:

% python
Python 3.8.12 (default, Sep 11 2021, 01:14:09)
[Clang 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> PYTHON_PLATFORM = platform.system() + '-' + platform.machine()
>>> print(PYTHON_PLATFORM)
FreeBSD-amd64

VEnv Python:

% zvenvsdk.sh venv
(venv38zephyr) python
Python 3.8.12 (default, Sep 11 2021, 01:14:09)
[Clang 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> PYTHON_PLATFORM = platform.system() + '-' + platform.machine()
>>> print(PYTHON_PLATFORM)
FreeBSD-amd64

@sylvioalves
Copy link

@cederom Can you confirm whether zephyr/modules/hal/espressif/tools/idf_tools.py contains proper FreeBSD-amd64 entry in your environment?

https://github.com/zephyrproject-rtos/hal_espressif/blob/zephyr/tools/idf_tools.py#L129

@cederom
Copy link
Contributor Author

cederom commented Oct 8, 2021

Okay, that was problem with my local Zephyr Env launcher script, I have removed and re-created everything from scratch and it works now! :-)

SORRY, and THANK YOU for your time @sylvioalves !! :-)

I can see that this ESP-IDF is a core for Zephyr and NuttX. Sweet! :-)

I would like to try ESP32-C3 / RISC-V on both Zephyr and NuttX :-)

Quick question what toolchain env variable should I use for riscv on Zephyr do you know? :-)

@sylvioalves
Copy link

Hi, great!

You can follow the getting started as in https://docs.zephyrproject.org/latest/boards/riscv/esp32c3_devkitm/doc/index.html.

Also, west espressif install informs the toolchain path once it finishes downloading it. Does that work for you?

@cederom
Copy link
Contributor Author

cederom commented Oct 8, 2021

(venv38zephyr) west espressif install
=== downloading ESP-IDF tools..
Installing tools: xtensa-esp32-elf, xtensa-esp32s2-elf, riscv32-esp-elf, openocd-esp32
Skipping xtensa-esp32-elf@esp-2020r3-8.4.0 (already installed)
Skipping xtensa-esp32s2-elf@esp-2020r3-8.4.0 (already installed)
Skipping riscv32-esp-elf@1.24.0.123_64eb9ff-8.4.0 (already installed)
Skipping openocd-esp32@v0.10.0-esp32-20200709 (already installed)
=== downloading ESP-IDF tools completed
The toolchain has been downloaded to /home/XXX/.espressif/tools/zephyr
Export or set the following variables into the environment:
export ESPRESSIF_TOOLCHAIN_PATH="/home/XXX/.espressif/tools/zephyr"
export ZEPHYR_TOOLCHAIN_VARIANT="espressif"

Blinky nor Hello World does not build yet, but I have a good starting point, thank you @sylvioalves ! I have the ESP32-C3-WROOM and ESP32-C3-MINI, on tuesday I should get their DevKits so I can verify on real hardware :-) I will return with success or when stuck :-) Thank you!! :-)

@sylvioalves
Copy link

Please, try: rm -rf build; west build -p -b esp32c3_devkitm samples/hello_world.
Only esp32c3_devkitm is supported yet.

@cederom
Copy link
Contributor Author

cederom commented Oct 8, 2021

Ah, the Toolchain Path was recently simplified to just use ESPRESSIF_TOOLCHAIN_PATH="${HOME}/.espressif/tools/zephyr "? Now it works! And its more clear now! I can use only one ESP32 toolchain to build for different ESP32 cores including Xtensa and RISC-V.. no need to setup local rv32 toolchain anymore! AWSOME!! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants