Browse Source

Merge pull request 'Updated ARM (aarch64) cross compile document as it was broken' (#11) from jahway603/hush-docs:master into master

Reviewed-on: hush/docs#11
pull/14/head
jahway603 2 years ago
parent
commit
396dbe5b2c
  1. 93
      advanced/cross-compile-hush-full-node-to-aarch64-with-docker.md

93
advanced/cross-compile-hush-full-node-to-aarch64-with-docker.md

@ -1,84 +1,88 @@
# Cross compiling a Hush full node daemon from AMD64 to ARM64(aarch64) CPU architecture with Docker
**Requirements:** Docker-Engine & arm64(aarch64) architecture with Debian operating system like a <a href="https://www.raspberrypi.org/products/raspberry-pi-400/specifications/">Raspberry Pi 400</a>
**Requirements:** Docker-Engine & arm64(aarch64) architecture with Debian operating system, such as a [Raspberry Pi 400](https://www.raspberrypi.org/products/raspberry-pi-400/specifications/)
## Summary
Cross compiling a Hush full node daemon from **AMD64** (also known as x86 architecture) to **ARM64(aarch64)** CPU architecture with Docker.
These are instructions for cross compiling a Hush full node daemon on a regular **AMD64** PC (also known as x86 architecture) to **ARM64(aarch64)** CPU architecture with Docker.
The following instructions enables a smoother transition between your desktop/laptop to the raspberry pi device.
Some issues I encountered *without* the virtual environment was **glibc** version differences on two different machines. Initially, I tested the installation by building & compiling on the **Broadcom BCM2711** quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz device by itself through the normal hush3 instructions provided, but I ran into another set of problems with <a href="https://gcc.gnu.org/">gcc(g++)</a> <a href="https://packages.debian.org/sid/g++-multilib">**g++-multilib**</a> for the arm64(aarch64) architecture; there are no multilib packages for the arm64(aarch64) architecture.
These instructions were created as a result of (#1) issues with **glibc** versions differing on the two different machine architectures and (#2) no gcc and g++ multilib packages existing natively on the arm64(aarch64) architecture.
*Note: This should work on all types of arm64(aarch64) devices. By cross compiling (building) on another machine for another machine type, we bypass the ARMv7 requirements. We copy over the binaries built to the Raspberry Pi. Cross compiling is where we compile on one machine to be used on another machine type; this is useful for machines that don't have lots of hardware resources to compile on or in our case, **G++-multilib** isn't built for ARM64(aarch64) devices (at this point in spacetime) and hushd requires it to compile the fresh binaries.*
*Note: This should work on all types of arm64(aarch64) devices. By cross compiling (building) on a different system for another machine type, we are able to bypass the ARMv7 requirements. Cross compiling is useful for machines that don't have lots of hardware resources to compile on or, in this case, **G++-multilib** isn't available on ARM64(aarch64) devices and hushd requires it to compile binaries.*
**NOTE: THIS IS CURRENTLY NOT WORKING ON HUSHD 3.9.2 BECAUSE OF THE NEW INCLUSION OF RANDOMX. THIS IS CURRENTLY ONLY WORKING UPTO HUSHD 3.9.1. More testing is needed to get this working on 3.9.2...**
1. ### Let's Begin!
- Install & setup Docker-Engine <a href="https://docs.docker.com/engine/install/ubuntu/"> Docker-Engine Installation </a>
- Install & setup Docker-Engine. Most users will install this via their operating system's package manager, but also refer to [Docker-Engine Installation](https://docs.docker.com/engine/install/ubuntu/) for additional information.
`sudo docker run -it --rm -v /tmp:/tmp debian:bullseye`
This creates a container with the latest version of Debian. A bind mount is created mapping the /tmp directory on the host machine to the /tmp directory on the container. The additional options mean the container will run in interactive mode with a terminal, and the container will be destroyed when you stop(exit) it.
2. ### Upgrade the Docker OS image packages
Make sure we have the latest versions of everything in the base OS image.
`apt-get -y update && apt-get -y upgrade`
2. ### Install Hush build dependencies
*Note: the dependencies for arm64(aarch64) are slightly different; the extra deps are **libboost-dev**, **libdb++-dev**, **libwolssl-dev** and **g++-aarch64-linux-gnu** *
3. ### Install Hush build dependencies
*Note: the dependencies for arm64(aarch64) are slightly different*
`apt-get -y install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake nano curl unzip libsodium-dev libboost-dev libdb++-dev libwolfssl-dev g++-aarch64-linux-gnu`
```
apt-get -y install build-essential pkg-config libc6-dev m4 autoconf libtool libncurses-dev unzip git python3 python-is-python3 zlib1g-dev wget bsdmainutils
automake nano curl unzip libsodium-dev libboost-dev libdb++-dev libwolfssl-dev g++-aarch64-linux-gnu g++
```
3. ### Pull or clone latest hush3 from git.hush.is
4. ### Pull or clone latest hush3 from git.hush.is
`git clone https://git.hush.is/hush/hush3.git && cd hush3`
4. ### Build and compile for aarch64-linux-gnu device
5. ### Build and compile for aarch64-linux-gnu device
`HOST=aarch64-linux-gnu ./build.sh -j$(nproc)`
Relax and let the code flow. It normally takes 15-30min to compile successfully for me.
Relax and let the code flow. It normally takes 15-30 minutes to compile successfully, but may take longer on some systems.
5. ### Prepare binaries for our ARM64(aarch64) device
On success of building the Hush binaries, we first want to "prepare" them. We do this so we don't end up with a 311 MB hushd binary and instead get the proper size of 15 MB.
6. ### Prepare binaries for our ARM64(aarch64) device
On success of building the Hush binaries, we first want to "prepare" them. We do this so we don't end up with a 311 MB hushd binary and instead get the correct size, which is much smaller.
The following commands are used in the **Docker container terminal**:
`aarch64-linux-gnu-strip src/hushd`
`aarch64-linux-gnu-strip src/hush-cli`
`aarch64-linux-gnu-strip src/hush-tx`
```
aarch64-linux-gnu-strip src/hushd
aarch64-linux-gnu-strip src/hush-cli
aarch64-linux-gnu-strip src/hush-tx
```
6. ### Copy binaries from Docker container to our desktop
7. ### Copy binaries from Docker container to our desktop
Next we will copy these new binaries from our Docker container to our desktop and exit the Docker container.
The following cp command used in the **Docker container terminal** copies from the docker container to actual desktop machine environment into the /tmp/hush-arm64 directory.
`mkdir /tmp/hush-arm64`
`cp src/hushd /tmp/hush-arm64/`
`cp src/hush-cli /tmp/hush-arm64/`
`cp src/hush-tx /tmp/hush-arm64/`
`cp src/hush-smart-chain /tmp/hush-arm64/`
`cp asmap.dat /tmp/hush-arm64/`
`cp sapling-output.params /tmp/hush-arm64/`
`cp sapling-spend.params /tmp/hush-arm64/`
```
mkdir /tmp/hush-arm64
cp src/hushd /tmp/hush-arm64/
cp src/hush-cli /tmp/hush-arm64/
cp src/hush-tx /tmp/hush-arm64/
cp src/hush-smart-chain /tmp/hush-arm64/
cp asmap.dat /tmp/hush-arm64/
cp sapling-output.params /tmp/hush-arm64/
cp sapling-spend.params /tmp/hush-arm64/
```
Then you can type exit in the docker container when you are done.
`exit` ***Note: on `exit`, the docker container will be completely destroyed!***.
7. ### Copy binaries to ARM64(aarch64) device
Next we will copy these new binaries to our ARM64(aarch64) device. Now that these are on our **actual desktop machine**, we will next copy them to the raspberry pi.
The installation location is up to you, but for this example we will use **/home/username/hush3-folder** and assume that you have the raspberry pi media mounted on your desktop system. If you have a GUI, you can simply drag / drop or CTRL + C and CTRL + V the folder to the drive if copying between drives is troublesome. Remember though, if copying with GUI, you may run into permission problems.
`sudo cp -rv /tmp/hush-arm64/ /media/username/external-drive/home/username/hush3-folder`
8. ### Copy binaries to ARM64(aarch64) device
Next we will copy these new binaries to our ARM64(aarch64) device. Now that these are on our **actual desktop machine**, we will next copy them to our raspberry pi (or other ARM device).
** Alternative copying method (for a currently running raspberry pi) is to use scp. Please do a web search for that command's syntax. **
The installation location is up to you, but for this example we will use **/home/username/hush3-folder**, which has to already exist on the raspberry pi end, and we assume that your raspberry pi is already running a server. If you want to mount the media on your desktop system, then please do a web search for those instructions, but most people will be scp'ing the files to their raspberry pi.
#### Changing permissions recursively for every file and folder
*Tip: chmod 755: Only owner can write, read and execute for everyone.*
Substitute your username and server name or IP below in the commands below:
`sudo chmod 755 -Rv /tmp/hush-arm64`
```
cd /tmp/hush-arm64
scp * username@YOUR-SERVER-NAME-OR-IP:/home/username/hush3-folder/
```
#### Changing ownership of file/folder for rpi device
*Tip: for security purposes, I recommend creating a new username for the rpi hush server; using root for any application is bad security practice*
`sudo chown -Rv rpi-username /media/username/external-drive/home/username/hush3-folder/`
8. ### Launch a fresh hush daemon(node) puppy on ARM64(aarch64)
9. ### Launch a fresh hush daemon(node) puppy on ARM64(aarch64)
`./hushd --version`
@ -91,6 +95,7 @@ Happy Hacking! [Hooray!]
## Automation with Docker
*Note: this has not been recently tested...*
I will update the steps required to automatically build and run hushd with a Dockerfile. This is useful for testing and also aids in other hush puppies who don't need to deep dive into developer chores and maintainance. Required dep is Docker-Engine.
### Create Hush docker image
@ -104,6 +109,8 @@ I will update the steps required to automatically build and run hushd with a Doc
## Support, Socials and Licensing
<a href="https://git.hush.is/hush/hush3#support-and-socials"> Support, Socials and Licensing</a>
[Support, Socials and Licensing](https://git.hush.is/hush/hush3#support-and-socials)
#### Credits
This documentation, formatting, testing, hacking and many headaches created this after about ~34 hours of tedious focus and work.
Odinzu originally created this documentation (along with testing) after about ~34 hours of tedious focus and work. This documentation has continued to be updated by the Hush devs, so that it will still work, as it has changed from its original form.

Loading…
Cancel
Save