diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58f4a86..e635f75 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,20 +21,24 @@ jobs: sudo apt-get update sudo apt-get install --yes --no-install-recommends libguestfs-tools qemu-user-static binfmt-support curl -LO https://raw.githubusercontent.com/ev3dev/brickstrap/master/src/brickstrap.sh - - name: build sling and sinter + - name: Build sling and sinter run: ./build_sling.sh - - name: build qrcode generator + - name: Build QR code generator run: ./build_qrcode.sh - - name: build nus login program + - name: Build prompt for NUS_STU login run: ./build_prompt.sh - - name: build uuidtob62 + - name: Build uuidtob62 CLI tool run: ./build_uuidtob62.sh - - name: check the outputs + - name: Build RTL8821CU Wi-Fi driver + run: ./build_driver.sh + - name: Check the outputs run: | - file build-ev3/sling build-ev3/sinter_host file build-ev3/executables/show_qrcode build-ev3/executables/nus_login build-ev3/executables/uuidtob62 + file build-ev3/sling build-ev3/sinter_host \ + file build-ev3/executables/show_qrcode build-ev3/executables/nus_login build-ev3/executables/uuidtob62 \ + file image/rtl8821cu-driver/8821cu.ko image/rtl8821cu-driver/8821cu.conf - name: make vmlinuz readable run: sudo chmod 755 /boot/vmlinuz* - - name: build image + - name: Build EV3-Source image run: ./build_image.sh - uses: actions/upload-artifact@v2 if: ${{ github.event_name == 'workflow_dispatch' }} diff --git a/build_driver.sh b/build_driver.sh new file mode 100755 index 0000000..dc0c01c --- /dev/null +++ b/build_driver.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -euxo pipefail +SCRIPT_DIR="$(dirname "$(realpath -s "${BASH_SOURCE[0]}")")" +IMAGE_NAME="sourceacademy/rtl8821cu" +OUTPUT_DIR="image/rtl8821cu-driver" + +cd rtl8821cu-driver +docker build -t "$IMAGE_NAME" . + +cd "$SCRIPT_DIR" +mkdir -p "$OUTPUT_DIR" +cd "$OUTPUT_DIR" +docker run --rm -w /root/work/rtl8821cu/ "$IMAGE_NAME" cat 8821cu.ko > 8821cu.ko +docker run --rm -w /root/work/rtl8821cu/ "$IMAGE_NAME" cat 8821cu.conf > 8821cu.conf + +# Clean up +docker rmi "$IMAGE_NAME" diff --git a/image/Dockerfile b/image/Dockerfile index 1090fb7..2015bca 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -3,8 +3,8 @@ FROM ev3dev/ev3dev-stretch-ev3-base COPY executables/uuidtob62 sling sinter_host /usr/local/bin/ # Copy WiFi drivers -COPY rtl8812cu-driver/8821cu.conf /etc/modprobe.d/ -COPY rtl8812cu-driver/8821cu.ko /lib/modules/4.14.117-ev3dev-2.3.5-ev3/drivers/net/wireless/ +COPY rtl8821cu-driver/8821cu.conf /etc/modprobe.d/ +COPY rtl8821cu-driver/8821cu.ko /lib/modules/4.14.117-ev3dev-2.3.5-ev3/drivers/net/wireless/ # Copy configurations and run setup COPY bootstrap.sh start-sling.sh sling.service panel.service show-secret.sh show-qr.sh /usr/local/bin/ diff --git a/image/rtl8812cu-driver/8821cu.conf b/image/rtl8812cu-driver/8821cu.conf deleted file mode 100644 index c6aecc7..0000000 --- a/image/rtl8812cu-driver/8821cu.conf +++ /dev/null @@ -1,159 +0,0 @@ -# /etc/modprobe.d/8821cu.conf -# -# Purpose: Allow easy access to specific driver options. -# -# Warning: Some adapters based on the rtl8821cu chipset may require the -# `rtw_RFE_type` option to be set. If wifi or bluetooth does not work -# after driver installation, see the appropriate section in the below -# documentation. -# -# Edit the following line to change, add or delete options: -options 8821cu rtw_drv_log_level=0 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_power_mgnt=1 rtw_dfs_region_domain=0 rtw_RFE_type=7 -# -# After editing is complete, save this file (if using nano: Ctrl + x, y, Enter) -# and reboot to activate the changes. -# -# Documentation: -# -# ----- -# -# Log options ( rtw_drv_log_level ) -# -# 0 = NONE (default) -# 1 = ALWAYS -# 2 = ERROR -# 3 = WARNING -# 4 = INFO -# 5 = DEBUG -# 6 = MAX -# -# Note: You can save a log file that only includes RTW log entries by running -# the following in a terminal: -# -# sudo ./save-log.sh -# -# Note: The name of the log file will be ```rtw.log```. -# -# ----- -# -# LED options ( rtw_led_ctrl ) -# -# 0 = Always off -# 1 = Normal blink (default) -# 2 = Always on -# -# ----- -# -# VHT options ( rtw_vht_enable ) -# -# 0 = Disable -# 1 = Enable (default) -# 2 = Force auto enable (use only for 5 GHz AP mode) -# -# Notes: -# - A non-default setting can degrade performance greatly in managed mode. -# - Option 2 allows 80 MHz channel width for 5GHz AP mode, such as when -# you are using hostapd. -# -# ----- -# -# Power options ( rtw_power_mgnt ) -# -# 0 = Disable power saving -# 1 = Power saving on, minPS (default) -# 2 = Power saving on, maxPS (not recommended for AP mode) -# -# ----- -# -# Country Code options ( rtw_country_code ) -# -# Note: Allows the Country Code to be set in cases where it is unable to -# be obtained from the operating system. -# -# Example for the US: rtw_country_code=US -# Example for Panama: rtw_country_code=PA -# Example for Norway: rtw_country_code=NO -# Example for Kuwait: rtw_country_code=KW -# Example for Taiwan: rtw_country_code=TW -# -# ----- -# -# DFS Options ( rtw_dfs_region_domain ) -# -# 0 = NONE (default) -# 1 = FCC -# 2 = MKK -# 3 = ETSI -# -# Notes: -# - Activates DFS channels in AP mode. -# - DFS FCC 80 MHz channels for hostapd: 52(58), 100(106), 116(122) and 132(138) -# - For more information: https://en.wikipedia.org/wiki/List_of_WLAN_channels -# -# Note: An AP needs to listen on a DFS channel for a period of 60 seconds -# before transmitting on the channel. If any radar pulses are detected, -# the AP cannot use that channel and will have to try a different channel. -# -# ----- -# -# Select P2P interface in concurrent mode ( rtw_sel_p2p_iface ) -# -# 0 = Sets interface 0 to be p2p interface -# 1 = Sets interface 1 to be p2p interface (default) -# -# ----- -# -# Select RFE type ( rtw_RFE_type ) -# -# 0 = (2-Ant, DPDT), (2G_WLG, iPA, iLNA, iSW), (5G, iPA, iLNA, iSW) -# 1 = (1-Ant, SPDT@Ant1), (2G_WLG, iPA, iLNA, iSW), (5G, iPA, iLNA, iSW) -# 2 = (1-Ant, SPDT@Ant1) , (2G_BTG, iPA, iLNA, iSW), (5G, iPA, iLNA, iSW) -# 3 = (1-Ant, DPDT@Ant2), (2G_WLG, iPA, iLNA, iSW), (5G, iPA, iLNA, iSW) -# 4 = (1-Ant, DPDT@Ant2), (2G_BTG, iPA, iLNA, iSW), (5G, iPA, iLNA, iSW) -# 5 = (2-Ant), (2G_WLG, iPA, iLNA, iSW), (5G, iPA, iLNA, iSW) -# 6 = (2-Ant), (2G_WLG, iPA, iLNA, iSW), (5G, iPA, iLNA, iSW) -# 7 = (1-Ant), (2G_BTG, iPA, iLNA, iSW), (5G, iPA, iLNA, iSW) (try this setting first) -# 64 = this appears to be the default on adapters that do not support bluetooth -# -# Note: RFE Type is used to set antenna isolation and the BT coexistence -# mechanism. Some adapters require this setting and some do not. If wifi -# does not work without this setting, the setting probably needs to be -# set. It may be necessary to try different settings to determine -# which setting is optimal for your adapter. -# -# ----- -# -# To see all options that are available: -# -# $ ls /sys/module/8821cu/parameters/ -# -# ----- -# -# To see the values that are in use: -# -# $ grep [[:alnum:]] /sys/module/8821cu/parameters/* -# -# ----- -# -# hostapd setup information for rtl8821cu -# Note: The best settings can vary but the following may be a good place to start. -# -# /etc/modprobe.d/8821cu.conf -# options 8821cu rtw_drv_log_level=0 rtw_led_ctrl=0 rtw_vht_enable=2 rtw_power_mgnt=1 rtw_dfs_region_domain=1 -# -# Note: The best setting for `rtw_dfs_region_domain=` will depend on your location. -# -# /etc/hostapd/hostapd.conf -# -# hw ht capab: 0x862 -# ht_capab=[HT40+][HT40-][SHORT-GI-20][SHORT-GI-40][MAX-AMSDU-7935] -# -# hw vht capab: 0x03c00022 -# vht_capab=[MAX-MPDU-11454][SHORT-GI-80][HTC-VHT][MAX-A-MPDU-LEN-EXP7] -# -# ----- - - - - - diff --git a/image/rtl8812cu-driver/8821cu.ko b/image/rtl8812cu-driver/8821cu.ko deleted file mode 100644 index f27530c..0000000 Binary files a/image/rtl8812cu-driver/8821cu.ko and /dev/null differ diff --git a/rtl8821cu-driver/Dockerfile b/rtl8821cu-driver/Dockerfile new file mode 100644 index 0000000..124df02 --- /dev/null +++ b/rtl8821cu-driver/Dockerfile @@ -0,0 +1,3 @@ +FROM --platform=amd64 ubuntu:20.04 +COPY setup.sh /root +RUN ["bash", "-c", "chmod 755 /root/setup.sh && exec /root/setup.sh"] \ No newline at end of file diff --git a/rtl8821cu-driver/setup.sh b/rtl8821cu-driver/setup.sh new file mode 100644 index 0000000..877465e --- /dev/null +++ b/rtl8821cu-driver/setup.sh @@ -0,0 +1,50 @@ +#!/usr/bin/bash +set -euxo pipefail + +GNU_PATH="/usr/lib/x86_64-linux-gnu" +WORKDIR="$HOME/work" + +# Install dependencies +apt-get update +apt-get install -y software-properties-common +apt-add-repository ppa:ev3dev/tools +apt-get install -y wget git build-essential ncurses-dev fakeroot bc u-boot-tools lzop flex bison libssl-dev gcc-arm-linux-gnueabihf + +wget https://releases.linaro.org/components/toolchain/binaries/6.4-2018.05/arm-linux-gnueabihf/gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz +tar xf gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz +mv gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf "$GNU_PATH/gcc-linaro-arm-linux-gnueabihf-6.4" + +# Fix error due to deprecated git:// protocol on GitHub +git config --global url."https://".insteadOf git:// + +# Create working directory +mkdir -p $WORKDIR +cd $WORKDIR + +# Clone environment +git clone --depth 1 --recursive --branch ev3dev-stretch https://github.com/ev3dev/ev3dev-buildscripts.git +git clone --depth 1 --recursive --branch ev3dev-stretch https://github.com/ev3dev/ev3-kernel.git + +# Update submodule +cd ev3-kernel/drivers/lego +git pull origin ev3dev-stretch +cd $WORKDIR + +# Build the EV3 kernel +cd ev3dev-buildscripts +echo "export EV3DEV_MAKE_ARGS=-j$(nproc)" > local-env +./build-kernel +cd $WORKDIR + +# Download Wi-Fi driver +git clone --depth 1 https://gitee.com/coolflyreg163/rtl8821cu.git +cd rtl8821cu + +# Compile Wi-Fi driver +BIN_PATH="$GNU_PATH/gcc-linaro-arm-linux-gnueabihf-6.4/bin" +make ARCH=arm KVER=4.14 \ +KSRC="$WORKDIR/ev3dev-buildscripts/build-area/linux-ev3dev-ev3-obj" \ +CC="$BIN_PATH/arm-linux-gnueabihf-gcc" \ +LD="$BIN_PATH/arm-linux-gnueabihf-ld" + +