RedBear IOT pHAT for WiFi and BT

I just got hold of one of these boards (GitHub - redbear/IoT_pHAT: WiFi + Bluetooth, designed for the Raspberry Pi Zero) and am looking to use it with OSMC on a Pi Zero (1.3). From what I have read the board uses the same chipset as the on-board WiFi and BT on the new Pi 3 and should work under Raspbian.

I have been through the steps to update the EEPROM firmware using OSMC and that all worked well. The correct firmware version is shown when running:

cat /proc/device-tree/hat/product

Running:

ifconfig

Does not list it as a piece of hardware.

I am wondering what might be missing from OSMC that is required to get it setup. This post suggests WiringPi is required (which I am building now) and I have set the following in my config.txt:

init_uart_clock=48000000
dtparam=i2c_arm=on 

Any suggestions would be much appreciated.

Hi

Let me know what CONFIG_ options to add and I’ll get it included.

This won’t reach OSMC’s August update (which is scheduled for tomorrow), but I can produce a kernel with support and get you to test it just after then.

Sam

Thanks Sam, much appreciated.

I fired up a standard install of Raspbian to see if I could spot the differences. Running vcgencmd get_config int showed a similar config to OSMC:

Raspbian:

arm_freq=1000
audio_pwm_mode=1
config_hdmi_boost=5
core_freq=400
disable_auto_turbo=1
disable_commandline_tags=2
force_eeprom_read=1
force_pwm_open=1
framebuffer_ignore_alpha=1
framebuffer_swap=1
gpu_freq=300
hdmi_force_cec_address=65535
ignore_lcd=1
init_uart_clock=0x2dc6c0
over_voltage_avs=0x249f0
overscan_bottom=32
overscan_left=32
overscan_right=32
overscan_top=32
pause_burst_frames=1
program_serial_random=1
sdram_freq=450
temp_limit=85

OSMC:

arm_freq=850
audio_pwm_mode=1
config_hdmi_boost=5
core_freq=375
disable_auto_turbo=1
disable_commandline_tags=2
disable_splash=1
force_eeprom_read=1
force_pwm_open=1
framebuffer_ignore_alpha=1
framebuffer_swap=1
gpu_freq=300
hdmi_force_cec_address=65535
hdmi_ignore_cec_init=1
ignore_lcd=1
init_uart_clock=0x2dc6c00
over_voltage_avs=0x249f0
pause_burst_frames=1
program_serial_random=1
sdram_freq=450
sdtv_aspect=1
temp_limit=85

The main difference seems to be around the available kernal modules, lsmod shows:

Raspbian:

bnep                   11853  2 
hci_uart               21122  1 
btbcm                   7885  1 hci_uart
bluetooth             365780  8 bnep,btbcm,hci_uart
ax88179_178a           16089  0 
sg                     20799  0 
brcmfmac              202038  0 
snd_bcm2835            23163  0 
brcmutil                9031  1 brcmfmac
snd_pcm                95441  1 snd_bcm2835
snd_timer              22396  1 snd_pcm
snd                    68368  3 snd_bcm2835,snd_timer,snd_pcm
cfg80211              499234  1 brcmfmac
rfkill                 21397  4 cfg80211,bluetooth
bcm2835_gpiomem         3823  0 
bcm2835_wdt             4133  0 
uio_pdrv_genirq         3718  0 
uio                    10230  1 uio_pdrv_genirq
ipv6                  367607  24 

OSMC:

8021q                  21672  0 
garp                    7807  1 8021q
stp                     2218  1 garp
llc                     5918  2 stp,garp
uas                    17270  0 
ax88179_178a           24752  0 
snd_bcm2835            23591  0 
snd_pcm               115645  1 snd_bcm2835
snd_timer              28675  1 snd_pcm
bcm2835_thermal         2435  0 
snd                    79485  3 snd_bcm2835,snd_timer,snd_pcm
i2c_bcm2708             5964  0 
bcm2835_gpiomem         3823  0 
bcm2835_wdt             4197  0 
uio_pdrv_genirq         3846  0 
uio                    10288  1 uio_pdrv_genirq
sg                     23990  0 
md_mod                165493  0 
fuse                  111723  1 
ipv6                  433779  40 

If there is anything I should be looking for specifically then let me know.

Here is what I think I need for this to work. I have not found a way to test it just yet:

  • CONFIG_BT_HCIBTSDIO
  • CONFIG_BT_HCIUART
  • CONFIG_BRCMSMAC
  • CONFIG_BRCMFMAC_SDIO

and possibly:

  • CONFIG_BRCMSTB_GISB_ARB

I can see that I can modify these in /boot/config-4.4.16-4-osmc, would I need to re-compile the kernel in order for these changes to be reflected? (this is all new to me).

My OSMC remote has arrived so I am looking forward to getting this up and running :slight_smile:

  • All included (apart from SoftMAC maybe?)

Here’s the best way to do it all:

I understand this is brief, but you’ll likely work it out :slight_smile:

Edit: just refreshed my memory, if build for a Pi Zero, you want rbp1, but I’d also like to see support added for rbp2/rbp3 if applicable.

Sam

Can I double check this step @sam_nazarko - it seems to wipe out the entire rbp1-000-add-kernel-config.patch file. I am running: diff -u /dev/null .config > rbp1-000-add-kernel-config.patch and it comes back with diff: .config: No such file or directory. I created the file .config and then they both end up blank.

I have compared the current RBP1 and RBP2 configs and whilst these settings are mostly present in RBP2 they are missing from RBP1, so I think this could well be the changes I need.

I also interested to make it work in OSMC. I’ve heavily customized my OSMC and dont want to change OS or install from scratch. Looking forward for the solution

You need the .config file to be present in the kernel sources directory.

They’re in RBP2 because of the integrated WiFi and BT modules on the Pi 3. The Pi 3 and Pi 2 have the same kernel.

Sam

So here is the process have gone through:

  • Install git sudo apt-get install build-essential git
  • Grab the repo git clone https://github.com/osmc/osmc
  • Move /boot/config-4.4.16-4-osmc to ~/osmc/package/kernel-osmc/patches/.config
  • cd ~/osmc/package/kernel-osmc/patches/
  • Edit the new .config file I have just created with my new settings (to reflect Pi2/3)
  • diff -u /dev/null .config > rbp1-000-add-kernel-config.patch
  • cd ~/osmc/package/kernel-osmc/
  • make rbp1

I am now waiting for it to build. It is taking a while and seems to be installing all sorts of stuff.

This isn’t correct.

You shouldn’t manually edit the config. You need to run make menuconfig and diff against the new config.

Thanks for all your help and patience on this Sam. I think I might be missing a dependency on my Pi. I get make: *** No rule to make target 'menuconfig'. Stop. From what I have read, the Makefiles should contain a menuconfig entry, but I am not seeing any of those in the OSMC repo. Do you know what I am missing?

You need to pull the kernel source first.

So I grabbed the kernel source from https://github.com/raspberrypi/linux.git with git clone --depth 1 https://github.com/raspberrypi/linux.git.

Attempting make menuconfig resulted in:

make menuconfig
  HOSTCC  scripts/basic/fixdep
scripts/basic/fixdep.c:444:1: fatal error: opening dependency file scripts/basic/.fixdep.d: Permission denied
 }
 ^
compilation terminated.

I am going to have a break I think :dizzy_face:

Managed to make some progress following the kernel compile guides here: Kernel building - Raspberry Pi Documentation and generated a new config using make menuconfig late last night. Left the build going over night but lost my SSH connection in the night and it does not look like it completed.

Running again now and I am guessing it will be ready in about 5 hours or so, hoping all will be well this time.

It would be great if there was a way to patch the kernel rather than rebuild from scratch as the Pi is so slow.

The build system uses ccache, so when you’re on the right track, compilation is about an hour with a fast SD card.

That’s not quite right, because you won’t necessarily be making a config against the kernel version we use and you won’t be using our patches which add some drivers (CONFIG_) options.

The best way is to run make rbp2 once and let it build with the OSMC config. You will then have a complete source tree under src/ and you can run make menuconfig, make your adjustments, diff -u /dev/null .config, drop it in patches and re-run make.

Sam

Hi Sam,

It is possible to include this fix on the next OSMC update? I’m sure were not only two person have this board. thanks in advance.

When I know what needs to be done to add support (i.e which kernel config options), sure

Thanks! look forward on this. If you need someone with this board to beta test, just let me know. thanks!

What we need is someone to work out exactly what needs to be done and actually contribute to add support. Sam requested this above…

I’ve given as detailed information as I can without a board.