Giter VIP home page Giter VIP logo

blwnet_xram's Introduction

blwnet_xram

Linux virtual Ethernet driver and utility enabling BL808 Linux to use on-chip Wi-Fi

Overview

The entire software is mainly divided into two parts: M0 firmware and Linux software. The M0 firmware runs the Wi-Fi protocol stack, providing a virtual Ethernet interface. The Linux software connects this Ethernet interface to the Linux system, utilizing the Wi-Fi functionality provided by M0.

blwnet_xram itself manages the Ethernet interface and command channel, and is divided into two parts: the kernel driver and the user-space control program. The driver communicates downwards with M0 through shared memory and IPC, and communicates upwards with the user-space control program via netlink socket.

The driver will create two interfaces: bleth0 for STA (Station) and bleth1 for AP (Access Point). The program blctl is used for control, such as sending association and scan commands, among others.

At present, STA, AP and STA/AP mixed modes are supported.

Get started

This section provides a quick guide to experience Wi-Fi functionality. For instructions on compiling the related binary files, please refer to the next section.

  1. Environment requirements
  • Linux PC
  • BL808 board with >= 8MB flash(tested: Sipeed M1S)
  1. Download bl_iot_sdk
git clone --recursive [email protected]:bouffalolab/bl_iot_sdk.git
  1. Build M0 and D0 firmwares
cd bl_iot_sdk/customer_app/bl808/bl808_demo_linux
./build_all

romfs/c906.bin and bl808_demo_linux.bin will be generated.

  1. Burn bins to chip
  • Open Bouffalo Lab Dev Cube, which can be obtained from https://dev.bouffalolab.com/download
  • Select chip mode to BL808
  • Refer to the diagram below for configuring the burning options. Alt text
  • Make BL808 enter flashing mode
  • Click "Create & Download"
  1. Reset BL808
  • M0 firmware will boot Linux. Linux console should be available on D0 UART(PIN 16, 17).
  1. Use Wi-Fi
  • First load the kernel module

    insmod blwnet.ko
  • Use blctl to send commands

    Scan

    ./blctl wifi_scan

    Obtain scan results

    ./blctl wifi_scan_results

    Connect to AP

    ./blctl connect_ap <ssid> [password]

    Once connected, obtain IP addresses via DHCP

    udhcpc -i bleth0

    Start AP

    [CHANNEL=chn] ./blctl start_ap <ssid> [password]
    ifconfig bleth1 192.169.99.1
    udhcpd udhcpd.conf

    For more command options, see output of:

    ./blctl

How to build bins

hw.dtb

# hw808c.dts is located in bl_iot_sdk/customer_app/bl808/bl808_demo_linux
dtc -I dts -O dtb -o hw.dtb hw808c.dts

OpenSBI & Kernel Image

Refer to https://github.com/bouffalolab/bl808_linux.

Main steps:

Kernel Image

cp c906.config .config
make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- menuconfig # enter menuconfig, change nothing, save&exit
make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- Image
xz --check=crc32 --lzma2=dict=32KiB -k arch/riscv/boot/Image

arch/riscv/boot/Image.xz will be generated.

OpenSBI

Note that PINMUX might need to be changed. See https://github.com/bouffalolab/bl808_linux/blob/main/patch/m1sdock/m1sdock_uart_pin_def.patch.

Kernel address is at 0x50200000: change FW_JUMP_ADDR in platform/thead/c910/config.mk.

Kernel driver blwnet.ko and utility blctl

  1. First make sure that you can build kernel image in the previous step
  2. Make a complete build of kernel. This is crucial for building the out-of-tree kernel module.
cd bl808_linux/linux-5.10.4-808/
make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- -j
  1. Build driver and utility
cd blwnet_xram
# Replace <kernel_dir> with kernel path in the previous step
make CONFIG_BL_INTF=XRAM KDIR=<kernel_dir> ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- CC=riscv64-unknown-linux-gnu-gcc AR=riscv64-unknown-linux-gnu-ar -j

blwnet.ko and userspace/blctl will be generated.

rootfs.cpio.gz

Not available at the moment.

Known issues

  • Some blctl sub commands might not work. For example: OTA is not tested.
  • Interface carrier state will be lost if set down and up manually.
  • Linux clock may be far from accurate.

blwnet_xram's People

Contributors

fangzheli avatar ivq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.