diff mbox series

[2/2] board: amarula: a64-relic: Add WiFi support

Message ID 20180528171227.8352-2-jagan@amarulasolutions.com
State Superseded
Headers show
Series [1/2] board: amarula: Add A64-Relic support | expand

Commit Message

Jagan Teki May 28, 2018, 5:12 p.m. UTC
Amarula A64-Relic board has AP6330 WiFi/BT combo, but does
not have ethernet port. So it makes sense to enable wireless
networking by default:
- add broadcom wireless firmware package to image
- add basic wireless tools to image
- add rootfs overlay with proper NVRAM file for on-board AP6330 chip
- add init script to load modules
- update readme.txt to test wifi

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 board/amarula/a64-relic/readme.txt                 |  9 +++
 .../rootfs_overlay/etc/init.d/S02-modload          | 12 ++++
 .../rootfs_overlay/etc/modules-load.d/modules.conf |  1 +
 .../lib/firmware/brcm/brcmfmac4330-sdio.txt        | 83 ++++++++++++++++++++++
 configs/amarula_a64_relic_defconfig                | 12 ++++
 5 files changed, 117 insertions(+)
 create mode 100755 board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload
 create mode 100644 board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf
 create mode 100644 board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt

Comments

Arnout Vandecappelle May 30, 2018, 9:40 p.m. UTC | #1
On 28-05-18 19:12, Jagan Teki wrote:
> Amarula A64-Relic board has AP6330 WiFi/BT combo, but does
> not have ethernet port. So it makes sense to enable wireless
> networking by default:
> - add broadcom wireless firmware package to image
> - add basic wireless tools to image
> - add rootfs overlay with proper NVRAM file for on-board AP6330 chip
> - add init script to load modules
> - update readme.txt to test wifi
> 
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  board/amarula/a64-relic/readme.txt                 |  9 +++
>  .../rootfs_overlay/etc/init.d/S02-modload          | 12 ++++
>  .../rootfs_overlay/etc/modules-load.d/modules.conf |  1 +
>  .../lib/firmware/brcm/brcmfmac4330-sdio.txt        | 83 ++++++++++++++++++++++
>  configs/amarula_a64_relic_defconfig                | 12 ++++
>  5 files changed, 117 insertions(+)
>  create mode 100755 board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload
>  create mode 100644 board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf
>  create mode 100644 board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt
> 
> diff --git a/board/amarula/a64-relic/readme.txt b/board/amarula/a64-relic/readme.txt
> index 534ed32e7b..18824e1669 100644
> --- a/board/amarula/a64-relic/readme.txt
> +++ b/board/amarula/a64-relic/readme.txt
> @@ -57,4 +57,13 @@ GPT:
>    $ fastboot -i 0x1f3a flash esp boot.vfat
>    $ fastboot -i 0x1f3a flash system rootfs.ext2
>  
> +WiFi
> +====
> +

 Maybe add a little bit of text here. "To use the WiFi, you need to configure
your accesspoint first. Log in over the serial port, then type:"

> + # wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
> +   (type password and enter)
> + # wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
> + # udhcpc -i wlan0

 Could we add the latter two to an init script instead? Should be S40 so it
coincides with S40network from ifupdown-scripts.

 So in the readme, these two lines would then be replaced with

# /etc/init.d/S40wlan start

> + # ping google.com
> +
>  Enjoy!
> diff --git a/board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload b/board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload
> new file mode 100755
> index 0000000000..81d85ce01c
> --- /dev/null
> +++ b/board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload
> @@ -0,0 +1,12 @@
> +#!/bin/sh
> +#
> +
> +load_modules()
> +{
> +	while IFS= read -r line; do
> +		modprobe -a $line
> +	done < "/etc/modules-load.d/modules.conf"
> +}
> +
> +load_modules
> +echo "Loading modules: OK"

 Init scripts should handle the start and stop arguments, otherwise the module
will be loaded again during shutdown.

 Also, I don't think it makes a lot of sense to introduce all this flexibility.
Just include 'modprobe -a brcmfmac' to S40wlan.

> diff --git a/board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf b/board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf
> new file mode 100644
> index 0000000000..a86ef4c668
> --- /dev/null
> +++ b/board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf
> @@ -0,0 +1 @@
> +brcmfmac
> diff --git a/board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt b/board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt
> new file mode 100644
> index 0000000000..d095f24c26
> --- /dev/null
> +++ b/board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt
> @@ -0,0 +1,83 @@
> +#AP6330_NVRAM_V1.0_20121130
> +#Sample variables file for BCM94330 SD FC AGB board

 Arg, these horrible brcm config files...


 Regards,
 Arnout

[snip]
Thomas Petazzoni May 31, 2018, 6:57 a.m. UTC | #2
Hello,

On Wed, 30 May 2018 23:40:59 +0200, Arnout Vandecappelle wrote:

> > + # wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
> > +   (type password and enter)
> > + # wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
> > + # udhcpc -i wlan0  
> 
>  Could we add the latter two to an init script instead? Should be S40 so it
> coincides with S40network from ifupdown-scripts.
> 
>  So in the readme, these two lines would then be replaced with
> 
> # /etc/init.d/S40wlan start

I'm not sure how that would work. You first need to enter the
passphrase for the WiFi chip to associate with the AP, and therefore
before doing the udhcp.

So when you suggest to replace the last two lines by
"/etc/init.d/S40wlan start", how is this going to work considering that
starting the S40wlan script has already been done at boot time ?

> > +load_modules()
> > +{
> > +	while IFS= read -r line; do
> > +		modprobe -a $line
> > +	done < "/etc/modules-load.d/modules.conf"
> > +}
> > +
> > +load_modules
> > +echo "Loading modules: OK"  
> 
>  Init scripts should handle the start and stop arguments, otherwise the module
> will be loaded again during shutdown.
> 
>  Also, I don't think it makes a lot of sense to introduce all this flexibility.
> Just include 'modprobe -a brcmfmac' to S40wlan.

Not directly related to Jagan's submission, but we do have this need to
load modules at startup for a number of platforms. Isn't it time to
have a generic init script that reads /etc/modules for this ? It's also
a question that has been asked a number of times on IRC: "how do I ask
my Buildroot system to load a kernel module at startup". Of course the
answer is simple: add an init script, but since the question has been
asked many times, perhaps it's worth adding some generic script ?

Or maybe in this case mdev support should be enabled to ensure modules
are loaded automatically ?

Best regards,

Thomas
Arnout Vandecappelle May 31, 2018, 7:22 a.m. UTC | #3
On 31-05-18 08:57, Thomas Petazzoni wrote:
> Hello,
> 
> On Wed, 30 May 2018 23:40:59 +0200, Arnout Vandecappelle wrote:
> 
>>> + # wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
>>> +   (type password and enter)
>>> + # wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
>>> + # udhcpc -i wlan0

 I notice now that it was just copied from warp7 :-)

>>
>>  Could we add the latter two to an init script instead? Should be S40 so it
>> coincides with S40network from ifupdown-scripts.
>>
>>  So in the readme, these two lines would then be replaced with
>>
>> # /etc/init.d/S40wlan start
> 
> I'm not sure how that would work. You first need to enter the
> passphrase for the WiFi chip to associate with the AP, and therefore
> before doing the udhcp.
> 
> So when you suggest to replace the last two lines by
> "/etc/init.d/S40wlan start", how is this going to work considering that
> starting the S40wlan script has already been done at boot time ?

 If no ssid/password is configured, wpa_supplicant will just not connect, it
will just run as daemon. Same for udhcpc, it will just retry until the interface
is up.

 But you're right: it should be restart instead of start, so that the running
wpa_supplicant and udhcpc are killed before restarting them.


>>> +load_modules()
>>> +{
>>> +	while IFS= read -r line; do
>>> +		modprobe -a $line
>>> +	done < "/etc/modules-load.d/modules.conf"
>>> +}
>>> +
>>> +load_modules
>>> +echo "Loading modules: OK"  
>>
>>  Init scripts should handle the start and stop arguments, otherwise the module
>> will be loaded again during shutdown.
>>
>>  Also, I don't think it makes a lot of sense to introduce all this flexibility.
>> Just include 'modprobe -a brcmfmac' to S40wlan.
> 
> Not directly related to Jagan's submission, but we do have this need to
> load modules at startup for a number of platforms. Isn't it time to
> have a generic init script that reads /etc/modules for this ? It's also
> a question that has been asked a number of times on IRC: "how do I ask
> my Buildroot system to load a kernel module at startup". Of course the
> answer is simple: add an init script, but since the question has been
> asked many times, perhaps it's worth adding some generic script ?

 Yes indeed. Perhaps a separate package like ifupdown-scripts. It should
probably depend on !UDEV.

 This could also be used for arcturus then.

> Or maybe in this case mdev support should be enabled to ensure modules
> are loaded automatically ?

 Probably, yes, since in most cases you need firmware as well. Actually, good
point: isn't mdev needed anyway to load the firmware? Oh, right, the kernel will
autoload since 4.something so all the defconfigs we have that add mdev "For
automatic firmware loading" are actually wrong...

 But yes, mdev is probably the easier way.

 Regards,
 Arnout
diff mbox series

Patch

diff --git a/board/amarula/a64-relic/readme.txt b/board/amarula/a64-relic/readme.txt
index 534ed32e7b..18824e1669 100644
--- a/board/amarula/a64-relic/readme.txt
+++ b/board/amarula/a64-relic/readme.txt
@@ -57,4 +57,13 @@  GPT:
   $ fastboot -i 0x1f3a flash esp boot.vfat
   $ fastboot -i 0x1f3a flash system rootfs.ext2
 
+WiFi
+====
+
+ # wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
+   (type password and enter)
+ # wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
+ # udhcpc -i wlan0
+ # ping google.com
+
 Enjoy!
diff --git a/board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload b/board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload
new file mode 100755
index 0000000000..81d85ce01c
--- /dev/null
+++ b/board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload
@@ -0,0 +1,12 @@ 
+#!/bin/sh
+#
+
+load_modules()
+{
+	while IFS= read -r line; do
+		modprobe -a $line
+	done < "/etc/modules-load.d/modules.conf"
+}
+
+load_modules
+echo "Loading modules: OK"
diff --git a/board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf b/board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf
new file mode 100644
index 0000000000..a86ef4c668
--- /dev/null
+++ b/board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf
@@ -0,0 +1 @@ 
+brcmfmac
diff --git a/board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt b/board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt
new file mode 100644
index 0000000000..d095f24c26
--- /dev/null
+++ b/board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt
@@ -0,0 +1,83 @@ 
+#AP6330_NVRAM_V1.0_20121130
+#Sample variables file for BCM94330 SD FC AGB board
+manfid=0x2d0
+prodid=0x0547
+vendid=0x14e4
+devid=0x4360
+boardtype=0x05e1
+boardrev=0x1202
+boardflags=0x0080200
+nocrc=1
+xtalfreq=26000
+boardnum=22
+macaddr=00:90:4c:c5:12:38
+ag0=254
+aa2g=1
+ccode=ALL
+pa0itssit=0x20
+pa0b0=5587
+pa0b1=-633
+pa0b2=-158
+rssismf2g=0xa
+rssismc2g=0x3
+rssisav2g=0x7
+#rssi params for 5GHz
+rssismf5g=0x4
+rssismc5g=0x3
+rssisav5g=0x7
+#PA parameters for lower a-band
+pa1lob0=4748
+pa1lob1=-566
+pa1lob2=-180
+#PA parameters for midband
+pa1b0=4762
+pa1b1=-593
+pa1b2=-172
+#PA parameters for high band
+#pa1hib0=4596
+pa1hib0=4666
+pa1hib1=-619
+pa1hib2=-163
+rxpo5g=0
+maxp2ga0=74
+maxp5ga0=66
+maxp5gla0=66
+maxp5gha0=66
+# 2.4G Tx Power offsets
+cck2gpo=0x2222
+ofdm2gpo=0x44444444
+mcs2gpo0=0x6666
+mcs2gpo1=0x6666
+# 5G Tx Power offsets
+ofdm5gpo=0x44444444
+ofdm5glpo=0x44444444
+ofdm5ghpo=0x44444444
+mcs5gpo0=0x6666
+mcs5gpo1=0x6666
+mcs5glpo0=0x6666
+mcs5glpo1=0x6666
+mcs5ghpo0=0x6666
+mcs5ghpo1=0x6666
+sromrev=3
+il0macaddr=00:90:4c:c5:12:38
+wl0id=0x431b
+cckPwrOffset=4
+swctrlmap_2g=0x44844484,0x42824282,0x40804484,0x18282,0x1ff
+triso5g=0
+swctrlmap_5g=0x00100010,0x20202020,0x20202020,0x14202,0x0f0
+rfreg033=0x19
+rfreg033_cck=0x1f
+dacrate2g=160
+dacrate5g=160
+txalpfbyp2g=1
+bphyscale=17
+cckPwrIdxCorr=-15
+pacalidx2g=50
+#pacalidx5g=20
+noise_cal_ref_2g=53
+noise_cal_po_2g=0
+noise_cal_ref_5g=52
+noise_cal_po_5g=5,0,0
+# 4330 OOB parameter: High level trigger
+muxenab=0x10
+
diff --git a/configs/amarula_a64_relic_defconfig b/configs/amarula_a64_relic_defconfig
index 07f1a72363..d1da97ed5c 100644
--- a/configs/amarula_a64_relic_defconfig
+++ b/configs/amarula_a64_relic_defconfig
@@ -45,3 +45,15 @@  BR2_PACKAGE_HOST_MTOOLS=y
 BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
 BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/amarula/a64-relic/genimage.cfg"
 BR2_ROOTFS_POST_BUILD_SCRIPT="board/amarula/a64-relic/post-build.sh"
+BR2_ROOTFS_OVERLAY="board/amarula/a64-relic/rootfs_overlay"
+
+# wireless firmware
+BR2_PACKAGE_LINUX_FIRMWARE=y
+BR2_PACKAGE_LINUX_FIRMWARE_BRCM_BCM43XX=y
+
+# wireless tools
+BR2_PACKAGE_IW=y
+BR2_PACKAGE_WPA_SUPPLICANT=y
+BR2_PACKAGE_WPA_SUPPLICANT_NL80211=y
+BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y
+BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y