diff options
Diffstat (limited to 'docs/misc')
-rw-r--r-- | docs/misc/bbb_ehci.html | 523 | ||||
-rw-r--r-- | docs/misc/bbb_ehci.md | 398 | ||||
-rw-r--r-- | docs/misc/index.html | 366 | ||||
-rw-r--r-- | docs/misc/index.md | 358 | ||||
-rw-r--r-- | docs/misc/patch.html | 218 | ||||
-rw-r--r-- | docs/misc/patch.md | 151 |
6 files changed, 907 insertions, 1107 deletions
diff --git a/docs/misc/bbb_ehci.html b/docs/misc/bbb_ehci.html deleted file mode 100644 index e79cf0ac..00000000 --- a/docs/misc/bbb_ehci.html +++ /dev/null @@ -1,523 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - - <style type="text/css"> - @import url('../css/main.css'); - </style> - - <title>EHCI debugging on the BeagleBone Black</title> -</head> - -<body> - - <div class="section"> - <h1 id="pagetop">EHCI debugging on the BeagleBone Black</h1> - - <p><a href="./">Back to previous index</a></p> - </div> - - <div class="section"> - <h1>EHCI debugging</h1> - <ol class="toc"> - <li><a href="#FindUSBportonthetargetthatsupportsEHCIdebug">Find - USB port on the target that supports EHCI debug</a></li> - <li><a href="#InitialsetupofBBBtoactasEHCIdebugdongle">Initial - setup of BBB to act as EHCI debug dongle</a></li> - <li><a href="#PatchBBBsgdbgpmoduleoptionalbuthighlyrecommended">Patch - BBB's <tt>g_dbgp</tt> module (optional, but highly recommended)</a></li> - <li><a href="#ConfigurelibrebootwithEHCIdebug">Configure - libreboot with EHCI debug</a> - <ol> - <li><a href="#SelectingHCDIndexandUSBDebugport">Selecting - <tt>HCD Index</tt> and <tt>USB Debug port</tt></a></li> - </ol></li> - <li><a href="#Howtogetthedebuglogs">How to get the debug - logs</a></li> - <li><a - href="#EnebleEHCIDebugonthetargetskerneloptionalrecommended">Eneble - EHCI Debug on the target's kernel (optional, recommended)</a></li> - <li><a href="#References">References</a></li> - </ol> - <p> - <strong> - NOTE: this documentation may be outdated, and discusses - configuring EHCI debug on the default Debian system that the BBB - sometimes comes with. If you want an easier time, just use - <a href="https://www.coreboot.org/BBB_screwdriver">BBB ScrewDriver</a> - which comes pre-configured. - </strong> - </p> - <p>If your computer does not boot after installing libreboot, it is - very useful to get debug logs from it, from the payload (grub) and/or - the kernel (if gets to there). All of them stream debug logs on the - available serial (RS-232) by default. However, most of todays laptops - lack RS-232 port. The other option is to stream the logs to USB EHCI - debug port.</p> - <p>This section explains step-by-step how to setup BBB as a - “USB EHCI debug dongle” and configure libreboot and the - linux kernel to stream logs to it (TODO: grub).</p> - <p>I will refer to three computers:</p> - <ul> - <li><b>host</b> - this is the computer you use, have - tools, compiler, Internet, etc</li> - <li><b>BBB</b> - Beaglebone Black (rev. B or higher, i - use rev. C)</li> - <li><b>target</b> - the computer you are trying to - install liberboot</li> - </ul> - <h3 id="FindUSBportonthetargetthatsupportsEHCIdebug">Find USB port - on the target that supports EHCI debug</h3> - <p> - Not all USB controllers support EHCI debug (see: <a - href="http://www.coreboot.org/EHCI_Debug_Port#Hardware_capability">EHCI - Debug Port</a> ). Even more, if a USB controller supports EHCI debug, it - is available only <b>on a single port</b> that might or might - not be exposed externally. - </p> - <ul> - <li>You need running OS (GNU+Linux) on your target for this step - (If you’ve flashed libreboot and it does not boot, you have to - flush back the stock bios)</li> - <li>You need USB memory stick (the data on it will not be - touched).</li> - <li>The EHCI debugging can not be done through external hub, BBB - must be connected directly to the debug port of the controller (so, no - hubs)</li> - </ul> - <ul> - <li>Download<sup class="footnote"><a href="#___fn1">1</a></sup> <a - href="http://www.coreboot.org/pipermail/coreboot/attachments/20080909/ae11c291/attachment.sh">this</a> - shell script. - </li> - </ul> - <ol> - <li>Plug the usb stick in the first available usb port</li> - <li>Run the script, you will get output similar to following:</li> -<pre>The following PCI devices support a USB debug port (says lspci): 0000:00:1a.0 0000:00:1d.0 -The following PCI devices support a USB debug port (says the kernel): 0000:00:1a.0 0000:00:1d.0 -*PCI device 0000:00:1a.0, USB bus 3, USB physical port 1* -*PCI device 0000:00:1d.0, USB bus 4, USB physical port 2* -Currently connected high-speed devices: -/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M - |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M - |__ Port 7: Dev 14, If 0, Class=Hub, Driver=hub/4p, 480M - |__ Port 1: Dev 15, If 0, Class=Hub, Driver=hub/4p, 480M - |__ Port 3: Dev 17, If 0, Class=Hub, Driver=hub/2p, 480M - |__ Port 4: Dev 18, If 0, Class=Hub, Driver=hub/4p, 480M -/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M - |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M -/: *Bus 01*.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M - |__ *Port 3: Dev 31, If 0, Class=Mass Storage, Driver=usb-storage, 480M* -</pre> - <li>The buses the support debug are Bus 3 (0000:00:1a.0) on Port 1 - and Bus 4 (0000:00:1d.0) on port 2. Your usb stick is plugged on Bus - 1, Port 3</li> - <li>Repeat the steps, plugging the USB stick in the next available - port</li> - <li>Go through all available ports and remember(write down) those - for which bus/port of the usb stick matches one of the bus/port that - support debug (bold).</li> - </ol> - <p>Remember (write down) for each port (external plug) you found - that supports debug: <b>PCI device id, the bus id, the port number, and - the physical location of the usb plug.</b></p> - <p>If you do not find a match, you can not get debug over EHCI. - Sorry.</p> - <p id="___fn1" class="footnote"> - <sup>1</sup> The guys from coreboot were talking about including the - script in coreboot distribution (check the status). - </p> - <h3 id="InitialsetupofBBBtoactasEHCIdebugdongle">Initial setup of - BBB to act as EHCI debug dongle</h3> - <p>BBB must be powered with a barrel power connector since the - mini-B USB plug will be used for the EHCI debug stream. So you will - need:</p> - <ul> - <li>power supply (5V, 2A(10W) is sufficient).</li> - <li>an extra usb cable: A to mini-B</li> - </ul> - <p> - (On BBB) The linux kernel includes module (g_dbgp that enables one of the usb ports on a computer to behave as EHCI - debug dongle. Make sure you have this module available on your BBB - (Debian 7.8 that comes with BBB should have it), if not, you should - compile it yourself (see next section): - </p> -<pre>ls /lib/modules/3.8.13-bone70/kernel/drivers/usb/gadget/g_dbgp.ko</pre> - <p> - Unload all other - g_* - modules: - </p> -<pre># lsmod -# rmmod g_multi -... -</pre> - <p> - Then load - g_dbgp - : - </p> -<pre># modprobe g_dbgp -# lsmod # should show that g_dbgp is loaded, and no other g_* -</pre> - <p> - Plug the mini-B side of the USB cable in your BBB and the A side in - your target. Then one of the usb devices on your target (with - lsusb - ) should be: - </p> -<pre>Bus 001 Device 024: ID 0525:c0de Netchip Technology, Inc.</pre> - <p>If you see the device on the target, you are good to continue to - the next step.</p> - <h3 id="PatchBBBsgdbgpmoduleoptionalbuthighlyrecommended"> - Patch BBB’s - g_dbgp - module (optional, but highly recommended) - </h3> - <p> - For the reasons why you need this, see: <a - href="http://www.coreboot.org/EHCI_Gadget_Debug">EHCI Gadget Debug</a>.<br />Make - sure that you have cross compiling environment for - arm-linux-gnueabihf - setup on your <em>host</em>. - </p> - <ul> - <li>On BBB: uname -r - this will give you version - number like 3.8.13-bone70 (I will refer to this as: $mav.$miv-$lv: - where mav=3.8, miv=13, lv=bone70 - </li> - <li>Get the BBB kernel ready on your host for cross-compiling:</li> - </ul> -<pre>$ cd $work_dir -$ git clone https://github.com/beagleboard/kernel.git -$ cd kernel -$ git checkout $mav (see above) -$ ./patch.sh -$ wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O kernel/firmware/am335x-pm-firmware.bin -$ cp configs/beaglebone kernel/arch/arm/configs/beaglebone_defconfig -</pre> - <ul> - <li>Download the patch from <a - href="http://www.coreboot.org/images/8/88/Ehci-debug-gadget-patches.tar.gz">here</a></li> - <li>tar -xf Ehci-debug-gadget-patches.tar.gz (will - create dir: usbdebug-gadget)</li> - <li>Note that there are two patches (patch_1 and patch_2) for each - of the two different version of the kernel (3.8 and 3.10). I will use - 3.8. (If using kernel 3.12 patch_1 is not needed)</li> - <li>cd kernel (note that this is one more level: you - should be in $work_dir/kernel/kernel)</li> - <li>Apply the patches:</li> - </ul> -<pre> -git apply ../usbdebug-gadget/v3.8-debug-gadget/0001-usb-dbgp-gadget-Fix-re-connecting-after-USB-disconne.patch -git apply ../usbdebug-gadget/v3.8-debug-gadget/0002-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch -; -make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- beaglebone_defconfig -j4@ -</pre> - <ul> - <li> - You should also apply the linux-libre <i>deblob</i> script to turn it into linux-libre - (deletes all the blobs from the linux kernel). - <a href="http://www.fsfla.org/ikiwiki/selibre/linux-libre/">fsfla website</a> - - see <a href="http://www.fsfla.org/svn/fsfla/software/linux-libre/scripts/">scripts</a>. - </li> - <li>Get your current BBB kernel config (from: /boot/config-<ver>) - and copy it to your host as $work_dir/kernel/kernel/.config</li> -<pre> -make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- oldconfig - all default answers</pre> - <li>Set proper version number: - <ul> - <li>On your host, edit $work_dir/kernel/kernel/.config - (the one you’ve just copied from BBB), find the line CONFIG_LOCALVERSION="<something - or empty>" and change it to CONFIG_LOCALVERSION="-$lv", - so it will look something like: CONFIG_LOCALVERSION="-bone70"</li> - </ul> - </li> - <li>Also, make sure that: CONFIG_USB_G_DBGP=m (If - not, make menuconfig, and set @Device Drivers-> USB - Support -> USB Gadget Support -> EHCI Debug Device Gadget=m</li> - <li>Build the module:</li> - </ul> -<pre> -$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 (is it possoble to build only the gadget modules) -$ mkdir ../tmp && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../tmp modules_install -</pre> - <ul> - <li>on BBB, backup /lib/modules/3.8.13-bone70/kernel/drivers/usb/gadget - (i.e. mv - /lib/modules/3.8.13-bone70/kernel/drivers/usb/gadget $HOME) - </li> - <li>copy the freshly compiled usb/gadget dir to /lib/modules/3.8.13-bone70/kernel/drivers/usb</li> - <li>restart BBB</li> - <li>Remove all g_* modules (rmmod - g_<>) - </li> - <li>modprobpe g_dbgp</li> - </ul> - <h3 id="ConfigurelibrebootwithEHCIdebug">Configure libreboot with - EHCI debug</h3> - <p> - Libreboot(coreboot) should be configured with debug turned on and to - push debug messages to the EHCI debug port.<br />If you’ve - downloaded the binary distribution, you can check if it is properly - configured in the following way: - </p> - <ul> - <li>Go to the libreboot dist root directory cd - $libreboot_bin</li> - <li>Locate the rom image for your target (I will call it: $img_path) - </li> - <li>Running the following command will extract the config in a - file ./my_config: - </li> - </ul> -<pre> -./cbfstool/i686/cbfstool $img_path extract -n config -f ./my_config -</pre> - <ul> - <li>Make sure that the following params in the config are set as - following:</li> - </ul> -<pre> -CONFIG_USBDEBUG=y (Generic Drivers -> USB 2.0 EHCI debug dongle support) -CONFIG_USBDEBUG_IN_ROMSTAGE=y (Generic Drivers -> Enable early (pre-RAM) usbdebug) -CONFIG_USBDEBUG_HCD_INDEX=<HCD Index of usb controller - see below> (Generic Drivers -> Index for EHCI controller to use with usbdebug) -CONFIG_USBDEBUG_DEFAULT_PORT=<USB Debug port - see below> (Generic Drivers -> Default USB port to use as Debug Port) -</pre> - <p> - The following three are behind radio button in the menu. Only the first - one<sup class="footnote"><a href="#___fn2">2</a></sup> should be = y - </p> -<pre> -USBDEBUG_DONGLE_STD=y (Generic Drivers -> Type of dongle (Net20DC or compatible) -> Net20DC or compatible) -CONFIG_USBDEBUG_DONGLE_BEAGLEBONE=n (Generic Drivers -> Type of dongle (Net20DC or compatible) -> BeagleBone) -CONFIG_USBDEBUG_DONGLE_BEAGLEBONE_BLACK=n (Generic Drivers -> Type of dongle (Net20DC or compatible) -> BeagleBone Black) -</pre> - <p id="___fn2" class="footnote"> - <sup>2</sup> The g_dbgp module on BeagleBone Black (Rev. C) reports it self as Net20DC, the - other options are for older BB(B) - ver1. This is documented <a - href="https://johnlewis.ie/coreboot-ehci-debug-gadget-demonstration/">here</a> - (also tested/verified). - </p> - <p> - Then:<br /> -<pre> -CONFIG_CONSOLE_USB=y (Console -> USB dongle console output) -</pre> - </p> - <p> - Also - Debugging ---> Output verbose XYZ - ) (<b>FIXME</b> somebody verify these): - </p> -<pre> -CONFIG_DEBUG_CBFS=y (Output verbose CBFS debug messages ) -CONFIG_HAVE_DEBUG_RAM_SETUP=y (??? What/where is this) -CONFIG_DEBUG_RAM_SETUP=y (Output verbose RAM init debug messages) -CONFIG_DEBUG_SMI=y (Output verbose SMI debug messages) -CONFIG_DEBUG_ACPI=y (Output verbose ACPI debug messages ) -CONFIG_DEBUG_USBDEBUG=y (Output verbose USB 2.0 EHCI debug dongle messages) -</pre> - <p>If some of the above mentioned configuration options are not as - specified, you have to configure and compile libreboot yourself. Please - refer to the doc(<b>FIXME: link</b> about compiling libreboot.</p> - <h4 id="SelectingHCDIndexandUSBDebugport"> - Selecting - HCD Index - and - USB Debug port - </h4> - <p> - This applies (and works) only if the USB controller that supports debug - (found in the first section) is from Intel.<br />If the PCI ID of the - port you found in the first section is - 0000:00:1a.0 - or - 0000:00:1d.0 - , you are ok. Otherwise you have to try without guarantee that will - work. - </p> - <p> - If the externally exposed port is on a bus with - PCI ID == 0000:00:1a.0 - then for - CONFIG_USBDEBUG_HCD_INDEX - choose 2, otherwise choose 0 - . - </p> - <p> - For - CONFIG_USBDEBUG_DEFAULT_PORT - choose the port from the first section that correspond to the - PCI ID - </p> - <p> - Notes:<br />The above is based on the implementation of - coreboot/src/southbridge/intel/common/usb_debug.c : pci_ehci_dbg_dev() - .<br />This is enough as it applies for the supported GM45/G45 - Thinkpads. coreboot support some other contollers too, but they are - irellevent for libreboot (for now). - </p> - <ul> - <li>On T500 (with switchable GPU) the debug ports for both intel - controllers is exposed.</li> - <li>On x200t the debug ports for both intel controllers is - exposed.</li> - </ul> - <h3 id="Howtogetthedebuglogs">How to get the debug logs</h3> - <ul> - <li>Plug the USB cable in the target’s debug port (the one - you found in step 1) and BBB’s mini-B USB</li> - <li>Make sure no other then g_dbgp of the g_* - modules is loaded on your BBB - </li> - <li>On the BBB:</li> - </ul> -<pre> -stty -icrnl -inlcr -F /dev/ttyGS0 -cat /dev/ttyGS0 -</pre> - <ul> - <li>Power on the target with libreboot</li> - <li>You should see debug logs comming on your BBB console</li> - </ul> - <p> - Note that this is not permanent on BBB, if you reboot it, you have to - rmmod g_* - and - modprobe g_dbgp - </p> - <h3 id="EnebleEHCIDebugonthetargetskerneloptionalrecommended">Eneble - EHCI Debug on the target’s kernel (optional, recommended)</h3> - <p>You have to know how to compile kernel for your target.</p> - <ol> - <li>Check if early debugging is already enabled: grep - CONFIG_EARLY_PRINTK_DBGP /boot/config-<ver></li> - <li>If enabled, you do not have to compile the kernel (skip this - step). Otherwise, prepare kernel source for your distribution and - select (Kernel hacking -> Early printk via EHCI debug - port). Compile and install the new kernel. - </li> - <li>Edit your grub configuration and add following to the kenel - parameters<sup class="footnote"><a href="#___fn20">20</a></sup><sup - class="footnote"><a href="#___fn21">21</a></sup>: earlyprintk=dbgp,keep. - Also, try: earlyprintk=dbgp<N>,keep where N - is the debug port id if the first does not work. - </li> - </ol> - <h3 id="References">References</h3> - <p id="___fn10" class="footnote"> - <sup>10</sup> <a href="http://www.coreboot.org/EHCI_Debug_Port">EHCI - Debug Port</a> - </p> - <p id="___fn11" class="footnote"> - <sup>11</sup> <a - href="https://johnlewis.ie/coreboot-ehci-debug-gadget-demonstration/">coreboot - EHCI debug gadget demonstration</a> - </p> - <p id="___fn12" class="footnote"> - <sup>12</sup> <a href="http://www.coreboot.org/EHCI_Gadget_Debug">EHCI - Gadget Debug</a> - </p> - <p id="___fn13" class="footnote"> - <sup>13</sup> <a - href="http://www.coreboot.org/images/8/88/Ehci-debug-gadget-patches.tar.gz">Ehci-debug-gadget-patches.tar.gz</a> - </p> - <p id="___fn14" class="footnote"> - <sup>14</sup> <a - href="http://wiki.beyondlogic.org/index.php/BeagleBoneBlack_Building_Kernel">Compiling - the BeagleBone Black Kernel</a> - </p> - <p id="___fn15" class="footnote"> - <sup>15</sup> - http://dumb-looks-free.blogspot.ca/2014/06/beaglebone-black-bbb-compile-kernel.html - </p> - <p id="___fn16" class="footnote"> - <sup>16</sup> - http://dumb-looks-free.blogspot.fr/2014/06/beaglebone-black-bbb-kernal-headers.html - </p> - <p id="___fn17" class="footnote"> - <sup>17</sup> <a href="http://elinux.org/Building_BBB_Kernel">Building - BBB Kernel</a> - </p> - <p id="___fn18" class="footnote"> - <sup>18</sup> - http://komposter.com.ua/documents/USB-2.0-Debug-Port%28John-Keys%29.pdf - </p> - <p id="___fn19" class="footnote"> - <sup>19</sup> <a href="http://cs.usfca.edu/~cruse/cs698s10/">Exploring - USB at the Hardware/Software Interface</a> - </p> - <p id="___fn20" class="footnote"> - <sup>20</sup> - https://www.kernel.org/doc/Documentation/x86/earlyprintk.txt - </p> - <p id="___fn21" class="footnote"> - <sup>21</sup> https://wiki.ubuntu.com/Kernel/Debugging/USBearlyprintk - </p> - <p> - <b>TODO</b>: - </p> - <ol> - <li>grub does not send messages to EHCI debug. Investigate.</li> - <li>The section “Configure libreboot with EHCI debug” - can be skipped/simplified if a common configuration works for all - relevant targets is selected as defualt</li> - <li>Patch and compule g_dbgp on BBB instead cross-compile</li> - <li>Find a simple way to send debug messages from targets userland</li> - </ol> - </div> - - <div class="section"> - - <p> - Copyright © 2015 Alex David <opdecirkel@gmail.com><br/> - Permission is granted to copy, distribute and/or modify this document - under the terms of the Creative Commons Attribution-ShareAlike 4.0 International license - or any later version published by Creative Commons; - - A copy of the license can be found at <a href="../cc-by-sa-4.0.txt">../cc-by-sa-4.0.txt</a> - </p> - - <p> - Updated versions of the license (when available) can be found at - <a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">https://creativecommons.org/licenses/by-sa/4.0/legalcode</a> - </p> - - <p> - UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE - EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS - AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF - ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, - IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, - WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, - ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT - KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT - ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. - </p> - <p> - TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE - TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, - NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, - INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, - COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR - USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR - DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR - IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. - </p> - <p> - The disclaimer of warranties and limitation of liability provided - above shall be interpreted in a manner that, to the extent - possible, most closely approximates an absolute disclaimer and - waiver of all liability. - </p> - - </div> - -</body> -</html> diff --git a/docs/misc/bbb_ehci.md b/docs/misc/bbb_ehci.md new file mode 100644 index 00000000..0cb49278 --- /dev/null +++ b/docs/misc/bbb_ehci.md @@ -0,0 +1,398 @@ +<div class="section"> + +EHCI debugging on the BeagleBone Black {#pagetop} +====================================== + +[Back to previous index](./) + +</div> + +<div class="section"> + +EHCI debugging +============== + +1. [Find USB port on the target that supports EHCI + debug](#FindUSBportonthetargetthatsupportsEHCIdebug) +2. [Initial setup of BBB to act as EHCI debug + dongle](#InitialsetupofBBBtoactasEHCIdebugdongle) +3. [Patch BBB\'s `g_dbgp` module (optional, but highly + recommended)](#PatchBBBsgdbgpmoduleoptionalbuthighlyrecommended) +4. [Configure libreboot with EHCI + debug](#ConfigurelibrebootwithEHCIdebug) + 1. [Selecting `HCD Index` and + `USB Debug port`](#SelectingHCDIndexandUSBDebugport) +5. [How to get the debug logs](#Howtogetthedebuglogs) +6. [Eneble EHCI Debug on the target\'s kernel (optional, + recommended)](#EnebleEHCIDebugonthetargetskerneloptionalrecommended) +7. [References](#References) + +**NOTE: this documentation may be outdated, and discusses configuring +EHCI debug on the default Debian system that the BBB sometimes comes +with. If you want an easier time, just use [BBB +ScrewDriver](https://www.coreboot.org/BBB_screwdriver) which comes +pre-configured.** + +If your computer does not boot after installing libreboot, it is very +useful to get debug logs from it, from the payload (grub) and/or the +kernel (if gets to there). All of them stream debug logs on the +available serial (RS-232) by default. However, most of todays laptops +lack RS-232 port. The other option is to stream the logs to USB EHCI +debug port. + +This section explains step-by-step how to setup BBB as a “USB EHCI debug +dongle” and configure libreboot and the linux kernel to stream logs to +it (TODO: grub). + +I will refer to three computers: + +- **host** - this is the computer you use, have tools, compiler, + Internet, etc +- **BBB** - Beaglebone Black (rev. B or higher, i use rev. C) +- **target** - the computer you are trying to install liberboot + +### Find USB port on the target that supports EHCI debug {#FindUSBportonthetargetthatsupportsEHCIdebug} + +Not all USB controllers support EHCI debug (see: [EHCI Debug +Port](http://www.coreboot.org/EHCI_Debug_Port#Hardware_capability) ). +Even more, if a USB controller supports EHCI debug, it is available only +**on a single port** that might or might not be exposed externally. + +- You need running OS (GNU+Linux) on your target for this step (If + you've flashed libreboot and it does not boot, you have to flush + back the stock bios) +- You need USB memory stick (the data on it will not be touched). +- The EHCI debugging can not be done through external hub, BBB must be + connected directly to the debug port of the controller (so, no hubs) + +<!-- --> + +- Download^[1](#___fn1)^ + [this](http://www.coreboot.org/pipermail/coreboot/attachments/20080909/ae11c291/attachment.sh) + shell script. + +1. Plug the usb stick in the first available usb port +2. Run the script, you will get output similar to following: +3. The buses the support debug are Bus 3 (0000:00:1a.0) on Port 1 and + Bus 4 (0000:00:1d.0) on port 2. Your usb stick is plugged on Bus 1, + Port 3 +4. Repeat the steps, plugging the USB stick in the next available port +5. Go through all available ports and remember(write down) those for + which bus/port of the usb stick matches one of the bus/port that + support debug (bold). + +Remember (write down) for each port (external plug) you found that +supports debug: **PCI device id, the bus id, the port number, and the +physical location of the usb plug.** + +If you do not find a match, you can not get debug over EHCI. Sorry. + +^1^ The guys from coreboot were talking about including the script in +coreboot distribution (check the status). + +### Initial setup of BBB to act as EHCI debug dongle {#InitialsetupofBBBtoactasEHCIdebugdongle} + +BBB must be powered with a barrel power connector since the mini-B USB +plug will be used for the EHCI debug stream. So you will need: + +- power supply (5V, 2A(10W) is sufficient). +- an extra usb cable: A to mini-B + +(On BBB) The linux kernel includes module (g\_dbgp that enables one of +the usb ports on a computer to behave as EHCI debug dongle. Make sure +you have this module available on your BBB (Debian 7.8 that comes with +BBB should have it), if not, you should compile it yourself (see next +section): + + ls /lib/modules/3.8.13-bone70/kernel/drivers/usb/gadget/g_dbgp.ko + +Unload all other g\_\* modules: + + # lsmod + # rmmod g_multi + ... + +Then load g\_dbgp : + + # modprobe g_dbgp + # lsmod # should show that g_dbgp is loaded, and no other g_* + +Plug the mini-B side of the USB cable in your BBB and the A side in your +target. Then one of the usb devices on your target (with lsusb ) should +be: + + Bus 001 Device 024: ID 0525:c0de Netchip Technology, Inc. + +If you see the device on the target, you are good to continue to the +next step. + +### Patch BBB's g\_dbgp module (optional, but highly recommended) {#PatchBBBsgdbgpmoduleoptionalbuthighlyrecommended} + +For the reasons why you need this, see: [EHCI Gadget +Debug](http://www.coreboot.org/EHCI_Gadget_Debug).\ +Make sure that you have cross compiling environment for +arm-linux-gnueabihf setup on your *host*. + +- On BBB: uname -r - this will give you version number like + 3.8.13-bone70 (I will refer to this as: \$mav.\$miv-\$lv: where + mav=3.8, miv=13, lv=bone70 +- Get the BBB kernel ready on your host for cross-compiling: + +<!-- --> + + $ cd $work_dir + $ git clone https://github.com/beagleboard/kernel.git + $ cd kernel + $ git checkout $mav (see above) + $ ./patch.sh + $ wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O kernel/firmware/am335x-pm-firmware.bin + $ cp configs/beaglebone kernel/arch/arm/configs/beaglebone_defconfig + +- Download the patch from + [here](http://www.coreboot.org/images/8/88/Ehci-debug-gadget-patches.tar.gz) +- tar -xf Ehci-debug-gadget-patches.tar.gz (will create dir: + usbdebug-gadget) +- Note that there are two patches (patch\_1 and patch\_2) for each of + the two different version of the kernel (3.8 and 3.10). I will use + 3.8. (If using kernel 3.12 patch\_1 is not needed) +- cd kernel (note that this is one more level: you should be in + \$work\_dir/kernel/kernel) +- Apply the patches: + +<!-- --> + + git apply ../usbdebug-gadget/v3.8-debug-gadget/0001-usb-dbgp-gadget-Fix-re-connecting-after-USB-disconne.patch + git apply ../usbdebug-gadget/v3.8-debug-gadget/0002-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch + ; + make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- beaglebone_defconfig -j4@ + +- You should also apply the linux-libre *deblob* script to turn it + into linux-libre (deletes all the blobs from the linux kernel). + [fsfla website](http://www.fsfla.org/ikiwiki/selibre/linux-libre/) - + see + [scripts](http://www.fsfla.org/svn/fsfla/software/linux-libre/scripts/). +- Get your current BBB kernel config (from: /boot/config-<ver>) + and copy it to your host as \$work\_dir/kernel/kernel/.config +- Set proper version number: + - On your host, edit \$work\_dir/kernel/kernel/.config (the one + you've just copied from BBB), find the line + CONFIG\_LOCALVERSION=\"<something or empty>\" and change + it to CONFIG\_LOCALVERSION=\"-\$lv\", so it will look something + like: CONFIG\_LOCALVERSION=\"-bone70\" +- Also, make sure that: CONFIG\_USB\_G\_DBGP=m (If not, make + menuconfig, and set @Device Drivers-> USB Support -> USB + Gadget Support -> EHCI Debug Device Gadget=m +- Build the module: + +<!-- --> + + $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 (is it possoble to build only the gadget modules) + $ mkdir ../tmp && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../tmp modules_install + +- on BBB, backup /lib/modules/3.8.13-bone70/kernel/drivers/usb/gadget + (i.e. mv /lib/modules/3.8.13-bone70/kernel/drivers/usb/gadget + \$HOME) +- copy the freshly compiled usb/gadget dir to + /lib/modules/3.8.13-bone70/kernel/drivers/usb +- restart BBB +- Remove all g\_\* modules (rmmod g\_<>) +- modprobpe g\_dbgp + +### Configure libreboot with EHCI debug {#ConfigurelibrebootwithEHCIdebug} + +Libreboot(coreboot) should be configured with debug turned on and to +push debug messages to the EHCI debug port.\ +If you've downloaded the binary distribution, you can check if it is +properly configured in the following way: + +- Go to the libreboot dist root directory cd \$libreboot\_bin +- Locate the rom image for your target (I will call it: \$img\_path) +- Running the following command will extract the config in a file + ./my\_config: + +<!-- --> + + ./cbfstool/i686/cbfstool $img_path extract -n config -f ./my_config + +- Make sure that the following params in the config are set as + following: + +<!-- --> + + CONFIG_USBDEBUG=y (Generic Drivers -> USB 2.0 EHCI debug dongle support) + CONFIG_USBDEBUG_IN_ROMSTAGE=y (Generic Drivers -> Enable early (pre-RAM) usbdebug) + CONFIG_USBDEBUG_HCD_INDEX=<HCD Index of usb controller - see below> (Generic Drivers -> Index for EHCI controller to use with usbdebug) + CONFIG_USBDEBUG_DEFAULT_PORT=<USB Debug port - see below> (Generic Drivers -> Default USB port to use as Debug Port) + +The following three are behind radio button in the menu. Only the first +one^[2](#___fn2)^ should be = y + + USBDEBUG_DONGLE_STD=y (Generic Drivers -> Type of dongle (Net20DC or compatible) -> Net20DC or compatible) + CONFIG_USBDEBUG_DONGLE_BEAGLEBONE=n (Generic Drivers -> Type of dongle (Net20DC or compatible) -> BeagleBone) + CONFIG_USBDEBUG_DONGLE_BEAGLEBONE_BLACK=n (Generic Drivers -> Type of dongle (Net20DC or compatible) -> BeagleBone Black) + +^2^ The g\_dbgp module on BeagleBone Black (Rev. C) reports it self as +Net20DC, the other options are for older BB(B) - ver1. This is +documented +[here](https://johnlewis.ie/coreboot-ehci-debug-gadget-demonstration/) +(also tested/verified). + +Then:\ + + CONFIG_CONSOLE_USB=y (Console -> USB dongle console output) + +Also Debugging \-\--> Output verbose XYZ ) (**FIXME** somebody verify +these): + + CONFIG_DEBUG_CBFS=y (Output verbose CBFS debug messages ) + CONFIG_HAVE_DEBUG_RAM_SETUP=y (??? What/where is this) + CONFIG_DEBUG_RAM_SETUP=y (Output verbose RAM init debug messages) + CONFIG_DEBUG_SMI=y (Output verbose SMI debug messages) + CONFIG_DEBUG_ACPI=y (Output verbose ACPI debug messages ) + CONFIG_DEBUG_USBDEBUG=y (Output verbose USB 2.0 EHCI debug dongle messages) + +If some of the above mentioned configuration options are not as +specified, you have to configure and compile libreboot yourself. Please +refer to the doc(**FIXME: link** about compiling libreboot. + +#### Selecting HCD Index and USB Debug port {#SelectingHCDIndexandUSBDebugport} + +This applies (and works) only if the USB controller that supports debug +(found in the first section) is from Intel.\ +If the PCI ID of the port you found in the first section is 0000:00:1a.0 +or 0000:00:1d.0 , you are ok. Otherwise you have to try without +guarantee that will work. + +If the externally exposed port is on a bus with PCI ID == 0000:00:1a.0 +then for CONFIG\_USBDEBUG\_HCD\_INDEX choose 2, otherwise choose 0 . + +For CONFIG\_USBDEBUG\_DEFAULT\_PORT choose the port from the first +section that correspond to the PCI ID + +Notes:\ +The above is based on the implementation of +coreboot/src/southbridge/intel/common/usb\_debug.c : +pci\_ehci\_dbg\_dev() .\ +This is enough as it applies for the supported GM45/G45 Thinkpads. +coreboot support some other contollers too, but they are irellevent for +libreboot (for now). + +- On T500 (with switchable GPU) the debug ports for both intel + controllers is exposed. +- On x200t the debug ports for both intel controllers is exposed. + +### How to get the debug logs {#Howtogetthedebuglogs} + +- Plug the USB cable in the target's debug port (the one you found in + step 1) and BBB's mini-B USB +- Make sure no other then g\_dbgp of the g\_\* modules is loaded on + your BBB +- On the BBB: + +<!-- --> + + stty -icrnl -inlcr -F /dev/ttyGS0 + cat /dev/ttyGS0 + +- Power on the target with libreboot +- You should see debug logs comming on your BBB console + +Note that this is not permanent on BBB, if you reboot it, you have to +rmmod g\_\* and modprobe g\_dbgp + +### Eneble EHCI Debug on the target's kernel (optional, recommended) {#EnebleEHCIDebugonthetargetskerneloptionalrecommended} + +You have to know how to compile kernel for your target. + +1. Check if early debugging is already enabled: grep + CONFIG\_EARLY\_PRINTK\_DBGP /boot/config-<ver> +2. If enabled, you do not have to compile the kernel (skip this step). + Otherwise, prepare kernel source for your distribution and select + (Kernel hacking -> Early printk via EHCI debug port). Compile and + install the new kernel. +3. Edit your grub configuration and add following to the kenel + parameters^[20](#___fn20)[21](#___fn21)^: earlyprintk=dbgp,keep. + Also, try: earlyprintk=dbgp<N>,keep where N is the debug port + id if the first does not work. + +### References {#References} + +^10^ [EHCI Debug Port](http://www.coreboot.org/EHCI_Debug_Port) + +^11^ [coreboot EHCI debug gadget +demonstration](https://johnlewis.ie/coreboot-ehci-debug-gadget-demonstration/) + +^12^ [EHCI Gadget Debug](http://www.coreboot.org/EHCI_Gadget_Debug) + +^13^ +[Ehci-debug-gadget-patches.tar.gz](http://www.coreboot.org/images/8/88/Ehci-debug-gadget-patches.tar.gz) + +^14^ [Compiling the BeagleBone Black +Kernel](http://wiki.beyondlogic.org/index.php/BeagleBoneBlack_Building_Kernel) + +^15^ +http://dumb-looks-free.blogspot.ca/2014/06/beaglebone-black-bbb-compile-kernel.html + +^16^ +http://dumb-looks-free.blogspot.fr/2014/06/beaglebone-black-bbb-kernal-headers.html + +^17^ [Building BBB Kernel](http://elinux.org/Building_BBB_Kernel) + +^18^ +http://komposter.com.ua/documents/USB-2.0-Debug-Port%28John-Keys%29.pdf + +^19^ [Exploring USB at the Hardware/Software +Interface](http://cs.usfca.edu/~cruse/cs698s10/) + +^20^ https://www.kernel.org/doc/Documentation/x86/earlyprintk.txt + +^21^ https://wiki.ubuntu.com/Kernel/Debugging/USBearlyprintk + +**TODO**: + +1. grub does not send messages to EHCI debug. Investigate. +2. The section “Configure libreboot with EHCI debug” can be + skipped/simplified if a common configuration works for all relevant + targets is selected as defualt +3. Patch and compule g\_dbgp on BBB instead cross-compile +4. Find a simple way to send debug messages from targets userland + +</div> + +<div class="section"> + +Copyright © 2015 Alex David <opdecirkel@gmail.com>\ +Permission is granted to copy, distribute and/or modify this document +under the terms of the Creative Commons Attribution-ShareAlike 4.0 +International license or any later version published by Creative +Commons; A copy of the license can be found at +[../cc-by-sa-4.0.txt](../cc-by-sa-4.0.txt) + +Updated versions of the license (when available) can be found at +<https://creativecommons.org/licenses/by-sa/4.0/legalcode> + +UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT +POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND +AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND +CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, +OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, +ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE +OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF +WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT +APPLY TO YOU. + +TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU +ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR +OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, +PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES +ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN +IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, +COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT +ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + +The disclaimer of warranties and limitation of liability provided above +shall be interpreted in a manner that, to the extent possible, most +closely approximates an absolute disclaimer and waiver of all liability. + +</div> diff --git a/docs/misc/index.html b/docs/misc/index.html deleted file mode 100644 index be54aab7..00000000 --- a/docs/misc/index.html +++ /dev/null @@ -1,366 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - - <style type="text/css"> - @import url('../css/main.css'); - </style> - - <title>Miscellaneous</title> -</head> - -<body> - - <div class="section"> - <h1 id="pagetop">Miscellaneous</h1> - <p> - Or <a href="../">Back to main index</a>. - </p> - <ul> - <li><a href="#debian_powertop">High Pitched Whining Noise on Idle (how to remove in Debian or Devuan)</a></li> - <li><a href="#high_pitch_parabola">High Pitched Whining Noise on Idle (how to remove in Parabola)</a></li> - <li><a href="#serial">X60/T60: Serial port - how to use (for dock owners)</a></li> - <li><a href="#powerbeeps">Power Management Beeps on Thinkpads</a></li> - <li><a href="patch.html">Using diff and patch</a></li> - <li><a href="#backlight control">Finetune backlight control on intel gpu’s</a></li> - <li><a href="#get_edid_panelname">Get EDID: Find out the name (model) of your LCD panel</a></li> - <li><a href="bbb_ehci.html">How to enable EHCI debugging on the BeagleBone Black</a></li> - <li><a href="#e1000-hang">e1000e driver trouble shooting (Intel NICs)</a></li> - </ul> - </div> - - <div class="section"> - - <h1 id="debian_powertop">High Pitched Whining Noise on Idle (how to remove in Debian or Devuan)</h1> - - <div class="subsection"> - <h2 id="debian_powertop_autostart">Start powertop automatically at boot time</h2> - - <p>Included with libreboot is a script called 'powertop.debian'. Run this as root and it will setup powertop to run with --auto-tune - at boot time. Load the file in your text editor to see how it does that.</p> - - <p>$ <b>sudo ./resources/scripts/misc/powertop.debian</b></p> - <p> - Might want to run with --calibrate first - </p> - <p> - If powertop doesn't work, another way (reduces battery life slightly) is - to add <i>processor.max_cstate=2</i> to the <i>linux</i> line in grub.cfg, - using <a href="../gnulinux/grub_cbfs.html">this guide</a>. - </p> - </div> - - <p><a href="#pagetop">Back to top of page</a></p> - - </div> - - <div class="section"> - - <h1 id="high_pitch_parabola">High Pitched Whining Noise on Idle (how to remove in Parabola)</h1> - - <p>The following removes most of the noise. It reduces what is a high frequency whine - (that not everyone can hear) to a slight buzz (which most people can't hear or doesn't bother most people).</p> - - <p>This is not perfect! The full solution is still not discovered but this is a step towards that. - Also, in some instances you will need to run 'sudo powertop --auto-tune' again. - This needs to be implemented properly in coreboot itself!</p> - - <p>On the X60 with coreboot or libreboot, there is a high pitched sound when idle. - So far we have use processor.max_cstate=2 or idle=halt in GRUB. - These consume power. Stop using them! </p> - - <p>Be root<br/> - <b>$ su -</b></p> - - <p>Installed powertop:<br/> - <b># pacman -S powertop</b></p> - - <p>and added the following to /etc/systemd/system/powertop.service :</p> - -<pre><i> -[Unit] -Description=Powertop tunings - -[Service] -Type=oneshot -RemainAfterExit=no -ExecStart=/usr/bin/powertop --auto-tune -# "powertop --auto-tune" still needs a terminal for some reason. Possibly a bug? -Environment="TERM=xterm" - -[Install] -WantedBy=multi-user.target -</i></pre> - - - <p>Finally, as root do that:<br/> - <b># systemctl enable powertop</b><br/> - <b># systemctl start powertop</b></p> - - <p>The next time you boot the system, the buzz will be gone.</p> - - <p> - Might want to run with --calibrate first - </p> - <p> - If powertop doesn't work, another way (reduces battery life slightly) is - to add <i>processor.max_cstate=2</i> to the <i>linux</i> line in grub.cfg, - using <a href="../gnulinux/grub_cbfs.html">this guide</a>. - </p> - - <p><a href="#pagetop">Back to top of page</a></p> - - </div> - - <div class="section"> - - <h1 id="serial">X60/T60: Serial port - how to use (for dock owners)</h1> - <p> - For the Thinkpad X60 you can use the <b>"UltraBase X6"</b> dock (for the X60 Tablet it is called - X6 Tablet UltraBase). For the ThinkPad T60, - you can use the <b>"Advanced Mini Dock"</b>. - </p> - <p> - If you are using one of the ROM images with 'serial' in the name, then you have serial port enabled in libreboot - and you have memtest86+ included inside the ROM. Connect your null modem cable to the serial port on the dock - and connect the other end to a 2nd system using your USB Serial adapter. - </p> - <p> - On the 2nd system, you can try this (using GNU Screen):<br/> - <b>$ sudo screen /dev/ttyUSB0 115200</b> - </p> - <p> - How to quit GNU Screen: Ctrl+A then release and press K, and then press Y. - </p> - <p>There are also others like Minicom but I like GNU Screen</p> - <p> - By doing this before booting the X60/T60, you will see console output from libreboot. You will also see - GRUB displaying on the serial output, and you will be able to see MemTest86+ on the serial output aswell. - You can also configure your distro so that a terminal (TTY) is accessible from the serial console. - </p> - <p> - The following guide is for Ubuntu, but it should work in Debian and Devuan, to enable a serial console using GeTTY:<br/> - <a href="https://help.ubuntu.com/community/SerialConsoleHowto">https://help.ubuntu.com/community/SerialConsoleHowto</a> - (we DO NOT recommend Ubuntu, because it contains non-free software in the default repos. Use Debian or Devuan) - </p> - <p> - Note: part of the tutorial above requires changing your grub.cfg. Just change the <b>linux</b> line to add instructions for enabling getty. - See <a href="../gnulinux/grub_cbfs.html">../gnulinux/grub_cbfs.html</a>. - </p> - <p><a href="#pagetop">Back to top of page</a> - - </div> - <div class="section" id="backlight control"> - <h1>Finetune backlight control on intel gpu’s </h1> - <p> - Sometimes the backlight control value (BLC_PWM_CTL) set by libreboot is not ideal. The result is either flicker, which could cause nausea or epilepsy or an uneven backlight and/or coil whine coming from the display. To fix this a different value for the gpu reg BLC_PWM_CTL needs to be set. See p94 of <a href="https://01.org/sites/default/files/documentation/g45_vol_3_register_0_0.pdf">https://01.org/sites/default/files/documentation/g45_vol_3_register_0_0.pdf</a> for more information on this reg. The tool for setting registry values on intel gpu’s is included in intel-gpu-tools. Install intel-gpu-tools: <b>sudo apt-get install intel-gpu-tools</b> - </p> - <p> - You can set values:</br> - <b>sudo intel_reg write 0x00061254 <your_value></b> - </p> - <p> - The value set has the following structure: bits [31:16] is PWM divider. PWM / PWM_divider = frequency bits [15:0] is the duty cycle and determines the portion of the backlight modulation frequency. A value of 0 will mean that the display is off. A value equal to the backlight modulation frequency means full on. The value should not be larger than the backlight modulation frequency. - </p> - <p> - On displays with a CCFL backlight start from: 0x60016001 To verify if all modes work as desired use:</br> - <b>xbacklight -set 10</b> - and gradually increase until 100. Displays with an LED backlight need a lower backlight modulation. Do the same thing but start from 0x01290129 . Try setting different values until you have found a value which presents no issue. - </p> - <p> - It is important to know that there are four failure modes: - <ol> - <li>flickering very fast, which could cause epilepsy (frequency is too low. decrease divider)</li> - <li>randomly flickering in random intervals - driver IC cannot keep up with toggling the mosfet (frequency too fast, increase divider)</li> - <li>frequency is in audible range and causes coils to whine (frequency is too high. increase divider)</li> - <li>backlight is uneven. (CCFL specific, frequency is too high. increase divider)</li> - </ol> - </p> - <p> - To check for flickering try moving your laptop while looking at it. - </p> - <p> - A higher frequency equals higher power consumption. You want to find the highest good working value. - </p> - <p> - Next this value should be set at boot: either add</br> - <pre>intel_reg write 0x00061254 <your_ideal_value></pre> - before exit 0 in /etc/rc.local or create a systemd service file /etc/systemd/system/backlight.service: - <pre> -[Unit] -Description=Set BLC_PWM_CTL to a good value -[Service] -Type=oneshot -RemainAfterExit=no -ExecStart=/usr/bin/intel_reg write 0x00061254 <your_value> -[Install] -WantedBy=multi-user.target - </pre> - Now start and enable it: <b>sudo systemctl start backlight && sudo systemctl enable backlight </b> - </p> - <p> - Special note on i945: - </p> - <p> - i945 behaves differently. Bit 16 needs to be 1 and the duty cycle is not updated when backlight is changed. There are no available datasheets on this target so why it behaves in such a way is not known. So to find a working value BLC_PWM_CTL set bit 16 to 1 and make sure PWM divider == duty cycle. see <a href="https://review.coreboot.org/#/c/10624/">https://review.coreboot.org/#/c/10624/</a> on bit 16. The cause of this issue is that i945, in contrast with to GM45, is set to work in BLM Legacy Mode. This makes backlight more complicated since the duty cycle is derived from 3 instead of 2 registers using the following formula:</br> - <verbatim> - if(BPC[7:0] <> xFF) then BPCR[15:0] * BPC[7:0] Else BPCR[15:0] - </verbatim> - </br> - BPC is LBB - PCI Backlight Control Register, described on <a href="http://www.mouser.com/pdfdocs/945gmedatasheet.pdf">http://www.mouser.com/pdfdocs/945gmedatasheet.pdf</a> on page 315. BPCR is BLC_PWM_CTL described in <a href="https://01.org/sites/default/files/documentation/g45_vol_3_register_0_0.pdf">https://01.org/sites/default/files/documentation/g45_vol_3_register_0_0.pdf</a> on page 94. More research needs to be done on this target so proceed with care. - </p> - </div> - - - <div class="section" id="powerbeeps"> - - <h1>Power Management Beeps on Thinkpads</h1> - - <p> - When disconnecting or connecting the charger, a beep occurs. - When the battery goes to a critically low charge level, - a beep occurs. Nvramtool is included in libreboot, and can - be used to enable or disable this behaviour. - </p> - - <p> - Disable or enable beeps when removing/adding the charger:<br/> - $ <b>sudo ./nvramtool -w power_management_beeps=Enable</b><br/> - $ <b>sudo ./nvramtool -w power_management_beeps=Disable</b> - </p> - - <p> - Disable or enable beeps when battery is low:<br/> - $ <b>sudo ./nvramtool -w low_battery_beep=Enable</b><br/> - $ <b>sudo ./nvramtool -w low_battery_beep=Disable</b> - </p> - - <p> - A reboot is required, for these changes to take effect. - </p> - - </div> - - <div class="section"> - - <h1 id="get_edid_panelname">Get EDID: Find out the name (model) of your LCD panel</h1> - <p> - Get the panel name with <b>sudo get-edid | strings</b><br/> - Or look in <b>/sys/class/drm/card0-LVDS-1/edid</b> - </p> - <p> - Alternatively you can use i2cdump. In Debian and Devuan, this is in the package i2c-tools.<br/> - $ <b>sudo modprobe i2c-dev</b><br/> - $ <b>sudo i2cdump -y 5 0x50</b> (you might have to change the value for -y)<br/> - $ <b>sudo rmmod i2c-dev</b><br/> - You'll see the panel name in the output (from the EDID dump). - </p> - <p> - If neither of these options work (or they are unavailable), physically removing the LCD panel is an option. - Usually, there will be information printed on the back. - </p> - - <p><a href="#pagetop">Back to top of page.</a></p> - - </div> - - <div class="section"> - - <h1 id="e1000-hang">e1000e driver trouble shooting (Intel NICs)</h1> - <p> - Example error, ¿may happen on weird and complex routing schemes(citation needed for cause): - </p> -<pre> -e1000e 0000:00:19.0 enp0s25: Detected Hardware Unit Hang -</pre> - <p> - Possible workaround, tested by Nazara: Disable C-STATES.<br/> - <strong> - NOTE: this also disables power management, because disabling C-States - means that your CPU will now be running at full capacity (and therefore - using more power) non-stop, which will drain battery life if this is a laptop. - If power usage is a concern, then you should not use this. - (we're also not sure whether this workaround is appropriate) - </strong> - </p> - <p> - To disable c-states, do this in GNU+Linux:<br/> - <strong> - for i in /sys/devices/system/cpu/cpu/cpuidle/state/disable; do echo 1 > $i; done - </strong> - </p> - <p> - You can reproduce this issue more easily by sending lots of traffic across - subnets on the same interface (NIC). - </p> - <p> - More information, including logs, can be found on - <a href="https://notabug.org/vimuser/libreboot/issues/23">this page</a>. - </p> - - </div> - - <div class="section"> - - <h1 id="usb_keyboard_gm45">USB keyboard wakeup on GM45 laptops</h1> - <p> - Look at resources/scripts/helpers/misc/libreboot_usb_bugfix - </p> - <p> - Put this script in /etc/init.d/ on debian-based systems. - </p> - - </div> - - <div class="section"> - - <p> - Copyright © 2014, 2015, 2016 Leah Rowe <info@minifree.org><br/> - Permission is granted to copy, distribute and/or modify this document - under the terms of the Creative Commons Attribution-ShareAlike 4.0 International license - or any later version published by Creative Commons; - - A copy of the license can be found at <a href="../cc-by-sa-4.0.txt">../cc-by-sa-4.0.txt</a> - </p> - - <p> - Updated versions of the license (when available) can be found at - <a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">https://creativecommons.org/licenses/by-sa/4.0/legalcode</a> - </p> - - <p> - UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE - EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS - AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF - ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, - IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, - WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, - ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT - KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT - ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. - </p> - <p> - TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE - TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, - NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, - INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, - COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR - USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR - DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR - IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. - </p> - <p> - The disclaimer of warranties and limitation of liability provided - above shall be interpreted in a manner that, to the extent - possible, most closely approximates an absolute disclaimer and - waiver of all liability. - </p> - - </div> - -</body> -</html> diff --git a/docs/misc/index.md b/docs/misc/index.md new file mode 100644 index 00000000..6db759a7 --- /dev/null +++ b/docs/misc/index.md @@ -0,0 +1,358 @@ +<div class="section"> + +Miscellaneous {#pagetop} +============= + +Or [Back to main index](../). + +- [High Pitched Whining Noise on Idle (how to remove in Debian or + Devuan)](#debian_powertop) +- [High Pitched Whining Noise on Idle (how to remove in + Parabola)](#high_pitch_parabola) +- [X60/T60: Serial port - how to use (for dock owners)](#serial) +- [Power Management Beeps on Thinkpads](#powerbeeps) +- [Using diff and patch](patch.html) +- [Finetune backlight control on intel gpu's](#backlight%20control) +- [Get EDID: Find out the name (model) of your LCD + panel](#get_edid_panelname) +- [How to enable EHCI debugging on the BeagleBone + Black](bbb_ehci.html) +- [e1000e driver trouble shooting (Intel NICs)](#e1000-hang) + +</div> + +<div class="section"> + +High Pitched Whining Noise on Idle (how to remove in Debian or Devuan) {#debian_powertop} +====================================================================== + +<div class="subsection"> + +Start powertop automatically at boot time {#debian_powertop_autostart} +----------------------------------------- + +Included with libreboot is a script called \'powertop.debian\'. Run this +as root and it will setup powertop to run with \--auto-tune at boot +time. Load the file in your text editor to see how it does that. + +\$ **sudo ./resources/scripts/misc/powertop.debian** + +Might want to run with \--calibrate first + +If powertop doesn\'t work, another way (reduces battery life slightly) +is to add *processor.max\_cstate=2* to the *linux* line in grub.cfg, +using [this guide](../gnulinux/grub_cbfs.html). + +</div> + +[Back to top of page](#pagetop) + +</div> + +<div class="section"> + +High Pitched Whining Noise on Idle (how to remove in Parabola) {#high_pitch_parabola} +============================================================== + +The following removes most of the noise. It reduces what is a high +frequency whine (that not everyone can hear) to a slight buzz (which +most people can\'t hear or doesn\'t bother most people). + +This is not perfect! The full solution is still not discovered but this +is a step towards that. Also, in some instances you will need to run +\'sudo powertop \--auto-tune\' again. This needs to be implemented +properly in coreboot itself! + +On the X60 with coreboot or libreboot, there is a high pitched sound +when idle. So far we have use processor.max\_cstate=2 or idle=halt in +GRUB. These consume power. Stop using them! + +Be root\ +**\$ su -** + +Installed powertop:\ +**\# pacman -S powertop** + +and added the following to /etc/systemd/system/powertop.service : + + [Unit] + Description=Powertop tunings + + [Service] + Type=oneshot + RemainAfterExit=no + ExecStart=/usr/bin/powertop --auto-tune + # "powertop --auto-tune" still needs a terminal for some reason. Possibly a bug? + Environment="TERM=xterm" + + [Install] + WantedBy=multi-user.target + +Finally, as root do that:\ +**\# systemctl enable powertop**\ +**\# systemctl start powertop** + +The next time you boot the system, the buzz will be gone. + +Might want to run with \--calibrate first + +If powertop doesn\'t work, another way (reduces battery life slightly) +is to add *processor.max\_cstate=2* to the *linux* line in grub.cfg, +using [this guide](../gnulinux/grub_cbfs.html). + +[Back to top of page](#pagetop) + +</div> + +<div class="section"> + +X60/T60: Serial port - how to use (for dock owners) {#serial} +=================================================== + +For the Thinkpad X60 you can use the **\"UltraBase X6\"** dock (for the +X60 Tablet it is called X6 Tablet UltraBase). For the ThinkPad T60, you +can use the **\"Advanced Mini Dock\"**. + +If you are using one of the ROM images with \'serial\' in the name, then +you have serial port enabled in libreboot and you have memtest86+ +included inside the ROM. Connect your null modem cable to the serial +port on the dock and connect the other end to a 2nd system using your +USB Serial adapter. + +On the 2nd system, you can try this (using GNU Screen):\ +**\$ sudo screen /dev/ttyUSB0 115200** + +How to quit GNU Screen: Ctrl+A then release and press K, and then press +Y. + +There are also others like Minicom but I like GNU Screen + +By doing this before booting the X60/T60, you will see console output +from libreboot. You will also see GRUB displaying on the serial output, +and you will be able to see MemTest86+ on the serial output aswell. You +can also configure your distro so that a terminal (TTY) is accessible +from the serial console. + +The following guide is for Ubuntu, but it should work in Debian and +Devuan, to enable a serial console using GeTTY:\ +<https://help.ubuntu.com/community/SerialConsoleHowto> (we DO NOT +recommend Ubuntu, because it contains non-free software in the default +repos. Use Debian or Devuan) + +Note: part of the tutorial above requires changing your grub.cfg. Just +change the **linux** line to add instructions for enabling getty. See +[../gnulinux/grub\_cbfs.html](../gnulinux/grub_cbfs.html). + +[Back to top of page](#pagetop) + +</div> + +<div id="backlight control" class="section"> + +Finetune backlight control on intel gpu's +========================================= + +Sometimes the backlight control value (BLC\_PWM\_CTL) set by libreboot +is not ideal. The result is either flicker, which could cause nausea or +epilepsy or an uneven backlight and/or coil whine coming from the +display. To fix this a different value for the gpu reg BLC\_PWM\_CTL +needs to be set. See p94 of +<https://01.org/sites/default/files/documentation/g45_vol_3_register_0_0.pdf> +for more information on this reg. The tool for setting registry values +on intel gpu's is included in intel-gpu-tools. Install intel-gpu-tools: +**sudo apt-get install intel-gpu-tools** + +You can set values: **sudo intel\_reg write 0x00061254 +<your\_value>** + +The value set has the following structure: bits \[31:16\] is PWM +divider. PWM / PWM\_divider = frequency bits \[15:0\] is the duty cycle +and determines the portion of the backlight modulation frequency. A +value of 0 will mean that the display is off. A value equal to the +backlight modulation frequency means full on. The value should not be +larger than the backlight modulation frequency. + +On displays with a CCFL backlight start from: 0x60016001 To verify if +all modes work as desired use: **xbacklight -set 10** and gradually +increase until 100. Displays with an LED backlight need a lower +backlight modulation. Do the same thing but start from 0x01290129 . Try +setting different values until you have found a value which presents no +issue. + +It is important to know that there are four failure modes: + +1. flickering very fast, which could cause epilepsy (frequency is too + low. decrease divider) +2. randomly flickering in random intervals - driver IC cannot keep up + with toggling the mosfet (frequency too fast, increase divider) +3. frequency is in audible range and causes coils to whine (frequency + is too high. increase divider) +4. backlight is uneven. (CCFL specific, frequency is too high. increase + divider) + +To check for flickering try moving your laptop while looking at it. + +A higher frequency equals higher power consumption. You want to find the +highest good working value. + +Next this value should be set at boot: either add + + intel_reg write 0x00061254 <your_ideal_value> + +before exit 0 in /etc/rc.local or create a systemd service file +/etc/systemd/system/backlight.service: + [Unit] + Description=Set BLC_PWM_CTL to a good value + [Service] + Type=oneshot + RemainAfterExit=no + ExecStart=/usr/bin/intel_reg write 0x00061254 <your_value> + [Install] + WantedBy=multi-user.target + + +Now start and enable it: **sudo systemctl start backlight && sudo +systemctl enable backlight** +Special note on i945: + +i945 behaves differently. Bit 16 needs to be 1 and the duty cycle is not +updated when backlight is changed. There are no available datasheets on +this target so why it behaves in such a way is not known. So to find a +working value BLC\_PWM\_CTL set bit 16 to 1 and make sure PWM divider == +duty cycle. see <https://review.coreboot.org/#/c/10624/> on bit 16. The +cause of this issue is that i945, in contrast with to GM45, is set to +work in BLM Legacy Mode. This makes backlight more complicated since the +duty cycle is derived from 3 instead of 2 registers using the following +formula: if(BPC\[7:0\] <> xFF) then BPCR\[15:0\] \* BPC\[7:0\] +Else BPCR\[15:0\] BPC is LBB - PCI Backlight Control Register, described +on <http://www.mouser.com/pdfdocs/945gmedatasheet.pdf> on page 315. BPCR +is BLC\_PWM\_CTL described in +<https://01.org/sites/default/files/documentation/g45_vol_3_register_0_0.pdf> +on page 94. More research needs to be done on this target so proceed +with care. + +</div> + +<div id="powerbeeps" class="section"> + +Power Management Beeps on Thinkpads +=================================== + +When disconnecting or connecting the charger, a beep occurs. When the +battery goes to a critically low charge level, a beep occurs. Nvramtool +is included in libreboot, and can be used to enable or disable this +behaviour. + +Disable or enable beeps when removing/adding the charger:\ +\$ **sudo ./nvramtool -w power\_management\_beeps=Enable**\ +\$ **sudo ./nvramtool -w power\_management\_beeps=Disable** + +Disable or enable beeps when battery is low:\ +\$ **sudo ./nvramtool -w low\_battery\_beep=Enable**\ +\$ **sudo ./nvramtool -w low\_battery\_beep=Disable** + +A reboot is required, for these changes to take effect. + +</div> + +<div class="section"> + +Get EDID: Find out the name (model) of your LCD panel {#get_edid_panelname} +===================================================== + +Get the panel name with **sudo get-edid | strings**\ +Or look in **/sys/class/drm/card0-LVDS-1/edid** + +Alternatively you can use i2cdump. In Debian and Devuan, this is in the +package i2c-tools.\ +\$ **sudo modprobe i2c-dev**\ +\$ **sudo i2cdump -y 5 0x50** (you might have to change the value for +-y)\ +\$ **sudo rmmod i2c-dev**\ +You\'ll see the panel name in the output (from the EDID dump). + +If neither of these options work (or they are unavailable), physically +removing the LCD panel is an option. Usually, there will be information +printed on the back. + +[Back to top of page.](#pagetop) + +</div> + +<div class="section"> + +e1000e driver trouble shooting (Intel NICs) {#e1000-hang} +=========================================== + +Example error, ¿may happen on weird and complex routing schemes(citation +needed for cause): + + e1000e 0000:00:19.0 enp0s25: Detected Hardware Unit Hang + +Possible workaround, tested by Nazara: Disable C-STATES.\ +**NOTE: this also disables power management, because disabling C-States +means that your CPU will now be running at full capacity (and therefore +using more power) non-stop, which will drain battery life if this is a +laptop. If power usage is a concern, then you should not use this. +(we\'re also not sure whether this workaround is appropriate)** + +To disable c-states, do this in GNU+Linux:\ +**for i in /sys/devices/system/cpu/cpu/cpuidle/state/disable; do echo 1 +> \$i; done** + +You can reproduce this issue more easily by sending lots of traffic +across subnets on the same interface (NIC). + +More information, including logs, can be found on [this +page](https://notabug.org/vimuser/libreboot/issues/23). + +</div> + +<div class="section"> + +USB keyboard wakeup on GM45 laptops {#usb_keyboard_gm45} +=================================== + +Look at resources/scripts/helpers/misc/libreboot\_usb\_bugfix + +Put this script in /etc/init.d/ on debian-based systems. + +</div> + +<div class="section"> + +Copyright © 2014, 2015, 2016 Leah Rowe <info@minifree.org>\ +Permission is granted to copy, distribute and/or modify this document +under the terms of the Creative Commons Attribution-ShareAlike 4.0 +International license or any later version published by Creative +Commons; A copy of the license can be found at +[../cc-by-sa-4.0.txt](../cc-by-sa-4.0.txt) + +Updated versions of the license (when available) can be found at +<https://creativecommons.org/licenses/by-sa/4.0/legalcode> + +UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT +POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND +AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND +CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, +OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, +ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE +OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF +WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT +APPLY TO YOU. + +TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU +ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR +OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, +PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES +ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN +IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, +COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT +ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + +The disclaimer of warranties and limitation of liability provided above +shall be interpreted in a manner that, to the extent possible, most +closely approximates an absolute disclaimer and waiver of all liability. + +</div> diff --git a/docs/misc/patch.html b/docs/misc/patch.html deleted file mode 100644 index 1e459a1f..00000000 --- a/docs/misc/patch.html +++ /dev/null @@ -1,218 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - - <style type="text/css"> - @import url('../css/main.css'); - </style> - - <title> - Libreboot documentation: using diff and patch - </title> - -</head> - -<body> - - <div class="section"> - <h1 id="pagetop">Diff and patch</h1> - <p>This is just a quick guide for reference, use 'man' to know more.</p> - <p> - <a href="./">Back to index</a> - </p> - </div> - - <div class="section"> - - <h1> - Apply a patch - </h1> - - <p class="important"> - To apply a patch to a single file, do that in it's directory:<br/> - <b>$ patch < foo.patch</b> - </p> - - <p> - Assuming that the patch is distributed in unified format identifying - the file the patch should be applied to, the above will work. Otherwise:<br/> - <b>$ patch foo.txt < bar.patch</b> - </p> - - <p> - You can apply a patch to an entire directory, but note the "p level". - What this means is that inside patch files will be the files that you - intend to patch, identified by path names that might be different - when the files ane located on your own computer instead of on the computer - where the patch was created. 'p' level instructs the 'patch' utility to - ignore parts of the path name to identify the files correctly. Usually a - p level of 1 will work, so you would use:<br/> - <b>$ patch -p1 < baz.patch</b> - </p> - - <p> - Change to the top level directory before running this. If a patch level - of 1 cannot identify the files to patch, then inspect the patch file for file names. - For example:<br/> - <b>/home/user/do/not/panic/yet.c</b> - </p> - - <p> - and you are working in a directory that contains panic/yet.c, use:<br/> - <b>$ patch -p5 < baz.patch</b> - </p> - - <p> - You usually count one up for each path separator (forward slash) - removed from the beginning of the path, until you are left with a path - that exists in the current working directory. The count is the p level. - </p> - - <p> - Removing a patch using the -R flag<br/> - <b>$ patch -p5 -R < baz.patch</b> - </p> - - <p><a href="#pagetop">Back to top of page.</a></p> - - </div> - - <div class="section"> - - <h1> - Create a patch with diff - </h1> - - <p> - Diff can create a patch for a single file:<br/> - <b>$ diff -u original.c new.c > original.patch</b> - </p> - - <p> - For diff'ing a source tree:<br/> - <b>$ cp -R original new</b> - </p> - - <p> - Do whatever you want in new/ and then diff it:<br/> - <b>$ diff -rupN original/ new/ > original.patch</b> - </p> - - <p><a href="#pagetop">Back to top of page.</a></p> - - </div> - - <div class="section"> - - <h1> - git diff - </h1> - - <p> - git is something special. - </p> - <p> - Note: this won't show new files created. - </p> - - <p> - Just make whatever changes you want to a git clone and then:<br/> - <b>$ git diff > patch.git</b> - </p> - - <p> - Note the git revision that you did this with:<br/> - <b>$ git log</b> - </p> - - <p> - Alternatively (better yet), commit your changes and then use:<br/> - $ <b>git format-patch -N</b><br/> - Replace N with the number of commits that you want to show. - </p> - - <p><a href="#pagetop">Back to top of page.</a></p> - - </div> - - <div class="section"> - - <h1> - git apply - </h1> - - <p>it really is.</p> - - <p> - Now to apply that patch in the future, just git clone it again and do - with the git revision you found from above:<br/> - <b>$ git reset --hard REVISIONNUMBER</b> - </p> - - <p> - Now put patch.git in the git clone directory and do:<br/> - <b>$ git apply patch.git</b> - </p> - - <p> - If you use a patch from git format-patch, then use <b>git am patch.git</b> instead of <b>git apply patch.git</b>. git-am - will re-create the commits aswell, instead of just applying the patch. - </p> - - <p><a href="#pagetop">Back to top of page.</a></p> - - </div> - - <div class="section"> - - <p> - Copyright © 2014, 2015 Leah Rowe <info@minifree.org><br/> - Permission is granted to copy, distribute and/or modify this document - under the terms of the Creative Commons Attribution-ShareAlike 4.0 International license - or any later version published by Creative Commons; - - A copy of the license can be found at <a href="../cc-by-sa-4.0.txt">../cc-by-sa-4.0.txt</a> - </p> - - <p> - Updated versions of the license (when available) can be found at - <a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">https://creativecommons.org/licenses/by-sa/4.0/legalcode</a> - </p> - - <p> - UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE - EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS - AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF - ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, - IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, - WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, - ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT - KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT - ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. - </p> - <p> - TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE - TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, - NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, - INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, - COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR - USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR - DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR - IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. - </p> - <p> - The disclaimer of warranties and limitation of liability provided - above shall be interpreted in a manner that, to the extent - possible, most closely approximates an absolute disclaimer and - waiver of all liability. - </p> - - </div> - -</body> -</html> diff --git a/docs/misc/patch.md b/docs/misc/patch.md new file mode 100644 index 00000000..46d6a15a --- /dev/null +++ b/docs/misc/patch.md @@ -0,0 +1,151 @@ +<div class="section"> + +Diff and patch {#pagetop} +============== + +This is just a quick guide for reference, use \'man\' to know more. + +[Back to index](./) + +</div> + +<div class="section"> + +Apply a patch +============= + +To apply a patch to a single file, do that in it\'s directory:\ +**\$ patch < foo.patch** + +Assuming that the patch is distributed in unified format identifying the +file the patch should be applied to, the above will work. Otherwise:\ +**\$ patch foo.txt < bar.patch** + +You can apply a patch to an entire directory, but note the \"p level\". +What this means is that inside patch files will be the files that you +intend to patch, identified by path names that might be different when +the files ane located on your own computer instead of on the computer +where the patch was created. \'p\' level instructs the \'patch\' utility +to ignore parts of the path name to identify the files correctly. +Usually a p level of 1 will work, so you would use:\ +**\$ patch -p1 < baz.patch** + +Change to the top level directory before running this. If a patch level +of 1 cannot identify the files to patch, then inspect the patch file for +file names. For example:\ +**/home/user/do/not/panic/yet.c** + +and you are working in a directory that contains panic/yet.c, use:\ +**\$ patch -p5 < baz.patch** + +You usually count one up for each path separator (forward slash) removed +from the beginning of the path, until you are left with a path that +exists in the current working directory. The count is the p level. + +Removing a patch using the -R flag\ +**\$ patch -p5 -R < baz.patch** + +[Back to top of page.](#pagetop) + +</div> + +<div class="section"> + +Create a patch with diff +======================== + +Diff can create a patch for a single file:\ +**\$ diff -u original.c new.c > original.patch** + +For diff\'ing a source tree:\ +**\$ cp -R original new** + +Do whatever you want in new/ and then diff it:\ +**\$ diff -rupN original/ new/ > original.patch** + +[Back to top of page.](#pagetop) + +</div> + +<div class="section"> + +git diff +======== + +git is something special. + +Note: this won\'t show new files created. + +Just make whatever changes you want to a git clone and then:\ +**\$ git diff > patch.git** + +Note the git revision that you did this with:\ +**\$ git log** + +Alternatively (better yet), commit your changes and then use:\ +\$ **git format-patch -N**\ +Replace N with the number of commits that you want to show. + +[Back to top of page.](#pagetop) + +</div> + +<div class="section"> + +git apply +========= + +it really is. + +Now to apply that patch in the future, just git clone it again and do +with the git revision you found from above:\ +**\$ git reset \--hard REVISIONNUMBER** + +Now put patch.git in the git clone directory and do:\ +**\$ git apply patch.git** + +If you use a patch from git format-patch, then use **git am patch.git** +instead of **git apply patch.git**. git-am will re-create the commits +aswell, instead of just applying the patch. + +[Back to top of page.](#pagetop) + +</div> + +<div class="section"> + +Copyright © 2014, 2015 Leah Rowe <info@minifree.org>\ +Permission is granted to copy, distribute and/or modify this document +under the terms of the Creative Commons Attribution-ShareAlike 4.0 +International license or any later version published by Creative +Commons; A copy of the license can be found at +[../cc-by-sa-4.0.txt](../cc-by-sa-4.0.txt) + +Updated versions of the license (when available) can be found at +<https://creativecommons.org/licenses/by-sa/4.0/legalcode> + +UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT +POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND +AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND +CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, +OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, +ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE +OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF +WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT +APPLY TO YOU. + +TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU +ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR +OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, +PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES +ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN +IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, +COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT +ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + +The disclaimer of warranties and limitation of liability provided above +shall be interpreted in a manner that, to the extent possible, most +closely approximates an absolute disclaimer and waiver of all liability. + +</div> |