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

More Zephyr doc updates #175

Merged
merged 5 commits into from
Oct 27, 2023
Merged

More Zephyr doc updates #175

merged 5 commits into from
Oct 27, 2023

Conversation

erlingrj
Copy link
Collaborator

I am sorry for the all the Zephyr updates. Here is my final proposal which I think is quite macOS compatible also

Copy link
Contributor

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not able to get this to work on a Mac.
First, following "Install Zephyr SDK" at https://docs.zephyrproject.org/latest/develop/getting_started/index.html gives the following output:

Installing host tools ...
SKIPPED: macOS host tools are not available yet.

Proceeding anyway:

$ west build src-gen/HelloWorld -t run
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base (cached)).
-- Application: /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld/src-gen/HelloWorld
-- CMake version: 3.27.6
-- Cache files will be written to: /Users/edwardlee/Library/Caches/zephyr
-- Zephyr version: 3.4.0 (/Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: qemu_cortex_m3
-- Found toolchain: gnuarmemb (/usr/local/)
CMake Error at /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/cmake/compiler/gcc/generic.cmake:9 (message):
  Zephyr was unable to find the toolchain.  Is the environment misconfigured?

  User-configuration:

  ZEPHYR_TOOLCHAIN_VARIANT: gnuarmemb

  Internal variables:

  CROSS_COMPILE: /usr/local//bin/arm-none-eabi-

  TOOLCHAIN_HOME: /usr/local/

Call Stack (most recent call first):
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/cmake/modules/FindHostTools.cmake:107 (include)
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/cmake/modules/dts.cmake:9 (find_package)
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/cmake/modules/zephyr_default.cmake:115 (include)
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
  CMakeLists.txt:9 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /opt/homebrew/bin/cmake -DWEST_PYTHON=/Users/edwardlee/.pyenv/versions/3.10.13/bin/python3.10 -B/Users/edwardlee/Library/CloudStorage/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld/build -GNinja -S/Users/edwardlee/Library/CloudStorage/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld/src-gen/HelloWorld

I found this page: https://learn.adafruit.com/blinking-led-with-zephyr-rtos/installing-zephyr-osx#installing-the-development-toolchain-3056482, which isn't quite right, but the following partially worked:

brew install --cask gcc-arm-embedded

However, this puts the tools in /opt/homebrew and the above command seems to still look for them in /usr/local. Suggestions?

@erlingrj
Copy link
Collaborator Author

Hi Edward. I have verified that this works on my macOS Ventura. The error seems to be that it doesn't find the SDK that you have installed. This is the output from my machine:

(.venv) erling@Erlings-MacBook-Pro ~/d/l/a/HelloWorld (main)> west lfc src/HelloWorld.lf --build "-t run"
Executing lfc command: `lfc -c -n src/HelloWorld.lf`
lfc: info: Generating code for: file:/Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/src/HelloWorld.lf
lfc: info: Generation mode: STANDALONE
lfc: info: Generating sources into: /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/src-gen/HelloWorld
Cleaning /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/bin
Cleaning /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/src-gen
Cleaning /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/include
lfc: info: Code generation finished.
Executing west command: `west build src-gen/HelloWorld -t run`
-- west build: running target run
[0/1] Re-running CMake...
Loading Zephyr default modules (Zephyr base (cached)).
-- Application: /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/src-gen/HelloWorld
-- CMake version: 3.27.7
-- Cache files will be written to: /Users/erling/Library/Caches/zephyr
-- Zephyr version: 3.4.0 (/Users/erling/dev/lf-zephyr-workspace/deps/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: qemu_cortex_m3
-- Found host-tools: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
-- Found toolchain: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
-- Found BOARD.dts: /Users/erling/dev/lf-zephyr-workspace/deps/zephyr/boards/arm/qemu_cortex_m3/qemu_cortex_m3.dts
-- Found devicetree overlay: /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/src-gen/HelloWorld/app.overlay
-- Generated zephyr.dts: /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /Users/erling/dev/lf-zephyr-workspace/apps/HelloWorld/build/zephyr/dts.cmake
  1. Are you sure ./setup.sh ran to completion when you installed the SDK? I recommend untarring it to /opt/ and running ./setup.sh, I also got the warning that the host-tools couldn't be installed. So that is not the culprit.

  2. Did you run the west zephyr-export command?

  3. You could try to force CMake to find the right toolchain, even though this should happen by itself when not-specified and when you have run the setup script. But you can set the following environment variables

ZEPHYR_TOOLCHAIN_VARIANT=zephyr
ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk-0.16.3 # This is where it is located on my machine.

This should not be necessary though...

@edwardalee
Copy link
Contributor

Yes, I did all these things. I initially tried putting the SDK installation somewhere other than /opt, but moving it there doesn't help. Note that west seems to be looking in /usr/local/bin despite the environment variables being set correctly, as shown at the end of the following trace:

west build src-gen/HelloWorld -t run
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base (cached)).
-- Application: /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld/src-gen/HelloWorld
-- CMake version: 3.27.6
-- Cache files will be written to: /Users/edwardlee/Library/Caches/zephyr
-- Zephyr version: 3.4.0 (/Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: qemu_cortex_m3
-- Found host-tools: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
-- Found toolchain: gnuarmemb (/usr/local/)
CMake Error at /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/cmake/compiler/gcc/generic.cmake:9 (message):
  Zephyr was unable to find the toolchain.  Is the environment misconfigured?

  User-configuration:

  ZEPHYR_TOOLCHAIN_VARIANT: gnuarmemb

  Internal variables:

  CROSS_COMPILE: /usr/local//bin/arm-none-eabi-

  TOOLCHAIN_HOME: /usr/local/

Call Stack (most recent call first):
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/cmake/modules/FindHostTools.cmake:107 (include)
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/cmake/modules/dts.cmake:9 (find_package)
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/cmake/modules/zephyr_default.cmake:115 (include)
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /Users/edwardlee/Dropbox/Projects/Zepher/lf-zephyr-workspace/deps/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
  CMakeLists.txt:9 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /opt/homebrew/bin/cmake -DWEST_PYTHON=/Users/edwardlee/.pyenv/versions/3.10.13/bin/python3.10 -B/Users/edwardlee/Library/CloudStorage/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld/build -GNinja -S/Users/edwardlee/Library/CloudStorage/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld/src-gen/HelloWorld
(zepher) ~/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld % echo $ZEPHYR_TOOLCHAIN_VARIANT
zephyr
(zepher) ~/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld % echo $ZEPHYR_SDK_INSTALL_DIR
/opt/zephyr-sdk-0.16.3
(zepher) ~/Dropbox/Projects/Zepher/lf-zephyr-workspace/apps/HelloWorld % 

@erlingrj
Copy link
Collaborator Author

That is very strange. Can you try to deleting the build folder between these builds?

@erlingrj
Copy link
Collaborator Author

The problem you are experiencing Edward seems specific to your system. I am able to follow this guide on my MacBook and another person was also able to do it on his MacBook: lf-lang/lingua-franca#2064.

I will merge this PR since the docs are now out-of-date with lf-west-template. I can continue helping you to debug this problem though!

@erlingrj erlingrj merged commit c7525e3 into lf-lang:main Oct 27, 2023
1 check passed
@erlingrj erlingrj deleted the zephyr-update branch October 28, 2023 12:31
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.

2 participants