Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
network_protocol_programming_lab:3_preparedebian [2020/03/23 12:07] – [Enable UIO PRU Driver] rathkenetwork_protocol_programming_lab:3_preparedebian [2022/04/14 16:51] (current) – [Final Test] fangenoorth
Line 1: Line 1:
 ====== Debian Preparation for PPL ====== ====== Debian Preparation for PPL ======
  
-===== Get Package Updates =====+===== Get PPL Files for BeagleBone Black =====
  
-All of the following commands assume to be the superuserTo become superuseryou have to enter the command:+First you need to download all the stuff for the PPL on the BeagleBone Black 
 +In the home directoryexecute the following command:
  
 <code bash> <code bash>
-sudo --H+wget http://kn-pr.tkn.tu-berlin.de/ppl/Beaglebone.tar.gz
 </code> </code>
  
-after booting the BeagleBone Black and logging in into the //debian// account.+If you are unsure in which directory you currently are, execute the ''cd'' command first. This will change into the home directory.
  
-Otherwise you have to prefix every command with the word //sudo//. E.g. instead entering the command //apt-get update// enter the command //sudo apt-get update//.+Now extract the archive by executing the command:
  
-Now, after you have become superuser, ist is good advice to update the operation system with new packages by entrain the command+<code bash> 
 +tar -xzf Beaglebone.tar.gz 
 +</code> 
 + 
 +You will see a new directory called Beaglebone, containing additional directories:
  
 <code bash> <code bash>
-apt-get update+ls Beaglebone 
 +dts  spi  SPI_test
 </code> </code>
  
-and+We will need these later. For now let's focus on the proper setup and configuration of the Debian operating system that is required for this lab. 
 + 
 + 
 +===== Update Packages ===== 
 + 
 +All of the following commands assume to be executed by the superuser. To become superuser, you have to enter the command:
  
 <code bash> <code bash>
-apt-get upgrade+sudo -s -H
 </code> </code>
  
-This ensured the the operation system is up do date.+after booting the BeagleBone Black and logging in into the //debian// account, whose default password is //temppwd//
 + 
 +Otherwise you have to prefix every command with the word //sudo//. E.g. instead entering the command //apt-get update// enter the command //sudo apt-get update//.
  
-Looking carefully at the output of the //apt-get upgrade// command, you will recognize that an error occurs upgrading the dnsmasq package. This will resultthat communication via the USB interface will not work correctly. To fix the error enter the following commands:+Nowafter you have become superuserit is a good advice to update the operating system with new packages by entering the commands:
  
 <code bash> <code bash>
-systemctl enable dnsmasq.service  +apt-get update 
-systemctl restart dnsmasq.service+apt-get upgrade
 </code> </code>
  
-If you have forgotten to enable the dnsmasq deamon, your host system will not obtain an IP address automatically after the next restart of the BeagleBone Black. In this case you have to assign an IP address manually.+This ensures the the operation system is up do date.
  
 ===== Install additional Packages ===== ===== Install additional Packages =====
Line 44: Line 57:
 </code> </code>
  
 +
 +===== Set Time Zone =====
 +
 +You may set the timezone to German standard time using the following command:
 +
 +<code bash>
 +timedatectl set-timezone Europe/Berlin
 +</code>
 +
 +Issue the ''timedatectl'' command without parameters to verify your system time. If it's not synchronized correctly, don't worry, it will eventually synchronize later.
  
 ===== Kernel Upgrade ===== ===== Kernel Upgrade =====
  
-at the time of writing this memo, the lastest kernel version of the Debian distribution was //4.4.68-ti-r112//. +At the time of writing this memo, the  kernel version included in the Debian image was //4.19.94-ti-r42//. 
-To get the latest stable kernel release, that mostly is a newer kernel than the kernel of the Debian distribution, do the following:+To update to the latest stable kernel release, that most likely is a newer kernel than the kernel of the Debian image, do the following:
  
 <code bash> <code bash>
Line 56: Line 79:
 </code> </code>
  
-Unfortunately, the is a bug in the kernel update script, resulting that the configuration file of dnsmasq server is wrong. To continue to use the USB interfaces for Internet access enter the following command: +Now boot the BeagleBone Black once again.
- +
-<code bash> +
-touch /etc/dnsmasq.d/.SoftAp0 +
-</code> +
- +
-This //touch// command creates an empty file, indicating not to change the dnsmasq configuration file at the boot process. Now boot the BeagleBone Black once again.+
  
 <code bash> <code bash>
Line 68: Line 85:
 </code> </code>
  
-After the reboot von in again. The cost of the command+After the reboot, let's check our new upgraded kernel:
  
 <code bash> <code bash>
 uname -a uname -a
-Linux beaglebone 4.4.155-ti-r155 #SMP Thu May 23 05:22:53 UTC 2019 armv7l GNU/Linux+Linux beaglebone 4.19.94-ti-r72 #1buster SMP PREEMPT Tue Mar 8 22:13:06 UTC 2022 armv7l GNU/Linux
 </code> </code>
  
-Now the kernel version //4.4.155-ti-r155// is installed.+Now the kernel version //4.19.94-ti-r72// is installed. 
 ===== Device tree modifications ===== ===== Device tree modifications =====
  
 ==== Device tree compiler and overlays ==== ==== Device tree compiler and overlays ====
  
-In PPL, we need an device tree overlay to enable the SPI controller and the PRU. Therefore a patched  device tree compiler is needed. An addition the device tree overlay blobs for the peripheral is helpful.+In PPL, we need to configure the device tree of the system. A device tree dynamically((dynamically in this context means without having to recompile the kernel)) describes which and how hardware is connected to the system. As we use the SPI protocol to communicate with the CC1200, we need to configure our hardware in a way that the kernel is able to communicate with the SPI controller and the PRU in the first placeThis can be done by loading so called device tree overlays which overwrite the default configuration done by the master device tree, which gets shipped by the kernel.
  
-To install these things go to directory:+In the following we will instruct the bootloader (called U-Boot) to load some device tree overlays during boot, which are required to configure the hardware peripherals to fit our needs. You will also compile and install a custom device tree overlay, which represents the actual wiring of the CC1200 to the BeagleBone's pins. This is required because there are multiple pins we could connect the CC1200 to and the kernel is unable to automatically discover these.
  
-<code bash> +In first versions the wiring was made by hand. Today an adapter card is used. The wiring is shown in Fig. 1 and described [[network_protocol_programming_lab:wiring_beaglebone_cc1200|here]].
-cd /opt/source/bb.org-overlays +
-</code>+
  
-Now, test if the device tree compiler is installed: +<imgcaption image1 | Wireing of BeagleBone Black with CC1200>{{:network_protocol_programming_lab:beaglebone-cc1200.png}}</imgcaption>
- +
-<code bash> +
-dtc --version +
-VersionDTC 1.4.4 +
-</code> +
- +
-Update dtc by executing: +
- +
-<code bash> +
-./dtc-overlay.sh +
-</code> +
- +
-Install the device tree overlay blobs: +
- +
-<code bash> +
-./install.sh +
-</code>+
  
 ==== Disable HDMI ==== ==== Disable HDMI ====
-The pins of HDMI are multiplexed with the pins of the SPI. In order to use the SPI, the HDMI pins must be disabled by uncommenting the following line in the file ///boot/uEnv.txt//:+The pins of HDMI port are multiplexed with the pins of the SPI bus. In order to use the SPI bus, the HDMI pins must be disabled by uncommenting the following line in the file ///boot/uEnv.txt//:
  
 <code bash> <code bash>
-##BeagleBone Black: HDMI (Audio/Video) disabled: +disable_uboot_overlay_video=1
-dtb=am335x-boneblack-emmc-overlay.dtb+
 </code> </code>
 +
 ==== Disable default pin configuration ==== ==== Disable default pin configuration ====
  
-Per default the pins of the BeagleBone Black are wired for universal use, meaning the pins are connected to the common used devices. This will result in an error, if loading your own device tree overlay.+Per default the pins of the BeagleBone Black are wired for universal use, meaning the pins are connected to the commonly used devices. This will result in an error, if loading your own device tree overlay.
  
-To disable universal use, change the following line in the file ///boot/uEnv.txt//+To disable universal use, comment out the following line in the file ///boot/uEnv.txt//
  
 <code bash> <code bash>
-cmdline=coherent_pool=1M net.ifnames=0 quiet cape_universal=enable+enable_uboot_cape_universal=1
 </code> </code>
  
-to 
- 
-<code bash> 
-cmdline=coherent_pool=1M net.ifnames=0 quiet 
-</code>  
 ==== Reboot  and Test ==== ==== Reboot  and Test ====
  
 To make the changes effective, reboot. To make the changes effective, reboot.
  
-To testthat the HDMI is disables execute the following command:+To test that HDMI is disabled, execute the following command:
  
 <code bash> <code bash>
-grep "pin 41"  /sys/kernel/debug/pinctrl/44e10800.pinmux/pins+grep "pin 41" /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins
 </code> </code>
  
Line 142: Line 136:
  
 <code bash> <code bash>
-pin 41 (44e108a4.0) 0000002f pinctrl-single+pin 41 (PIN4144e108a4 0000002f pinctrl-single
 </code> </code>
  
-If the Hex-code is not //0000002f// the HDMI is still enabled.+If the Hex-code is not //0000002f// HDMI is still enabled.
  
-===== Enable UIO PRU Driver =====+==== PRU Driver ====
  
-((original source: http://catch22.eu/beaglebone/beaglebone-pru-uio/))+((original source: https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_PRU_Options))
  
-The communication between ARM host processor an the PRU (Programmable Realtime Unit) is implemented either by the Remoteproc-Driver or the UIO PRU Driver. Per default the Remoreproc-Driver is enabled. In this memo, it will be described, how to enable the UIO PRU Driver.+The communication between the ARM host processor and the PRU (Programmable Realtime Unit) is implemented either by the Remoteproc-Driver or the UIO PRU driver. Per default the Remoteproc driver is used. In this memo, it will be described, how to enable the UIO PRU driver.
  
-After booting an fresh Debian image an executing the command:+After booting fresh Debian image and executing the command:
  
 <code bash> <code bash>
 lsmod lsmod
 +
 Module                  Size  Used by Module                  Size  Used by
-pvrsrvkm              445708  0  +pru_rproc              28672  0 
-evdev                  14151  1  +irq_pruss_intc         20480  1 pru_rproc 
-uio_pdrv_genirq         4243  0  +pruss                  16384  pru_rproc 
-uio                    10972  uio_pdrv_genirq +pm33xx                 16384  0 
-8021q                  24428   +wkup_m3_ipc            16384  pm33xx 
-garp                    7497  1 8021q +wkup_m3_rproc          16384  1 
-mrp                     9351  8021q +remoteproc             57344  3 pru_rproc,wkup_m3_rproc,wkup_m3_ipc 
-stp                     2622  garp +virtio                 16384  remoteproc 
-llc                     6287  2 stp,garp +pvrsrvkm              421888 
-usb_f_acm               8681  2  +virtio_ring            28672  remoteproc 
-u_serial               14137  3 usb_f_acm +pruss_soc_bus          16384  0 
-usb_f_ecm              11448  2  +usb_f_acm              16384  2 
-usb_f_mass_storage     50793  2  +u_serial               20480  3 usb_f_acm 
-usb_f_rndis            26505  4  +usb_f_ncm              28672  2 
-u_ether                14733  usb_f_ecm,usb_f_rndis +usb_f_mass_storage     53248  2 
-libcomposite           54424  18 usb_f_acm,usb_f_ecm,usb_f_rndis,usb_f_mass_storage +uio_pdrv_genirq        16384  0 
-spidev                  9308  0  +uio                    20480  1 uio_pdrv_genirq 
-tieqep                 10365  0  +usb_f_rndis            32768  4 
-pru_rproc              15879  2  +u_ether                20480  usb_f_ncm,usb_f_rndis 
-pruss_intc              8923  1 pru_rproc +libcomposite           65536  18 usb_f_acm,usb_f_ncm,usb_f_mass_storage,usb_f_rndis
-pruss                  12346  1 pru_rproc              10972  1 uio_pdrv_genirq+
 </code> </code>
  
-and looking at the output. It seemsthe UIO PRU Driver (uio_pdrv_genirq) is already been enabled. But this Assumption is wrong. It needs several steps to enable the driver: +Looking at the output, it seems the UIO PRU driver (uio_pdrv_genirq) is already enabled, but this Assumption is wrong. It needs several steps to enable the driver
-==== Device tree modifications to enable UIO PRU driver ====+ 
 +=== Enable UIO PRU driver ===
  
-Go to the directory:+We need to instruct the bootloader to load the device tree overlay blob which enables the UIO driver. This can be done by uncommenting the the following line in the file ///boot/uEnv.txt//:
  
 <code bash> <code bash>
-cd /opt/source/dtb-4.4-ti/+uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
 </code> </code>
  
-Now, modify the file //src/arm/am335x-boneblack-emmc-overlay.dts// by uncommenting the UIO PRU part and commenting the the remoterpc part:+We should also disable the overlay for the unused rproc driver by commenting out the following line in the same file:
  
 <code bash> <code bash>
-/* #include "am33xx-pruss-rproc.dtsi" */ /* line 22 */ +uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
-#include "am33xx-pruss-uio.dtsi"         /* line 32 */ +
-</code>  +
- +
-After editing is finished, compile the device tree files by +
- +
-<code bash> +
-make +
-</code>  +
- +
-and install the device tree binary by +
- +
-<code bash> +
-make install+
 </code> </code>
  
-In the last step, the binary device tree must be enables in the file ///boot/uEnv.txt//. 
-If not already done look at [[network_protocol_programming_lab:3_preparedebian#Disable HDMI|Disable HDMI]]. 
  
-==== Disabling the Remoteproc drivers ====+=== Disable the Remoteproc drivers ===
  
-Finally the UIO PRU driver must be enables and the Remoteproc driver must be disables by +Finally the Remoteproc driver must be disabled by editing the file ///etc/modprobe.d/pruss-blacklist.conf// (create the file if it's not there).
-editing the file ///etc/modprobe.d/pruss-blacklist.conf//.+
  
 Remove the line '//blacklist uio_pruss//' and add the following lines: Remove the line '//blacklist uio_pruss//' and add the following lines:
Line 232: Line 211:
 </code> </code>
  
-==== Test ====+=== Test UIO driver ===
  
-To check, if the device tree file has been loaded correctly, execute +To verify that the device tree modifications have been loaded correctly, execute:
  
 <code bash> <code bash>
 lsmod lsmod
 +
 Module                  Size  Used by Module                  Size  Used by
-pvrsrvkm              445708  0  +pm33xx                 16384  0 
-uio_pruss               4387   +wkup_m3_ipc            16384  1 pm33xx 
-evdev                  14151  1  +wkup_m3_rproc          16384  1 
-uio_pdrv_genirq         4243  0  +remoteproc             57344  wkup_m3_rproc,wkup_m3_ipc 
-uio                    10972  uio_pruss,uio_pdrv_genirq +virtio                 16384  1 remoteproc 
-usb_f_acm               8681   +virtio_ring            28672  1 remoteproc 
-u_serial               14137  3 usb_f_acm +pvrsrvkm              421888  0 
-usb_f_ecm              11448   +uio_pruss              16384  0 
-8021q                  24428  0  +usb_f_acm              16384  2 
-garp                    7497  1 8021q +u_serial               20480  3 usb_f_acm 
-mrp                     9351  1 8021q +uio_pdrv_genirq        16384  0 
-stp                     2622  1 garp +usb_f_ncm              28672  2 
-llc                     6287  stp,garp +uio                    20480  2 uio_pruss,uio_pdrv_genirq 
-usb_f_mass_storage     50793  2  +usb_f_mass_storage     53248  2 
-usb_f_rndis            26505  4  +usb_f_rndis            32768  4 
-u_ether                14733  usb_f_ecm,usb_f_rndis +u_ether                20480  usb_f_ncm,usb_f_rndis 
-libcomposite           54424  18 usb_f_acm,usb_f_ecm,usb_f_rndis,usb_f_mass_storage +libcomposite           65536  18 usb_f_acm,usb_f_ncm,usb_f_mass_storage,usb_f_rndis 
-tieqep                 10365 +</code>
  
 +Now only //UIO PRU// drivers are loaded and no //rproc// drivers.
 +
 +
 +==== Install the PPL Device Tree Overlay ====
 +
 +For PPL the CC1200 is connected to the SPI bus of the BeagleBone Black and the SPI bus is controlled by the PRU.
 +Therefore we have to tell the Linux kernel how exactly the CC1200 is wired with the PRU and the system. This is described in a device tree overlay file which you have downloaded in the very first step of this chapter. Change to the directory where you have downloaded the ppl files to, e.g.:
 +
 +<code bash>
 +cd ~/Beaglebone/dts
 </code> </code>
  
-Now only //UIO PRU// drivers are loaded and no //Remoreproc// drivers.+Directory //dts// contains the file //BB-BONE-CC1200-00A0.dts//. In this file the device tree modifications are included. To compile it to a binary file enter: 
 + 
 +<code bash> 
 +dtc -O dtb -o  BB-BONE-CC1200-00A0.dtbo -b 0 -@ BB-BONE-CC1200-00A0.dts 
 +</code> 
 + 
 +During the compilation you can safely ignore warnings like 
 +<code bash> 
 +BB-BONE-CC1200-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property 
 +</code> 
 + 
 +//dtc// is the device tree compiler, which produces the bizarre overlay file //BB-BONE-CC1200-00A0.dtbo//. Next copy this file to the system firmware directory: 
 + 
 +<code bash> 
 +cp BB-BONE-CC1200-00A0.dtbo /lib/firmware/ 
 +</code> 
 + 
 +Now that we have compiled the device tree overlay and placed it in the right location, we have to instruct the bootloader to load this custom overlay. To do so open the file ///boot/uEnv.txt// and find the line: 
 + 
 +<code bash> 
 +###Custom Cape 
 +#dtb_overlay=/lib/firmware/<file8>.dtbo 
 +</code> 
 + 
 +Uncomment this line and edit it so that it loads our own device tree overlay blob: 
 + 
 +<code bash> 
 +dtb_overlay=/lib/firmware/BB-BONE-CC1200-00A0.dtbo 
 +</code> 
 + 
 +After that, reboot. 
 + 
 +===== Final Test ===== 
 + 
 +After all that is done we can do a final test to verify that all the hardware is configured correctly. 
 + 
 +Execute the command as root and inspect its output: 
 + 
 +<code bash> 
 +/opt/scripts/tools/version.sh | grep -i uboot 
 +</code> 
 + 
 +It should look like the following: 
 + 
 +<code> 
 +UBOOT: Booted Device-Tree:[am335x-boneblack-uboot.dts] 
 +UBOOT: Loaded Overlay:[AM335X-PRU-UIO-00A0] 
 +UBOOT: Loaded Overlay:[BB-ADC-00A0.bb.org-overlays] 
 +UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0.bb.org-overlays] 
 +uboot_overlay_options:[enable_uboot_overlays=1] 
 +uboot_overlay_options:[disable_uboot_overlay_video=1] 
 +uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo] 
 +uboot_overlay_options:[dtb_overlay=/lib/firmware/BB-BONE-CC1200-00A0.dtbo] 
 +cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet] 
 +</code> 
 + 
 +If you see any of the following lines in the output, something went wrongRedo the above steps in this case. 
 + 
 +<code> 
 +UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts] 
 +UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0] 
 +UBOOT: Loaded Overlay:[BB-HDMI-TDA998x-00A0] 
 +uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo] 
 +uboot_overlay_options:[enable_uboot_cape_universal=1] 
 +</code>
network_protocol_programming_lab/3_preparedebian.1584961626.txt.gz · Last modified: 2020/03/23 12:07 by rathke
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0