3

I'm working on setting up the pinmux on a BeagleBone so that I can access multiple UARTS. The OS is Angstrom Linux (the demo image, if that helps). I have a shell script:

#!/bin/sh

echo "Configuring Pinmux"

echo 0 > /sys/kernel/debug/omap_mux/uart1_txd
echo 20> /sys/kernel/debug/omap_mux/uart1_rxd

echo "UART 1 (TX):"
cat /sys/kernel/debug/omap_mux/uart1_txd
echo

echo "UART 1 (RX):"
cat /sys/kernel/debug/omap_mux/uart1_rxd
echo

echo 1 > /sys/kernel/debug/omap_mux/spi0_d0
echo 21> /sys/kernel/debug/omap_mux/spi0_sclk

echo "UART 2 (TX):"
cat /sys/kernel/debug/omap_mux/spi0_d0
echo

echo "UART 2 (RX):"
cat /sys/kernel/debug/omap_mux/spi0_sclk
echo

Which sets up the UARTS for use. Now, I want this script to run on boot, so that I don't have to mess with it every time. Where should I put this/ make a link in order to do that?

2

Just checked Angstrom Linux, it's Debian based, so copy these lines to /etc/rc.local would work for you:

echo 0 > /sys/kernel/debug/omap_mux/uart1_txd
echo 20> /sys/kernel/debug/omap_mux/uart1_rxd
echo 1 > /sys/kernel/debug/omap_mux/spi0_d0
echo 21> /sys/kernel/debug/omap_mux/spi0_sclk
2

So, after much digging, I found the correct way to do this. Angstrom uses systemd to launch things on boot, so putting things in /etc/rc*n*.d doesn't work correctly. Instead, you make a service, tell systemd about it, and then it works automagically.

In /lib/systemd/system, I created a file called pinmux.service:

[Unit]
Description=Setting up Pinmux

[Service]
ExecStart = /home/**username**/pinmux.sh

[Install]
WantedBy=multi-user.target

This calls the shell script in my home directory called pinmux.sh, which does all the setting, as noted in my question.

To enable it, call systemctl enable pinmux.service, followed by systemctl start pinmux.service.

Now, the script will be called on boot.

  • 1
    I wonder if there is a way to "systemctl start" within the image creation. Apart from the dirty way of creating a link in /etc/systemd/system – Jaap Versteegh May 7 '13 at 17:19
1

As a newbie, I know two ways to do that, easy one comes: in /etc/rc5.d you can see some files whose names starting with some numbers which assigns who is going to start first, and they are started from the first number to last number respectively. Put your script here with the last number:

vi /etc/rc5.d/S25yourScript.sh

I assume S25 the last number :) paste your script here and exit. When you reboot once your script will work

  • 1
    Don't use a file in /etc/rc*.d, use a link instead, put the real file to /etc/init.d – daisy Sep 28 '12 at 9:51
  • yes thats true, im sorry. You should put the same script to /etc/init.d also. Without it, its not working. Thank you Warl0ck – Ibrahim Arli Sep 28 '12 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.