User avatar
MartyMacGyver
Posts: 32
Joined: Sat Jan 26, 2013 1:37 am

Solutions to RPi 3 migration issues (incl. Bluetooth & O.C.)

Sat Mar 26, 2016 8:57 am

When migrating from the RPi 2 to the RPi 3 there are some things to consider if you want to be able to boot, let alone have Bluetooth working and your system properly optimized (or at least no longer optimized for Pi 2 specs!) Below I cover the issues I found and solved during my migration to the RPi 3 today.

My starting point: Raspbian Jessie on the RPi 2 with the latest software and firmware updates. YMMV if you are using other distributions! Bluetooth 4.0 and BLE (Bluetooth Low Energy) was working fine with the Plugable adapter.

I just received my Pi3 so I shut down the Pi2, cloned the card (backups are nice!) and popped it into the Pi3. You'll notice the lack of a spring in there - this change gives a better electrical connection.

Note: As part of this, I switched from my usual SanDisk to a Samsung EVO Plus 32 GB card because I'd read that it's got the best overall mix of 4K R/W speeds along with large block R/W speeds of any Micro SD card out there. So far so good, but YMMV. (Read more at http://www.jeffgeerling.com/blogs/jeff- ... crosd-card)

I booted the cloned SD on the Pi 3 and changed the hostname right away. Edit /etc/hosts and /etc/hostname similarly to accomplish this. Rebooted again after that.

SInce I'm not using the Plugable BLE adapter on the 3, I tried the native bluetooth - and it failed miserably - it couldn't even see the controller! (and no, lsusb won't help here - neither WiFI nor BT are on the USB bus on the RPi 3). hcitool lescan was telling me about a "Set scan parameters failed: File descriptor in bad state". I searched around and found some Q&A but nothing that helped me.

I found the pi-bluetooth and bluez-firmware packages to be the crucial difference between the Pi 3 and the Pi 2 (h/t to
https://www.pi-supply.com/make/fix-rasp ... 16fd43adaa for calling this out. From other readings I thought that pi-bluetooth was just an aggregate of the discrete packages, but evidently not.)

So, in a nutshell:

Before you migrate from Pi2:

Code: Select all

sudo apt-get update
sudo apt-get updgrade -y
sudo apt-get dist-upgrade -y
Reboot, check, and shut down. (Now's a great time to back it up!)

Plug the SD card or its clone into the Pi3, then:

Update /etc/hosts and /etc/hostname (then reboot) if you plan to keep using your Pi 2 as well

Then:

Code: Select all

sudo apt-get purge bluez-utils blueman bluez bluez-firmware pi-bluetooth
sudo apt-get install blueman bluez  # RPi 2
sudo apt-get install blueman bluez bluez-firmware pi-bluetooth  # RPi 3
sudo usermod -G bluetooth -a pi  # Or it won't work
cat /etc/group | grep bluetooth
sudo service bluetooth status

# Reboot

# Test
sudo service bluetooth status
rfkill list
sudo hcitool lescan
bluetoothctl
I just tested this and once I did the pi-bluetooth step it just worked. I then purged and reinstalled the bluetooth stack as above and *after* the reboot it worked fine for me once again. Tested an app I've been working on and it worked fine communicating with an external device via BLE.

Overclocking and defaults:

If you ever configured your overclock settings (to defaults or otherwise) in /boot/config.txt, don't forget to comment out those overclock settings or update them to the new defaults! (I had mine optimized for the RPi 2... settings which worked on the RPi 3 but basically throttled it down from its defaults!)

Code: Select all

# Pi3 defaults
arm_freq=1200
core_freq=400
sdram_freq=450
These were found at https://retroresolution.com/2016/03/24/ ... rformance/

I chose to use the slightly more aggressive settings below - Bluetooth worked fine after the reboot. YMMV as always (remember that in a pinch you can directly edit config.txt after mounting the SD card as a drive in your computer - this makes it easy to undo or comment out undesirable config modifications, such as the sort that don't allow a stable bootup!):

Code: Select all

# Pi3 OC
arm_freq=1350
core_freq=500
sdram_freq=450
over_voltage=4
You can check the current CPU frequency settings and temp as follows:

Code: Select all

sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
/opt/vc/bin/vcgencmd measure_temp
lscpu

louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Re: Solutions to RPi 3 migration issues (incl. Bluetooth & O

Sat Mar 18, 2017 6:40 pm

Thanks for your detailed post.
unfortunately none of this worked for me - I still get "Set scan parameters failed: File descriptor in bad state"

back to searching ..

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26659
Joined: Sat Jul 30, 2011 7:41 pm

Re: Solutions to RPi 3 migration issues (incl. Bluetooth & O

Sat Mar 18, 2017 6:45 pm

louiscar wrote:Thanks for your detailed post.
unfortunately none of this worked for me - I still get "Set scan parameters failed: File descriptor in bad state"

back to searching ..

What are you trying to do and where/when do you get the error?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Re: Solutions to RPi 3 migration issues (incl. Bluetooth & O

Sat Mar 18, 2017 7:45 pm

Hi jamesh,

I'm trying to get the internal bluetooth adapter to work. I've followed the OPs instructions to the letter and also tried an rpi-update.

"sudo hcitool lescan" will give the error I specified above.

curiously before I began this, the GUI had a greyed out bluetooth icon. After doing the above I get a seemingly active bluetooth icon but in addition to the greyed one. It allows me to turn bluetooth on but has no scan option / discovery option and selecting devices will tell me no adapter found.

Return to “General discussion”