LuisPons
Posts: 5
Joined: Thu Apr 06, 2017 10:31 am

Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 10:47 am

Hello there!
I have been using raspberries in my classes for a few years (I try add more hours each year, as they work really well).
I teach low level programming, but I am mostly centered on optimization.

The RPi3 has all I need for my purposes, it's superscalar, has a modern floating point unit and even a decent vector unit, all under a simple and efficient instruction set.

My problem is the CPU keeps switching from 600 to 1200 mhz in order to save power. This makes my task very difficuly, as I try to teach my students how to properly order instructions for maximum performance. As the clock dances from one freq. to another, all measurements go to hell.

In other systems, if you load the CPU for a few ms, the clock keeps in boost or high speed mode. Not in the case of the RPi3, which seems to be configured to go low speed even if some pipelines are not busy (that's my feeling at least).

Is it possible to configure the OS in order to estabilize it in low or high speed? I just need to keep it's operation as predictable as possible for education purposes.
Consistent 600 mhz would be ok; 1200 mhz would be nice to have.

User avatar
mikronauts
Posts: 2637
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 4:00 pm

put force_turbo=1 into /boot/config.txt

http://elinux.org/RPiconfig#force_turbo_mode
LuisPons wrote: My problem is the CPU keeps switching from 600 to 1200 mhz in order to save power. This makes my task very difficuly, as I try to teach my students how to properly order instructions for maximum performance. As the clock dances from one freq. to another, all measurements go to hell.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

LuisPons
Posts: 5
Joined: Thu Apr 06, 2017 10:31 am

Re: Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 5:03 pm

Thanks, mikronauts.

I want to try arm_freq=600 and force_turbo=1. This should freeze the clock at 600 mhz, I guess.

Now I have the most stupid problem; I cannot modify the boot/config.txt file in any way. I am trying both the Raspbian PIXEL (updated las week) and a PC using Ubuntu. I use sudo in all cases.
I modify the file and check the content (cat boot/config.txt). Everything seems OK.
If I eject the sdcard and plug it in again, the file shows the original content. No modification.

W. H. Heydt
Posts: 8868
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 5:11 pm

LuisPons wrote:Thanks, mikronauts.

I want to try arm_freq=600 and force_turbo=1. This should freeze the clock at 600 mhz, I guess.
The Pi2Bv1.2 (aka Pi2B2) uses the same SoC and defaults to 900MHz, so it should be safe to force that speed. A test under load while monitoring the CPU temp would show if you're going to have problems.
Now I have the most stupid problem; I cannot modify the boot/config.txt file in any way. I am trying both the Raspbian PIXEL (updated las week) and a PC using Ubuntu. I use sudo in all cases.
I modify the file and check the content (cat boot/config.txt). Everything seems OK.
If I eject the sdcard and plug it in again, the file shows the original content. No modification.
What is your working directory when you do the editing? (The command 'pwd' will show it.) If you're not in /boot, you'll need to use the full path. I.e. from /home/pi, I would use 'sudo vi /boot/config.txt', whereas from /boot, i would use 'sudo vi config.txt'. Substitute your editor of choice for 'vi'. (Being sure to save the file when I'm done, of course.)

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5147
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 5:29 pm

An alternative method would be to change the cpufreq governor which handles the switching to turbo mode:

Code: Select all

echo powersave | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
powersave mode will run at the lower frequency (600MHz) always.
ondemand will dynamically switch
performance will run at the highere frequency (1200MHz) always.

LuisPons
Posts: 5
Joined: Thu Apr 06, 2017 10:31 am

Re: Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 5:30 pm

W. H. Heydt,

Are you sure the Raspberry Pi 2 Model B uses the same SOC?
I am reading it uses a Broadcom BCM2836 SoC with a 900 MHz 32-bit quad-core ARM Cortex-A7 processor.
The Raspberry Pi 3 uses a Broadcom BCM2837 SoC with a Cortex A53, 64 bits.

About the nasty config problem, I am trying to modify /boot/config.txt in all ways possible.
I even tried OSX, which does not let me write files there. It says "read-only filesystem". So now I suspect the partition is marked as inconsistent or something similar.

jahboater
Posts: 2913
Joined: Wed Feb 04, 2015 6:38 pm

Re: Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 5:34 pm

LuisPons wrote: I modify the file and check the content (cat boot/config.txt). Everything seems OK.
If I eject the sdcard and plug it in again, the file shows the original content. No modification.
Perhaps type "sync" and/or properly unmount the filesystem before ejecting the card. You must not simply pull the card out!

The new Pi2 V1.2 has the same SoC as the Pi3, the BCM2837.

LuisPons
Posts: 5
Joined: Thu Apr 06, 2017 10:31 am

Re: Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 9:46 pm

dom,
thanks a lot, that way of setting the governor works perfectly. You saved my day!
I tested my little benchmark and the readings match a clock at 600 mhz very closely.
All the classroom cards were copied from my (probably damaged) sdcard; so for the next classes I will use your method, thanks again.

jahboater,
I usually eject sdcards or just shutdown the system. But sometimes we connect the RPi to the classroom monitor's USB for power. This means people often power down the monitors, forgetting the RPi is connected and they cut down its power. It happens very often.
I guess my sdcard got caught in one of those accidents. Well, I will try fsck or something related.

BTW, I am surprised there is a RPi2 using the Cortex A58. Confusing...what's the point? It does not seem cheaper than the RPi3.

W. H. Heydt
Posts: 8868
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Stabilizing RPi3 speed for my classes

Thu Apr 06, 2017 11:23 pm

LuisPons wrote:W. H. Heydt,

Are you sure the Raspberry Pi 2 Model B uses the same SOC?
I'm sure. I have one sitting on my desk right now.
I am reading it uses a Broadcom BCM2836 SoC with a 900 MHz 32-bit quad-core ARM Cortex-A7 processor.
The Raspberry Pi 3 uses a Broadcom BCM2837 SoC with a Cortex A53, 64 bits.
Pi2Bv1.1 used the BCM2836. Last Fall (2016), the RPT quietly started using BCM2837 SoC on the Pi2B, giving it a v1.2 version number. So, yes, the Pi2Bv1.2 uses the same SoC as the Pi3B, but the default clock remained at 900MHz for the Pi2Bv1.2. The change didn't get a lot of notice. Not all vendor pages have caught up with the change, and some vendors appear to still be selling older stocks of the v1.1 board (CanaKit, for instance, is actually still selling v1.1 Pi2B boards...I asked. MCM, on the other hand, has the newer, v1.2 Pi2Bs.).
About the nasty config problem, I am trying to modify /boot/config.txt in all ways possible.
I even tried OSX, which does not let me write files there. It says "read-only filesystem". So now I suspect the partition is marked as inconsistent or something similar.
I've used a Win7 PC, opening /boot files in LibreOffice and saving them with no issues. One can, of course, do it directly on the Pi, though you need to use root privileges to write the files. Bear in mind that the /boot partition is FAT32, so it lacks permissions bits that a normal Linux or unix partition has.

LuisPons
Posts: 5
Joined: Thu Apr 06, 2017 10:31 am

Re: Stabilizing RPi3 speed for my classes

Fri Apr 07, 2017 7:47 am

W. H. Heydth,
thanks for the hint, the boot partition can be edited on windows. I didn't notice it's FAT32.

Unfortunately, it seems I have a very rare problem with this sdcard.
- fsck says the partition is ok.
- I can edit files, drop files into the partition, rename files...
- If I eject the card and re-insert it, the while partition appears as original, all my modifications dissapear.

I checked the physical protection switch of the card. The problem is not there.

It seems like all file modifications are performed on the memory cache, and the filesystem fails to mirror them on the actual disk...

All info I found (vaguely) related to this problem is:
NOTE: You may find that your changes to config.txt disappear after a reboot. This is a very rare problem and seems to depend on the type of SD card. In this case, use a Windows/Linux/OS X PC to edit the file, see instructions above.
http://elinux.org/R-Pi_configuration_file

Oh, well. I guess I will have to prepare a new image from zero.

JamesPi123
Posts: 84
Joined: Fri Sep 23, 2016 10:02 pm
Location: Inside my Pi
Contact: Website

Re: Stabilizing RPi3 speed for my classes

Thu Apr 13, 2017 2:15 am

Doing

Code: Select all

force_turbo=1
will set the warranty bit on your Raspberry Pis

Return to “Staffroom, classroom and projects”

Who is online

Users browsing this forum: No registered users and 4 guests