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 [2022/04/12 15:49] fangenoorthnetwork_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 ===== 
 + 
 +First you need to download all the stuff for the PPL on the BeagleBone Black.  
 +In the home directory, execute the following command: 
 + 
 +<code bash> 
 +wget http://kn-pr.tkn.tu-berlin.de/ppl/Beaglebone.tar.gz 
 +</code> 
 + 
 +If you are unsure in which directory you currently are, execute the ''cd'' command first. This will change into the home directory. 
 + 
 +Now extract the archive by executing the command: 
 + 
 +<code bash> 
 +tar -xzf Beaglebone.tar.gz 
 +</code> 
 + 
 +You will see a new directory called Beaglebone, containing additional directories: 
 + 
 +<code bash> 
 +ls Beaglebone 
 +dts  spi  SPI_test 
 +</code> 
 + 
 +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: All of the following commands assume to be executed by the superuser. To become superuser, you have to enter the command:
Line 13: Line 40:
 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//. 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, after you have become superuser, it is a good advice to update the operating system with new packages by entering the command:+Now, after you have become superuser, it is a good advice to update the operating system with new packages by entering the commands:
  
 <code bash> <code bash>
 apt-get update apt-get update
-</code> 
- 
-and 
- 
-<code bash> 
 apt-get upgrade apt-get upgrade
 </code> </code>
Line 35: 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 =====
Line 53: Line 85:
 </code> </code>
  
-After the reboot let's check our new upgraded kernel:+After the rebootlet's check our new upgraded kernel:
  
 <code bash> <code bash>
Line 61: Line 93:
  
 Now the kernel version //4.19.94-ti-r72// 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. In addition the device tree overlay blobs for the peripherals are 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.
  
-The device tree overlay reflects the wiring of the BeagleBone Black with the CC1200. In first versions the wireing was made by handToday an adapter card is used. The wiring is is shown in Fig. 1 and described [[network_protocol_programming_lab:wiring_beaglebone_cc1200|here]].+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 pinsThis is required because there are multiple pins we could connect the CC1200 to and the kernel is unable to automatically discover these.
  
 +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]].
  
 <imgcaption image1 | Wireing of BeagleBone Black with CC1200>{{:network_protocol_programming_lab:beaglebone-cc1200.png}}</imgcaption> <imgcaption image1 | Wireing of BeagleBone Black with CC1200>{{:network_protocol_programming_lab:beaglebone-cc1200.png}}</imgcaption>
- 
-To install these things go to directory and update the scripts first: 
- 
-<code bash> 
-cd /opt/source/bb.org-overlays 
-git pull 
-</code> 
- 
-Now, test if the device tree compiler is installed: 
- 
-<code bash> 
-dtc --version 
-Version: DTC 1.4.7 
-</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 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//:+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>
Line 131: Line 139:
 </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: https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_PRU_Options)) ((original source: https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_PRU_Options))
  
-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 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 a fresh Debian image and executing the command: After booting a fresh Debian image and executing the command:
Line 145: Line 153:
  
 Module                  Size  Used by Module                  Size  Used by
-usb_f_acm              16384  2 +pru_rproc              28672  0 
-u_serial               20480  3 usb_f_acm +irq_pruss_intc         20480  1 pru_rproc 
-usb_f_ecm              20480  2 +pruss                  16384  1 pru_rproc
-usb_f_mass_storage     53248 +
-usb_f_rndis            32768  4 +
-u_ether                20480  2 usb_f_ecm,usb_f_rndis +
-libcomposite           65536  18 usb_f_ecm,usb_f_acm,usb_f_mass_storage,usb_f_rndis+
 pm33xx                 16384  0 pm33xx                 16384  0
 wkup_m3_ipc            16384  1 pm33xx wkup_m3_ipc            16384  1 pm33xx
 wkup_m3_rproc          16384  1 wkup_m3_rproc          16384  1
-uio_pdrv_genirq        16384  0 
-uio                    20480  1 uio_pdrv_genirq 
-pruss_soc_bus          16384  0 
-pru_rproc              28672  0 
-pruss                  16384  1 pru_rproc 
-irq_pruss_intc         20480  1 pru_rproc 
 remoteproc             57344  3 pru_rproc,wkup_m3_rproc,wkup_m3_ipc remoteproc             57344  3 pru_rproc,wkup_m3_rproc,wkup_m3_ipc
 virtio                 16384  1 remoteproc virtio                 16384  1 remoteproc
 +pvrsrvkm              421888  0
 virtio_ring            28672  1 remoteproc virtio_ring            28672  1 remoteproc
-spidev                 20480  0+pruss_soc_bus          16384  0 
 +usb_f_acm              16384  2 
 +u_serial               20480  3 usb_f_acm 
 +usb_f_ncm              28672  2 
 +usb_f_mass_storage     53248 
 +uio_pdrv_genirq        16384  0 
 +uio                    20480  1 uio_pdrv_genirq 
 +usb_f_rndis            32768  4 
 +u_ether                20480  2 usb_f_ncm,usb_f_rndis 
 +libcomposite           65536  18 usb_f_acm,usb_f_ncm,usb_f_mass_storage,usb_f_rndis
 </code> </code>
  
-and looking at the output. It seems, the 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.
  
-==== Enable UIO PRU driver ====+=== Enable UIO PRU driver ===
  
-We need to instruct the bootloader to load 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//:+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>
Line 177: Line 185:
 </code> </code>
  
-We should also disable the device tree overlay for the unused rproc driver by commenting out the following line in the same file:+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>
Line 184: Line 192:
  
  
-==== Disabling the Remoteproc drivers ====+=== Disable the Remoteproc drivers ===
  
 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). 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).
Line 203: 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>
Line 231: Line 239:
  
 Now only //UIO PRU// drivers are loaded and no //rproc// drivers. 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>
 +
 +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 wrong. Redo 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.1649771393.txt.gz · Last modified: 2022/04/12 15:49 by fangenoorth
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0