Skip to content

Commit

Permalink
Openwrt and new compiler related fixes (abperiasamy#285)
Browse files Browse the repository at this point in the history
* rtw-ap: Fix compiler warning.

Signed-off-by: Ben Greear <greearb@candelatech.com>

* makefile:  Add entry for compiling against openwrt tree.

Users would need to edit it to match their path, but
this should get them started.

Signed-off-by: Ben Greear <greearb@candelatech.com>

* makefile:  Allow defining KSRC outside of build.

So, you can do this:

KSRC=/tmp/my/kernel make

And not have to edit the makefile to have this function as desired.

Signed-off-by: Ben Greear <greearb@candelatech.com>

* Fix stack-too-large warning on x86-64 compile

Signed-off-by: Ben Greear <greearb@candelatech.com>

* compile:  Allow cross-compiling on cmd-line w/out editing Makefile

For instance:

KSRC=/home/greearb/git/openwrt-neo2-dev/build_dir/target-aarch64_cortex-a53_musl/linux-sunxi_cortexa53/linux-4.14.78 \
 EXT_EXTRA_CFLAGS=-DCONFIG_LITTLE_ENDIAN ARCH=arm64 CROSS_COMPILE=aarch64-openwrt-linux- MODDESTDIR=/tmp make V=1

Signed-off-by: Ben Greear <greearb@candelatech.com>

* build:  Attempt to auto-detect endian-ness.

Will make building in openwrt much easier.

Signed-off-by: Ben Greear <greearb@candelatech.com>

* Fix build against openwrt backports tree.

Like breaks builds elsewhere, can fix it up later.

Signed-off-by: Ben Greear <greearb@candelatech.com>

* Register wiphy after we probe MAC addr.

This way the phy object has a valid MAC-addr, which can be helpful
for identification.

Signed-off-by: Ben Greear <greearb@candelatech.com>

* Make sure MAC is set in wiphy_preinit

This is needed to make sure the phy registers with a proper MAC
address instead of all 00

Signed-off-by: Ben Greear <greearb@candelatech.com>

* Fix build on 4.19 kernel.

Signed-off-by: Ben Greear <greearb@candelatech.com>

* Fix compile against 4.20 kernel.

Remove some variable-length arrays (which could be security bugs,
ways to overflow the stack it seems), and remove use of
get_monotonic_boottime.

Signed-off-by: Ben Greear <greearb@candelatech.com>

* Support arm64
  • Loading branch information
greearb authored and harshavardhana committed Mar 8, 2019
1 parent fb91faf commit ba6fa69
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 106 deletions.
26 changes: 25 additions & 1 deletion Makefile
Expand Up @@ -83,6 +83,7 @@ CONFIG_PLATFORM_ARM_S3C6K4 = n
CONFIG_PLATFORM_MIPS_RMI = n
CONFIG_PLATFORM_RTD2880B = n
CONFIG_PLATFORM_MIPS_AR9132 = n
CONFIG_PLATFORM_OPENWRT_NEO2 = n
CONFIG_PLATFORM_RTK_DMP = n
CONFIG_PLATFORM_MIPS_PLM = n
CONFIG_PLATFORM_MSTAR389 = n
Expand Down Expand Up @@ -869,18 +870,31 @@ EXTRA_CFLAGS += -DCONFIG_TDLS
endif

ifeq ($(CONFIG_PLATFORM_I386_PC), y)

ifdef EXT_EXTRA_CFLAGS
EXTRA_CFLAGS += $(EXT_EXTRA_CFLAGS)
else
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
#EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
#EXTRA_CFLAGS += -DCONFIG_P2P_IPS
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ | sed -e s/ppc64le/powerpc/)
endif
ifndef ARCH
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/ppc64le/powerpc/ -e s/aarch64/arm64/)
ARCH ?= $(SUBARCH)
endif
ifndef CROSS_COMPILE
CROSS_COMPILE ?=
endif
ifndef KVER
KVER ?= $(shell uname -r)
endif
ifndef KSRC
KSRC := /lib/modules/$(KVER)/build
endif
ifndef MODDESTDIR
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/
endif
INSTALL_PREFIX :=
endif

Expand Down Expand Up @@ -1046,6 +1060,16 @@ CROSS_COMPILE := mips-openwrt-linux-
KSRC := /home/alex/test_openwrt/tmp/linux-2.6.30.9
endif

# This is how I built for openwrt Neo2 platform. --Ben
ifeq ($(CONFIG_PLATFORM_OPENWRT_NEO2), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH := arm64
CROSS_COMPILE := aarch64-openwrt-linux-
#export PATH=$PATH:/home/greearb/git/openwrt-neo2-dev/staging_dir/toolchain-aarch64_cortex-a53_gcc-7.3.0_musl/bin/
#export STAGING_DIR=/home/greearb/git/openwrt-neo2-dev/staging_dir
KSRC := /home/greearb/git/openwrt-neo2-dev/build_dir/target-aarch64_cortex-a53_musl/linux-sunxi_cortexa53/linux-4.14.78
endif

ifeq ($(CONFIG_PLATFORM_DMP_PHILIPS), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DRTK_DMP_PLATFORM
ARCH := mips
Expand Down
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -79,6 +79,13 @@ Load module
# sudo modprobe -a rtl8812au
```

# Cross-compiling. You can now specify variables on the command line w/out editing
# makefile. For instance, this builds against recent OpenWRT neo2 platform. Your
# Cross-compile binaries should be in your PATH.

KSRC=/home/greearb/git/openwrt-neo2-dev/build_dir/target-aarch64_cortex-a53_musl/linux-sunxi_cortexa53/linux-4.14.78 EXT_EXTRA_CFLAGS=-DCONFIG_LITTLE_ENDIAN ARCH=arm64 CROSS_COMPILE=aarch64-openwrt-linux- MODDESTDIR=/tmp make V=1


Setup DKMS

```sh
Expand Down
2 changes: 1 addition & 1 deletion core/rtw_ap.c
Expand Up @@ -194,7 +194,7 @@ void rtw_add_bcn_ie(_adapter *padapter, WLAN_BSSID_EX *pnetwork, u8 index, u8 *d
u8 bmatch = _FALSE;
u8 *pie = pnetwork->IEs;
u8 *p=NULL, *dst_ie=NULL, *premainder_ie=NULL, *pbackup_remainder_ie=NULL;
u32 i, offset, ielen, ie_offset, remainder_ielen = 0;
u32 i, offset, ielen = 0, ie_offset, remainder_ielen = 0;

for (i = sizeof(NDIS_802_11_FIXED_IEs); i < pnetwork->IELength;) {
pIE = (PNDIS_802_11_VARIABLE_IEs)(pnetwork->IEs + i);
Expand Down
7 changes: 6 additions & 1 deletion core/rtw_mlme_ext.c
Expand Up @@ -3534,7 +3534,8 @@ void issue_p2p_GO_response(_adapter *padapter, u8* raddr, u8* frame_body,uint le
u8 action = P2P_PUB_ACTION_ACTION;
u32 p2poui = cpu_to_be32(P2POUI);
u8 oui_subtype = P2P_GO_NEGO_RESP;
u8 wpsie[ 255 ] = { 0x00 }, p2pie[ 255 ] = { 0x00 };
u8 *wpsie;
u8 p2pie[ 255 ] = { 0x00 };
u8 p2pielen = 0;
uint wpsielen = 0;
u16 wps_devicepassword_id = 0x0000;
Expand All @@ -3560,6 +3561,8 @@ void issue_p2p_GO_response(_adapter *padapter, u8* raddr, u8* frame_body,uint le
return;
}

wpsie = rtw_zmalloc(256);

DBG_871X( "[%s] In, result = %d\n", __FUNCTION__, result );
//update attribute
pattrib = &pmgntframe->attrib;
Expand Down Expand Up @@ -3965,6 +3968,8 @@ void issue_p2p_GO_response(_adapter *padapter, u8* raddr, u8* frame_body,uint le

dump_mgntframe(padapter, pmgntframe);

kfree(wpsie);

return;

}
Expand Down
4 changes: 3 additions & 1 deletion include/drv_conf.h
Expand Up @@ -19,7 +19,9 @@
******************************************************************************/
#ifndef __DRV_CONF_H__
#define __DRV_CONF_H__
#include "autoconf.h"

#include <generated/autoconf.h>
#include "rtl_autoconf.h"

#if defined (PLATFORM_LINUX) && defined (PLATFORM_WINDOWS)

Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions include/rtw_byteorder.h
Expand Up @@ -25,6 +25,18 @@
#error "Shall be CONFIG_LITTLE_ENDIAN or CONFIG_BIG_ENDIAN, but not both!\n"
#endif

#if !((defined CONFIG_LITTLE_ENDIAN) || (defined CONFIG_BIG_ENDIAN))
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define CONFIG_LITTLE_ENDIAN
//#warning "Auto-detected little-endian system...hope it is correct!"
#else
#if __BYTE_ORDER == __BIG_ENDIAN
//#warning "Auto-detected big-endian system...hope it is correct!"
#define CONFIG_BIG_ENDIAN
#endif
#endif
#endif

#if defined (CONFIG_LITTLE_ENDIAN)
#ifndef CONFIG_PLATFORM_MSTAR389
# include <byteorder/little_endian.h>
Expand Down
2 changes: 1 addition & 1 deletion include/wifi.h
Expand Up @@ -977,7 +977,7 @@ typedef enum _HT_CAP_AMPDU_FACTOR {
* According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
*/
#define IEEE80211_MIN_AMPDU_BUF 0x8
#define IEEE80211_MAX_AMPDU_BUF 0x40
//#define IEEE80211_MAX_AMPDU_BUF 0x40


/* Spatial Multiplexing Power Save Modes */
Expand Down
12 changes: 8 additions & 4 deletions os_dep/linux/ioctl_cfg80211.c
Expand Up @@ -349,6 +349,9 @@ static int rtw_ieee80211_channel_to_frequency(int chan, int band)

static u64 rtw_get_systime_us(void)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
return ktime_to_us(ktime_get_boottime());
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
struct timespec ts;
get_monotonic_boottime(&ts);
Expand All @@ -358,6 +361,7 @@ static u64 rtw_get_systime_us(void)
do_gettimeofday(&tv);
return ((u64)tv.tv_sec*1000000) + tv.tv_usec;
#endif
#endif
}

#define MAX_BSSINFO_LEN 1000
Expand Down Expand Up @@ -5837,10 +5841,6 @@ void rtw_cfg80211_init_wiphy(_adapter *padapter)

/* init regulary domain */
rtw_regd_init(padapter);

/* copy mac_addr to wiphy */
_rtw_memcpy(wiphy->perm_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);

}

/*
Expand Down Expand Up @@ -5959,6 +5959,10 @@ static void rtw_cfg80211_preinit_wiphy(_adapter *padapter, struct wiphy *wiphy)
//wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
#endif


/* copy mac_addr to wiphy */
_rtw_memcpy(wiphy->perm_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(RTW_VENDOR_EXT_SUPPORT)
rtw_cfgvendor_attach(wiphy);
#endif
Expand Down

0 comments on commit ba6fa69

Please sign in to comment.