diff --git a/advanced/cross-compile-hush-full-node-to-aarch64-with-docker.md b/advanced/cross-compile-hush-full-node-to-aarch64-with-docker.md index d3a53a7..9819876 100644 --- a/advanced/cross-compile-hush-full-node-to-aarch64-with-docker.md +++ b/advanced/cross-compile-hush-full-node-to-aarch64-with-docker.md @@ -1,11 +1,10 @@ -# Cross compiling a Hush full node daemon from AMD64 to ARM64(aarch64) CPU architecture with Docker. +# 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 Raspberry Pi 400 -*For this documentation, I setup DietPi It is a Debian:buster OS build.* -0. ## Summary +## Summary -Cross compiling a Hush full node daemon from **AMD64** to **ARM64(aarch64)** CPU architecture with Docker. +Cross compiling a Hush full node daemon from **AMD64** (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 gcc(g++) **g++-multilib** for the arm64(aarch64) architecture; there are no multilib packages for the arm64(aarch64) architecture. @@ -15,58 +14,59 @@ Some issues I encountered *without* the virtual environment was **glibc** versio 1. ### Let's Begin! - Install & setup Docker-Engine Docker-Engine Installation -`sudo docker run -it --rm -v /tmp:/tmp debian:buster` - -*Note: we chose this debian type because it has the same ldd --version (glibc) on it. At the moment, there is no DietPi docker image to pull from.* +`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. `apt-get -y update && apt-get -y upgrade` -2. ### Install Hush build depedencies -*Note: the dependencies for arm64(aarch64) are slightly different; the extra deps are **libboost-dev**, **libdb++-dev**, **libwolssl-dev** and **g++-aarch64-linux-gnu**; libwolf and g++-arch-linux-gnu will be installed later* - -`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` +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. ### Add to sources list -To install a dep *wolfssl-dev* that isn't on the normal *debian:latest*, we must add to our */etc/apt/sources.list*. -`nano /etc/apt/sources.list` +`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` -At the bottom of the list, type or copy/paste the following line -#### libwolfssl-dev dependency -`deb http://ftp.us.debian.org/debian buster-backports main` +3. ### Pull or clone latest hush3 from git.hush.is +`git clone https://git.hush.is/hush/hush3.git && cd hush3` -CTRL + X then Y for Yes to confirm and save changes. +4. ### Build and compile for aarch64-linux-gnu device +`HOST=aarch64-linux-gnu ./build.sh -j$(nproc)` -`apt-get -y update` +Relax and let the code flow. It normally takes 15-30min to compile successfully for me. + +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. -#### Install mo dependencies: +The following commands are used in the **Docker container terminal**: -*Note: We install these deps later because of other dep requirements.* -`apt-get -y install libwolfssl-dev` +`aarch64-linux-gnu-strip src/hushd` +`aarch64-linux-gnu-strip src/hush-cli` +`aarch64-linux-gnu-strip src/hush-tx` -- Install GNU C++ compiler for the arm64(aarch64) architecture -`apt-get -y install g++-aarch64-linux-gnu` +6. ### 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. -4. ### Pull or clone latest hush3 from git.hush.is -`git clone https://git.hush.is/hush/hush3.git && cd hush3` +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. -5. ### Build and compile for aarch64-linux-gnu device -`HOST=aarch64-linux-gnu ./build.sh -j$(nproc)` +`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/` -Relax and let the code flow [cat drinking coffee meme] [matrix meme] It normally takes 15-30min to compile successfully for me. - -6. ### Copy binaries to ARM64(aarch64) device. +Then you can type exit in the docker container when you are done. +`exit` ***Note: on `exit`, the docker container will be completely destroyed!***. -On success of building the Hush binaries, we copy them to our ARM64(aarch64) device and exit the Docker container. - -The following cp command used in the **Docker container terminal** copies from docker container to actual machine environment. +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. -`cp -rv ../hush3/ /tmp/hush-arm64` +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. -On the actual **machine environment terminal** we copy all folders and files to raspberry pi drive. The installation location is up to you, but for simplicity sake, I added **/home/user/hush3-foler-name** as a placeholder. 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` -`sudo cp -rv /tmp/hush-arm64/ /media/username/external-drive/home/username/hush-arm64` +** Alternative copying method (for a currently running raspberry pi) is to use scp. Please do a web search for that command's syntax. ** #### Changing permissions recursively for every file and folder *Tip: chmod 755: Only owner can write, read and execute for everyone.* @@ -76,20 +76,18 @@ On the actual **machine environment terminal** we copy all folders and files to #### 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/dietpi/hush-arm64/` - -`exit` ***Note: on `exit`, the docker container will be completely destroyed!***. +`sudo chown -Rv rpi-username /media/username/external-drive/home/username/hush3-folder/` -7. ### Launch a fresh hush daemon(node) puppy on ARM64(aarch64) +8. ### Launch a fresh hush daemon(node) puppy on ARM64(aarch64) -`./src/hushd --version` +`./hushd --version` We have successfully cross-compiled a hushd for a arm64(aarch64) from amd64 or other architecture. -*Note: this has only been tested from amd64 architecture; we will update this list later for other tested hardware; the process will almost be identical, but other deps may be needed* +*Note: this has only been tested from amd64 architecture; we will update this list later for other tested hardware; the process will almost be identical, but other dependencies may be needed* Happy Hacking! [Hooray!] - +![Happy hush puppy rocket](https://git.hush.is/hush/memes/raw/branch/master/hush/hush-puppy-rocket.gif) ## Automation with Docker diff --git a/images/knomp-hush-miner.png b/images/hnomp-hush-miner.png similarity index 100% rename from images/knomp-hush-miner.png rename to images/hnomp-hush-miner.png