Created
March 23, 2024 03:23
-
-
Save davidbuzz/e42bbe9dae75b64bc572a41756c7ac1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
export INSTALLTO=/home/buzz2 | |
# will end up as: home/buzz2/zephyrproject | |
echo repo: https://github.com/zephyrproject-rtos/zephyr | |
echo docs: https://docs.zephyrproject.org/latest/ | |
echo supported boards: https://docs.zephyrproject.org/latest/boards/index.html | |
echo https://docs.zephyrproject.org/latest/develop/getting_started/index.html | |
echo getting started on ubuntu: | |
wget https://apt.kitware.com/kitware-archive.sh | |
#sudo bash kitware-archive.sh | |
#'Only Ubuntu Focal (20.04) and Jammy (22.04) are supported. Aborting.' | |
sudo cp /etc/os-release /etc/os-release.old | |
sudo sed -i 's/mantic/jammy/' /etc/os-release.old | |
sudo sed -i 's/os-release/os-release.old/' kitware-archive.sh | |
sudo bash kitware-archive.sh | |
sudo apt install --no-install-recommends git cmake ninja-build gperf \ | |
ccache dfu-util device-tree-compiler wget \ | |
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \ | |
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 | |
cmake --version | |
python3 --version | |
dtc --version | |
echo Get Zephyr and install Python dependencies: | |
#cd ~ or some place else.... | |
cd $INSTALLTO | |
sudo apt install python3-venv | |
python3 -m venv ./zephyrproject/.venv | |
source ./zephyrproject/.venv/bin/activate | |
pip install west | |
#cd ~ or some place else.... | |
cd $INSTALLTO | |
west init ./zephyrproject | |
cd ./zephyrproject | |
west update | |
west zephyr-export | |
pip install -r ./zephyr/scripts/requirements.txt | |
echo Install the Zephyr SDK into HOME: | |
#todo put this in $INSTALLTO, not ~ | |
cd ~ | |
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz | |
wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/sha256.sum | shasum --check --ignore-missing | |
tar xvf zephyr-sdk-0.16.5-1_linux-x86_64.tar.xz | |
cd zephyr-sdk-0.16.5-1 | |
./setup.sh | |
sudo cp ~/zephyr-sdk-0.16.5-1/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d | |
sudo udevadm control --reload | |
echo determine supported board name and while there see if has any extra instructions: | |
echo https://docs.zephyrproject.org/latest/boards/index.html#boards | |
echo eg: esp32s3_devkitm | |
echo esp32s3: | |
west blobs fetch hal_espressif | |
echo needs "--sysbuild" added to build steps below... | |
echo tip: '-p always' option forces a pristine build, and is recommended for new users. | |
echo Build the Blinky Sample: | |
cd ./zephyrproject/zephyr | |
#west build -p always -b <your-board-name> samples/basic/blinky | |
#west build -p always -b esp32s3_devkitm --sysbuild samples/basic/blinky [fails] | |
#[works]: | |
west build -p always -b esp32s3_devkitm --sysbuild samples/hello_world | |
echo Flash the Sample: | |
west flash | |
# results: | |
# (.venv) [ ... zephyr]$ west flash | |
# -- west flash: rebuilding | |
# [0/6] Performing build step for 'hello_world' | |
# ninja: no work to do. | |
# [1/6] Performing build step for 'mcuboot' | |
# ninja: no work to do. | |
# [6/6] Completed 'mcuboot' | |
# -- west flash: using runner esp32 | |
# -- runners.esp32: reset after flashing requested | |
# .... | |
# Uploading stub... | |
# Running stub... | |
# Stub running... | |
# Changing baud rate to 921600 | |
# Changed. | |
# Configuring flash size... | |
# Auto-detected Flash size: 8MB | |
# Flash will be erased from 0x00010000 to 0x00024fff... | |
# Wrote 98304 bytes at 0x00010000 in 0.5 seconds (1584.5 kbit/s)... | |
# Hash of data verified. | |
# Leaving... | |
# Hard resetting via RTS pin... | |
echo If doing ESP32-S3: | |
echo esp32-s3: https://docs.zephyrproject.org/latest/boards/espressif/esp32s3_devkitm/doc/index.html | |
echo to see the output of the program running after flash run: 'west espressif monitor' | |
# zephyr]$ west espressif monitor | |
# Serial port /dev/ttyUSB0 | |
# Connecting.... | |
# Detecting chip type... ESP32-S3 | |
# --- idf_monitor on /dev/ttyUSB0 115200 --- | |
# [snip bootloader output] | |
# *** Booting Zephyr OS build v3.6.0-1544-g397b8465dc6b *** | |
# Hello World! esp32s3_devkitm/esp32s3/procpu | |
#esp32-s3 tips: | |
# it appears u can build/flash/upload/monitor connected to EITHER of the usb ports on the devkitm (labeled USB and UART), but | |
# the 'monitor' output only shows up when connected on the UART port. i suspect this means u can't gdb-debug and monitor at the same time.? | |
echo debugging esp32s3 : | |
echo get experimental esp32 debugger: https://github.com/erhankur/openocd-esp32/tree/zephyr_riscv_thread_awareness | |
cd ~/.espressif/tools/ | |
git clone https://github.com/erhankur/openocd-esp32 openocd-esp32-zephyr | |
cd openocd-esp32-zephyr | |
git checkout ephyr_riscv_thread_awareness | |
./bootstrap | |
# install-it-over-the-top / put it at the same path as my 'west -v debug' command was looking for it: | |
./configure --prefix=/home/buzz/zephyr-sdk-0.16.5-1/sysroots/x86_64-pokysdk-linux/usr | |
make | |
sudo make install | |
# zephyr ships with a version thats too old: | |
# https://github.com/zephyrproject-rtos/zephyr/issues/66379 | |
# echo check openocd version: | |
/home/buzz/zephyr-sdk-0.16.5-1/sysroots/x86_64-pokysdk-linux/usr/bin/openocd --version | |
#Open On-Chip Debugger 0.11.0+dev-00728-gb6f95a16c (2024-02-17-23:51) | |
#hack to use the newer "non experimental" openocd version: | |
#cd /home/buzz/zephyr-sdk-0.16.5-1/sysroots/x86_64-pokysdk-linux/usr/ | |
#wget https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20240318/openocd-esp32-linux-amd64-0.12.0-esp32-20240318.tar.gz | |
#tar --strip-components=1 -zxvpf openocd-esp32-linux-amd64-0.12.0-esp32-20240318.tar.gz | |
# also need espressifs gdb version: https://github.com/zephyrproject-rtos/zephyr/issues/3550#issuecomment-331657018 | |
#source /home/buzz2/ardupilot/modules/esp_idf/export.sh | |
#... after a 'west build xxx' | |
#... and after a 'west flash' | |
#west debug | |
west -v debug | |
# after everything is installed and u've build and flashed before, u can just do: | |
#cd ~ or some place else.... | |
cd $INSTALLTO | |
cd ./zephyrproject | |
source ./.venv/bin/activate | |
cd zephyr | |
west build -p always -b esp32s3_devkitm --sysbuild samples/hello_world | |
#west build -p always -b esp32s3_devkitm --sysbuild samples/hello_world -DOPENOCD="/home/buzz/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin/openocd" -DOPENOCD_DEFAULT_PATH="/home/buzz/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/share" | |
#west build -p always -b esp32s3_devkitm --sysbuild samples/hello_world -DOPENOCD="~/.espressif/tools/zephyr/openocd-esp32/bin/openocd" -DOPENOCD_DEFAULT_PATH="~/.espressif/tools/zephyr/openocd-esp32/share" -DGDB="/home/buzz/.espressif/tools/xtensa-esp-elf-gdb/11.2_20220823/xtensa-esp-elf-gdb/bin/xtensa-esp32s3-elf-gdb" | |
west flash | |
west espressif monitor | |
west -v debug | |
# note the path above that openocd is found at.. eg: 'runners.openocd: /home/buzz/zephyr-sdk-0.16.5-1/sysroots/x86_64-pokysdk-linux/usr/bin/openocd ...' | |
# use that path below to put an updated ocd version in the same spot: | |
# cd /home/buzz2/zephyrproject/zephyr/ | |
# rm -rf build | |
# west build -p always -b esp32s3_devkitm --sysbuild samples/hello_world | |
# west flash | |
# west -v debug | |
# add your own github remote/fork to the main repo and optionally push there. | |
# todo.. just set zephyr,console = &usb_serial; in your DT. Multiple boards do this, take a look at ./boards/xtensa/esp32s3_luatos_core/esp32s3_luatos_core_usb.dts for an example. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment