OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Sep 22, 2017 6:09 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: building WiFi support
PostPosted: Sat Sep 09, 2017 2:52 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 133
Hi

Where to start if I have to start building support for wireless network from scratch ?

For example, I have been able to code XHCI driver from scratch by going through intel manual and support USB MSD and Keyboard - all coded from scratch (also referred Ben's book)

Similarly, where to start if I need to support Wi-Fi ? i.e. to code low level device driver and then building other higher network protocol layers.. is that even practical ? How long (months and years) it might take if I get required documents and source code references (say from Linux kernel) ? say if I can spend max 1 hr a day for this

I prefer to do it from scratch as my intention is to learn and explore - but wonder if that's practical in case of network support... ! if it's not then what options do I have in order to support Wi-Fi in my kernel ?

Thanks
Prajwal

_________________
complexity is the core of simplicity


Top
 Profile  
 
 Post subject: Re: building WiFi support
PostPosted: Sat Sep 09, 2017 8:30 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 17, 2016 6:58 am
Posts: 68
Location: The Internet
802.11 is the WIFI standard

_________________
Everyone should know how to program a computer, because it teaches you how to think! -Steve Jobs
Code:
while ( ! ( succeed = try() ) );


Top
 Profile  
 
 Post subject: Re: building WiFi support
PostPosted: Sat Sep 09, 2017 8:52 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8089
Location: At his keyboard!
Hi,

prajwal wrote:
Where to start if I have to start building support for wireless network from scratch ?


The first step would be finding a wifi card/chip where programming information is available. For "too many" there isn't any information and even well known OSs (e.g. Linux) struggle to provide bare minimum support. It's not like USB where there's only 4 (easily obtained) standards that all USB controllers follow.

Beyond that, I have no clue - I use wired ethernet (none of my computers have any wifi). :)

MajickTek wrote:
802.11 is the WIFI standard


If you've got a bag full of transistors and a soldering iron, then that standard would help you to create your own wifi circuit. It won't help you figure out how to write a driver for someone else's wifi circuit/card/chip (e.g. which PCI and/or memory mapped registers do what).


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: building WiFi support
PostPosted: Sat Sep 09, 2017 12:41 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 17, 2016 6:58 am
Posts: 68
Location: The Internet
brendan wrote:
MajickTek wrote:
802.11 is the WIFI standard


If you've got a bag full of transistors and a soldering iron, then that standard would help you to create your own wifi circuit. It won't help you figure out how to write a driver for someone else's wifi circuit/card/chip (e.g. which PCI and/or memory mapped registers do what).


Cheers,

Brendan

Hardware is proprietary, might as well us an open source wifi dongle

_________________
Everyone should know how to program a computer, because it teaches you how to think! -Steve Jobs
Code:
while ( ! ( succeed = try() ) );


Top
 Profile  
 
 Post subject: Re: building WiFi support
PostPosted: Sat Sep 09, 2017 5:31 pm 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 133
ha ha.. ok, its very difficult as I expected :) can't compare it with USB

I have 2 machines with Ubuntu installed.
One has 'Qualcomm Atheros QCA9565 / AR9565 wireless network adapter'
The other has 'Intel Dual Band Wireless-AC 8265 adapter'

1. If not writing code from scratch, would Linux kernel open-source have required code/library/modules that can be ported - is that feasible ?
2. Even if I am able to port, what does the device driver code correspond to in network protocol stack ? the PHY/Data link layer ?
[ I am sorry, I am not familiar with network part ]
3. Appreciate if you can point me to some guide and/or explain (in brief) what are the different layers/protocol stacks to implement to build support up-to TCP/IP ?
4. Which module should I port from Linux open-source and which ones are feasible to write by myself (if any) ? (judging by the level of complexity I can deal with by writing XHCI driver) - in a time-frame say 200 hrs of development

Thanks
Prajwal

_________________
complexity is the core of simplicity


Top
 Profile  
 
 Post subject: Re: building WiFi support
PostPosted: Sat Sep 09, 2017 5:55 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 859
Location: Maadi, Cairo, Egypt
prajwal wrote:
1. If not writing code from scratch, would Linux kernel open-source have required code/library/modules that can be ported - is that feasible ?

I'm sure the Linux drivers can be ported, but I doubt it would be easy. Haiku also has some open-source wireless drivers.

prajwal wrote:
2. Even if I am able to port, what does the device driver code correspond to in network protocol stack ? the PHY/Data link layer ?

Yes. The device driver, whether it's wireless or ethernet transmits and receives packets across the physical network.

prajwal wrote:
3. Appreciate if you can point me to some guide and/or explain (in brief) what are the different layers/protocol stacks to implement to build support up-to TCP/IP ?

A minimalist TCP/IP stack must implement at least IP, ARP, ICMP, UDP and TCP. Of course, you'll need other things to make it practical, like DHCP which will allow you to have an IP address at all, and detect the router, DNS server, and other useful information.

prajwal wrote:
4. Which module should I port from Linux open-source and which ones are feasible to write by myself (if any) ? (judging by the level of complexity I can deal with by writing XHCI driver) - in a time-frame say 200 hrs of development

I can't really answer this question, TBH.

If you want to implement networking, I'd suggest going with ethernet first, because it's much simpler than Wi-Fi, more people here (including myself) have implemented it, and there are more cards which have free specifications. Something relatively easy to start with is the RTL8139 or Intel i8254x cards.

As for the network stack itself, which isn't much different whether it's ethernet or Wi-Fi, you'd implement it in layers. There would be a link layer, which communicates with the ethernet/wireless driver directly to transmit/receive packets using MAC addresses. On top of the link layer, you would implement IP and ARP. ARP allows you to resolve IP addresses into MAC addresses. Just like your ARP layer can request other devices' MAC addresses, it also has to respond when someone requests your MAC address. On top of IP, you would implement the transport/control protocols, UDP, TCP and ICMP. Then you can implement any application-level protocols you'd like, such as DHCP, DNS, HTTP, NTP, and any others you can think of.

You'll definitely need Wireshark, and a dump of all the packets passing through your code. QEMU's "-net dump,file=file.pcap" option will help a lot here. This will help you verify that the network driver works at all.

_________________
Byte me; OS site, source code.
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: building WiFi support
PostPosted: Sat Sep 09, 2017 7:31 pm 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 133
Thanks a lot omarrx024! That was indeed very helpful information.

I was clueless but this post has got me some clarity good enough at-least to start in a proper direction.

More information or help welcome on this topic from all

_________________
complexity is the core of simplicity


Top
 Profile  
 
 Post subject: Re: building WiFi support
PostPosted: Mon Sep 18, 2017 8:52 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 09, 2014 7:11 pm
Posts: 86
Location: Within a meter of a computer
I've looked into this before, so I'd like to think I know a little about the situation. Essentially, you won't find documentation for pretty much any built-in wifi chipset. There are however, a few dongles available which do have their specifications easily obtainable on the internet. So essentially, you'll have to look around and find a dongle chipset that has documentation, they're usually less than $10 on Amazon, so it isn't all too expensive either. You'd be writing a USB device driver for it though, rather than a PCI driver. There is a unified linux driver for current realtek wifi chips, but honestly, the code is difficult to follow and at least to me, it's far more convenient to just write a usb driver than try to figure out the code.

_________________
"If the truth is a cruel mistress, than a lie must be a nice girl"
Working on Cardinal
Find me at #Cardinal-OS on freenode!


Top
 Profile  
 
 Post subject: Re: building WiFi support
PostPosted: Mon Sep 18, 2017 10:06 am 
Online
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 961
Location: Athens, GA, USA
MajickTek wrote:
brendan wrote:
If you've got a bag full of transistors and a soldering iron, then that standard would help you to create your own wifi circuit. It won't help you figure out how to write a driver for someone else's wifi circuit/card/chip (e.g. which PCI and/or memory mapped registers do what).


Cheers,

Brendan

Hardware is proprietary, might as well us an open source wifi dongle


I think you missed Brendan's point. The problem is that the spec tells you how the hardware should behave, in terms of communicating with other wireless devices; it says nothing about the software interface, including whether there is one at all. That is the information you need when writing a driver, and there is no standard to speak of for that.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
μή εἶναι βασιλικήν ἀτραπόν ἐπί γεωμετρίαν
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: frolv, Google [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group