by nwestfal » Sat Sep 06, 2014 7:25 pm
I was able to solve this, even without having a serial cable.
First, having successfully flashed the new uboot, but of course still unsuccessful flash of the uboot environment at 0xc0000, I decided to go ahead and try rebooting. Unfortunately the /boot/uEnv.txt didn't help, as it didn't pick up the ethaddr from it. So that's a no go as an alternative. But I did note that I had activity on the external usb hard drive, and the light on the front of the E02 turned green after awhile, so I surmised that Arch was at least booting up.
Since I didn't have a serial cable to see what was happening during the boot process, I decided to plug the usb drive into my OpenSUSE desktop to mount the alarm parition and take a look at the journal. Assuming your Arch partition is mounted on /mnt/alarm, You can view the journal from the Arch installation on the USB drive with the following command:
$this->bbcode_second_pass_code('', '
journalctl -D /mnt/alarm/var/log/journal --no-pager
')
I saw the following lines:
$this->bbcode_second_pass_code('', '
Jul 03 18:46:23 alarm systemd-networkd[119]: lo : gained carrier
Jul 03 18:46:23 alarm systemd-networkd[119]: eth0 : link configured
Jul 03 18:46:23 alarm systemd[1]: Started Network Service.
Jul 03 18:46:23 alarm systemd-networkd[119]: eth0 : could not bring up interface: Cannot assign requested address
')
At this point it is pretty clear that Arch is booting fine. I am providing addtional troubleshooting steps I used below. For anyone having this problem, the ultimate solution was a pretty simple fix, which you can skip down to if you want.
I decided to do a little more troubleshooting. I wanted to see the output of ifconfig and dmesg, so I enabled an rc.local script:
Create file /usr/lib/systemd/system/rc-local.service with the following contents:
$this->bbcode_second_pass_code('', '
[Unit]
Description=/etc/rc.local compatibility
[Service]
Type=oneshot
ExecStart=/etc/rc.local
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
')
Then to enable the service you have to create a symlink:
$this->bbcode_second_pass_code('', '
cd /mnt/alarm/etc/systemd/system/multi-user.target.wants/
ln -s /usr/lib/systemd/system/rc-local.service rc-local.service
')
This enables use of an /etc/rc.local file to execute any commands we want to. There is probably a better alternative that is more systemd compliant, but it gets the job done.
Then I created /etc/rc.local with the following contents:
$this->bbcode_second_pass_code('', '
#!/usr/bin/bash
/root/info.sh > /root/info.txt
')
This just runs a script in root's home directory and redirects output to a text file so that I could view the file later mounted in the desktop machine again.
The contents of /root/info.sh were:
$this->bbcode_second_pass_code('', '
ifconfig -a
echo "========"
dmesg
echo "========"
journalctl --no-pager
')
Dont forget to grant execute permission on both /etc/rc.local and /root/info.sh
You can put whatever other troubleshooting commands you want to in there as well. I was mainly interested in the output of ifconfig. So with all that in place, I plugged the drive back into the E02 and powered it on, let it boot up and waited for the light on the E02 to turn green. After waiting a sufficient amount of time, I powered it off again and mounted the drive on the desktop machine again. I checked the contents of /root/info.txt and saw from the ifconfig output that the MAC address was all zeroes:
$this->bbcode_second_pass_code('', '
eth0: flags=4098<BROADCAST,MULTICAST> mtu 1500
inet6 fe80::24b:5bfc:8a9e:b148 prefixlen 64 scopeid 0x20<link>
ether 00:00:00:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 11
')
And this of course was preventing the eth0 interface from being configured properly.
Here is the ultimate fix. We need to assign a MAC address to the eth0 interface before the networking comes up. This can be done by editing /usr/lib/systemd/system/systemd-networkd.service and adding the following line to the [Service] section:
$this->bbcode_second_pass_code('', '
ExecStartPre=/sbin/ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
')
The command "/sbin/ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx" sets the hardware address of the eth0 interface.
(the actual address to use can be found on the label affixed to the bottom of the E02)
So my systemd-networkd.service looks like this:
$this->bbcode_second_pass_code('', '
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Network Service
Documentation=man:systemd-networkd.service(8)
ConditionCapability=CAP_NET_ADMIN
DefaultDependencies=no
After=dbus.service network-pre.target systemd-sysusers.service
Before=network.target multi-user.target shutdown.target
Conflicts=shutdown.target
Wants=network.target
[Service]
Type=notify
Restart=always
RestartSec=0
ExecStartPre=/sbin/ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
ExecStart=/usr/lib/systemd/systemd-networkd
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_CHOWN CAP_DAC_OVERRIDE C
AP_FOWNER
ProtectSystem=full
ProtectHome=yes
WatchdogSec=1min
[Install]
WantedBy=multi-user.target
')
After making the above change, I plugged the drive back into the E02, powered it on and low and behold, it shows up in my router with the correct MAC address and I can ping it and ssh into it!
An alternative to using "/sbin/ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx" is to use the macchanger utility, but since that is not installed by default, that's a bit more difficult to do since you would have to install the files from the package manually. That was going to to be my next attempt if the above didn't work, but happily the ifconfig workaround worked just fine.
A possible gotcha could be if a system update ever overwrites the file /usr/lib/systemd/system/systemd-networkd.service. A solution to this could be to just replace the symlink under /etc/systemd/system/multi-user.target.wants/ with the actual systemd-networkd.service file.
UPDATE: I did a system update with "pacman -Syu", which installed a new version of systemd, and it did indeed clobber my modifed /usr/lib/systemd/system/systemd-networkd.service. I've been experimenting with trying to set up a separate systemd service to run the command, so far unsuccessful. For now I just replaced the symlink with a copy of the systemd-networkd.service file.
UPDATE - 9/9/2014 - I discovered that instead of modifying the file systemd-networkd.service, another (arguably better) way to fix the MAC address is with the use of a .link file placed under /etc/systemd/network/.
I created a file /etc/systemd/network/98-fix-no-hw-address.link which contains:
$this->bbcode_second_pass_code('', '
[Match]
MACAddress=00:00:00:00:00:00
[Link]
MACAddress=00:xx:xx:xx:xx:xx
')
This means any interface that comes up with hardware address 00:00:00:00:00:00 will have it's hardware address set to 00:xx:xx:xx:xx:xx. The file name is prefixed with "98" in order to supercede the default link file in /usr/lib/systemd/network/99-default.link.
Last edited by
nwestfal on Wed Sep 10, 2014 12:36 am, edited 1 time in total.
-Neal