you can not modify the initrd, nor can you modify the readonly rootfs or the readonly kernel, this is by (security-)design
the method i described above is the only way to do it without making any incompatible changes to the system …
Edit: indeed you can patch the drivers themselves in the kernel tree to look at certain writable places (like /run) that you then fill from a daemon snap … (or patch them to read a kernel cmdline option)
now if you create a /run/ethaddr0 (from a snap for example) the mac address should be read from there … (if the smsc75xx driver supports that behaviour indeed)
after booting from sdcard or even after reboot after first boot, it does not creates this file /run/ethaddr0.
i guess in case of wifi, snapcraft core is creating /run/macaddr0 file and writing content to it
ln -s /run/macaddr0 $SNAPCRAFT_PART_INSTALL/firmware/wlan/
i am able to create a snap and install in --devmode and /run/ethmacaddr0 got created.
in the uboot.env.in i had added this args=androidboot.serialno=f2103d96 ethmacaddr=58fcdb4020fe
so it will have persistent storage. I can change the ethmacaddr for each boards in uboot or using fw_setenv
But it creates only when i run that snap. is it possible to run that snap by default before ethernet(smsc75xx) driver gets loaded.
is it possible to build the custom core-build ? so that i can modify the dragonmac and add a new ethmacaddr script also
ethmacaddr
#!/bin/sh -e
initramfs local-premount script to set a
mac address on the dragonboard
PREREQ=""
Output pre-requisites
prereqs()
{
echo “$PREREQ”
}
case “$1” in
prereqs)
prereqs
exit 0
;;
esac
if [ -e /proc/device-tree/model ]; then
if grep -q “APQ 8016” /proc/device-tree/model; then
if grep -q ethmacaddr /proc/cmdline; then
for i in $(cat /proc/cmdline); do
case “$i” in
ethmacaddr=*)
echo “${i#ethmacaddr=}”|
sed ‘s/.{2}/&:/g;s/.$//’ >/run/ethmacaddr0
;;
esac
done
fi
fi
fi
for a second interface just add an additional line to the config file… after configuring it once the devices should come up with the new MAC addresses on each boot …
mac spoofing does not work always, i tried multiple reboots, it does not sets the mac addresses assigned in /var/snap/mac-spoofer/current/config . it picks the random mac addresses for interafces.
While you could do that for development, a custom core is not upgradeable, the same goes for the kernel snap if you change the initrd … i’d suggest to rather find out why exactly the mac spoofer snap does not work (does it run to early ? try adding some sleep to the script for a test) and fix that …
as i said above, this is a workaound for a bug in the driver introduced by the 96board guys. if the driver gets fixed to actually use ROM code as it should, the link in /run as well as the script in initrd will be removed. This is nothing permanent, normally MAC addresses are set form the hardware.
did you look at that “daemon” ? it is a script that only executes 3 lines of ip/ifconfig commands per device, nothing more … (and technically the poper way to do this if your network devices actually operate according to the spec)
In the old world (when using ifupdown) you would have used /etc/network/interfaces and added something like:
hwaddress ether 00:01:04:1b:2C:1F
to that file to set a mac address from software, but Ubuntu Core uses netplan instead of ifupdown which does not support this feature yet, so the call to “ip link set <device> address <addr>” is the proper fallback way until netplan grows such a feature. the initrd hack will go away as soon as the driver is fixed by upstream to read from the ROM or to use the devicetree for the address.
"this is a workaound for a bug in the driver introduced by the 96board guys. if the driver gets fixed to actually use ROM code "
this is not going to get fixed. dragonboard is already manufactured without any EEPROM on board. so the mac address has to be stored in emmc only.
the initrd hack will go away as soon as the driver is fixed by upstream to read from the ROM or to use the devicetree for the address.
since there is no ROM, i guess you are talking about storing the MAC addresses in devicetree(apq8016-sbc-snappy.dtsi)
In this case if there are 100 boards, each boards should be flashed with different .img by building different kernel snaps with modification in the .dtsi file.
Not really … it will likely just feed the devicetree from the lk during boot (by using the board serial), similar to to the pending patch used for setting the BT address at:
As you had mentioned earlier this post fix for bt mac address, similar for wlan also.
This is a temporary solution to ensure that each board gets a unique MAC address, provided by the bootloader. there is on going work to get rid of this hack and store MAc addresses in a persistent area on the eMMC
i just had an IRC discussion with the 96boards maintainer that cares for the dragonboard:
<ogra_> ndec, do you plan do do a similar fix as https://git.linaro.org/landing-teams/working/qualcomm/lk.git/commit/?h=release/LA.BR.1.2.7-03810-8x16.0&id=372982a4d4c4922e9214ff7d6aa5348aaba602a7 for the wlan address at some point (i'd really like t get rid of the initrd hack to feed /run/macaddr0 at some point)
<ndec> ogra_: hi! it's done for wlan already. it was done before the bt stuff actually.
<ndec> this commit is before the one you linked: https://git.linaro.org/landing-teams/working/qualcomm/lk.git/commit/?h=release/LA.BR.1.2.7-03810-8x16.0&id=d27b915da64b5e3bc2f672cc8757ce523bf1b89c
<ndec> and the driver already has support, https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/wireless/ath/wcn36xx/main.c#n1279
<ndec> ogra_: btw, these days, we are trying to define a 'provision' file that would contain the 'real' MAC addresses for wlan and bt.
<ndec> the provisioning would/could be done in production (or re-done by end users)
<ndec> no, the bootloader will read that 'provision info' and populate the DTB at run time
<ogra_> with no fallback to serial at all ?
<ndec> yes, with a fallback.
<ogra_> ah
<ndec> the thing is that the boards are being provisioned with real MAC address (Arrow bought them). and right now they are not being used
<ndec> QCOM already has a 'solution' for this problem in their Windows 10 image. we are trying to reuse their provisioning file format.
<ogra_> so what would happen if i dropped the /run/macaddr0 hack right now (assuming i have the lk and kernel patches indeed)
<ndec> ogra_: nothing would happen, it would just work ;-)
so in that light, expect the script in the initrd to go away soon … (but you should be able to use the mentioned “provision” file at some point, until then i’d still recommend using something like the mac-spoofer snap)