diff --git a/books/beaglebone-cookbook/01basics/basics.rst b/books/beaglebone-cookbook/01basics/basics.rst index d1bc345671159bd6f3c50bd7f3a1f528333d9ca4..5f8c39b84fef154cf40963d9b735d5f6b786b771 100644 --- a/books/beaglebone-cookbook/01basics/basics.rst +++ b/books/beaglebone-cookbook/01basics/basics.rst @@ -69,13 +69,13 @@ The Bone acting like a USB drive and the files you see are located on the Bone. .. _basics_open_vsc: Browse to http://192.168.7.2:3000 from your -host computer (:ref:`basics_05gettingStarted_fig`). If the page is not found, run the following: - -.. code-block:: - - bone$ sudo systemctl start bb-code-server.service - -Wait a minute and try the URL again. +host computer (:ref:`basics_05gettingStarted_fig`). If the page is not found, run the following: + +.. code-block:: shell-session + + bone$ sudo systemctl start bb-code-server.service + +Wait a minute and try the URL again. .. _basics_05gettingStarted_fig: @@ -131,7 +131,7 @@ following the instructions in :ref:`basics_out_of_the_box` to log into the Bone. .. code-block:: bash - bone$ cat /etc/dogtag + bone$ cat /etc/dogtag BeagleBoard.org Debian Bullseye IoT Image 2023-06-03 I'm running the 2023-06-03 version. @@ -287,7 +287,7 @@ Change to the directory that contains your file, make it executable, and then ru .. code-block:: bash bone$ cd ~/examples/BeagleBone/Black/ - bone$ ./seqLEDs.py + bone$ ./seqLEDs.py The *cd* is the change directory command. After you *cd*, @@ -310,9 +310,9 @@ Solution On your host computer, open a browser and go to https://forum.beagleboard.org/tag/latest-images This shows you a list of dates of the most recent Debian images (:ref:`basics_deb1`). -.. todo - Update for 2023-06-03 - +.. todo + Update for 2023-06-03 + .. _basics_deb1: .. figure:: figures/deb1.png diff --git a/books/beaglebone-cookbook/11misc/figures/Makefile b/books/beaglebone-cookbook/11misc/figures/Makefile index bf01a3248aef0988a85054a044f650cd3fa1e386..3edc4473723c45020431ef884a6afe09994d5ca4 100644 --- a/books/beaglebone-cookbook/11misc/figures/Makefile +++ b/books/beaglebone-cookbook/11misc/figures/Makefile @@ -4,16 +4,16 @@ KDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(CURDIR) all: - make -C $(KDIR) M=$(PWD) modules + make -C $(KDIR) M=$(PWD) modules clean: - make -C $(KDIR) M=$(PWD) cleanobj-m += tmp114.o + make -C $(KDIR) M=$(PWD) cleanobj-m += tmp114.o KDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(CURDIR) all: - make -C $(KDIR) M=$(PWD) modules + make -C $(KDIR) M=$(PWD) modules clean: - make -C $(KDIR) M=$(PWD) clean + make -C $(KDIR) M=$(PWD) clean diff --git a/books/beaglebone-cookbook/11misc/figures/kernel.org.drivers.png b/books/beaglebone-cookbook/11misc/figures/kernel.org.drivers.png new file mode 100644 index 0000000000000000000000000000000000000000..c83a5d2463b5eb1899b0ab0793af42f6ff1cc84e Binary files /dev/null and b/books/beaglebone-cookbook/11misc/figures/kernel.org.drivers.png differ diff --git a/books/beaglebone-cookbook/11misc/figures/kernel.org.plain.png b/books/beaglebone-cookbook/11misc/figures/kernel.org.plain.png new file mode 100644 index 0000000000000000000000000000000000000000..68b8ba4efe8de9cccb9bb78a0676bdd4b4e40e3d Binary files /dev/null and b/books/beaglebone-cookbook/11misc/figures/kernel.org.plain.png differ diff --git a/books/beaglebone-cookbook/11misc/figures/kernel.org.png b/books/beaglebone-cookbook/11misc/figures/kernel.org.png new file mode 100644 index 0000000000000000000000000000000000000000..a29bf5a42aabd662770c9d2648700e167556de3d Binary files /dev/null and b/books/beaglebone-cookbook/11misc/figures/kernel.org.png differ diff --git a/books/beaglebone-cookbook/11misc/figures/kernel.org.tmp117.png b/books/beaglebone-cookbook/11misc/figures/kernel.org.tmp117.png new file mode 100644 index 0000000000000000000000000000000000000000..8af8e80ea90cb6622329f36944cda75044d1026a Binary files /dev/null and b/books/beaglebone-cookbook/11misc/figures/kernel.org.tmp117.png differ diff --git a/books/beaglebone-cookbook/11misc/misc.rst b/books/beaglebone-cookbook/11misc/misc.rst index 8e0e5c6431f8335f4d608fe2a732db0b4b7cb486..7b03b8001ac454fd7c310b23ca44f5b7e8b74c2f 100644 --- a/books/beaglebone-cookbook/11misc/misc.rst +++ b/books/beaglebone-cookbook/11misc/misc.rst @@ -13,7 +13,7 @@ BeagleConnect Freedom Here are some notes on how to setup and use the Connect. First get the flasher image from: -https://www.beagleboard.org/distros/beagleplay-home-assistant-webinar-demo-image +https://www.beagleboard.org/distros/beagleplay-home-assistant-webinar-demo-image Flash the eMMC (which also loads the cc1352 with the correct firmware) @@ -165,8 +165,8 @@ First edit `/etc/hosts` and add a couple of lines. host$ sudo nano /etc/hosts -You may use whatever editor you want. I suggest nano since it's easy to figure -out. Add the following to the end of `/etc/hosts` and quit the editor. +You may use whatever editor you want. I suggest ``nano`` since it's easy to figure +out. Add the following to the end of ``/etc/hosts`` and quit the editor. 192.168.7.2 bone @@ -175,7 +175,7 @@ Now you can connect with host$ ssh debian@bone Let's make it so you don't have to enter `debian`. On your host computer, -put the following in `~/.ssh/config` (Note: ~ is a shortcut for your home directory.) +put the following in ``~/.ssh/config`` (Note: ~ is a shortcut for your home directory.) .. code-block:: @@ -218,10 +218,12 @@ By default the image we are running doesn't allow a root login. You can always sudo from debian, but sometimes it's nice to login as root. Here's how to setup root so you can login from your host without a password. -.. code-block:: bash - +.. code-block:: shell-session + host$ ssh bone + bone$ sudo -i + root@bone# nano /etc/ssh/sshd_config Search for the line @@ -240,32 +242,32 @@ and change it to Save the file and quit the editor. Restart ssh so it will reread the file. -.. code-block:: bash +.. code-block:: shell-session root@bone# systemctl restart sshd And assign a password to root. -.. code-block:: bash +.. code-block:: shell-session root@bone# passwd Now open another window on your host computer and enter: -.. code-block:: bash +.. code-block:: shell-session host$ ssh-copy-id root@bone and enter the root password. Test it with: -.. code-block:: bash +.. code-block:: shell-session host$ ssh root@bone You should be connected without a password. Now go back to the Bone and turn off the root password access. -.. code-block:: bash +.. code-block:: shell-session root@bone# nano /etc/ssh/sshd_config @@ -277,7 +279,7 @@ Restore the line: and restart sshd. -.. code-block:: bash +.. code-block:: shell-session root@bone# systemctl restart sshd root@bone# exit @@ -285,6 +287,8 @@ and restart sshd. You should now be able to go back to your host computer and login as root on the bone without a password. +.. code-block:: shell-session + host$ ssh root@bone You have access to your bone without passwords only from you host computer. Try it from another computer and see what happens @@ -309,7 +313,7 @@ it display on the host. #. First ssh to the Beagle using the `-X` flag. -.. code-block:: bash +.. code-block:: shell-session host$ ssh -X debian@10.0.5.10 @@ -348,7 +352,7 @@ https://serverfault.com/questions/362529/how-can-i-sniff-the-traffic-of-remote-m First login to the Beagle and install tcpdump. Use your Beagle's IP address. -.. code-block:: bash +.. code-block:: shell-session host$ ssh 192.168.7.2 bone$ sudo apt update @@ -357,7 +361,7 @@ IP address. Next, create a named pipe and have wireshark read from it. -.. code-block:: bash +.. code-block:: shell-session host$ mkfifo /tmp/remote host$ wireshark -k -i /tmp/remote @@ -365,7 +369,7 @@ Next, create a named pipe and have wireshark read from it. Then, run tcpdump over ssh on your remote machine and redirect the packets to the named pipe: -.. code-block:: bash +.. code-block:: shell-session host$ ssh root@192.168.7.2 "tcpdump -s 0 -U -n -w - -i any not port 22" > /tmp/remote @@ -448,11 +452,40 @@ Googling tmp006 and tmp007 shows that they are Infrared Thermopile Sensors, not Browse over to http://kernel.org to see if there are tmp114 drivers in the newer versions of the kernel. The first line in the table is **mainline**. Click on the **browse** link on the right. + +.. figure:: figures/kernel.org.png + :align: center + :alt: http://kernel.org + + The Linux Kernel Archives, kernel.org + Here you will see the top level of the Linux sourse tree for the *mainline* version of the kernel. + +.. figure:: figures/kernel.org.drivers.png + :align: center + :alt: http://kernel.org drivers + + The Linux Kernel Archives, drivers + Click on **drivers** and then **iio**. Finally, since tmp114 is a temperture sensor, click on **temperature**. + +.. figure:: figures/kernel.org.tmp117.png + :align: center + :alt: http://kernel.org tmp117 + + The Linux Kernel Archives, tmp117 driver + Here you see all the source code for the iio temperature drivers for the mainline version of the kernel. We've seen tmp006 and tmp007 as before, tmp117 is new. Maybe it will work. Click on **tmp117.c** to see the code. -Looks like it also works for the tmp116 too. Let's try convering it to work with the tmp114. +Looks like it also works for the tmp116 too. + +.. figure:: figures/kernel.org.plain.png + :align: center + :alt: http://kernel.org plain + + The Linux Kernel Archives, plain button + +Let's try convering it to work with the tmp114. A quick way to copy the code to the bone is to right-click on the **plain** link and select *Copy link address*. Then, on the bone enter **wget** and paste the link. Mine looks like the following, yours will be similar. @@ -596,7 +629,7 @@ Creating a new device Once you've converted the module for the tmp114 and inserted it, you can now create a new device. -.. code-block:: bash +.. code-block:: shell-session bone$ cd /sys/class/i2c-adapter/i2c-3 bone$ sudo chgrp gpio * @@ -620,13 +653,13 @@ You only need to do this once. Now make a new device. -.. code-block:: bash +.. code-block:: shell-session bone$ echo tmp114 0x4d > new_device Look in the demsg window and you should see: -.. code-block:: bash +.. code-block:: shell-session [Jun22 19:24] tmp114 3-004d: tmp114_identify id (0x1114) [ +0.000027] tmp114 3-004d: tmp114_probe id (0x1114) @@ -634,7 +667,7 @@ Look in the demsg window and you should see: It's been found! Let's see what it knows about it. -.. code-block:: bash +.. code-block:: shell-session bone$ iio_info Library version: 0.24 (git tag: v0.24) @@ -652,7 +685,7 @@ two values (**raw** and **scale**) that were read from it. Let's read them ours Do an *ls* and you'll see a new directory, **3-004d**. This is address 0x4d on bus 3, just what we wanted. -.. code-block:: bash +.. code-block:: shell bone$ cd 3-004d/iio:device1 bone$ ls @@ -664,14 +697,14 @@ You'll have to look in the datasheet to learn how to convert the temperature. If you try to run i2cget again, you'll get an error: -.. code-block:: bash +.. code-block:: shell bone$ i2cget -y 3 0x4d 0 w Error: Could not set address to 0x4d: Device or resource busy This is because the module is using it. Delete the device and you'll have access again. -.. code-block:: bash +.. code-block:: shell bone$ echo 0x4d > /sys/class/i2c-adapter/i2c-3/delete_device bone$ i2cget -y 3 0x4d 0 w @@ -699,69 +732,42 @@ Here's what you need to do to fork the repository and render a local copy of the documentation. Browse to https://docs.beagleboard.org/latest/ and click on the **Edit on GitLab** button on the upper-right of the page. Clone the repository. -.. code-block:: bash +.. code-block:: shell bash$ git clone git@git.beagleboard.org:docs/docs.beagleboard.io.git bash$ cd docs.beagleboard.io + Then run the following to load the **code** submodule -.. code-block:: bash +.. code-block:: shell bash$ git submodule update --init -Now, sync changes with upstream: - -.. code-block:: bash - - bone$ git remote add upstream https://git.beagleboard.org/docs/docs.beagleboard.io.git - bone$ git fetch upstream - bone$ git pull upstream main - -Using Docker (Podman) -^^^^^^^^^^^^^^^^^^^^^ -It is probably easies to use docker (or podman) if you are already familiar with container workflow. -The repository contains a helper script `docker-build-env.sh` which creates ephemeral container and drops you into bash inside. The project is mouted at `/build/docs.beagleboard.org`. - - -.. note:: - - This section of docs assume that you are using rootless docker or podman. In case of rootful docker, you might run into permission issues +Set up the environment for Sphinx. -.. code-block:: bash +.. code-block:: shell - ./docker-build-env.sh - cd /build/docs.beagleboard.org - make clean + bash$ python -m venv .venv + bash$ source .venv/bin/activate + bash$ pip install -r ./requirements.txt + bash$ make livehtml -To generate HTML output of docs: +This starts a local web server that you can point your browser to to see the formatted text. -.. code-block:: bash - make html - -To generate PDF output of docs: - -.. code-block:: bash - - make latexpdf - -To preview docs on your local machine: +Now, sync changes with upstream: .. code-block:: bash - python3 -m http.server -d _build/html/ - + bone$ git remote add upstream https://git.beagleboard.org/docs/docs.beagleboard.io.git + bone$ git fetch upstream + bone$ git pull upstream main Downloading Sphinx ^^^^^^^^^^^^^^^^^^ -Skip this section if you are using docker as shown above. - -Run the following to download and setup Sphinx locally. - -.. note:: - - This will take a while, it loads some 6G bytes. +Run the following to download Sphinx. Note: This will take a while, it loads +some 6G bytes. .. code-block:: bash @@ -769,21 +775,22 @@ Run the following to download and setup Sphinx locally. bone$ sudo apt upgrade bone$ sudo apt install -y \ make git wget \ - doxygen librsvg2-bin\ + doxygen graphviz librsvg2-bin\ texlive-latex-base texlive-latex-extra latexmk texlive-fonts-recommended \ python3 python3-pip \ + python3-sphinx python3-sphinx-rtd-theme python3-sphinxcontrib.svg2pdfconverter \ + python3-pil \ imagemagick-6.q16 librsvg2-bin webp \ texlive-full texlive-latex-extra texlive-fonts-extra \ fonts-freefont-otf fonts-dejavu fonts-dejavu-extra fonts-freefont-ttf - -In case of any problems, checkout `Beagleboard Forum <https://forum.beagleboard.org/>`_. - -Setup virtual environment for python using the `venv-build-env.sh` script at the project root. - -.. literalinclude:: ../../../venv-build-env.sh - :language: bash - :caption: Bash script for setting up virtual environment - :linenos: + bone$ python3 -m pip install --upgrade pip + bone$ pip install -U sphinx_design + bone$ pip install -U sphinxcontrib-images + bone$ pip install -U sphinx-serve + +These instructions came from `lorforlinux +<https://beagleboard.slack.com/archives/C8S7EKZC2/p1684940872699269>`_ +on the Beagleboard Slack channel. Now go to the cloned *docs.beagleboard.io* repository folder and do the following. To clean build directory: @@ -811,12 +818,6 @@ To preview docs on your local machine: bone$ sphinx-serve -For hot reload in development: - -.. code-block:: bash - - bone$ make livehtml - Then point your browser to localhost:8081. .. tip:: diff --git a/intro/beagle101/blinkLED.rst b/intro/beagle101/blinkLED.rst index eb0f0b9798d23b725755bba17e081d863cf808b0..8b2d521e79c0553a5d98c1255eaca5f01441d70a 100644 --- a/intro/beagle101/blinkLED.rst +++ b/intro/beagle101/blinkLED.rst @@ -442,20 +442,20 @@ the USR button and you'll see: The following script uses evtest to wait for the USR button to be pressed and then turns on the LED. -.. literalinclude:: buttonEvent.sh +.. literalinclude:: code/buttonEvent.sh :language: Shell :caption: buttonEvent.sh :linenos: -:download:`buttonEvent.sh<buttonEvent.sh>` +:download:`code/buttonEvent.sh<code/buttonEvent.sh>` Try running it and pressing the USR button. The next script polls the USR button and toggles the LED. -.. literalinclude:: buttonLED.sh +.. literalinclude:: code/buttonLED.sh :language: shell :caption: buttonLED.sh :linenos: -:download:`buttonLED.sh<buttonLED.sh>` +:download:`code/buttonLED.sh<code/buttonLED.sh>` diff --git a/intro/beagle101/code/blinkInternalLED.sh b/intro/beagle101/code/blinkInternalLED.sh new file mode 100755 index 0000000000000000000000000000000000000000..485c563dcfa09bcd71245b4379f7af79c715a231 --- /dev/null +++ b/intro/beagle101/code/blinkInternalLED.sh @@ -0,0 +1,10 @@ +LED="3" + +LEDPATH='/sys/class/leds/beaglebone:green:usr' + +while true ; do + echo "1" > ${LEDPATH}${LED}/brightness + sleep 0.5 + echo "0" > ${LEDPATH}${LED}/brightness + sleep 0.5 +done diff --git a/intro/beagle101/buttonEvent.sh b/intro/beagle101/code/buttonEvent.sh similarity index 100% rename from intro/beagle101/buttonEvent.sh rename to intro/beagle101/code/buttonEvent.sh diff --git a/intro/beagle101/buttonLED.sh b/intro/beagle101/code/buttonLED.sh similarity index 100% rename from intro/beagle101/buttonLED.sh rename to intro/beagle101/code/buttonLED.sh diff --git a/intro/beagle101/code/seqLEDs.py b/intro/beagle101/code/seqLEDs.py new file mode 100755 index 0000000000000000000000000000000000000000..40f684a9b050206e48e6a8951637dbafcce9a820 --- /dev/null +++ b/intro/beagle101/code/seqLEDs.py @@ -0,0 +1,21 @@ +import time +import os + +LEDs=4 +LEDPATH='/sys/class/leds/beaglebone:green:usr' + +Open a file for each LED +f = [] +for i in range(LEDs): + f.append(open(LEDPATH+str(i)+"/brightness", "w")) + +Sequence +while True: + for i in range(LEDs): + f[i].seek(0) + f[i].write("1") # 1 turns the LED on + time.sleep(0.25) + for i in range(LEDs): + f[i].seek(0) + f[i].write("0") # 0 turns the LED off + time.sleep(0.25)