Difference between revisions of "EBC Exercise 08 Installing Development Tools 4.4"

From eLinux.org
Jump to: navigation, search
(Initial page)
 
m (Updating scripts before updating the Kernel)
 
(32 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
{{YoderHead}}
 
{{YoderHead}}
  
Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit ([https://c9.io/ cloud9]), compile ([http://gcc.gnu.org/ gcc]) and run all on the Beagle.  Later, when we start compiling the [http://www.kernel.org/ kernel] or the boot loader, ([http://www.denx.de/wiki/U-Boot U-boot]) you will need to cross compile on a Linux machine and copy the results to the Beagle.
+
Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit ([https://aws.amazon.com/cloud9/ cloud9]), compile ([http://gcc.gnu.org/ gcc]) and run all on the Beagle.  Later, when we start compiling the [http://www.kernel.org/ kernel] or the boot loader, ([http://www.denx.de/wiki/U-Boot U-boot]) you will need to cross compile on a Linux machine and copy the results to the Beagle.
  
 
The purpose of this exercise is to install all the tools needed for compiling on your host so they will be ready when you need them.
 
The purpose of this exercise is to install all the tools needed for compiling on your host so they will be ready when you need them.
Line 8: Line 8:
 
'''Tip:''' Run this exercise using a wired connection if you can. The Ubuntu wireless driver can be finicky, and if it stops working you'll have to restart some of this.
 
'''Tip:''' Run this exercise using a wired connection if you can. The Ubuntu wireless driver can be finicky, and if it stops working you'll have to restart some of this.
  
== The 3.8 Kernel ==
+
== The 5.x Kernel ==
{{EBC3.8}}Make sure you installed the cross compiler ([[EBC Exercise 08a Cross-Compiling]]) before doing this exercise.
 
  
=== Getting the 3.8 Kernel ===
+
=== Updating scripts before updating the Kernel ===
 +
Various things change when changing kernel versions.  When preparing to use a new Kernel it's best to be sure your scripts are up to date.
 +
Do this by:
 +
 
 +
bone$ '''cd /opt/scripts'''
 +
bone$ '''git pull'''
 +
Just to be sure:
 +
bone$ '''sudo reboot'''
 +
 
 +
You are now up to date and things are more likely to work when switching Kernels.
 +
 
 +
=== Getting the 5.x Kernel ===
  
 
These notes taken from [http://www.youtube.com/watch?v=HJ9nUqYMjqs&t=4m10s Beaglebone: Adding USB Wi-Fi & Building a Linux Kernel] starting around 4 minutes and ending around 21 minutes.  Uses kernel from [http://eewiki.net/display/linuxonarm/BeagleBone+Black Robert C. Nelson's BeagleBone Black] page.
 
These notes taken from [http://www.youtube.com/watch?v=HJ9nUqYMjqs&t=4m10s Beaglebone: Adding USB Wi-Fi & Building a Linux Kernel] starting around 4 minutes and ending around 21 minutes.  Uses kernel from [http://eewiki.net/display/linuxonarm/BeagleBone+Black Robert C. Nelson's BeagleBone Black] page.
  
  host$ '''git clone git://github.com/RobertCNelson/linux-dev.git'''
+
  host$ '''git clone https://github.com/RobertCNelson/bb-kernel.git''' (42M)
  host$ '''cd linux-dev'''
+
  host$ '''cd bb-kernel'''
  host$ '''git checkout origin/am33x-v3.8 -b am33x-v3.8'''
+
host$ '''git remote show origin'''
  host$ '''time git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git''' (21 minutes)
+
The last command lists all the versions of the kernel that are available.  Pick one and check it out. I usually pick the one with the highest
host$ '''cp system.sh.sample system.sh'''
+
version number.
Now make the following changes to '''system.sh'''.  The <code>></code> shows what's in system.sh.sample. The <code><</code> shows what you should change it to.
+
  host$ '''git checkout am33x-v5.10'''
  host$ '''diff system.sh*'''
+
Branch 'am33x-v5.10' set up to track remote branch 'am33x-v5.10' from 'origin'.
  15c15
+
  Switched to a new branch 'am33x-v5.10'
  < CC=arm-linux-gnueabi-
+
 
---
+
Now at this point you have a choice, you can run '''./build_kernel.sh'''
> #CC=arm-linux-gnueabi-
+
and build the kernel, or run '''./build_deb.sh''' which will also build
21c21
+
the kernel, but it will combine all the output files in
< LINUX_GIT=~/BeagleBoard/linux-stable/
+
one '''.deb''' install fileI suggest running '''./build_deb.sh''',
---
+
 
  > #LINUX_GIT=/home/user/linux-stable/
+
  host$ '''./build_kernel.sh''' or '''./build_deb.sh'''
  31c31
+
  + Detected build host [Ubuntu 20.04.1 LTS]
  < ZRELADDR=0x80008000
+
+ host: [x86_64]
  ---
+
  + git HEAD commit: [a7ff6610037f33b2a8c19d7f111cf9e43aa3c4ef]
  > #ZRELADDR=0x80008000
+
-----------------------------
 +
  cpio: cpio (GNU cpio) 2.13
 +
  You're missing command lzop
 +
  Please install missing commands
 +
  -----------------------------
 +
 
 +
You ''may'' need to install some additional files. Run the suggested commands.
  
Now build the kernel.
+
host$ '''sudo apt-get update'''
 +
host$ '''sudo apt install lzop'''
 
  host$ '''./build_kernel.sh'''
 
  host$ '''./build_kernel.sh'''
  + Detected build host [Ubuntu 14.04 LTS]
+
  + Detected build host [Ubuntu 20.04.1 LTS]
 
  + host: [x86_64]
 
  + host: [x86_64]
  + git HEAD commit: [58ee2121370badd3c0a22e39f67068f242d5e068]
+
  + git HEAD commit: [a7ff6610037f33b2a8c19d7f111cf9e43aa3c4ef]
 +
-----------------------------
 +
cpio: cpio (GNU cpio) 2.13
 +
lzop: lzop 1.04
 
  Debian/Ubuntu/Mint: missing dependencies, please install:
 
  Debian/Ubuntu/Mint: missing dependencies, please install:
 
  -----------------------------
 
  -----------------------------
 
  sudo apt-get update
 
  sudo apt-get update
  sudo apt-get install build-essential device-tree-compiler fakeroot lzma lzop u-boot-tools   libncurses5-dev:amd64 libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386
+
  sudo apt-get install build-essential fakeroot lzma gettext bison flex pkg-config libmpc-dev u-boot-tools libncurses5-dev:amd64
 +
  libssl-dev:amd64
 
  -----------------------------
 
  -----------------------------
 
  * Failed dependency check
 
  * Failed dependency check
 +
 +
host$ '''sudo apt-get install build-essential fakeroot lzma gettext bison flex pkg-config libmpc-dev u-boot-tools libncurses5-dev:amd64 libssl-dev:amd64 libssl-dev:amd64'''
  
The build script is telling you what you need to install.  Do the installs and rerun the build command.
+
Then run again.
 
  host$ '''./build_kernel.sh'''
 
  host$ '''./build_kernel.sh'''
  + Detected build host [Ubuntu 12.04.2 LTS]
+
+ Detected build host [Ubuntu 20.04.1 LTS]
  Debian/Ubuntu/Mint: missing dependicies, please install:
+
+ host: [x86_64]
  -----------------------------
+
+ git HEAD commit: [a7ff6610037f33b2a8c19d7f111cf9e43aa3c4ef]
  sudo apt-get update
+
-----------------------------
  sudo apt-get install libncurses5-dev
+
cpio: cpio (GNU cpio) 2.13
  -----------------------------
+
lzop: lzop 1.04
  * Failed dependency check
+
'/home/mark_a_yoder/BeagleBoard/bb-kernel/system.sh.sample' -> '/home/mark_a_yoder/BeagleBoard/bb-kernel/system.sh'
If you don't get this error, move to the next step. I fixed this error by editing <code>linux-dev/tools/host_det.sh</code> and commenting out the line:
+
Installing Toolchain: gcc_arm_gnueabihf_9
# dpkg -l | grep libncurses5-dev | grep ${deb_arch} >/dev/null || deb_pkgs="${deb_pkgs}libncurses5-dev "
+
-----------------------------
It was looking for amd64 in the <code>dpkg -l</code> listing and it wasn't appearing.
 
  
=== Building the 3.8 Kernel ===
+
At this point the scripts are downloading the cross compiler, the kernel sources and anything else you need to compile the kernel for the bone.
  
Rerun the kernel build
+
=== Building the 5.x Kernel ===
host$ '''./build_kernel.sh'''
 
 
At some point you will see
 
At some point you will see
[[File:KernelConfiguration.png]]
 
[http://www.youtube.com/watch?v=HJ9nUqYMjqs&t=13m30s Go back to the video above and forward to 13:30].  Here you will see how to configure the kernel. Once you've exited the configuration tool the kernel will start compiling.  If you have a multicore machine you will see all the cores busy.  It's only a few more minutes before it is done.
 
  
=== Installing the 3.8 Kernel on Your Black Bone ===
+
[[File:KernelConfig2.png]]
 +
 
 +
Hit the right arrow to select '''Exit''' and then hit ENTER.  The compilation will continue.
  
==== Updating and running off the eMMC ====
+
=== Installing the Kernel on Your Bone ===
[[EBC_Exercise_23_Configuring_the_Kernel#Making_and_Installing_the_kernel]] has instructions for copying the correct files to the eMMC to update the kernel.
+
The following are three ways you can use to install a new kernel on your Bone. 
 +
The first method works if you ran '''build_deb.sh'''.
  
==== Booting off the SD card ====
+
The other two methods are used if you ran '''build_kernel.sh'''
Here are some '''optional''' instructions for booting off the SD card rather than the eMMC.
 
  
So far you'be been running everything off the onboard 2G flash. You can continue to do so, but when installing a new kernel there is a good chance you mess up your image and it will be another 45 minutes to reflash itInstead go back to [[EBC_Exercise_03_Installing_a_Beagle_OS]] an instead of installing the eMMC flasher image from [http://beagleboard.org/latest-images], install the '''BeagleBone (Runs on BeagleBone Black as well without flashing the eMMC)''' image (first list).
+
You only need to use one methodIf you ran '''build_kernel.sh'''  
 +
I suggest you use the second one since you don't have to remove the SD card from the bone.
  
This time when you plug in the SD and boot the bone will boot from the SD card (rather than copying a new image to the 2G builting flash)I suggest programming 2 or 3 SD cards with this image.  That way if you really mess up one you can always switch to a another card and keep going.
+
==== Installing the kernel package - build_deb.sh ====
 +
The '''./build_deb.sh''' script creates a single '''.deb''' file that contains
 +
all the files needed for the new kernel. You find it here:
 +
host$ '''cd bb-kernel/deploy'''
 +
host$ '''ls -sh'''
 +
total 40M
 +
7.3M linux-headers-5.8.11-bone17_1xross_armhf.deb 8.0K linux-upstream_1xross_armhf.buildinfo
 +
  31M linux-image-5.8.11-bone17_1xross_armhf.deb    4.0K linux-upstream_1xross_armhf.changes
 +
  1.1M linux-libc-dev_1xross_armhf.deb
  
Also, if you are booting from the SD and mess up something, you can plug the messed up card into your host computer and fix things and try it again.
+
The '''linux-image-''' file is the one we want. It contains nearly 3000 files.
 +
host$ '''dpkg -c linux-image-5.8.11-bone17_1xross_armhf.deb  | wc
 +
    2981  17886  342664
 +
The dpkg command lists all the files in the .deb file and the '''wc''' counts
 +
all the lines in the output.  You can see those files with:
 +
bone$ '''dpkg -c linux-image-5.8.11-bone17_1xross_armhf.deb  | less'''
 +
drwxr-xr-x root/root        0 2020-09-29 14:16 ./
 +
drwxr-xr-x root/root        0 2020-09-29 14:16 ./boot/
 +
-rw-r--r-- root/root  4285674 2020-09-29 14:16 ./boot/System.map-5.8.11-bone17
 +
-rw-r--r-- root/root    182474 2020-09-29 14:16 ./boot/config-5.8.11-bone17
 +
drwxr-xr-x root/root        0 2020-09-29 14:16 ./boot/dtbs/
 +
drwxr-xr-x root/root        0 2020-09-29 14:16 ./boot/dtbs/5.8.11-bone17/
 +
-rwxr-xr-x root/root    87267 2020-09-29 14:16 ./boot/dtbs/5.8.11-bone17/am335x-abbbi.dtb
 +
-rwxr-xr-x root/root    86826 2020-09-29 14:16 ./boot/dtbs/5.8.11-bone17/am335x-baltos-ir2110.dtb
 +
-rwxr-xr-x root/root    87544 2020-09-29 14:16 ./boot/dtbs/5.8.11-bone17/am335x-baltos-ir3220.dtb
 +
You can see it's putting things in the '''/boot''' directory.
  
==== Copying to the SD Card ====
+
Note: You can also look into the other two .deb files and see what they install.
Now install by inserting the SD to be installed on into your host machine and run:
 
host$ ./tools/install_kernel.sh
 
  
Mine failed because there wasn't enough space on the VFAT partition for uImage, however uImage isn't needed there, so I just editted <code>install_kernel.sh</code> and commented out line '''160'''
+
Move the '''linux-image-''' file to your Bone.
  # mmc_partition_discover
+
host$ '''scp linux-image-5.8.11-bone17_1xross_armhf.deb bone:.'''
This keeps it from installing on the VFAT partition.
+
 
 +
Hint: You might have to add '''-P<port>''' if you changed your port number.
 +
You might have to use debian@192.168.7.2 for bone if you haven't set everything up.
 +
 
 +
Now ssh to the bone.
 +
host$ '''ssh bone'''
 +
bone$ '''ls -sh'''
 +
bin  exercises linux-image-5.8.11-bone17_1xross_armhf.deb
 +
Now install it.
 +
bone$ '''sudo dpkg --install linux-image-5.8.11-bone17_1xross_armhf.deb'''
 +
Wait a while. Once done check /boot.
 +
bone$ '''ls -sh /boot'''
 +
total 40M
 +
160K config-4.19.94-ti-r50      4.0K SOC.sh                    4.0K uEnv.txt.orig
 +
180K config-5.8.11-bone17      3.5M System.map-4.19.94-ti-r50  9.7M vmlinuz-4.19.94-ti-r50
 +
4.0K dtbs                      4.1M System.map-5.8.11-bone17  8.6M vmlinuz-5.8.11-bone17
 +
6.4M initrd.img-4.19.94-ti-r50  4.0K uboot
 +
6.8M initrd.img-5.8.11-bone17  4.0K uEnv.txt
 +
You see the new kernel files.  Check uEnv.txt.
 +
bone$ '''head /boot/uEnv.txt'''
 +
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
 +
# uname_r=4.19.94-ti-r50
 +
uname_r=5.8.11-bone17
 +
I added the commented out '''uname_r''' line to make it easy to switch between
 +
versions of the kernel.
 +
 
 +
Reboot and test out the new kernel.
 +
bone$ '''sudo reboot'''
 +
 
 +
==== Copying to SD card on a running Bone - build_kernel.sh====
 +
You can stop here if you've just finished the build_deb.sh method of installing the kernel.
 +
 
 +
The Bone can have multiple versions of the kernel installed on it.
 +
It's possible to update the kernel on the Bone while it's running. 
 +
After compiling on the host you need to install sshfs (you only need to do this once).
 +
 
 +
host$ '''sudo apt install sshfs '''
 +
 
 +
Then copy '''may_install_kernel.sh''' to the bb-kernel directory.
 +
host$ '''cd ~/BeagleBoard/bb-kernel'''
 +
host$ '''cp ~/BeagleBoard/exercises/linux/kernel/may_install_kernel.sh tools'''
 +
Now you can install the files using the following.  Note, you must run '''may_install_kernel.sh''' from the directory above as shown.
 +
host$ '''tools/may_install_kernel.sh'''
 +
Mounting sshfs
 +
-----------------------------
 +
sshfs mounted
 +
Installing 4.4.15-bone11 to sshfs
 +
‘/home/yoder/BeagleBoard/bb-kernel/deploy/4.4.15-bone11.zImage’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/zImage’
 +
Installing 4.4.15-bone11-dtbs.tar.gz to sshfs
 +
Installing 4.4.15-bone11 to sshfs
 +
‘/home/yoder/BeagleBoard/bb-kernel/deploy/4.4.15-bone11.zImage’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/boot/vmlinuz-4.4.15-bone11’
 +
Installing 4.4.15-bone11-dtbs.tar.gz to sshfs
 +
info: /boot/uEnv.txt: uname_r=4.4.15-bone11
 +
Installing 4.4.15-bone11-modules.tar.gz to sshfs
 +
tar: ./lib/modules/4.4.15-bone11/build: Cannot utime: No such file or directory
 +
tar: ./lib/modules/4.4.15-bone11/source: Cannot utime: No such file or directory
 +
tar: Exiting with failure status due to previous errors
 +
‘/home/yoder/BeagleBoard/bb-kernel/deploy/config-4.4.15-bone11’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/boot/config-4.4.15-bone11’
 +
info: [4.4.15-bone11] now installed...
 +
You may see about couple of error messages about ''build'' and ''source'', but it seems to work anyway.
 +
If you look in /boot/uEvt.txt, you'll see it's ready to boot your new kernel.
 +
bone$ '''head -3 /boot/uEnv.txt'''
 +
  #Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
 +
 +
uname_r=4.4.15-bone11
 +
If you change your mind about which kernel to boot, just edit the '''uname''' line.
 +
 
 +
==== Copying to the SD Card on Host - build_kernel.sh====
 +
You can also install the kernel on an SD card that is mounted on your host computer.  Plug it into your host and machine and run:
 +
host$ '''tools/install_kernel.sh'''
 +
 
 +
This works like the '''may_install_kernel.sh''', but it copies it to local host.  Once copied, eject the SD card and plug it into your Bone and boot.
  
 
=== Updating to a new version of the kernel ===
 
=== Updating to a new version of the kernel ===
  
When you build your kernel the uImage file has some version information in the name.  For example '''uImage-3.8.13-bone20'''.  The '''3.8.13''' is the version of the kernel and the '''bone20''' is the version of the patches applied to the kernel for the BeagleBone.  Over time new patches will be posted. These instructions show how to get the latest version.
+
When you build your kernel the uImage file has some version information in the name.  For example '''vmlinuz-4.4.21-ti-r47'''.  The '''4.4.21''' is the version of the kernel and the '''-ti-r47''' is the version of the patches applied to the kernel for the BeagleBone.  Over time new patches will be posted. These instructions show how to get the latest version.
  
 
How do you know if you have the latest version?  Run
 
How do you know if you have the latest version?  Run
  beagle$ '''uname -a'''
+
  bone$ '''uname -a'''
  Linux yoder-black-bone '''3.8.13-bone28''' #1 SMP Wed Oct 16 15:32:18 EDT 2013 armv7l GNU/Linux
+
  Linux yoder-debian-bone 4.4.21-ti-r47 #1 SMP Fri Sep 23 22:23:02 UTC 2016 armv7l GNU/Linux
to see what version you are running. [http://rcn-ee.net/deb/precise-armhf/ This site lists many different versions].  See if yours is the newest, if not continue on.
 
  
 
This [https://groups.google.com/forum/#!topic/beagleboard/D3wRnulVE1I post to the Google Group] lists the steps as "You need to recheckout master, delete your old branch and re-pull".  Here's how you do it.
 
This [https://groups.google.com/forum/#!topic/beagleboard/D3wRnulVE1I post to the Google Group] lists the steps as "You need to recheckout master, delete your old branch and re-pull".  Here's how you do it.
Line 140: Line 253:
 
  host$ '''./build_kernel.sh'''
 
  host$ '''./build_kernel.sh'''
 
Mine took some 26 minutes on an 8 core machine.
 
Mine took some 26 minutes on an 8 core machine.
 
== DAS U-boot ==
 
These instructions came from [http://www.eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-Bootloader Robert C Nelson's eewiki.net].
 
 
=== download ===
 
While we're at it, let's get the boot loader we'll be using.  It takes some 40 seconds.
 
 
host$ '''cd ~/BeagleBoard'''
 
host$ '''git clone git://git.denx.de/u-boot.git'''
 
host$ '''cd u-boot/'''
 
host$ '''git checkout v2013.07 -b tmp'''
 
 
=== U-Boot Patches ===
 
host$ '''wget https://raw.github.com/eewiki/u-boot-patches/master/v2013.07/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch'''
 
host$ '''patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch'''
 
 
=== compile ===
 
Now configure and build.  The first time takes some 1.5 minutes.  After that it's only 5 seconds or so.
 
host$ '''source ~/crossCompileEnv.sh'''
 
host$ '''make distclean'''
 
host$ '''make am335x_evm_config'''
 
host$ '''make'''
 
 
=== install ===
 
 
host$ '''scp u-boot.img root@beagle:.'''
 
beagle$ '''mkdir /media/BONE'''
 
beagle$ '''mount /dev/mmcblk0p1 /media/BONE'''
 
beagle$ '''cd /media/BONE'''
 
beagle$ '''mv u-boot.img u-boot.img.orig'''  # Save the working u-boot
 
beagle$ '''cp ~/u-boot.img u-boot.img.new'''
 
beagle$ '''cp u-boot.img.new u-boot.img'''
 
 
Once installed you are ready for u-boot work.
 
  
 
== Recovering ==
 
== Recovering ==

Latest revision as of 10:01, 12 October 2021

thumb‎ Embedded Linux Class by Mark A. Yoder


Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit (cloud9), compile (gcc) and run all on the Beagle. Later, when we start compiling the kernel or the boot loader, (U-boot) you will need to cross compile on a Linux machine and copy the results to the Beagle.

The purpose of this exercise is to install all the tools needed for compiling on your host so they will be ready when you need them.

Tip: Run this exercise using a wired connection if you can. The Ubuntu wireless driver can be finicky, and if it stops working you'll have to restart some of this.

The 5.x Kernel

Updating scripts before updating the Kernel

Various things change when changing kernel versions. When preparing to use a new Kernel it's best to be sure your scripts are up to date. Do this by:

bone$ cd /opt/scripts
bone$ git pull

Just to be sure:

bone$ sudo reboot

You are now up to date and things are more likely to work when switching Kernels.

Getting the 5.x Kernel

These notes taken from Beaglebone: Adding USB Wi-Fi & Building a Linux Kernel starting around 4 minutes and ending around 21 minutes. Uses kernel from Robert C. Nelson's BeagleBone Black page.

host$ git clone https://github.com/RobertCNelson/bb-kernel.git  (42M)
host$ cd bb-kernel
host$ git remote show origin

The last command lists all the versions of the kernel that are available. Pick one and check it out. I usually pick the one with the highest version number.

host$ git checkout am33x-v5.10
Branch 'am33x-v5.10' set up to track remote branch 'am33x-v5.10' from 'origin'.
Switched to a new branch 'am33x-v5.10'

Now at this point you have a choice, you can run ./build_kernel.sh and build the kernel, or run ./build_deb.sh which will also build the kernel, but it will combine all the output files in one .deb install file. I suggest running ./build_deb.sh,

host$ ./build_kernel.sh or ./build_deb.sh
+ Detected build host [Ubuntu 20.04.1 LTS]
+ host: [x86_64]
+ git HEAD commit: [a7ff6610037f33b2a8c19d7f111cf9e43aa3c4ef]
-----------------------------
cpio: cpio (GNU cpio) 2.13
You're missing command lzop
Please install missing commands
-----------------------------

You may need to install some additional files. Run the suggested commands.

host$ sudo apt-get update
host$ sudo apt install lzop
host$ ./build_kernel.sh
+ Detected build host [Ubuntu 20.04.1 LTS]
+ host: [x86_64]
+ git HEAD commit: [a7ff6610037f33b2a8c19d7f111cf9e43aa3c4ef]
-----------------------------
cpio: cpio (GNU cpio) 2.13
lzop: lzop 1.04
Debian/Ubuntu/Mint: missing dependencies, please install:
-----------------------------
sudo apt-get update
sudo apt-get install build-essential fakeroot lzma gettext bison flex pkg-config libmpc-dev u-boot-tools libncurses5-dev:amd64
 libssl-dev:amd64 
-----------------------------
* Failed dependency check

host$ sudo apt-get install build-essential fakeroot lzma gettext bison flex pkg-config libmpc-dev u-boot-tools libncurses5-dev:amd64 libssl-dev:amd64 libssl-dev:amd64

Then run again.

host$ ./build_kernel.sh
+ Detected build host [Ubuntu 20.04.1 LTS]
+ host: [x86_64]
+ git HEAD commit: [a7ff6610037f33b2a8c19d7f111cf9e43aa3c4ef]
-----------------------------
cpio: cpio (GNU cpio) 2.13
lzop: lzop 1.04
'/home/mark_a_yoder/BeagleBoard/bb-kernel/system.sh.sample' -> '/home/mark_a_yoder/BeagleBoard/bb-kernel/system.sh'
Installing Toolchain: gcc_arm_gnueabihf_9
-----------------------------

At this point the scripts are downloading the cross compiler, the kernel sources and anything else you need to compile the kernel for the bone.

Building the 5.x Kernel

At some point you will see

KernelConfig2.png

Hit the right arrow to select Exit and then hit ENTER. The compilation will continue.

Installing the Kernel on Your Bone

The following are three ways you can use to install a new kernel on your Bone. The first method works if you ran build_deb.sh.

The other two methods are used if you ran build_kernel.sh

You only need to use one method. If you ran build_kernel.sh I suggest you use the second one since you don't have to remove the SD card from the bone.

Installing the kernel package - build_deb.sh

The ./build_deb.sh script creates a single .deb file that contains all the files needed for the new kernel. You find it here:

host$ cd bb-kernel/deploy
host$ ls -sh
total 40M
7.3M linux-headers-5.8.11-bone17_1xross_armhf.deb  8.0K linux-upstream_1xross_armhf.buildinfo
 31M linux-image-5.8.11-bone17_1xross_armhf.deb    4.0K linux-upstream_1xross_armhf.changes
1.1M linux-libc-dev_1xross_armhf.deb

The linux-image- file is the one we want. It contains nearly 3000 files.

host$ dpkg -c linux-image-5.8.11-bone17_1xross_armhf.deb  | wc
   2981   17886  342664

The dpkg command lists all the files in the .deb file and the wc counts all the lines in the output. You can see those files with:

bone$ dpkg -c linux-image-5.8.11-bone17_1xross_armhf.deb  | less
drwxr-xr-x root/root         0 2020-09-29 14:16 ./
drwxr-xr-x root/root         0 2020-09-29 14:16 ./boot/
-rw-r--r-- root/root   4285674 2020-09-29 14:16 ./boot/System.map-5.8.11-bone17
-rw-r--r-- root/root    182474 2020-09-29 14:16 ./boot/config-5.8.11-bone17
drwxr-xr-x root/root         0 2020-09-29 14:16 ./boot/dtbs/
drwxr-xr-x root/root         0 2020-09-29 14:16 ./boot/dtbs/5.8.11-bone17/
-rwxr-xr-x root/root     87267 2020-09-29 14:16 ./boot/dtbs/5.8.11-bone17/am335x-abbbi.dtb
-rwxr-xr-x root/root     86826 2020-09-29 14:16 ./boot/dtbs/5.8.11-bone17/am335x-baltos-ir2110.dtb
-rwxr-xr-x root/root     87544 2020-09-29 14:16 ./boot/dtbs/5.8.11-bone17/am335x-baltos-ir3220.dtb

You can see it's putting things in the /boot directory.

Note: You can also look into the other two .deb files and see what they install.

Move the linux-image- file to your Bone.

host$ scp linux-image-5.8.11-bone17_1xross_armhf.deb bone:.

Hint: You might have to add -P<port> if you changed your port number. You might have to use debian@192.168.7.2 for bone if you haven't set everything up.

Now ssh to the bone.

host$ ssh bone
bone$ ls -sh
bin  exercises linux-image-5.8.11-bone17_1xross_armhf.deb

Now install it.

bone$ sudo dpkg --install linux-image-5.8.11-bone17_1xross_armhf.deb

Wait a while. Once done check /boot.

bone$ ls -sh /boot
total 40M
160K config-4.19.94-ti-r50      4.0K SOC.sh                     4.0K uEnv.txt.orig
180K config-5.8.11-bone17       3.5M System.map-4.19.94-ti-r50  9.7M vmlinuz-4.19.94-ti-r50
4.0K dtbs                       4.1M System.map-5.8.11-bone17   8.6M vmlinuz-5.8.11-bone17
6.4M initrd.img-4.19.94-ti-r50  4.0K uboot
6.8M initrd.img-5.8.11-bone17   4.0K uEnv.txt

You see the new kernel files. Check uEnv.txt.

bone$ head /boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
# uname_r=4.19.94-ti-r50
uname_r=5.8.11-bone17

I added the commented out uname_r line to make it easy to switch between versions of the kernel.

Reboot and test out the new kernel.

bone$ sudo reboot

Copying to SD card on a running Bone - build_kernel.sh

You can stop here if you've just finished the build_deb.sh method of installing the kernel.

The Bone can have multiple versions of the kernel installed on it. It's possible to update the kernel on the Bone while it's running. After compiling on the host you need to install sshfs (you only need to do this once).

host$ sudo apt install sshfs 

Then copy may_install_kernel.sh to the bb-kernel directory.

host$ cd ~/BeagleBoard/bb-kernel
host$ cp ~/BeagleBoard/exercises/linux/kernel/may_install_kernel.sh tools

Now you can install the files using the following. Note, you must run may_install_kernel.sh from the directory above as shown.

host$ tools/may_install_kernel.sh
Mounting sshfs
-----------------------------
sshfs mounted
Installing 4.4.15-bone11 to sshfs
‘/home/yoder/BeagleBoard/bb-kernel/deploy/4.4.15-bone11.zImage’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/zImage’
Installing 4.4.15-bone11-dtbs.tar.gz to sshfs
Installing 4.4.15-bone11 to sshfs
‘/home/yoder/BeagleBoard/bb-kernel/deploy/4.4.15-bone11.zImage’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/boot/vmlinuz-4.4.15-bone11’
Installing 4.4.15-bone11-dtbs.tar.gz to sshfs
info: /boot/uEnv.txt: uname_r=4.4.15-bone11
Installing 4.4.15-bone11-modules.tar.gz to sshfs
tar: ./lib/modules/4.4.15-bone11/build: Cannot utime: No such file or directory
tar: ./lib/modules/4.4.15-bone11/source: Cannot utime: No such file or directory
tar: Exiting with failure status due to previous errors
‘/home/yoder/BeagleBoard/bb-kernel/deploy/config-4.4.15-bone11’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/boot/config-4.4.15-bone11’
info: [4.4.15-bone11] now installed...

You may see about couple of error messages about build and source, but it seems to work anyway. If you look in /boot/uEvt.txt, you'll see it's ready to boot your new kernel.

bone$ head -3 /boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.4.15-bone11

If you change your mind about which kernel to boot, just edit the uname line.

Copying to the SD Card on Host - build_kernel.sh

You can also install the kernel on an SD card that is mounted on your host computer. Plug it into your host and machine and run:

host$ tools/install_kernel.sh

This works like the may_install_kernel.sh, but it copies it to local host. Once copied, eject the SD card and plug it into your Bone and boot.

Updating to a new version of the kernel

When you build your kernel the uImage file has some version information in the name. For example vmlinuz-4.4.21-ti-r47. The 4.4.21 is the version of the kernel and the -ti-r47 is the version of the patches applied to the kernel for the BeagleBone. Over time new patches will be posted. These instructions show how to get the latest version.

How do you know if you have the latest version? Run

bone$ uname -a
Linux yoder-debian-bone 4.4.21-ti-r47 #1 SMP Fri Sep 23 22:23:02 UTC 2016 armv7l GNU/Linux

This post to the Google Group lists the steps as "You need to recheckout master, delete your old branch and re-pull". Here's how you do it.

host$ cd linux-dev
host$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
	patches/defconfig
Please, commit your changes or stash them before you can switch branches.
Aborting

Hmm.... something has changed. See what it is.

host$ git diff patches/defconfig
diff --git a/patches/defconfig b/patches/defconfig
index d903776..3268287 100644
--- a/patches/defconfig
+++ b/patches/defconfig
@@ -2041,6 +2041,7 @@ CONFIG_JHD629_I2C=y
 # CONFIG_SERIAL_NONSTANDARD is not set
 # CONFIG_N_GSM is not set
 # CONFIG_TRACE_SINK is not set
+CONFIG_LPD8806=m
 CONFIG_DEVKMEM=y
 
 #

It looks like some configuration setting have changed. Since we are getting a new version of the kernel, let's revert back to the previous file and try again.

host$ git checkout patches/defconfig
host$ git checkout master
Switched to branch 'master'

Success, now step 2.

host$ git branch -d am33x-v3.8
warning: deleting branch 'am33x-v3.8' that has been merged to
         'refs/remotes/origin/am33x-v3.8', but not yet merged to HEAD.
Deleted branch am33x-v3.8 (was 3fc8a73).

Now repull

host$ git pull

Then start over again

host$ git checkout origin/am33x-v3.8 -b am33x-v3.8
Branch am33x-v3.8 set up to track remote branch am33x-v3.8 from origin.
Switched to a new branch 'am33x-v3.8'

Your system.sh file should be unchanged, so start building

host$ ./build_kernel.sh

Mine took some 26 minutes on an 8 core machine.

Recovering

If your Beagle fails to boot, follow the EBC_Exercise_22_Recovering instructions to recover.




thumb‎ Embedded Linux Class by Mark A. Yoder