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

Should build work for frdm_k64f board? #17

Closed
laodzu opened this issue Feb 23, 2020 · 5 comments
Closed

Should build work for frdm_k64f board? #17

laodzu opened this issue Feb 23, 2020 · 5 comments

Comments

@laodzu
Copy link

laodzu commented Feb 23, 2020

So I successfully ran the sample app for BOARD=qemu_cortex_m3 in Qemu with Zephyr v2.1.0. Now I want to switch to my little embedded board supported by Zephyr. So I was expecting

cmake -GNinja -DBOARD=frdm_k64f ..
ninja flash

to work. But instead it fails like this:

dzu@krikkit:/opt/src/git/zephyr-rust/samples/rust-app/build-arm (master)$ ninja flash
[1/164] Generating rust-app/Cargo.toml

  • crate_dir=/opt/src/git/zephyr-rust/samples/rust-app
  • outdir=/opt/src/git/zephyr-rust/samples/rust-app/build-arm/modules/zephyr-rust/rust-app
  • rm -rf /opt/src/git/zephyr-rust/samples/rust-app/build-arm/modules/zephyr-rust/rust-app
  • mkdir -p /opt/src/git/zephyr-rust/samples/rust-app/build-arm/modules/zephyr-rust/rust-app/src
  • echo extern crate app;
  • cat
    [8/164] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
    FAILED: zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
    ccache /opt/zephyr-sdk-0.10.3/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DBUILD_VERSION=zephyr-v2.1.0 -DKERNEL -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/opt/src/git/zephyrproject/zephyr/kernel/include -I/opt/src/git/zephyrproject/zephyr/arch/arm/include -I/opt/src/git/zephyrproject/zephyr/include -I/opt/src/git/zephyrproject/zephyr/include/drivers -Izephyr/include/generated -I/opt/src/git/zephyrproject/zephyr/soc/arm/nxp_kinetis/k6x -I/opt/src/git/zephyrproject/zephyr/ext/hal/cmsis/Core/Include -I/opt/src/git/zephyr-rust/uart-buffered/src -isystem /opt/src/git/zephyrproject/zephyr/lib/libc/minimal/include -isystem /opt/zephyr-sdk-0.10.3/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/8.3.0/include -isystem /opt/zephyr-sdk-0.10.3/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/8.3.0/include-fixed -Os -imacros/opt/src/git/zephyr-rust/samples/rust-app/build-arm/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mthumb -mcpu=cortex-m4 -imacros/opt/src/git/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/opt/src/git/zephyr-rust/samples/rust-app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/src/git/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/src/git/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -mabi=aapcs -march=armv7e-m -std=c99 -nostdinc -MD -MT zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj -MF zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj.d -o zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj -c /opt/src/git/zephyrproject/zephyr/arch/arm/core/offsets/offsets.c
    In file included from /opt/src/git/zephyrproject/zephyr/include/arch/arm/cortex_m/cmsis.h:17,
    from /opt/src/git/zephyrproject/zephyr/include/arch/arm/syscall.h:29,
    from /opt/src/git/zephyrproject/zephyr/include/arch/syscall.h:15,
    from /opt/src/git/zephyrproject/zephyr/include/syscall.h:12,
    from /opt/src/git/zephyrproject/zephyr/include/kernel_includes.h:32,
    from /opt/src/git/zephyrproject/zephyr/include/kernel.h:17,
    from /opt/src/git/zephyrproject/zephyr/arch/arm/core/offsets/offsets.c:25:
    /opt/src/git/zephyrproject/zephyr/soc/arm/nxp_kinetis/k6x/soc.h:32:10: fatal error: fsl_common.h: No such file or directory
    #include <fsl_common.h>
    ^~~~~~~~~~~~~~
    compilation terminated.

Is this expected to work and if yes, how can I fix it?

Thanks in advance
Detlev

@tylerwhall
Copy link
Owner

My guess is you need to run west update to get the BSP dependencies. The build instructions here need to be updated to use west, following the general steps from the quick start.

There are no special commands for the zephyr-rust build procedure, other than adding this repo to ZEPHYR_MODULES in the project's cmake file, so you'd probably get the same problem building zephyr proper. Could try that as a baseline.

@reardencode
Copy link

reardencode commented Mar 25, 2020

FWIW, I'm getting similar when I try to build zephyr-rust for any real targets. (can't find nrfx.h for Nordic targets, and fsl_common.h for NXP targets). Non-rust application builds work fine.

west build -p auto -b nrf52840_pca10059 ../zephyr-rust/samples/rust-app
-- west build: build configuration:
       source directory: /home/brandon/stash/zephyrproject/zephyr-rust/samples/rust-app
       build directory: /home/brandon/stash/zephyrproject/zephyr/build
       BOARD: nrf52840_pca10059 (origin: CMakeCache.txt)
-- west build: building application
[2/159] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
FAILED: zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj 
ccache /home/brandon/.nix-profile/bin/arm-none-eabi-gcc -DBUILD_VERSION=zephyr-v2.2.0 -DKERNEL -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I../kernel/include -I../arch/arm/include -I../include -Izephyr/include/generated -I../soc/arm/nordic_nrf/nrf52 -I../ext/hal/cmsis/Core/Include -I/home/brandon/stash/zephyrproject/zephyr-rust/uart-buffered/src -isystem ../lib/libc/minimal/include -isystem /nix/store/zwlyixabawzbj0ckmzhk8a55kyx99ka6-gcc-arm-embedded-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/include -isystem /nix/store/zwlyixabawzbj0ckmzhk8a55kyx99ka6-gcc-arm-embedded-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/include-fixed -Os -imacros/home/brandon/stash/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mthumb -mcpu=cortex-m4 -imacros/home/brandon/stash/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/brandon/stash/zephyrproject/zephyr-rust/samples/rust-app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/brandon/stash/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/brandon/stash/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -mabi=aapcs -march=armv7e-m -std=c99 -nostdinc -MD -MT zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj -MF zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj.d -o zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj   -c /home/brandon/stash/zephyrproject/zephyr/arch/arm/core/offsets/offsets.c
In file included from ../include/arch/arm/aarch32/cortex_m/cmsis.h:17,
                 from ../include/arch/arm/aarch32/syscall.h:29,
                 from ../include/arch/syscall.h:19,
                 from ../include/syscall.h:12,
                 from ../include/kernel_includes.h:32,
                 from ../include/kernel.h:17,
                 from /home/brandon/stash/zephyrproject/zephyr/arch/arm/core/offsets/offsets_aarch32.c:25,
                 from /home/brandon/stash/zephyrproject/zephyr/arch/arm/core/offsets/offsets.c:12:
../soc/arm/nordic_nrf/nrf52/soc.h:16:10: fatal error: nrfx.h: No such file or directory
 #include <nrfx.h>
          ^~~~~~~~
compilation terminated.

@reardencode
Copy link

reardencode commented Mar 26, 2020

Update: I was able to fix this error by changing CMakeLists.txt to add ${ZEPHYR_RUST} to the ZEPHYR_EXTRA_MODULES list instead of ZEPHYR_MODULES

Update2: With that change, I was able to write a rust-blinky app (GPIO controlled via a C function pointer) and run it on nrf52840_pca10059!

@SebastianBoe
Copy link

ZEPHYR_EXTRA_MODULES should be used when the intention is to add an extra module to those already found by west.

The build system variable ZEPHYR_MODULES is a CMake list of absolute paths to the directories containing Zephyr modules. [...]

If you have west installed, you don’t need to worry about how this variable is defined unless you are adding a new module. The build system knows how to use west to set ZEPHYR_MODULES. You can add additional modules to this list by setting the ZEPHYR_EXTRA_MODULES CMake variable or by adding a ZEPHYR_EXTRA_MODULES line to .zephyrrc (See the section on Environment Variables for more details). This can be useful if you want to keep the list of modules found with west and also add your own.

@tylerwhall
Copy link
Owner

I switched the samples to ZEPHYR_EXTRA_MODULES and that does indeed seem to fix the targets that use west modules. That driver example has been around for a while, not sure how I missed that, but thanks everyone!

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

No branches or pull requests

4 participants