Friday, April 3, 2020

Do something useful with your Pi4

You can now run Rosetta@home on the Pi4. They released a new app called "Rosetta for Portable devices" that will run under Raspbian but its for the ARM64 architecture.

Link to Rosetta@home: http://boinc.bakerlab.org/rosetta/

For those that don't know Rosetta is searching for proteins in relation to the Covid-19 virus. Its a BOINC-based project so you'll need to install that first. There are a few catches though.
  • You'll have to put the kernel into 64 bit mode.
  • You have to tell BOINC its an aarch64 platform (ARM64).
  • Some tasks can use up to 1.3GB of memory each so you need to limit how many run at the same time.

Most BOINC projects don't have aarch64 apps, particularly Einstein which gave me an incompatible app and then all the work units failed. You can go back to armhf (32 bit) mode later by reversing these steps.

Before somebody asks, yes you could theoretically do this on a Pi3B or a Pi3B+ but they only have 1GB of memory so its not worthwhile.

Assuming you still want to proceed this is the process.


1. Install BOINC
If you already have it installed then skip this step.If not install it and sign up to any projects you want to run. I won't go into detail here but if there is interest I can cover it in another blog post.

Set it to No New Tasks for all projects. If it has any work in progress let it finish and report it before proceeding.


2. Put the kernel into 64 bit mode
This tells the kernel to use 64 bit mode also known as ARM64 or aarch64. By default the kernel runs in 32 bit mode for compatibility with the older Pi software. You'll need the 4.19.75 or later kernel. To find out what you have currently type the following in a terminal or ssh session:
uname -a

If you have an older one then you'd better upgrade it to the latest packages and then come back to this step.

Make a copy of the config.txt first. Type:
cd /boot
sudo cp config.txt config.old

Edit the config.txt. Type:
sudo nano config.txt

Once in nano (its a text editor) scroll to the very end and add "arm_64bit=1" (without the quotes) on a new line.

Press Control-O to save the file.

Press Control-X to exit from nano.

Now reboot it by typing:
sudo reboot


3. Tell BOINC to use aarch64
Back in a terminal or ssh session type:
uname -a

You should see it says "aarch64" on the end of the line. If not then you need to fix that up first. If it does we now need to edit the cc_config.xml file that BOINC uses. Type:
cd /etc/boinc-client
sudo nano cc_config.xml

Blank out the contents using the delete or backspace keys and then paste or type this in:
<cc_config>
  <log_flags>
    <task>1</task>
    <file_xfer>1</file_xfer>
    <sched_ops>1</sched_ops>
  </log_flags>
  <options>
    <alt_platform>aarch64-unknown-linux-gnu</alt_platform>
  </options>
</cc_config>

Press Control-O to save the file.

Press Control-X to exit from nano.

We need to restart BOINC to pick up this change so type the following command:
sudo systemctl restart boinc-client

Now you can allow BOINC to accept tasks.


Why do we need to this?
When you install Raspbian on your Pi its all 32 bit, all the add-on programs and so on. Its known as armhf (ARM hard float). The Raspberry Pi Foundation made kernel changes to allow it to run in 64 bit mode. That's the kernel taken care of but the apps are still 32 bit.

When you install BOINC you get the armhf version. That is because the Foundation don't have aarch64 repositories. We then need to tell BOINC to use aarch64 as an alternative to armhf in order get 64 bit apps.

4 comments:

lakotamm said...

I wanted to say thank you! I managed to get Rosetta to run on my Raspberry Pi 3B+. I had to use ZRAM and increase swap (2048MB), but in the end it seems to be capable of running 3-4 tasks at once. Not bad at all!

faraz said...

Thanks, this worked but I had to put the option> stuff within the other cc_config> tags. At first I just it at the end of the file and naturally it did not do anything :-)

Mark G James said...

Regarding the option tags.

All of them need to be contained within a cc_config set of tags. The version of BOINC from the repository includes a small cc_config file that already has some logging flags. You can put the options before or after the logging flags. The order isn't important as long as they are between the cc_config opening and closing tags.

Unknown said...

Thank you! It would be nice to change the wording in the main text above, including the hint to the necessity to place the < option > inside the < cc_config > tag. I made the mistake + solving just again ... :-)