Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "ECE497 Notes on systemd"

From eLinux.org
Jump to: navigation, search
m (Gadgets)
m (Added Brian's response)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:ECE497]]
+
[[Category:ECE497Notes |sys]]
  
 
{{YoderHead}}
 
{{YoderHead}}
Line 9: Line 9:
  
 
[http://crashmag.net/useful-systemd-commands Here] is a nice list of useful commands.
 
[http://crashmag.net/useful-systemd-commands Here] is a nice list of useful commands.
 +
 +
[http://0pointer.de/blog/projects/socket-activated-containers.html systemd for Admins]
  
 
[http://www.freedesktop.org/wiki/Software/systemd/TipsAndTricks Tips and Tricks]
 
[http://www.freedesktop.org/wiki/Software/systemd/TipsAndTricks Tips and Tricks]
 +
 +
=== Changing the Bone's USB IP address ===
 +
 +
I think I've found an answer.  The BBB uses systemd to get the user space processes going at boot time. Look in '''/lib/systemd/system''' it see the various services that can be started.  The one of interest is '''/lib/systemd/system/udhcpd.service'''. This starts the dhcp server that assigns the IP address to the host.  Looking inside you see
 +
[Unit]
 +
Description=DHCP server for USB0 network gadget
 +
After=dev-usb0.device
 +
Conflicts=storage-gadget-init.service
 +
 +
[Service]
 +
ExecStart=/usr/sbin/udhcpd -f -S /etc/udhcpd.conf
 +
ExecStop=/bin/kill -TERM $MAINPID
 +
KillSignal=SIGINT
 +
 +
[Install]
 +
WantedBy=gether.target
 +
 +
It looks like '''/etc/udhcpd.conf''' is what configures the server.  In it we find:
 +
start      192.168.7.1
 +
end        192.168.7.1
 +
interface  usb0
 +
max_leases 1
 +
option subnet 255.255.255.252
 +
 +
On your second bone try editing this file to use a different range of addresses. That will assign your host a different number.  To give your beagle a different number, look near the bottom of '''/usr/bin/g-ether-load.sh'''.  I think that's where your BBB is assigned a number.
 +
 +
I haven't tested this.  Let me know if it works.
 +
 +
Mark,
 +
I followed your suggestion and, eventually, was able to get 2 BBB connected and working on a single PC. In addition to /etc/udhcpd.conf, I needed to edit  /usr/bin/g-ether-load.sh and /etc/udev/rules.d/udhcpd.rules However, I need more automated way to accomplish this task, since we can't expect our end users to log into our product and change the settings...
 +
 +
Thanks for your help.
 +
 +
Brian
  
 
=== Gadgets ===
 
=== Gadgets ===
Line 24: Line 60:
 
is what creates the info.txt file.
 
is what creates the info.txt file.
  
  beagle$ mount /dev/mmcblk0p1 /mnt
+
  beagle$ '''mount /dev/mmcblk0p1 /mnt'''
 +
 
 +
Here's a way to see what gadgets are out there
 +
 
 +
beagle$ '''systemctl --all | grep gadget'''
 +
sys-devi...et-usb0.device loaded active  plugged      /sys/devices/platform/omap/musb-ti81xx/musb-hdrc.0/gadget/net/usb0
 +
network-...t-init.service loaded active  exited        Start USB Ethernet gadget
 +
storage-...t-init.service loaded inactive dead          Start usb mass storage gadget
 +
udhcpd.service            loaded active  running      DHCP server for USB0 network gadget
 +
 
 +
or
 +
 
 +
systemctl --all '''--full''' | grep gadget
 +
sys-devices-platform-omap-musb\x2dti81xx-musb\x2dhdrc.0-gadget-net-usb0.device                loaded active  plugged        /sys/devices/platform/omap/musb-ti81xx/musb-hdrc.0/gadget/net/usb0
 +
network-gadget-init.service                                                                  loaded active  exited        Start USB Ethernet gadget
 +
storage-gadget-init.service                                                                  loaded inactive dead          Start usb mass storage gadget
 +
udhcpd.service                                                                                loaded active  running        DHCP server for USB0 network gadget
 +
 
 +
Where
 +
'''network-...t-init.service''' = '''network-gadget-init.service'''
 +
'''storage-...t-init.service''' = '''storage-gadget-init.service'''
 +
 
 +
'''/etc/udhcpd.conf''' is what assigned 192.168.7.1 to the host computer.
 +
 
 +
To stop the ethernet over USB and start the storage over USB for the current session
 +
 
 +
beagle$ '''/bin/systemctl stop  storage-gadget-init.service'''
 +
beagle$ '''/bin/systemctl start network-gadget-init.service'''
 +
 
 +
To go the other way:
 +
 
 +
beagle$ '''g-ether-start-service.sh'''
 +
 
 +
To keep the storage gadget from running on boot up. (I'm still checking this.)
 +
 
 +
beagle$ '''systemctl disable storage-gadget-init.service'''
  
 
{{YoderFoot}}
 
{{YoderFoot}}

Latest revision as of 21:57, 7 November 2013

thumb‎ Embedded Linux Class by Mark A. Yoder


The new BeagleImages use systemd for user space initialization.

Here, here and here are some tutorials that look good.

Here is information on runlevels.

Here is a nice list of useful commands.

systemd for Admins

Tips and Tricks

Changing the Bone's USB IP address

I think I've found an answer. The BBB uses systemd to get the user space processes going at boot time. Look in /lib/systemd/system it see the various services that can be started. The one of interest is /lib/systemd/system/udhcpd.service. This starts the dhcp server that assigns the IP address to the host. Looking inside you see

[Unit]
Description=DHCP server for USB0 network gadget
After=dev-usb0.device
Conflicts=storage-gadget-init.service

[Service]
ExecStart=/usr/sbin/udhcpd -f -S /etc/udhcpd.conf
ExecStop=/bin/kill -TERM $MAINPID
KillSignal=SIGINT

[Install]
WantedBy=gether.target

It looks like /etc/udhcpd.conf is what configures the server. In it we find:

start      192.168.7.1
end        192.168.7.1
interface  usb0
max_leases 1
option subnet 255.255.255.252

On your second bone try editing this file to use a different range of addresses. That will assign your host a different number. To give your beagle a different number, look near the bottom of /usr/bin/g-ether-load.sh. I think that's where your BBB is assigned a number.

I haven't tested this. Let me know if it works.

Mark, I followed your suggestion and, eventually, was able to get 2 BBB connected and working on a single PC. In addition to /etc/udhcpd.conf, I needed to edit /usr/bin/g-ether-load.sh and /etc/udev/rules.d/udhcpd.rules However, I need more automated way to accomplish this task, since we can't expect our end users to log into our product and change the settings...

Thanks for your help.

Brian

Gadgets

I found these gadgets

network-gadget-init.service  storage-gadget-init.service

in

/lib/systemd/system
/usr/bin/update-image-info-on-mmcblk0p1.sh

is what creates the info.txt file.

beagle$ mount /dev/mmcblk0p1 /mnt

Here's a way to see what gadgets are out there

beagle$ systemctl --all | grep gadget
sys-devi...et-usb0.device loaded active   plugged       /sys/devices/platform/omap/musb-ti81xx/musb-hdrc.0/gadget/net/usb0
network-...t-init.service loaded active   exited        Start USB Ethernet gadget
storage-...t-init.service loaded inactive dead          Start usb mass storage gadget
udhcpd.service            loaded active   running       DHCP server for USB0 network gadget

or

systemctl --all --full | grep gadget
sys-devices-platform-omap-musb\x2dti81xx-musb\x2dhdrc.0-gadget-net-usb0.device                loaded active   plugged        /sys/devices/platform/omap/musb-ti81xx/musb-hdrc.0/gadget/net/usb0
network-gadget-init.service                                                                   loaded active   exited         Start USB Ethernet gadget
storage-gadget-init.service                                                                   loaded inactive dead           Start usb mass storage gadget
udhcpd.service                                                                                loaded active   running        DHCP server for USB0 network gadget

Where

network-...t-init.service = network-gadget-init.service
storage-...t-init.service = storage-gadget-init.service

/etc/udhcpd.conf is what assigned 192.168.7.1 to the host computer.

To stop the ethernet over USB and start the storage over USB for the current session

beagle$ /bin/systemctl stop  storage-gadget-init.service
beagle$ /bin/systemctl start network-gadget-init.service

To go the other way:

beagle$ g-ether-start-service.sh

To keep the storage gadget from running on boot up. (I'm still checking this.)

beagle$ systemctl disable storage-gadget-init.service




thumb‎ Embedded Linux Class by Mark A. Yoder