Skip to content

Commit b1be685

Browse files
nklaymanlgirdwood
authored andcommitted
feat(getting_started): update organization and instructions
- Change the organization of the getting started section to make it easier to determine which guide to follow. - Add instructions for building a custom kernel with SOF config so that it can be booted on that same device. This is useful for people without dedicated test hardware who just want to try out the latest code, such as when they are running into issues with new hardware. - Revamp the ktest setup documentation. This was very out of date and had tons of errors, especially for using Fedora. It has now been validated to work on both Fedora and Ubuntu target devices, from a Ubuntu dev machine (but Fedora should work just fine too). Signed-off-by: Noah Klayman <noah.klayman@intel.com>
1 parent f33a5da commit b1be685

7 files changed

Lines changed: 374 additions & 135 deletions

File tree

getting_started/index.rst

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,36 @@ current distro release is always preferred.
2121
build-guide/build-3rd-party-toolchain
2222
build-guide/build-with-zephyr
2323

24-
Set up SOF on hardware
25-
**********************
24+
Set up SOF on a Linux machine
25+
*****************************
2626

27-
SOF runs on a variety of devices with varying audio capabilities so
28-
instructions may differ between devices.
27+
You can build the Linux kernel with the latest SOF code and install it locally or remotely with ktest.
28+
29+
Do this first:
30+
31+
.. toctree::
32+
:maxdepth: 1
33+
34+
setup_linux/prepare_build_environment
35+
36+
Then proceed based on if you are installing locally or through ktest:
37+
38+
.. toctree::
39+
:maxdepth: 1
40+
41+
setup_linux/install_locally
42+
setup_linux/setup_ktest_environment
43+
44+
Set up SOF on a special device
45+
******************************
46+
47+
SOF also runs on the MinnowBoard Turbot and the Up Squared board with Hifiberry Dac+.
2948

3049
.. toctree::
3150
:maxdepth: 1
3251

33-
setup/setup_minnowboard_turbot
34-
setup/setup_up_2_board
35-
setup/setup_ktest_environment
52+
setup_special_device/setup_minnowboard_turbot
53+
setup_special_device/setup_up_2_board
3654

3755
Debug Audio issues on Intel platforms
3856
*************************************
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
.. _install-locally:
2+
3+
Install the Kernel locally
4+
#######################################
5+
6+
.. contents::
7+
:local:
8+
:depth: 3
9+
10+
Introduction
11+
************
12+
13+
Make sure you have `setup your development environment <prepare_build_environment.html>`_ before following these steps. This page will guide you through the process of installing the kernel locally on your machine. It will be installed in addition to your distro's default kernel so that you can always change back to that in case something goes wrong. If you're interested in learning more about this process there's lots of online guides available, for example `Fedora's guide <https://docs.fedoraproject.org/en-US/quick-docs/kernel/build-custom-kernel/#_building_a_vanilla_upstream_kernel>`_ or `this wiki page <https://wiki.linuxquestions.org/wiki/How_to_build_and_install_your_own_Linux_kernel>`_.
14+
15+
16+
Build and install the kernel
17+
****************************
18+
19+
(You should be in the ``~/sof/linux`` directory you created on the setup page)
20+
21+
1. Load base kernel configuration
22+
---------------------------------
23+
24+
.. code-block:: bash
25+
26+
# This will copy the booted kernel's configuration so that it will be used as a base
27+
cp /boot/config-$(uname -r)* .config
28+
29+
30+
2. Apply SOF-specific configuration
31+
-----------------------------------
32+
33+
The following scripts will update your base config so that it uses the latest SOF modules. Run only one of them depending on your needs. If it prompts you with any questions, just press <enter> to accept the default value. Note that, by default, these scripts will set the configuration to only compile modules that are currently loaded in order to lower compile times. This means that when you've booted from the custom kernel some external devices may not work if they weren't connected while running this script. If you want to compile all modules, delete the line ``make localmodconfig`` from the script you will run in this step.
34+
35+
.. code-block:: bash
36+
37+
# For most users
38+
../kconfig/kconfig-distro-sof-update.sh
39+
# For additional logging and experimental device support
40+
../kconfig/kconfig-distro-sof-dev-update.sh
41+
42+
3. Compile the kernel
43+
---------------------
44+
45+
.. code-block:: bash
46+
47+
# The first time you run this it can take a while (over 30 minutes on some machines),
48+
# so grab a coffee or take an exercise break while it runs
49+
make -j$(nproc --all)
50+
51+
4. Install the kernel
52+
---------------------
53+
54+
.. code-block:: bash
55+
56+
sudo make modules_install
57+
sudo make install
58+
59+
If all went well, your freshly-built kernel will be installed and available at next boot. Restart your computer, and you should have the option to pick a kernel when it turns on. Select the kernel that has "-sof" at the end of it, and your computer should boot as normal using the kernel you just built. On Ubuntu, the kernel option may be hidden behind the "Advanced options for Ubuntu" submenu.
60+
61+
5. Updating and rebuilding
62+
--------------------------
63+
64+
If you need to try some new changes, you'll have to download the updated code and rebuild the kernel.
65+
66+
If you originally cloned the repo using git, you just need to pull the changes:
67+
68+
.. code-block:: bash
69+
70+
git pull
71+
# You should run this after switching branches or configuration or any other major code change
72+
# If you just pulled some minor updates, it's likely unnecessary and will increase your build time
73+
make clean
74+
75+
Now, repeat steps 3 and 4 to rebuild and reinstall the kernel. Reboot your computer, and select the kernel with -sof at the end to test it.
76+
77+
Unfortunately, if you downloaded via zip, the entire process has to be restarted from the "Get the kernel source" section; there's no good way to incrementally update. However, the kernel build should be faster now as part of it will be cached.
78+
79+
.. code-block:: bash
80+
81+
cd ..
82+
# Delete the old folder before starting over
83+
rm -rf linux
84+
85+
6. Removing the kernel
86+
----------------------
87+
88+
If you run into issues or no longer need the custom kernel, you can remove it.
89+
90+
Ubuntu:
91+
92+
.. code-block:: bash
93+
94+
cd ~/sof/linux
95+
sudo rm /boot/*-$(make kernelversion)
96+
sudo rm -rf /lib/modules/$(make kernelversion)
97+
sudo update-grub
98+
99+
Fedora:
100+
101+
.. code-block:: bash
102+
103+
cd ~/sof/linux
104+
sudo rm /boot/*-$(make kernelversion)*
105+
sudo rm -rf /lib/modules/$(make kernelversion)
106+
sudo grubby --remove-kernel=/boot/vmlinuz-$(make kernelversion)
107+
108+
109+
After rebooting, you should be back to your old kernel with all traces of the custom kernel installation gone. If you'd like, you can also delete the ``~sof`` directory to save disk space.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
.. _prepare-build-environment:
2+
3+
Set up a development environment to build the kernel
4+
####################################################
5+
6+
.. contents::
7+
:local:
8+
:depth: 3
9+
10+
Introduction
11+
************
12+
13+
14+
These instructions will help you set up a development environment for the SOF branch of the Linux kernel. If you have dedicated test hardware you can use ktest to install it over ssh, otherwise you can install it locally on your device in addition to your default kernel.
15+
16+
Prerequisites
17+
*************
18+
19+
1. Device requirements
20+
-----------------------
21+
22+
**Development device:** PC running Fedora 35+ or Ubuntu 20.04+.
23+
24+
**Target device:** PC running Fedora 35+ or Ubuntu 20.04+, with secure boot disabled. If the target device is different than the development device you must be able to ssh into the target, which is typically on the same local network/VPN.
25+
26+
2. Create working directory
27+
---------------------------
28+
29+
This directory can be located anywhere, simply change the ``SOF_WORKSPACE`` variable if you would like to store your sources somewhere else.
30+
31+
.. code-block:: bash
32+
33+
export SOF_WORKSPACE=~/work/sof
34+
mkdir -p $SOF_WORKSPACE
35+
cd $SOF_WORKSPACE
36+
37+
3. Install kernel build dependencies
38+
------------------------------------
39+
40+
Fedora (see `their guide <https://docs.fedoraproject.org/en-US/quick-docs/kernel/build-custom-kernel/#_get_the_dependencies>`_ for details):
41+
42+
.. code-block:: bash
43+
44+
sudo dnf install fedpkg
45+
fedpkg clone -a kernel
46+
cd kernel
47+
sudo dnf builddep kernel.spec
48+
sudo dnf install ccache
49+
cd ..
50+
51+
Ubuntu (see `their page <https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel>`_ for details):
52+
53+
.. code-block:: bash
54+
55+
sudo apt update
56+
sudo apt install git libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf dwarves zstd
57+
58+
4. Download the configuration scripts
59+
-------------------------------------
60+
61+
.. code-block:: bash
62+
63+
git clone https://github.com/thesofproject/kconfig.git
64+
65+
Get the kernel source
66+
*********************
67+
68+
There are two ways to get the kernel source. We strongly recommend using git as it makes updates **much** easier, but the zip download may be more successful if you have an unstable connection.
69+
70+
Option 1: Clone with git
71+
------------------------
72+
.. code-block:: bash
73+
74+
# If a maintainer requests that you check out a different branch
75+
# to test a bug fix, add -b [branch]
76+
# to the end of this command, where [branch] is the branch name
77+
git clone https://github.com/thesofproject/linux.git --depth=1
78+
cd linux
79+
80+
Option 2: Download via zip
81+
--------------------------
82+
83+
Visit the SOF Linux fork at https://github.com/thesofproject/linux. If a maintainer asks you to test a specific branch, click the dropdown with the text "topic/sof-dev" and select the branch they asked you to test. Then, click the green "Code" dropdown and select "download zip". Once it's downloaded, extract it to the directory you created in the previous step:
84+
85+
.. code-block:: bash
86+
87+
cd ~/Downloads
88+
unzip linux-*.zip -d $SOF_WORKSPACE
89+
cd $SOF_WORKSPACE
90+
mv linux-* linux
91+
cd linux
92+
93+
Build the kernel
94+
****************
95+
96+
Your device should now be ready to configure and build the kernel. How to proceed depends on if you are installing locally or on dedicated test hardware.
97+
98+
.. toctree::
99+
:maxdepth: 1
100+
101+
install_locally
102+
setup_ktest_environment

0 commit comments

Comments
 (0)