diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000000..dd84ea7824f11b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.gitignore b/.gitignore index 84e1a9d6d18c50..498005d3f38577 100644 --- a/.gitignore +++ b/.gitignore @@ -12,13 +12,10 @@ /logs /feeds /feeds.conf -/files /overlay /package/feeds /package/openwrt-packages key-build* -*.orig -*.rej *~ .#* *# diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000000..9cbbd46e565265 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ubuntu:18.04 + +RUN apt-get update &&\ + apt-get install -y sudo time git-core vim subversion build-essential gcc-multilib \ + libncurses5-dev zlib1g-dev gawk flex gettext wget unzip python &&\ + apt-get clean + +RUN useradd -m openwrt &&\ + echo 'openwrt ALL=NOPASSWD: ALL' > /etc/sudoers.d/openwrt + +USER openwrt +WORKDIR /home/openwrt + +RUN git clone https://github.com/LibreRouterOrg/openwrt.git &&\ + openwrt/scripts/feeds update -a &&\ + openwrt/scripts/feeds install -a &&\ + cp openwrt/configs/default_config openwrt/.config \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index 55ca92af65f8f5..00000000000000 --- a/README +++ /dev/null @@ -1,34 +0,0 @@ - _______ ________ __ - | |.-----.-----.-----.| | | |.----.| |_ - | - || _ | -__| || | | || _|| _| - |_______|| __|_____|__|__||________||__| |____| - |__| W I R E L E S S F R E E D O M - ----------------------------------------------------- - -This is the buildsystem for the OpenWrt Linux distribution. - -To build your own firmware you need a Linux, BSD or MacOSX system (case -sensitive filesystem required). Cygwin is unsupported because of the lack -of a case sensitive file system. - -You need gcc, binutils, bzip2, flex, python, perl, make, find, grep, diff, -unzip, gawk, getopt, subversion, libz-dev and libc headers installed. - -1. Run "./scripts/feeds update -a" to obtain all the latest package definitions -defined in feeds.conf / feeds.conf.default - -2. Run "./scripts/feeds install -a" to install symlinks for all obtained -packages into package/feeds/ - -3. Run "make menuconfig" to select your preferred configuration for the -toolchain, target system & firmware packages. - -4. Run "make" to build your firmware. This will download all sources, build -the cross-compile toolchain and then cross-compile the Linux kernel & all -chosen applications for your target system. - -Sunshine! - Your OpenWrt Community - http://www.openwrt.org - - diff --git a/README.md b/README.md new file mode 100644 index 00000000000000..263d3e7caec679 --- /dev/null +++ b/README.md @@ -0,0 +1,128 @@ + +## Build instructions + +Dependencies: You must have installed: gcc, binutils, bzip2, flex, python, +perl, make, find, grep, diff, unzip, gawk, getopt, subversion, time, +libz-dev (or zlib) and libc headers. + +1. Run `./scripts/feeds update -a` to obtain all the latest package definitions +defined in feeds.conf.default +2. Run `./scripts/feeds install -a` to install symlinks for all obtained +packages into package/feeds/ +3. Run `cp configs/default_config .config` +4. Run `make` to build your firmware. After choosing the options in the ncurses +menu, choose Exit and then Yes when asked if you want to save. + +### Building in docker container + +You need Docker installed, if you don't have it run `wget -O - https://get.docker.com | bash` to install. + +Simply run `docker run -it luandro/libremesh bash` or clone this repository and create a `docker build` yourself after you've modified the necessary files. Inside the container `cd openwrt` and run `make menuconfig` to select your targets and packages. Finally run `make` to build. + +## Development of LibreMesh packages + +To do work in libremesh packages you should make a clone of the repo and then +you can use this clone as part of the build using a local symbolic link. This way +you can change the files and run `make`. When you are satisfied by your changes you +should commit your changes to the lime-packages repo in a new branch and push this +to github and do a pull request. + +Fork the lime-packages repo in github and then clone it replacing yourgithubuser +``` +git clone git@github.com:yourgithubuser/lime-packages.git +``` + +Then edit feeds.conf.default and change the line + +``` +src-git libremesh https://github.com/libremesh/lime-packages.git;master +``` + +with this line replacing the path to repo and branch name (replace all the +line, check that src-git changed to src-link): + +``` +src-link libremesh /home/user/path/to/lime-packages +``` + +Run `./scripts/feeds update -a` and then `./scripts/feeds install -a` + +Now perform your changes to the lime-packages repo, editing files, etc. +If you are creating new packages you should run `feeds install -a` after you create +the package in order to be able to select the package with make menuconfig. + +When you want to create an image with your changes run `make`. If you need change +the package selection run `make menuconfig` and then `make`. + +## Testing a LibreMesh branch + +Edit feeds.conf.default, for example to test the `add-fft-eval` branch: + +``` +diff --git a/feeds.conf.default b/feeds.conf.default +index 5a681c88c4..ee2c5f1223 100644 +--- a/feeds.conf.default ++++ b/feeds.conf.default +@@ -3,6 +3,6 @@ src-git luci https://git.openwrt.org/project/luci.git^f64b1523447547032d5280fb0b + src-git routing https://git.openwrt.org/feed/routing.git^1b9d1c419f0ecefda51922a7845ab2183d6acd76 + src-git telephony https://git.openwrt.org/feed/telephony.git^b9d7b321d15a44c5abb9e5d43a4ec78abfd9031b + +-src-git libremesh https://github.com/libremesh/lime-packages.git;master ++src-git libremesh https://github.com/libremesh/lime-packages.git;add-fft-eval + src-git libremap https://github.com/libremap/libremap-agent-openwrt.git;master + src-git fbw https://github.com/libremesh/FirstBootWizard.git;master +``` + +``` +$ ./scripts/feeds update -a +``` + +update the feed as new packages may have beed added to a feed +``` +$ ./scripts/feeds install -a +``` + +## Changing package and options selection + +The config documentation is here `https://openwrt.org/docs/guide-developer/build-system/use-buildsystem`. +Some tips: +* The config is stored in .config +* To change the config use `make manuconfig` +* To know the difference between two configs, for example from the current config (.config) and +the default configuration run `$ ./scripts/diffconfig.sh | diff configs/default_config -` +* To save the new config to a new file (for backup purposes, to add it to a git repo, etc) run +`$ ./scripts/diffconfig.sh > configs/your_config` +* To change the default configuration, for example to perform a pull request to `git@github.com:LibreRouterOrg/openwrt.git` run +`$ ./scripts/diffconfig.sh > configs/default_config` + + +## Upgrading the buildroot + +``` +$ git pull + +$ ./scripts/feeds update -a + +$ ./scripts/feeds install -a +``` + +Copy the new config, be aware that this overwrites you local config!! +``` +$ cp configs/default_config .config +``` + +``` +$ make defconfig +$ make -j4 +... +``` + +## Notes + +* You can speed up the build process using more CPUs, for example with `make -j3` +the build uses 3 CPUs. +* For aditional documentation see + * https://openwrt.org/docs/guide-developer/build-system/use-buildsystem + * https://openwrt.org/docs/guide-developer/feeds + * https://openwrt.org/docs/guide-developer/packages + * https://openwrt.org/docs/guide-developer/start diff --git a/configs/default_config b/configs/default_config new file mode 100644 index 00000000000000..6dd6b646c765c6 --- /dev/null +++ b/configs/default_config @@ -0,0 +1,138 @@ +CONFIG_TARGET_ar71xx=y +CONFIG_TARGET_ar71xx_generic=y +CONFIG_TARGET_ar71xx_generic_DEVICE_librerouter-v1=y +CONFIG_DEVEL=y +CONFIG_BUSYBOX_CUSTOM=y +CONFIG_BUSYBOX_CONFIG_ASH_RANDOM_SUPPORT=y +CONFIG_BUSYBOX_CONFIG_DEVMEM=y +CONFIG_BUSYBOX_CONFIG_NC_SERVER=y +CONFIG_BWMNG_EXTENDEDSTATS=y +CONFIG_BWMNG_TIME=y +# CONFIG_FEED_libremap is not set +# CONFIG_FEED_libremesh is not set +# CONFIG_FEED_luci is not set +# CONFIG_FEED_packages is not set +# CONFIG_FEED_routing is not set +# CONFIG_FEED_telephony is not set +CONFIG_KERNEL_DEVMEM=y +CONFIG_KERNEL_RELAY=y +CONFIG_KMOD_BATMAN_ADV_BATMAN_V=y +CONFIG_KMOD_BATMAN_ADV_BLA=y +CONFIG_KMOD_BATMAN_ADV_DAT=y +CONFIG_KMOD_BATMAN_ADV_DEBUGFS=y +CONFIG_KMOD_BATMAN_ADV_MCAST=y +CONFIG_PACKAGE_ATH_DEBUG=y +CONFIG_PACKAGE_ATH_SPECTRAL=y +CONFIG_PACKAGE_babeld=y +CONFIG_PACKAGE_bandwidth-test=y +CONFIG_PACKAGE_batctl=y +CONFIG_PACKAGE_block-mount=y +CONFIG_PACKAGE_bwm-ng=y +# CONFIG_PACKAGE_dnsmasq is not set +CONFIG_PACKAGE_check-date-http=y +CONFIG_PACKAGE_deferable-reboot=y +CONFIG_PACKAGE_dnsmasq-dhcpv6=y +CONFIG_PACKAGE_ebtables=y +CONFIG_PACKAGE_ethtool=y +CONFIG_PACKAGE_fft-eval=y +CONFIG_PACKAGE_first-boot-wizard=y +CONFIG_PACKAGE_hotplug-initd-services=y +CONFIG_PACKAGE_ip-tiny=y +CONFIG_PACKAGE_ip6tables-mod-nat=y +CONFIG_PACKAGE_ipset=y +CONFIG_PACKAGE_iputils-ping=y +CONFIG_PACKAGE_iputils-ping6=y +CONFIG_PACKAGE_kmod-batman-adv=y +CONFIG_PACKAGE_kmod-crypto-crc32c=y +CONFIG_PACKAGE_kmod-crypto-hash=y +CONFIG_PACKAGE_kmod-dummy=y +CONFIG_PACKAGE_kmod-ebtables=y +CONFIG_PACKAGE_kmod-ebtables-ipv6=y +CONFIG_PACKAGE_kmod-fs-vfat=y +CONFIG_PACKAGE_kmod-ip6-tunnel=y +CONFIG_PACKAGE_kmod-ipt-conntrack=y +CONFIG_PACKAGE_kmod-ipt-ipset=y +CONFIG_PACKAGE_kmod-ipt-nat=y +CONFIG_PACKAGE_kmod-ipt-nat6=y +CONFIG_PACKAGE_kmod-iptunnel6=y +CONFIG_PACKAGE_kmod-lib-crc16=y +CONFIG_PACKAGE_kmod-lib-crc32c=y +CONFIG_PACKAGE_kmod-macvlan=y +CONFIG_PACKAGE_kmod-nf-conntrack=y +CONFIG_PACKAGE_kmod-nf-conntrack6=y +CONFIG_PACKAGE_kmod-nf-nat=y +CONFIG_PACKAGE_kmod-nf-nat6=y +CONFIG_PACKAGE_kmod-nfnetlink=y +CONFIG_PACKAGE_kmod-nls-cp437=y +CONFIG_PACKAGE_kmod-nls-iso8859-1=y +CONFIG_PACKAGE_kmod-nls-utf8=y +CONFIG_PACKAGE_kmod-tun=y +CONFIG_PACKAGE_kmod-usb-ledtrig-usbport=y +CONFIG_PACKAGE_kmod-usb-ohci=y +CONFIG_PACKAGE_libipset=y +CONFIG_PACKAGE_libiwinfo-lua=y +CONFIG_PACKAGE_liblucihttp=y +CONFIG_PACKAGE_liblucihttp-lua=y +CONFIG_PACKAGE_libmnl=y +CONFIG_PACKAGE_libncurses=y +CONFIG_PACKAGE_libpcap=y +CONFIG_PACKAGE_libremap-agent=y +CONFIG_PACKAGE_librt=y +CONFIG_PACKAGE_libubox-lua=y +CONFIG_PACKAGE_libubus-lua=y +CONFIG_PACKAGE_libuci-lua=y +CONFIG_PACKAGE_lime-app=y +CONFIG_PACKAGE_lime-debug=y +CONFIG_PACKAGE_lime-docs=y +CONFIG_PACKAGE_lime-docs-minimal=y +CONFIG_PACKAGE_lime-hwd-ground-routing=y +CONFIG_PACKAGE_lime-hwd-openwrt-wan=y +CONFIG_PACKAGE_lime-proto-anygw=y +CONFIG_PACKAGE_lime-proto-babeld=y +CONFIG_PACKAGE_lime-proto-batadv=y +CONFIG_PACKAGE_lime-proto-wan=y +CONFIG_PACKAGE_lime-report=y +CONFIG_PACKAGE_lime-system=y +CONFIG_PACKAGE_luci-base=y +CONFIG_PACKAGE_luci-lib-httpclient=y +CONFIG_PACKAGE_luci-lib-httpprotoutils=y +CONFIG_PACKAGE_luci-lib-ip=y +CONFIG_PACKAGE_luci-lib-json=y +CONFIG_PACKAGE_luci-lib-jsonc=y +CONFIG_PACKAGE_luci-lib-libremap=y +CONFIG_PACKAGE_luci-lib-libremap-babeld=y +CONFIG_PACKAGE_luci-lib-libremap-location=y +CONFIG_PACKAGE_luci-lib-libremap-system=y +CONFIG_PACKAGE_luci-lib-libremap-wireless=y +CONFIG_PACKAGE_luci-lib-nixio=y +CONFIG_PACKAGE_mtr=y +CONFIG_PACKAGE_netperf=y +CONFIG_PACKAGE_pirania=y +CONFIG_PACKAGE_pirania-app=y +CONFIG_PACKAGE_pv=y +CONFIG_PACKAGE_rpcd=y +CONFIG_PACKAGE_rpcd-mod-rrdns=y +CONFIG_PACKAGE_safe-reboot=y +CONFIG_PACKAGE_shared-state=y +CONFIG_PACKAGE_shared-state-babeld_hosts=y +CONFIG_PACKAGE_shared-state-bat_hosts=y +CONFIG_PACKAGE_shared-state-dnsmasq_hosts=y +CONFIG_PACKAGE_shared-state-dnsmasq_leases=y +CONFIG_PACKAGE_shared-state-nodes_and_links=y +CONFIG_PACKAGE_shared-state-persist=y +CONFIG_PACKAGE_shared-state-pirania=y +CONFIG_PACKAGE_sprunge=y +CONFIG_PACKAGE_tcpdump-mini=y +CONFIG_PACKAGE_terminfo=y +CONFIG_PACKAGE_ubus-lime-batman-adv=y +CONFIG_PACKAGE_ubus-lime-fbw=y +CONFIG_PACKAGE_ubus-lime-grondrouting=y +CONFIG_PACKAGE_ubus-lime-location=y +CONFIG_PACKAGE_ubus-lime-metrics=y +CONFIG_PACKAGE_ubus-lime-openairview=y +CONFIG_PACKAGE_ubus-lime-utils=y +CONFIG_PACKAGE_uhttpd=y +CONFIG_PACKAGE_uhttpd-mod-lua=y +CONFIG_PACKAGE_uhttpd-mod-ubus=y +CONFIG_PACKAGE_watchping=y +CONFIG_uhttpd_lua=y diff --git a/feeds.conf.default b/feeds.conf.default index 555c548cc305f0..2b2d7732129e7e 100644 --- a/feeds.conf.default +++ b/feeds.conf.default @@ -1,4 +1,7 @@ src-git packages https://git.openwrt.org/feed/packages.git^5779614d267732fc382c1684202543fdbd924b4c src-git luci https://git.openwrt.org/project/luci.git^4d6d8bc5b0d7ee71c7b29b12e7e0c2e1e86cb268 -src-git routing https://git.openwrt.org/feed/routing.git^bb156bf355b54236a52279522fabbec1e8dd7043 +src-git routing https://github.com/LibreRouterOrg/routing.git^2aa1506714d28704234998808249907a8289d945 src-git telephony https://git.openwrt.org/feed/telephony.git^507eabe1b60458ceb1a535aec9d12c8be95706f0 + +src-git libremesh https://github.com/libremesh/lime-packages.git^a5ab2e48bc9e6318c3928a5164238baa731af1d3 +src-git libremap https://github.com/libremesh/libremap-agent.git;master diff --git a/files/etc/config/lime-community b/files/etc/config/lime-community new file mode 100644 index 00000000000000..16124ddbc40693 --- /dev/null +++ b/files/etc/config/lime-community @@ -0,0 +1,19 @@ +# Read the documentation in /docs directory +# and on http://libremesh.org + +### System options + +config lime system + + +### Network general option + +config lime network + + +### WiFi general options + +config lime wifi + list modes 'ap_2ghz' + list modes 'apname_2ghz' + list modes 'ieee80211s_5ghz' diff --git a/files/etc/config/lime-defaults-factory b/files/etc/config/lime-defaults-factory new file mode 100644 index 00000000000000..05ad0a7f0a6ab2 --- /dev/null +++ b/files/etc/config/lime-defaults-factory @@ -0,0 +1,63 @@ +# Beware this file is NOT supposed to be edited by the end user, modify /etc/config/lime instead +# If the same option or list is defined both in /etc/config/lime and lime-defaults file, the former will prevail +# Beware this file is not supposed to store interface specific configuration, like "config net eth0" + +# Read the documentation in /docs directory +# and on http://libremesh.org + +config lime system + option hostname 'LiMe-%M4%M5%M6' + option domain 'lan' + option keep_on_upgrade 'libremesh base-files-essential /etc/sysupgrade.conf' + +config lime network + option primary_interface 'eth0' + option main_ipv4_address '10.%N1.0.0/16' + option anygw_dhcp_start '2' + option anygw_dhcp_limit '0' + option main_ipv6_address '2a00:1508:0a%N1:%N200::/64' + option bmx6_mtu '1500' + option bmx7_mtu '1500' + list protocols ieee80211s + list protocols lan + list protocols anygw + list protocols batadv:%N1 + list protocols bmx6:13 + list protocols olsr:14 + list protocols olsr6:15 + list protocols olsr2:16 + list protocols babeld:17 + list protocols bmx7:18 + list resolvers 4.2.2.2 # b.resolvers.Level3.net + list resolvers 141.1.1.1 # cns1.cw.net + list resolvers 2001:470:20::2 # ordns.he.net + option bmx6_mtu '1500' + option bmx6_publish_ownip false + option bmx6_over_batman false + option bmx6_pref_gw none + option bmx6_wifi_rate_max 54000000 + option bmx7_publish_ownip false + option bmx7_over_batman false + option bmx7_pref_gw none + option bmx7_wifi_rate_max 'auto' + option anygw_mac "aa:aa:aa:%N1:%N2:aa" + option use_odhcpd false + +config lime wifi + option channel_2ghz '11' + list channel_5ghz '157' + list channel_5ghz '48' + option htmode_5ghz 'HT40' + option distance_2ghz '100' + option distance_5ghz '1000' + list modes 'ap_2ghz' + list modes 'apname_2ghz' + list modes 'ieee80211s_5ghz' + option ap_ssid 'LibreMesh.org' + option apname_ssid 'LibreMesh.org/%H' + option adhoc_ssid 'LiMe' + option adhoc_bssid 'ca:fe:00:c0:ff:ee' + option adhoc_mcast_rate_2ghz '24000' + option adhoc_mcast_rate_5ghz '6000' + option ieee80211s_mesh_fwding '0' + option ieee80211s_mesh_id 'LiMe' diff --git a/files/etc/uci-defaults/92_add-librerouter-repos b/files/etc/uci-defaults/92_add-librerouter-repos new file mode 100644 index 00000000000000..cd785612179da4 --- /dev/null +++ b/files/etc/uci-defaults/92_add-librerouter-repos @@ -0,0 +1,28 @@ +#!/bin/sh + +. /etc/os-release +[ -f /etc/lime_release ] && . /etc/lime_release + +feeds_file="/etc/opkg/librerouterfeeds.conf" + +[ -f "$feeds_file" ] && { + echo "LibreRouter opkg feeds already defined - skipping" + exit 0 +} + +[ -z "$LEDE_ARCH" ] && { + echo "Release information not available, skipping opkg configuration" + exit 0 +} + +[ "$LIME_CODENAME" != "development" ] && { + base_url="http://repo.librerouter.org/releases/$LIME_RELEASE/targets/$LEDE_BOARD/packages" + echo "Configuring official LibreRouter opkg feeds" + echo "src/gz librerouter $base_url" > /etc/opkg/librerouterfeeds.conf + key_name="a71b3c8285abd28b" + key_content="RWSnGzyChavSiyQ+vLk3x7F0NqcLa4kKyXCdriThMhO78ldHgxGljM/8" + echo "$key_content" >> "/etc/opkg/keys/$key_name" +} || { + echo "Not configuring LibreRouter feed as it is a development built" +} + diff --git a/files/www/index.html b/files/www/index.html new file mode 100644 index 00000000000000..c0a2a9a92f2cf5 --- /dev/null +++ b/files/www/index.html @@ -0,0 +1,11 @@ + + + + + + + + +LiMe-App + + diff --git a/include/target.mk b/include/target.mk index 53d7436311c0c7..31588efe943099 100644 --- a/include/target.mk +++ b/include/target.mk @@ -10,14 +10,15 @@ ifneq ($(__target_inc),1) __target_inc=1 # default device type -DEVICE_TYPE?=router +DEVICE_TYPE?=librerouter # Default packages - the really basic set DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd # For nas targets DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm # For router targets -DEFAULT_PACKAGES.router:=dnsmasq iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd-ipv6only odhcp6c kmod-ipt-offload +DEFAULT_PACKAGES.router:=iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd-ipv6only odhcp6c kmod-ipt-offload +DEFAULT_PACKAGES.librerouter:=iptables ip6tables DEFAULT_PACKAGES.bootloader:= ifneq ($(DUMP),) diff --git a/package/boot/uboot-envtools/files/ar71xx b/package/boot/uboot-envtools/files/ar71xx index 2d9fcea1ac2f0b..e3cb0f89ac3b49 100644 --- a/package/boot/uboot-envtools/files/ar71xx +++ b/package/boot/uboot-envtools/files/ar71xx @@ -39,6 +39,7 @@ hornet-ub|\ hornet-ub-x2|\ jwap230|\ koala|\ +librerouter-v1|\ mr1750|\ mr1750v2|\ mr600|\ diff --git a/package/firmware/wireless-regdb/patches/900-tz.patch b/package/firmware/wireless-regdb/patches/900-tz.patch new file mode 100644 index 00000000000000..8b3b79f176c0c1 --- /dev/null +++ b/package/firmware/wireless-regdb/patches/900-tz.patch @@ -0,0 +1,22 @@ +--- a/db.txt ++++ b/db.txt +@@ -1209,8 +1209,8 @@ country TW: DFS-FCC + (57000 - 66000 @ 2160), (40) + + country TZ: +- (2402 - 2482 @ 40), (20) +- (5735 - 5835 @ 80), (30) ++ (2402 - 2484 @ 40), (30) ++ (5150 - 5835 @ 80), (30) + + # Source: + # #914 / 06 Sep 2007: http://www.ucrf.gov.ua/uk/doc/nkrz/1196068874 + +@@ -1334,3 +1334,7 @@ country ZW: DFS-ETSI + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + ++country VA: ++ (2402 - 2484 @ 40), (30) ++ (5150 - 5835 @ 80), (30) + diff --git a/package/kernel/om-watchdog/files/om-watchdog.init b/package/kernel/om-watchdog/files/om-watchdog.init index 10eb55ccc27f2a..0d90deacb8c0c6 100644 --- a/package/kernel/om-watchdog/files/om-watchdog.init +++ b/package/kernel/om-watchdog/files/om-watchdog.init @@ -26,6 +26,9 @@ get_gpio() { "mr600v2") return 15 ;; + "librerouter-v1") + return 2 + ;; "om2p"|\ "om2p-hs"|\ "om2p-hsv2"|\ diff --git a/package/network/services/uhttpd/patches/010-fix-cgi-script-timeout.patch b/package/network/services/uhttpd/patches/010-fix-cgi-script-timeout.patch new file mode 100644 index 00000000000000..74ba524b0667b3 --- /dev/null +++ b/package/network/services/uhttpd/patches/010-fix-cgi-script-timeout.patch @@ -0,0 +1,26 @@ +commit 1e6afc1a9ab22bba105191c2905d95aec7558e00 (HEAD -> fix_cgi_script_timeout) +Author: Santiago Piccinini +Date: Thu Oct 10 17:26:48 2019 -0300 + + do not cancell script killing after writing headers + + Before this change if the cgi script hangs after writing headers + then the process will never be killed. Let's only cancel the timeout + if the process ends. + + Signed-off-by: Santiago Piccinini + +--- a/proc.c ++++ b/proc.c +@@ -225,11 +225,9 @@ static void proc_handle_header(struct re + static void proc_handle_header_end(struct relay *r) + { + struct client *cl = r->cl; +- struct dispatch_proc *p = &cl->dispatch.proc; + struct blob_attr *cur; + int rem; + +- uloop_timeout_cancel(&p->timeout); + uh_http_header(cl, cl->dispatch.proc.status_code, cl->dispatch.proc.status_msg); + blob_for_each_attr(cur, cl->dispatch.proc.hdr.head, rem) + ustream_printf(cl->us, "%s: %s\r\n", blobmsg_name(cur), blobmsg_data(cur)); diff --git a/package/system/librerouter-hw/Makefile b/package/system/librerouter-hw/Makefile new file mode 100644 index 00000000000000..5670b33b38c8a3 --- /dev/null +++ b/package/system/librerouter-hw/Makefile @@ -0,0 +1,32 @@ +# +# Copyright (C) 2019 Santiago Piccinini +# +# This is free software, licensed under the GNU General Public License v3. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=librerouter-hw +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/$(PKG_NAME) + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Librerouter hardware tools +endef + +define Package/$(PKG_NAME)/description + Tools for the librerouter HW support. +endef + +define Build/Compile +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/ + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/system/librerouter-hw/files/etc/uci-defaults/99-run-librerouter-hw-check b/package/system/librerouter-hw/files/etc/uci-defaults/99-run-librerouter-hw-check new file mode 100755 index 00000000000000..adb5e133fcd299 --- /dev/null +++ b/package/system/librerouter-hw/files/etc/uci-defaults/99-run-librerouter-hw-check @@ -0,0 +1,6 @@ +#!/bin/sh + +# we wait until the LR is configured, up and stable +(sleep 200 && librerouter-hw-check )& + +exit 0 diff --git a/package/system/librerouter-hw/files/usr/sbin/librerouter-hw-check b/package/system/librerouter-hw/files/usr/sbin/librerouter-hw-check new file mode 100755 index 00000000000000..7d0804522ff52e --- /dev/null +++ b/package/system/librerouter-hw/files/usr/sbin/librerouter-hw-check @@ -0,0 +1,57 @@ +#!/usr/bin/env lua + +local ERRORS = false + +local function run_command_get_output(cmd) + local handle = io.popen(cmd) + local output = handle:read('*all') + handle:close() + return output +end + +local report_file = io.open('/root/librerouter-hw-check-report.txt', 'w') + +local function log(str) + print(str) + report_file:write(str..'\n') +end + +log('* Checking radio interfaces:') +local up_interfaces = run_command_get_output("iw dev | grep Interface | awk '{print $2}'") + +for _, iface_prefix in pairs({'wlan0', 'wlan1', 'wlan2'}) do + local up = string.find(up_interfaces, iface_prefix) ~= nil + if up then + log('\t' .. iface_prefix .. ' interface: OK') + else + log('\t' .. iface_prefix .. ' interface: BAD') + ERRORS = true + end +end + +log('* Checking mac addresses:') +local mac_addresses = run_command_get_output("cat /sys/class/net/*/address") + +local bad_mac_empty = string.find(mac_addresses, '02:03:04:05:06') ~= nil +local bad_mac_atheros = string.find(mac_addresses, '00:03:7f:00:01') ~= nil + +local bad_mac = bad_mac_empty or bad_mac_atheros +if bad_mac then + log('\tMAC address: BAD') + log(mac_addresses) + ERRORS = true +else + log('\tMAC address: OK') +end + +-- run safe-upgrade bootstraping. There is no problem if it is already bootstraped +run_command_get_output("safe-upgrade bootstrap") + + +if ERRORS then + log("ERROR: errors ocurred!") + os.exit(125) +else + log("SUCCESS") + os.exit(0) +end diff --git a/package/utils/busybox/config/miscutils/Config.in b/package/utils/busybox/config/miscutils/Config.in index 61c5458b637c6b..1b978195d89f33 100644 --- a/package/utils/busybox/config/miscutils/Config.in +++ b/package/utils/busybox/config/miscutils/Config.in @@ -157,6 +157,22 @@ config BUSYBOX_CONFIG_FEATURE_CROND_CALL_SENDMAIL help Command output will be sent to corresponding user via email. +config BUSYBOX_CONFIG_FEATURE_CROND_SPECIAL_TIMES + bool "Support special times (@reboot, @daily, etc) in crontabs" + default BUSYBOX_DEFAULT_FEATURE_CROND_SPECIAL_TIMES + depends on BUSYBOX_CONFIG_CROND + help + string meaning + ------ ------- + @reboot Run once, at startup + @yearly Run once a year: "0 0 1 1 *" + @annually Same as @yearly: "0 0 1 1 *" + @monthly Run once a month: "0 0 1 * *" + @weekly Run once a week: "0 0 * * 0" + @daily Run once a day: "0 0 * * *" + @midnight Same as @daily: "0 0 * * *" + @hourly Run once an hour: "0 * * * *" + config BUSYBOX_CONFIG_FEATURE_CROND_DIR string "crond spool directory" default BUSYBOX_DEFAULT_FEATURE_CROND_DIR diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds index 23f3d23bf53883..5da5a429b02b2a 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -249,6 +249,9 @@ cf-e530n) ;; cpe210|\ cpe210-v2|\ +cpe210-v3|\ +cpe510-v2|\ +cpe510-v3|\ cpe510|\ wbs210|\ wbs510) @@ -259,7 +262,10 @@ wbs510) ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "tp-link:green:link4" "wlan0" "76" "100" "-75" "13" case "$board" in - cpe210-v2) + cpe210-v2|\ + cpe210-v3|\ + cpe510-v2|\ + cpe510-v3) ucidef_set_led_netdev "lan" "LAN" "tp-link:green:lan0" "eth0" ;; *) diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network index e9522252a2b8ba..68b797a5813354 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -75,6 +75,9 @@ ar71xx_setup_interfaces() cf-e380ac-v1|\ cf-e380ac-v2|\ cpe210-v2|\ + cpe210-v3|\ + cpe510-v2|\ + cpe510-v3|\ dr342|\ eap120|\ eap300v2|\ @@ -447,6 +450,11 @@ ar71xx_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "1:lan" "5:wan" "6@eth1" ;; + librerouter-v1) + ucidef_set_interfaces_lan_wan "eth1.2" "eth0.1" + ucidef_add_switch "switch0" \ + "0@eth0" "5:wan" "6@eth1" "1:lan" "2:lan" "3:lan" "4:lan" + ;; nanostation-m-xw) ucidef_add_switch "switch0" \ "0@eth0" "5:lan" "1:wan" diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 4eb2abb26ca267..bf88ff35d33ce4 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -162,9 +162,18 @@ get_status_led() { cf-e385ac) status_led="$board:blue:wlan2g" ;; + cpe210-v2|\ + cpe210-v3|\ + cpe220-v3|\ + cpe510-v2|\ + cpe510-v3|\ + cpe210|\ cpe510) status_led="tp-link:green:link4" ;; + cpe610) + status_led="tp-link:green:link1" + ;; cr3000|\ cr5000) status_led="pcs:amber:power" diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index ccbd4e77c324a3..3d58fb1cbea35c 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -583,6 +583,10 @@ ar71xx_board_detect() { name="cpe210-v2" tplink_pharos_board_detect "$(tplink_pharos_v2_get_model_string)" ;; + *"CPE210 v3") + name="cpe210-v3" + tplink_pharos_board_detect "$(tplink_pharos_v2_get_model_string)" + ;; *"CPE505N") name="cpe505n" ;; @@ -590,6 +594,14 @@ ar71xx_board_detect() { name="cpe510" tplink_pharos_board_detect "$(tplink_pharos_get_model_string | tr -d '\r')" ;; + *"CPE510 v2") + name="cpe510-v2" + tplink_pharos_board_detect "$(tplink_pharos_v2_get_model_string)" + ;; + *"CPE510 v3") + name="cpe510-v3" + tplink_pharos_board_detect "$(tplink_pharos_v2_get_model_string)" + ;; *"CPE830") name="cpe830" ;; @@ -804,6 +816,9 @@ ar71xx_board_detect() { *"LAN Turtle") name="lan-turtle" ;; + *"LibreRouter v1"*) + name="librerouter-v1" + ;; *"Lima"*) name="lima" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index ca1270b7fdc84c..b13209788c2854 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -274,6 +274,7 @@ platform_check_image() { hornet-ub-x2|\ jwap230|\ lbe-m5|\ + librerouter-v1|\ lima|\ loco-m-xw|\ mzk-w04nu|\ @@ -587,10 +588,16 @@ platform_check_image() { tplink_pharos_check_image "$1" "7f454c46" "$(tplink_pharos_get_model_string)" '' && return 0 return 1 ;; - cpe210-v2) + cpe210-v2|\ + cpe210-v3) tplink_pharos_check_image "$1" "01000000" "$(tplink_pharos_v2_get_model_string)" '\0\xff\r' && return 0 return 1 ;; + cpe510-v2|\ + cpe510-v3) + tplink_pharos_check_image "$1" "7f454c46" "$(tplink_pharos_v2_get_model_string)" '\0\xff\r' && return 0 + return 1 + ;; a40|\ a60|\ mr1750|\ diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9 index 8aa0b41ae961d2..ac45683b4900f5 100644 --- a/target/linux/ar71xx/config-4.9 +++ b/target/linux/ar71xx/config-4.9 @@ -138,6 +138,7 @@ CONFIG_ATH79=y # CONFIG_ATH79_MACH_JWAP230 is not set # CONFIG_ATH79_MACH_KOALA is not set # CONFIG_ATH79_MACH_LAN_TURTLE is not set +CONFIG_ATH79_MACH_LIBREROUTERV1=y # CONFIG_ATH79_MACH_LIMA is not set # CONFIG_ATH79_MACH_MC_MAC1200R is not set # CONFIG_ATH79_MACH_MR12 is not set diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt index 1d0e3d910d42ab..409fb47c9d8b5e 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -1012,6 +1012,16 @@ config ATH79_MACH_WIFI_PINEAPPLE_NANO select ATH79_DEV_USB select ATH79_DEV_WMAC +config ATH79_MACH_LIBREROUTERV1 + bool "LibreRouter v1 board support" + select SOC_QCA955X + select ATH79_DEV_ETH + select ATH79_DEV_GPIO_BUTTONS + select ATH79_DEV_LEDS_GPIO + select ATH79_DEV_M25P80 + select ATH79_DEV_USB + select ATH79_DEV_WMAC + config ATH79_MACH_WRT160NL bool "Linksys WRT160NL board support" select SOC_AR913X diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile index 8800a7de102006..e6a83fd981804a 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile @@ -149,6 +149,7 @@ obj-$(CONFIG_ATH79_MACH_JWAP003) += mach-jwap003.o obj-$(CONFIG_ATH79_MACH_JWAP230) += mach-jwap230.o obj-$(CONFIG_ATH79_MACH_KOALA) += mach-koala.o obj-$(CONFIG_ATH79_MACH_LAN_TURTLE) += mach-lan-turtle.o +obj-$(CONFIG_ATH79_MACH_LIBREROUTERV1) += mach-librerouter-v1.o obj-$(CONFIG_ATH79_MACH_LIMA) += mach-lima.o obj-$(CONFIG_ATH79_MACH_MC_MAC1200R) += mach-mc-mac1200r.o obj-$(CONFIG_ATH79_MACH_MR12) += mach-mr12.o diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c index ceb1769ddd522d..d51014637c2798 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c @@ -230,12 +230,54 @@ static void __init cpe210_v2_setup(void) ath79_register_wmac(ee, mac); } +static void __init cpe510_v2_setup(void) +{ + u8 *mac = (u8 *) KSEG1ADDR(0x1f830008); + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); + + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */ + ath79_setup_ar933x_phy4_switch(false, false); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe210_v2_leds_gpio), + cpe210_v2_leds_gpio); + ath79_register_gpio_keys_polled(-1, CPE510_KEYS_POLL_INTERVAL, + ARRAY_SIZE(cpe510_gpio_keys), + cpe510_gpio_keys); + ath79_register_m25p80(NULL); + ath79_register_mdio(1, 0x0); + /* WAN */ + ath79_switch_data.phy4_mii_en = 1; + ath79_switch_data.phy_poll_mask = BIT(4); + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; + ath79_eth0_data.phy_mask = BIT(4); + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev; + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1); + ath79_register_eth(0); + /* LAN */ + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; + ath79_eth1_data.duplex = DUPLEX_FULL; + ath79_eth1_data.speed = SPEED_1000; + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0); + ath79_register_eth(1); + + ath79_register_wmac(ee, mac); +} + MIPS_MACHINE(ATH79_MACH_CPE210, "CPE210", "TP-LINK CPE210/220", cpe210_setup); MIPS_MACHINE(ATH79_MACH_CPE210_V2, "CPE210V2", "TP-LINK CPE210 v2", cpe210_v2_setup); +MIPS_MACHINE(ATH79_MACH_CPE210_V3, "CPE210V3", "TP-LINK CPE210 v3", + cpe210_v2_setup); + +MIPS_MACHINE(ATH79_MACH_CPE510_V2, "CPE510V2", "TP-LINK CPE510 v2", + cpe510_v2_setup); + +MIPS_MACHINE(ATH79_MACH_CPE510_V3, "CPE510V3", "TP-LINK CPE510 v3", + cpe510_v2_setup); + MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE510/520", cpe510_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-librerouter-v1.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-librerouter-v1.c new file mode 100644 index 00000000000000..1aff5cf2fccd1f --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-librerouter-v1.c @@ -0,0 +1,250 @@ +/* + * LibreRouter v1 support (based on AP135) + * + * Copyright (C) 2017 Daniel Golle + * + * Based on mach-wpj558.c and mach-tl-wr1043nd-v2.c + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "common.h" +#include "dev-ap9x-pci.h" +#include "dev-eth.h" +#include "dev-leds-gpio.h" +#include "dev-gpio-buttons.h" +#include "dev-m25p80.h" +#include "dev-nfc.h" +#include "dev-spi.h" +#include "dev-usb.h" +#include "dev-wmac.h" +#include "machtypes.h" +#include "pci.h" + +#define LIBREROUTERV1_MAC0_OFFSET 0x0 +#define LIBREROUTERV1_MAC1_OFFSET 0x6 +#define LIBREROUTERV1_WMAC_CALDATA_OFFSET 0x1000 + +#define LIBREROUTERV1_GPIO_BTN_RESET 17 + +#define LIBREROUTERV1_KEYS_POLL_INTERVAL 20 +#define LIBREROUTERV1_KEYS_DEBOUNCE_INTERVAL (3 * LIBREROUTERV1_KEYS_POLL_INTERVAL) + + +static struct gpio_keys_button librerouter_gpio_keys[] __initdata = { + { + .desc = "reset", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = LIBREROUTERV1_KEYS_DEBOUNCE_INTERVAL, + .gpio = LIBREROUTERV1_GPIO_BTN_RESET, + .active_low = 1, + } +}; + +static struct mtd_partition librerouter_spi_partitions[] = { + { + .name = "uboot", + .offset = 0, + .size = 0x0040000, + }, { + .name = "uboot-env", + .offset = 0x0040000, + .size = 0x0010000, + }, { + .name = "firmware", + .offset = 0x0050000, + .size = 0x07c0000, + }, { + .name = "art", + .offset = 0x0ff0000, + .size = 0x0010000, + } +}; + +static struct flash_platform_data librerouter_spi_flash_data = { + .parts = librerouter_spi_partitions, + .nr_parts = ARRAY_SIZE(librerouter_spi_partitions), +}; + +static struct spi_board_info librerouter_spi_info[] = { + { + .bus_num = 0, + .chip_select = 0, + .max_speed_hz = 25000000, + .modalias = "w25q256", + .platform_data = &librerouter_spi_flash_data, + }, +}; + +static struct ath79_spi_platform_data librerouter_spi_data = { + .bus_num = 0, + .num_chipselect = 1, +}; + +static struct resource librerouter_uart1_resources[] = { + { + .start = QCA955X_UART1_BASE, + .end = QCA955X_UART1_BASE + QCA955X_UART1_SIZE - 1, + .flags = IORESOURCE_MEM, + }, + { + .start = ATH79_MISC_IRQ(6), + .end = ATH79_MISC_IRQ(6), + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device librerouter_uart1_device = { + .name = "ar933x-uart", + .id = -1, + .resource = librerouter_uart1_resources, + .num_resources = ARRAY_SIZE(librerouter_uart1_resources), +}; + +static const struct ar8327_led_info librerouter_leds_qca8337[] = { + AR8327_LED_INFO(PHY0_0, HW, "librerouter:green:link0"), + AR8327_LED_INFO(PHY1_0, HW, "librerouter:green:link1"), +}; + +/* Blink rate: 1 Gbps -> 8 hz, 100 Mbs -> 4 Hz, 10 Mbps -> 2 Hz */ +static struct ar8327_led_cfg librerouter_qca8337_led_cfg = { + .led_ctrl0 = 0xcf37cf37, + .led_ctrl1 = 0xcf37cf37, + .led_ctrl2 = 0xcf37cf37, + .led_ctrl3 = 0x0, + .open_drain = true, +}; + +/* QCA8337 GMAC0 is connected with QCA9558 over RGMII */ +static struct ar8327_pad_cfg librerouter_qca8337_pad0_cfg = { + .mode = AR8327_PAD_MAC_RGMII, + .txclk_delay_en = true, + .rxclk_delay_en = true, + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1, + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2, + .mac06_exchange_dis = false, +}; + +/* QCA8337 GMAC6 is connected with QCA9558 over SGMII */ +static struct ar8327_pad_cfg librerouter_qca8337_pad6_cfg = { + .mode = AR8327_PAD_MAC_SGMII, + .sgmii_delay_en = true, + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0, +}; + + +static struct ar8327_platform_data librerouter_qca8337_data = { + .pad0_cfg = &librerouter_qca8337_pad0_cfg, + .pad6_cfg = &librerouter_qca8337_pad6_cfg, + .port0_cfg = { + .force_link = 1, + .speed = AR8327_PORT_SPEED_1000, + .duplex = 1, + .txpause = 1, + .rxpause = 1, + }, + .port6_cfg = { + .force_link = 1, + .speed = AR8327_PORT_SPEED_1000, + .duplex = 1, + .txpause = 1, + .rxpause = 1, + }, + .led_cfg = &librerouter_qca8337_led_cfg, + .num_leds = ARRAY_SIZE(librerouter_leds_qca8337), + .leds = librerouter_leds_qca8337, +}; + +static struct mdio_board_info librerouter_mdio0_info[] = { + { + .bus_id = "ag71xx-mdio.0", + .phy_addr = 0, + .platform_data = &librerouter_qca8337_data, + }, +}; + +static void __init librerouter_setup_qca955x_eth_cfg(u32 mask, + unsigned int rxd, + unsigned int rxdv, + unsigned int txd, + unsigned int txe) +{ + void __iomem *base; + u32 t; + + base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE); + + t = mask; + t |= rxd << QCA955X_ETH_CFG_RXD_DELAY_SHIFT; + t |= rxdv << QCA955X_ETH_CFG_RDV_DELAY_SHIFT; + t |= txd << QCA955X_ETH_CFG_TXD_DELAY_SHIFT; + t |= txe << QCA955X_ETH_CFG_TXE_DELAY_SHIFT; + + __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG); + + iounmap(base); +} + +static void __init librerouter_v1_setup(void) +{ + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); + + ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE); + ath79_register_spi(&librerouter_spi_data, + librerouter_spi_info, + ARRAY_SIZE(librerouter_spi_info)); + + mdiobus_register_board_info(librerouter_mdio0_info, + ARRAY_SIZE(librerouter_mdio0_info)); + ath79_register_mdio(0, 0x0); + + librerouter_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN, 2, 2, 0, 0); + + /* QCA9558 GMAC0 is connected to RMGII interface */ + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ath79_eth0_data.phy_mask = BIT(0); + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; + ath79_eth0_pll_data.pll_1000 = 0xa6000000; + + ath79_init_mac(ath79_eth0_data.mac_addr, art + LIBREROUTERV1_MAC0_OFFSET, 0); + ath79_register_eth(0); + + /* QCA9558 GMAC1 is connected to SGMII interface */ + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII; + ath79_eth1_data.speed = SPEED_1000; + ath79_eth1_data.duplex = DUPLEX_FULL; + ath79_eth1_pll_data.pll_1000 = 0x03000101; + + ath79_init_mac(ath79_eth1_data.mac_addr, art + LIBREROUTERV1_MAC1_OFFSET, 0); + + ath79_register_eth(1); + + ath79_register_gpio_keys_polled(-1, LIBREROUTERV1_KEYS_POLL_INTERVAL, + ARRAY_SIZE(librerouter_gpio_keys), + librerouter_gpio_keys); + + ath79_register_wmac(art + LIBREROUTERV1_WMAC_CALDATA_OFFSET, NULL); + + ath79_register_pci(); + ath79_register_usb(); + ath79_register_nfc(); + + platform_device_register(&librerouter_uart1_device); +} + +MIPS_MACHINE(ATH79_MACH_LIBREROUTERV1, "LIBREROUTERV1", "LibreRouter v1", librerouter_v1_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index 80f6e1d95b7a4e..7e4e69400570ec 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -75,6 +75,9 @@ enum ath79_mach_type { ATH79_MACH_CF_E530N, /* COMFAST CF-E530N */ ATH79_MACH_CPE210, /* TP-LINK CPE210 v1 */ ATH79_MACH_CPE210_V2, /* TP-LINK CPE210 v2 */ + ATH79_MACH_CPE210_V3, /* TP-LINK CPE210 v3 */ + ATH79_MACH_CPE510_V2, /* TP-LINK CPE510 v2 */ + ATH79_MACH_CPE510_V3, /* TP-LINK CPE510 v3 */ ATH79_MACH_CPE505N, /* P&W CPE505N */ ATH79_MACH_CPE510, /* TP-LINK CPE510 */ ATH79_MACH_CPE830, /* YunCore CPE830 */ @@ -148,6 +151,7 @@ enum ath79_mach_type { ATH79_MACH_JWAP230, /* jjPlus JWAP230 */ ATH79_MACH_KOALA, /* OCEDO Koala */ ATH79_MACH_LAN_TURTLE, /* Hak5 LAN Turtle */ + ATH79_MACH_LIBREROUTERV1, /* LibreRouter v1 */ ATH79_MACH_LIMA, /* 8devices Lima */ ATH79_MACH_MC_MAC1200R, /* MERCURY MAC1200R */ ATH79_MACH_MR12, /* Cisco Meraki MR12 */ diff --git a/target/linux/ar71xx/image/generic-tp-link.mk b/target/linux/ar71xx/image/generic-tp-link.mk index daf6c35ae4610d..caa0e881ad3d38 100644 --- a/target/linux/ar71xx/image/generic-tp-link.mk +++ b/target/linux/ar71xx/image/generic-tp-link.mk @@ -175,6 +175,20 @@ define Device/cpe510-520-v1 endef TARGET_DEVICES += cpe510-520-v1 +define Device/cpe510-v2 + $(Device/cpe510-520-v1) + DEVICE_TITLE := TP-LINK CPE510 v2 + BOARDNAME := CPE510V2 +endef +TARGET_DEVICES += cpe510-v2 + +define Device/cpe510-v3 + $(Device/cpe510-520-v1) + DEVICE_TITLE := TP-LINK CPE510 v3 + BOARDNAME := CPE510V3 +endef +TARGET_DEVICES += cpe510-v3 + define Device/cpe210-220-v1 $(Device/cpe510-520-v1) DEVICE_TITLE := TP-LINK CPE210/220 v1 @@ -195,6 +209,13 @@ define Device/cpe210-v2 endef TARGET_DEVICES += cpe210-v2 +define Device/cpe210-v3 + $(Device/cpe210-v2) + DEVICE_TITLE := TP-LINK CPE210 v3 + BOARDNAME := CPE210V3 +endef +TARGET_DEVICES += cpe210-v3 + define Device/wbs210-v1 $(Device/cpe510-520-v1) DEVICE_TITLE := TP-LINK WBS210 v1 diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk index 640557532c8a02..c181bfa682963a 100644 --- a/target/linux/ar71xx/image/generic.mk +++ b/target/linux/ar71xx/image/generic.mk @@ -1388,3 +1388,14 @@ define Device/fritz450e IMAGE_SIZE := 15232k endef TARGET_DEVICES += fritz450e + +define Device/librerouter-v1 + DEVICE_TITLE := LibreRouter v1 + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-storage safe-upgrade om-watchdog librerouter-hw + BOARDNAME := LIBREROUTERV1 + IMAGE_SIZE := 32384k + KERNEL := kernel-bin | lzma | uImage lzma + IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | \ + append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) +endef +TARGET_DEVICES += librerouter-v1 diff --git a/target/linux/ar71xx/patches-4.9/917-MIPS-ath79-add-qca955x-uart1-reg-defs.patch b/target/linux/ar71xx/patches-4.9/917-MIPS-ath79-add-qca955x-uart1-reg-defs.patch new file mode 100644 index 00000000000000..db19bfcbbecf57 --- /dev/null +++ b/target/linux/ar71xx/patches-4.9/917-MIPS-ath79-add-qca955x-uart1-reg-defs.patch @@ -0,0 +1,11 @@ +--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h ++++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h +@@ -137,6 +137,8 @@ + #define QCA955X_GMAC_SIZE 0x40 + #define QCA955X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000) + #define QCA955X_WMAC_SIZE 0x20000 ++#define QCA955X_UART1_BASE (AR71XX_APB_BASE + 0x00500000) ++#define QCA955X_UART1_SIZE 0x14 + #define QCA955X_EHCI0_BASE 0x1b000000 + #define QCA955X_EHCI1_BASE 0x1b400000 + #define QCA955X_EHCI_SIZE 0x1000 diff --git a/target/linux/ar71xx/patches-4.9/999-hack-spi-nor-disable-4byte-mode.patch b/target/linux/ar71xx/patches-4.9/999-hack-spi-nor-disable-4byte-mode.patch new file mode 100644 index 00000000000000..f1c0da798bd55b --- /dev/null +++ b/target/linux/ar71xx/patches-4.9/999-hack-spi-nor-disable-4byte-mode.patch @@ -0,0 +1,38 @@ +Index: linux-4.9.67/drivers/mtd/spi-nor/spi-nor.c +=================================================================== +--- linux-4.9.67.orig/drivers/mtd/spi-nor/spi-nor.c ++++ linux-4.9.67/drivers/mtd/spi-nor/spi-nor.c +@@ -1151,7 +1151,10 @@ static const struct flash_info spi_nor_i + { "w25q80", INFO(0xef5014, 0, 64 * 1024, 16, SECT_4K) }, + { "w25q80bl", INFO(0xef4014, 0, 64 * 1024, 16, SECT_4K) }, + { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) }, +- { "w25q256", INFO(0xef4019, 0, 64 * 1024, 512, SECT_4K) }, ++ { "w25q256", INFO(0xef4019, 0, 64 * 1024, 256, ++ SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | ++ SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) ++ }, + + /* Catalyst / On Semiconductor -- non-JEDEC */ + { "cat25c11", CAT25_INFO( 16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) }, +@@ -1711,20 +1714,7 @@ int spi_nor_scan(struct spi_nor *nor, co + } + + nor->program_opcode = SPINOR_OP_PP; +- +- if (info->addr_width) +- nor->addr_width = info->addr_width; +- else if (mtd->size > 0x1000000) { +- /* enable 4-byte addressing if the device exceeds 16MiB */ +- nor->addr_width = 4; +- if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || +- info->flags & SPI_NOR_4B_OPCODES) +- spi_nor_set_4byte_opcodes(nor, info); +- else +- set_4byte(nor, info, 1); +- } else { +- nor->addr_width = 3; +- } ++ nor->addr_width = 3; + + if (nor->addr_width > SPI_NOR_MAX_ADDR_WIDTH) { + dev_err(dev, "address width is too large: %u\n", diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c index 4b227e1c97b6c5..aa1fe843f4507b 100644 --- a/tools/firmware-utils/src/tplink-safeloader.c +++ b/tools/firmware-utils/src/tplink-safeloader.c @@ -155,7 +155,7 @@ static struct device_info boards[] = { .last_sysupgrade_partition = "support-list", }, - /** Firmware layout for the CPE210 V2 */ + /** Firmware layout for the CPE210 V2 and V3 */ { .id = "CPE210V2", .vendor = "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n", @@ -170,7 +170,11 @@ static struct device_info boards[] = { "CPE210(TP-LINK|US|N300-2|55530000):2.0\r\n" "CPE210(TP-LINK|UN|N300-2):2.0\r\n" "CPE210(TP-LINK|EU|N300-2):2.0\r\n" - "CPE210(TP-LINK|US|N300-2):2.0\r\n", + "CPE210(TP-LINK|US|N300-2):2.0\r\n" + "CPE210(TP-LINK|EU|N300-2|45550000):3.0\r\n" + "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n" + "CPE210(TP-LINK|UN|N300-2):3.0\r\n" + "CPE210(TP-LINK|EU|N300-2):3.0\r\n", .support_trail = '\xff', .soft_ver = NULL, @@ -210,7 +214,27 @@ static struct device_info boards[] = { "CPE510(TP-LINK|EU|N300-5):1.1\r\n" "CPE520(TP-LINK|UN|N300-5):1.1\r\n" "CPE520(TP-LINK|US|N300-5):1.1\r\n" - "CPE520(TP-LINK|EU|N300-5):1.1\r\n", + "CPE520(TP-LINK|EU|N300-5):1.1\r\n" + "CPE510(TP-LINK|EU|N300-5|00000000):2.0\r\n" + "CPE510(TP-LINK|EU|N300-5|45550000):2.0\r\n" + "CPE510(TP-LINK|EU|N300-5|55530000):2.0\r\n" + "CPE510(TP-LINK|UN|N300-5|00000000):2.0\r\n" + "CPE510(TP-LINK|UN|N300-5|45550000):2.0\r\n" + "CPE510(TP-LINK|UN|N300-5|55530000):2.0\r\n" + "CPE510(TP-LINK|US|N300-5|55530000):2.0\r\n" + "CPE510(TP-LINK|UN|N300-5):2.0\r\n" + "CPE510(TP-LINK|EU|N300-5):2.0\r\n" + "CPE510(TP-LINK|US|N300-5):2.0\r\n" + "CPE510(TP-LINK|EU|N300-5|00000000):3.0\r\n" + "CPE510(TP-LINK|EU|N300-5|45550000):3.0\r\n" + "CPE510(TP-LINK|EU|N300-5|55530000):3.0\r\n" + "CPE510(TP-LINK|UN|N300-5|00000000):3.0\r\n" + "CPE510(TP-LINK|UN|N300-5|45550000):3.0\r\n" + "CPE510(TP-LINK|UN|N300-5|55530000):3.0\r\n" + "CPE510(TP-LINK|US|N300-5|55530000):3.0\r\n" + "CPE510(TP-LINK|UN|N300-5):3.0\r\n" + "CPE510(TP-LINK|EU|N300-5):3.0\r\n" + "CPE510(TP-LINK|US|N300-5):3.0\r\n", .support_trail = '\xff', .soft_ver = NULL,