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

Update for latest Zephyr version (ESF-149) #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marekmatej
Copy link

This provides multiple fixes to make the Zephyr example work on the ESP32 boards with uart1 available.

Related PRs:

@github-actions github-actions bot changed the title Update for latest Zephyr version Update for latest Zephyr version (ESF-149) Aug 14, 2024
@Dzarda7
Copy link
Collaborator

Dzarda7 commented Aug 14, 2024

Hi @marekmatej, thank you for the fix. LGTM. Will wait for the merges to test it properly. Just a nitpick, can you please change the commit message? We use conventional commits which is checked by CI. Something like fix: Make changes for newest Zephyr? Thanks.

@DNedic PTAL.


zephyr_interface_library_named(esp_flasher)
zephyr_interface_library_named(esp_flasher)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lots of lines have been just reformatted to remove indentation, can we revert these?

Copy link
Author

Choose a reason for hiding this comment

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

yeah, so the order of the statements was a bit strange, and also I didn't like the unnecessary indentation so I fix it according to my taste. However, I can revert all that eye sugar if you don't like it :-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have a strong opinion on CMake formatting, but it would be more consistent with the rest of esp-serial-flasher to leave it as is, and also make the diffs smaller and git blame more meaningful.

@@ -1,34 +0,0 @@
/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you explain the reasoning behind removing the board dt overlay? I'm a bit confused on this part.

Copy link
Author

Choose a reason for hiding this comment

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

Sometimes there are too many boards overlay that are copy and paste stuff. For those cases, there is the socs folder where you can put all overlays/conf common on the SoC level. This was the exact case.

@DNedic
Copy link
Collaborator

DNedic commented Aug 14, 2024

Hi @marekmatej , nice work and thanks for helping out!

@DNedic
Copy link
Collaborator

DNedic commented Aug 14, 2024

Also, I would use the feat(zephyr): format for the conventional commit here and specify the Zephyr SDK version in the commit message.

@Dzarda7
Copy link
Collaborator

Dzarda7 commented Aug 14, 2024

Thanks for taking a look @DNedic, this should also fix the small Flash size for the images, that's why I wanted it to be fix, but I agree with the feat. Just so you understand.

@marekmatej marekmatej force-pushed the bugfix/zephyr_port_example branch 2 times, most recently from 65224a3 to 07f1bbe Compare August 16, 2024 15:32
@Dzarda7
Copy link
Collaborator

Dzarda7 commented Sep 19, 2024

@marekmatej can you please revert the CMakeLists changes? After that, I am going to merge it. I tested it and it works with minor fix not related to this PR. Thank you so much for your help.

Update Zephyr example for latest Zephyr version.
- replace board with the socs specific config
- fix warnings

Signed-off-by: Marek Matej <[email protected]>
Copy link
Collaborator

@Dzarda7 Dzarda7 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@beriberikix
Copy link

Which version of Zephyr was this tested against? I'm testing against main (d4b7bf9) and it doesn't compile. Probably an easy fix but I'm getting example_common.c:22:10: fatal error: esp_loader_io.h: No such file or director.

@marekmatej
Copy link
Author

marekmatej commented Nov 6, 2024

Which version of Zephyr was this tested against? I'm testing against main (d4b7bf9) and it doesn't compile. Probably an easy fix but I'm getting example_common.c:22:10: fatal error: esp_loader_io.h: No such file or director.

Hi @beriberikix, the fix used the upstream version as well, but that was weeks ago. Try to find esp_loader.h and rename it to esp_loader_io.h. It seems there was further renaming of the file.

@igrr
Copy link
Member

igrr commented Nov 6, 2024

Try to find esp_loader.h and rename it to esp_loader_io.h

But both files exist in the same directory: https://github.com/espressif/esp-serial-flasher/tree/master/include...

@Dzarda7
Copy link
Collaborator

Dzarda7 commented Nov 6, 2024

@beriberikix I am still able to build the zephyr example with this fix. I do not know much about zephyr so I am following the CI build process which is described here. I just use newest releases of all tools and master branch of zephyr. The build should be successful with this.

You also need to remove fflush(stdout); line here, mcu will throw panic error during runtime otherwise. I also needed to change the pins as the present ones are used for flash memory connection in ESP32-DevKitC V4.

Sorry for inconvenience, these changes will hopefully be merged soon, we are waiting for next zephyr release so we can mark it as supported. Thanks for understanding, I already proposed that tested versions should be stated with all ports.

If you have some troubles, let me know.

@beriberikix
Copy link

Totally understandable! I retried with a clean Zephyr environment and got the same issue. If I explicitly add the include and port directories to CMake, I get past the missing file errors:

zephyr_library_include_directories(
  ../common
  ../binaries
  ../../include
  ../../port
  )

However, linking fails because of undefined references. Ex.

/home/jberi/toolchains/zephyr-sdk-0.17.0/xtensa-espressif_esp32_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32_zephyr-elf/bin/ld.bfd: app/libapp.a(example_common.c.obj):(.literal.connect_to_target+0x1c): undefined reference to `esp_loader_connect'
/home/jberi/toolchains/zephyr-sdk-0.17.0/xtensa-espressif_esp32_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32_zephyr-elf/bin/ld.bfd: app/libapp.a(example_common.c.obj):(.literal.connect_to_target+0x20): undefined reference to `esp_loader_get_target'
...

Any ideas?

@Dzarda7
Copy link
Collaborator

Dzarda7 commented Nov 7, 2024

Did you clone the this repo and checked out correct branch? If so, you should be able to build the example using following commands:

cd esp-serial-flasher
mkdir zephyrproject-rtos
cd zephyrproject-rtos
git clone https://github.com/zephyrproject-rtos/zephyr.git
mkdir zephyr-sdk
cd zephyr-sdk
wget --no-verbose -O zephyr_sdk.tar.xz https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_linux-aarch64_minimal.tar.xz
tar xvf zephyr_sdk.tar.xz --strip-components=1
wget --no-verbose -O esp32_toolchain.tar.xz https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_xtensa-espressif_esp32_zephyr-elf.tar.xz
tar xvf esp32_toolchain.tar.xz
export ZEPHYR_SDK_INSTALL_DIR=$(pwd)
export ZEPHYR_TOOLCHAIN_VARIANT="zephyr"
cd ../zephyr
export ZEPHYR_BASE=$(pwd)
pip install -r scripts/requirements.txt
pip install wheel
west init -l .
unset IDF_PATH
west zephyr-export
west update hal_espressif
west build -p -b esp32_devkitc_wroom <<ABSOLUTE_PATH_TO_zephyr_example_FOLDER>> -DZEPHYR_EXTRA_MODULES=<<ABSOLUTE_PATH_TO_esp-serial-flasher_FOLDER>>


example of last command: west build -p -b esp32_devkitc_wroom /home/jarda/Documents/Espressif/zephyr_test/esp-serial-flasher/examples/zephyr_example -DZEPHYR_EXTRA_MODULES=/home/jarda/Documents/Espressif/zephyr_test/esp-serial-flasher

I am able to build it using these commands.

@beriberikix
Copy link

Hmm...yes, and just checked again. I didn't pass in the ZEPHYR_EXTRA_MODULES originally by that didn't make a difference.

@beriberikix
Copy link

Actually, I'm not sure what's the issue with my machine but I was able to build using Docker. Here's the Dockerfile I pulled together:

FROM ghcr.io/embeddedcontainers/zephyr:xtensa-espressif_esp32-0.17.0SDK

WORKDIR /workdir

RUN \
  git clone https://github.com/marekmatej/esp-serial-flasher \
  && cd esp-serial-flasher \
  && git checkout bugfix/zephyr_port_example \
  && cd ..

RUN \
  west init \
  && west update --narrow -o=--depth=1 \
  && pip3 install -r zephyr/scripts/requirements.txt \
  && west zephyr-export \
  && west update hal_espressif

# docker build -t esf-zephyr-esp:latest -f ./Dockerfile .
# docker run --rm -it -v ./zephyr-build:/workdir/build esf-zephyr-esp:latest
# west build -p -b esp32_devkitc_wroom /workdir/esp-serial-flasher/examples/zephyr_example -DZEPHYR_EXTRA_MODULES=/workdir/esp-serial-flasher

@Dzarda7
Copy link
Collaborator

Dzarda7 commented Nov 8, 2024

That is interesting. Do not you have exported some variable that messes up with the zephyr build? For example the IDF_PATH? Someone has ESP-IDF export script in .bashrc which might cause some issues.

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.

5 participants