mirror of https://github.com/aredn/aredn.git
hardware: add aredn definition for mikrotik 912uag-5hpnd
Mikrotik RouterBOARD 912UAG-5HPnD or BaseBox 5 definition
This commit is contained in:
parent
d66a7e8842
commit
8cbc9a1435
12
Makefile
12
Makefile
|
@ -5,6 +5,9 @@ include openwrt.mk
|
|||
MAINTARGET=$(word 1, $(subst -, ,$(TARGET)))
|
||||
SUBTARGET=$(word 2, $(subst -, ,$(TARGET)))
|
||||
|
||||
# export for test script use
|
||||
export AREDNSUBTARGET=$(SUBTARGET)
|
||||
|
||||
GIT_BRANCH=$(shell git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
|
||||
GIT_COMMIT=$(shell git rev-parse --short HEAD)
|
||||
|
||||
|
@ -125,7 +128,7 @@ else
|
|||
endif
|
||||
|
||||
# openwrt config
|
||||
$(OPENWRT_DIR)/.config: .stamp-feeds-updated $(TARGET_CONFIG) .stamp-build_rev
|
||||
$(OPENWRT_DIR)/.config: .stamp-feeds-updated $(TARGET_CONFIG) .stamp-build_rev always
|
||||
cat $(TARGET_CONFIG) >$(OPENWRT_DIR)/.config
|
||||
echo "CONFIG_VERSION_NUMBER=\"$(FW_VERSION)\"" >>$(OPENWRT_DIR)/.config
|
||||
echo "$(FW_VERSION)" >$(TOP_DIR)/files/etc/mesh-release
|
||||
|
@ -144,7 +147,8 @@ compile: stamp-clean-compiled .stamp-compiled
|
|||
$(TOP_DIR)/scripts/tests-prebuild.sh
|
||||
$(UMASK); \
|
||||
$(MAKE) -C $(OPENWRT_DIR) $(MAKE_ARGS)
|
||||
for FILE in `find $(TOP_DIR)/firmware/targets/ -name "*.bin"`; do \
|
||||
for FILE in `find $(TOP_DIR)/firmware/targets/ -name "*factory.bin" -o -name "*sysupgrade.bin" \
|
||||
-o -name "*.manifest" -o -name "*-mikrotik-vmlinux-initramfs.elf"`; do \
|
||||
[ -e "$$FILE" ] || continue; \
|
||||
NEWNAME="$${FILE/openwrt-/AREDN-}"; \
|
||||
NEWNAME="$${NEWNAME/ar71xx-generic-/}"; \
|
||||
|
@ -163,7 +167,7 @@ stamp-clean:
|
|||
rm -f .stamp-*
|
||||
|
||||
# unpatch needs "patches/" in openwrt
|
||||
.stamp-unpatched:
|
||||
.stamp-unpatched:
|
||||
# RC = 2 of quilt --> nothing to be done
|
||||
cd $(OPENWRT_DIR); quilt pop -a -f || [ $$? = 2 ] && true
|
||||
rm -rf $(OPENWRT_DIR)/tmp
|
||||
|
@ -173,6 +177,6 @@ stamp-clean:
|
|||
clean: stamp-clean .stamp-openwrt-cleaned
|
||||
|
||||
|
||||
.PHONY: openwrt-clean openwrt-clean-bin openwrt-update patch feeds-update prepare compile stamp-clean clean
|
||||
.PHONY: openwrt-clean openwrt-clean-bin openwrt-update patch feeds-update prepare compile stamp-clean clean always
|
||||
.NOTPARALLEL:
|
||||
.FORCE:
|
||||
|
|
|
@ -35,7 +35,11 @@ To obtain the source and build the firmware locally use:
|
|||
git clone https://github.com/aredn/aredn_ar71xx.git
|
||||
cd aredn_ar71xx
|
||||
vi config.mk # enter your callsign, etc.
|
||||
make
|
||||
# build default ubnt and tplink images
|
||||
make
|
||||
# copy the firmware image files to save elsewhere, will be cleaned next step
|
||||
# build mikrotik images
|
||||
make SUBTARGET=mikrotik
|
||||
```
|
||||
|
||||
Building the images may take minutes or hours depending on the machine.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
CONFIG_TARGET_ar71xx=y
|
||||
CONFIG_TARGET_ar71xx_mikrotik=y
|
||||
CONFIG_TARGET_SUBTARGET=mikrotik
|
||||
CONFIG_TARGET_ar71xx_mikrotik_DEVICE_nand-large=y
|
||||
CONFIG_PACKAGE_rbcfg=y
|
|
@ -4,7 +4,6 @@
|
|||
START=99
|
||||
boot() {
|
||||
|
||||
# Deal with lan and wifi having same mac address (common on TP-Link)
|
||||
if [ ! -f /etc/aredn_include/ethmacfixup ]
|
||||
then
|
||||
mkdir -p /etc/aredn_include
|
||||
|
@ -13,32 +12,29 @@ boot() {
|
|||
local wifiintf="wlan0"
|
||||
local lanmac=`ifconfig $lanintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'`
|
||||
local wifimac=`ifconfig $wifiintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'`
|
||||
local lanmacdigit=`printf "%X" $(((0x${lanmac:15} + 1) % 256))`
|
||||
local lanmacplusone=${lanmac:0:15}$lanmacdigit
|
||||
|
||||
if [ "$lanmac" = "$wifimac" ]
|
||||
# Deal with lan and wifi having same mac address (common on TP-Link)
|
||||
# Deal with lan mac + 1 = wifi mac address (common on Microtik and
|
||||
# breaks OLSR if using derived IP addresses)
|
||||
if [ "$lanmac" = "$wifimac" -o "$lanmacplusone" = "$wifimac" ]
|
||||
then
|
||||
local wifimacdigit=`echo $wifimac | awk 'BEGIN { FS = ":" } ;{print $4}'`
|
||||
local newmac="00:00:00:00:00:00"
|
||||
if [ "$wifimacdigit" = "FF" ]
|
||||
then
|
||||
newmac=`echo "$wifimac" | awk 'BEGIN { FS = ":" } ;{print $1":"$2":"$3":00:"$5":"$6}'`
|
||||
else
|
||||
local wifimacdigitplusone
|
||||
wifimacdigitplusone=`printf "%02X\n" $((0x$wifimacdigit + 1))`
|
||||
newmac=`echo "$wifimac:$wifimacdigitplusone" | awk 'BEGIN { FS = ":" } ;{print $1":"$2":"$3":"$7":"$5":"$6}'`
|
||||
fi
|
||||
lanintf=${lanintf%%.*}
|
||||
echo "" > /etc/aredn_include/ethmacfixup
|
||||
echo "config interface 'setethmac'" >> /etc/aredn_include/ethmacfixup
|
||||
echo -e "\toption\tifname\t'$lanintf'" >> /etc/aredn_include/ethmacfixup
|
||||
echo -e "\toption\tproto\t'none'" >> /etc/aredn_include/ethmacfixup
|
||||
echo -e "\toption\tmacaddr\t$newmac" >> /etc/aredn_include/ethmacfixup
|
||||
uci set "network.setethmac=interface"
|
||||
uci set "network.setethmac.ifname=$lanintf"
|
||||
uci set "network.setethmac.proto=none"
|
||||
uci set "network.setethmac.macaddr=$newmac"
|
||||
uci commit
|
||||
/etc/init.d/network reload
|
||||
/etc/init.d/network restart
|
||||
local wifimacdigit=`printf "%X" $(((0x${wifimac:9:2} + 1) % 256))`
|
||||
local newmac=${wifimac:0:9}${wifimacdigit}${wifimac:11}
|
||||
lanintf=${lanintf%%.*}
|
||||
echo "" > /etc/aredn_include/ethmacfixup
|
||||
echo "config interface 'setethmac'" >> /etc/aredn_include/ethmacfixup
|
||||
echo -e "\toption\tifname\t'$lanintf'" >> /etc/aredn_include/ethmacfixup
|
||||
echo -e "\toption\tproto\t'none'" >> /etc/aredn_include/ethmacfixup
|
||||
echo -e "\toption\tmacaddr\t$newmac" >> /etc/aredn_include/ethmacfixup
|
||||
uci set "network.setethmac=interface"
|
||||
uci set "network.setethmac.ifname=$lanintf"
|
||||
uci set "network.setethmac.proto=none"
|
||||
uci set "network.setethmac.macaddr=$newmac"
|
||||
uci commit
|
||||
/etc/init.d/network reload
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ case "$BOARD_TYPE" in
|
|||
airrouter)
|
||||
LINK1LED=$(readlink -f '/sys/class/leds/ubnt:green:globe')
|
||||
;;
|
||||
rb-912uag-5hpnd)
|
||||
LINK1LED=$(readlink -f '/sys/class/leds/rb:green:led1')
|
||||
;;
|
||||
*)
|
||||
LINK1LED=$(readlink -f /sys/class/leds/*link1)
|
||||
;;
|
||||
|
|
|
@ -258,12 +258,23 @@ if($fw_install and -f "$tmpdir/firmware")
|
|||
print "</center><br>\n";
|
||||
unless($debug)
|
||||
{
|
||||
if ( $parms{checkbox_keep_settings} )
|
||||
{
|
||||
# drop the page cache to take pressure of tmps for the upgrade process
|
||||
`echo 3 > /proc/sys/vm/drop_caches`;
|
||||
`/usr/local/bin/upgrade_kill_prep`;
|
||||
# drop the page cache to take pressure of tmps for the upgrade process
|
||||
`echo 3 > /proc/sys/vm/drop_caches`;
|
||||
`/usr/local/bin/upgrade_kill_prep`;
|
||||
|
||||
if ( $parms{checkbox_keep_settings} )
|
||||
{
|
||||
print "
|
||||
<center><h2>Firmware will be written in the background.</h2>
|
||||
<h3>If your computer is connected to the LAN of this node you may need to acquire<br>
|
||||
a new IP address and reset any name service caches you may be using.</h3>
|
||||
<h3>The node will reboot twice while the configuration is applied<br>
|
||||
When the node has finished booting you should ensure your computer has<br>
|
||||
received a new IP address and reconnect with<br>
|
||||
<a href='http://$node.local.mesh:8080/'>http://$node.local.mesh:8080/</a><br>
|
||||
(This page will automatically reload in 3 minutes)</h3>
|
||||
</center></body></html>
|
||||
";
|
||||
open (my $SYSUPGRADECONF, "/etc/arednsysupgrade.conf") or die "Failed to open arednsysupgrade.conf";
|
||||
open (my $TMPSYSUPGRADECONF, '>', "/tmp/sysupgradefilelist") or die "Failed to open TMPSYSUPGRADECONF";
|
||||
while (<$SYSUPGRADECONF>){
|
||||
|
@ -284,55 +295,37 @@ if($fw_install and -f "$tmpdir/firmware")
|
|||
<h3>An error occured trying to backup the file system. Node will now reboot.
|
||||
</center>
|
||||
";
|
||||
page_footer();
|
||||
print "</body></html>";
|
||||
nvram_set("nodeupgraded","0");
|
||||
system "/sbin/reboot";
|
||||
exit 1;
|
||||
page_footer();
|
||||
print "</body></html>";
|
||||
nvram_set("nodeupgraded","0");
|
||||
system "/sbin/reboot";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
system("rm -f /tmp/sysupgradefilelist");
|
||||
|
||||
print "
|
||||
<center><h2>Firmware will be written in the background.</h2>
|
||||
<h3>If you are connected to the LAN of this node you may need to acquire a new<br>
|
||||
DHCP lease and reset any name service caches you may be using.</h3>
|
||||
<h3>The node will reboot twice while the configuration is applied<br>
|
||||
When the node has finished booting you can get your new DHCP lease and reconnect with<br>
|
||||
<a href='http://$node.local.mesh:8080/'>http://$node.local.mesh:8080/</a><br>
|
||||
(This page will automatically reload in 3 minutes)</h3>
|
||||
</center></body></html>
|
||||
";
|
||||
|
||||
#open(FILE, "/sbin/sysupgrade -f /tmp/arednsysupgradebackup.tgz -q $tmpdir/firmware 2>&1 |") or die;
|
||||
# Fork this into the background so uhttpd can finish and send the rest of the page to the client
|
||||
`/usr/local/bin/spawn_sysupgrade $tmpdir/firmware 2>&1 &`;
|
||||
`sleep 2 && killall uhttpd &`;
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Writing firmware<br><br>\n";
|
||||
open(FILE, "/sbin/mtd write $tmpdir/firmware firmware 2>&1 |") or die;
|
||||
while(read FILE, $junk, 7) { print "|" }
|
||||
print "
|
||||
<center><h2>The node is rebooting</h2>
|
||||
<h3>If you are connected to the LAN of this node you may need to acquire a new<br>
|
||||
DHCP lease and reset any name service caches you may be using.</h3>
|
||||
<h3> When the node has fully rebooted you can get your new DHCP lease and reconnect with<br>
|
||||
<a href='http://localnode.local.mesh:8080/'>http://localnode.local.mesh:8080/</a><br>
|
||||
<center><h2>Firmware will be written in the background.</h2>
|
||||
<h3>If your computer is connected to the LAN of this node you may need to acquire<br>
|
||||
a new IP address and reset any name service caches you may be using.</h3>
|
||||
<h3>The node will reboot after the firmware has been written to flash memory<br>
|
||||
When the node has finished booting you should ensure your computer has<br>
|
||||
received a new IP address and reconnect with<br>
|
||||
<a href='http://localnode.local.mesh:8080/'>http://192.168.1.1:8080/</a><br>
|
||||
and continue setup of the node in firstboot state.<br>
|
||||
(This page will automatically reload in 3 minutes)</h3>
|
||||
</center>
|
||||
</center></body></html>
|
||||
";
|
||||
page_footer();
|
||||
print "</body></html>";
|
||||
system "/sbin/reboot" unless $debug;
|
||||
exit;
|
||||
`/sbin/sysupgrade -n $tmpdir/firmware 2>&1 &`;
|
||||
}
|
||||
`killall uhttpd &`;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# install patch
|
||||
if($patch_install and -f "$tmpdir/firmware")
|
||||
{
|
||||
|
|
|
@ -1012,6 +1012,15 @@ sub hardware_info
|
|||
'rfband' => '5800ubntus',
|
||||
'chanpower' => { 140 => '17', 184 => '26' },
|
||||
},
|
||||
'Mikrotik RouterBOARD 912UAG-5HPnD' => {
|
||||
'name' => 'Mikrotik RouterBOARD 912UAG-5HPnD',
|
||||
'comment' => 'Mikrotik RouterBOARD 912UAG-5HPnD in Testing',
|
||||
'supported' => '-1',
|
||||
'maxpower' => '30',
|
||||
'pwroffset' => '0',
|
||||
'usechains' => 1,
|
||||
'rfband' => '5800ubntus',
|
||||
},
|
||||
'0xc2a2' => {
|
||||
'name' => 'Bullet 2 HP',
|
||||
'comment' => 'Not enough Ram or flash',
|
||||
|
|
|
@ -36,38 +36,29 @@ LICENSE
|
|||
|
||||
# Variables that may need adjusting as time goes on
|
||||
|
||||
## Values for count of final images
|
||||
### This value should be updated as we add/remove device image types
|
||||
NUMBEROFIMAGESCOUNT=12
|
||||
### Static Files, only when buildroot changes adjust output files types.
|
||||
### These are files such as vmlinux, uimage, etc.
|
||||
STATICFILESCOUNT=0
|
||||
# update to add/remove device image targets
|
||||
GENERIC_COUNT=23
|
||||
MIKROTIK_COUNT=3
|
||||
|
||||
# END Variables that may need adjusting
|
||||
|
||||
|
||||
. "$SCRIPTBASE/sh2ju.sh"
|
||||
|
||||
# Check the count of image files named AREDN-*
|
||||
|
||||
# Make sure no files named openwrt* in output directory
|
||||
# Could mean an image rename problem or that the buildroot
|
||||
# was not clean before making images
|
||||
if [ "$(find ./openwrt/bin/* -maxdepth 4 -regex '\./openwrt/bin.*openwrt.*\.bin' | wc -l)" -eq "0" ]
|
||||
then
|
||||
juLog -name="no_firmware_images_named_openwrt" true
|
||||
else
|
||||
juLog -name="no_firmware_images_named_openwrt" false
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
# Check the count of image files named AREDN-*
|
||||
|
||||
## STATICFILESCOUNT + NUMBEROFIMAGESCOUNT * 2 for sysupgrade and factory files
|
||||
EXPECTEDFILESCOUNT=$(( STATICFILESCOUNT + NUMBEROFIMAGESCOUNT * 2 ))
|
||||
|
||||
if [ "$(find ./openwrt/bin/* -maxdepth 4 -regex ".*AREDN-.*\.bin" | wc -l)" -eq "$EXPECTEDFILESCOUNT" ]
|
||||
case $AREDNSUBTARGET in
|
||||
mikrotik)
|
||||
EXPECTEDFILESCOUNT=$MIKROTIK_COUNT
|
||||
;;
|
||||
generic)
|
||||
EXPECTEDFILESCOUNT=$GENERIC_COUNT
|
||||
;;
|
||||
*)
|
||||
EXPECTEDFILESCOUNT=0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$(find ./openwrt/bin/* -maxdepth 4 -name "AREDN*" | wc -l)" -eq "$EXPECTEDFILESCOUNT" ]
|
||||
then
|
||||
juLog -name="AREDN_image_files_exist" true
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue