MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU

Moderators: odroid, mdrjr

MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU

Unread postby BuckoNZ » Sun Jan 07, 2018 10:36 am

MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU
~ by BuckoNZ (Jan. 2018) ~


Intro, Disclaimer and Credits
I have no idea what I’m doing. I know little to nothing about cyrpto currencies and I did a little linux when I was at a technical institute about 17 years ago and I’ve done nothing with it since. However, that’s part of the reason that I decided to give this a crack. At least I might learn something right? So, I am not an expert and you follow these instructions at your own peril.

Many thanks to various forums for their assistance, especially in here:
https://bitcointalk.org/index.php?topic=735170.0

Other key resources were:
https://steemit.com/cryptocurrency/@gri ... spberry-pi
https://wiki.odroid.com/odroid-xu4/odroid-xu4
viewtopic.php?f=9&t=1645
https://www.phoronix.com/scan.php?page= ... px=MTI0MjI
https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
https://github.com/magi-project/magi
https://github.com/magi-project/m-cpuminer-v2


Initial XU4 Setup and Preparation

1) Grab a Linux image for your XU4 and flash it on your MicroSD using Etcher or similar. The build I used was this one:
https://odroid.in/ubuntu_16.04lts/ubunt ... 212.img.xz

2) Once flashed, booted and logging in for the first time, perform the following admin tasks:
- Setup your region, time zone, clock, etc.
- Configure your network settings how you ant them (DHCP? Manual IP?)
- Change the default password for both the ordoid user and the root user:
$ passwd
- Following the linux build release notes, ensure that everything is up to date:
https://wiki.odroid.com/odroid-xu4/os_i ... st-upgrade

3) After the reboot, there were quite a dependencies that the software we are to use needs, that is not part of the standard linux build. I will apologise in advance if I have missed any as I found the odd one here and there as I was working through this process:
$ sudo apt install -y git automake libssl-dev libdb-dev libboost-all-dev libminiupnpc-dev libgmp-dav libdb5.3++-dev

4) Reboot your XU4 at this point:
$ sudo reboot

5) Download the files needed for the Magi Core-Wallet (M-Wallet) and the M-CPUMiner-v2 mining tool:
$ cd ~ && git clone https://github.com/magi-project/magi
$ cd ~ && git clone https://github.com/magi-project/m-cpuminer-v2
$ cd ~ && wget http://m-core.org/bin/block-chain/m-block-chain.tar.gz


Installing/Compiling The Magi Wallet

1) It’s a good idea to double check your ARM architecture:
odroid@odroid:~$ uname -a
Linux odroid 4.14.11-97 #1 SMP PREEMPT Wed Jan 3 01:35:18 UTC 2018 armv7l armv7l armv7l GNU/Lin
ux

The import piece of information is the ‘armv7l’.

2) You now need to create a conf file so the M-Wallet will work specifically on your XU4 device:
$ cd ~/magi/src
$ make -f makefile.unix xCPUARCH=arm
7l

3) We now need to “install” the M-Wallet, so it can be called from anywhere – you don’t need to be in the correct folder structure to run it:
$ cd ~/magi/src
$ sudo install -m 755 magid /user/bin/magi
d

4) We now need to make a magi.conf file in a hidden folder so that the software will work correctly. Firstly create the hidden folder:
$ cd ~
$ mkdir ~/.magi


We now need to create the file itself:
$ touch ~/.magi/magi.conf

We now need to open the newly created file:
$ nano ~/.magi/magi.conf

We now need to put the following into the file:
# You must set rpcuser and rpcpassword to secure the JSON-RPC api
rpcuser=magixu4
rpcpassword=7dhf8SRjR8R5P9icfqjjbqAZqysYXeQSuX539JhXseLz
# Listen for RPC connections on this TCP port:
rpcport=8232
# server=1 to accept JSON-RPC commands
server=1
# listen=1 to accept connections from outside
listen=1
# RPC connection from localhost allowed
rpcallowip=127.0.0.1
# Add nodes to connect to specific peers
addnode=104.128.225.215
addnode=45.35.251.73
# posii=1 to enable PoS staking; default = 0
posii=1
# Transaction under stake with a value greater than the threshold is being splitted
stakesplitthreshold=500
# Transactions with values less than the threshold will combine into one
stakecombinethreshold=500


5) We now run the magid software as a headless daemon, which will create a number of other files and folders in the hidden /.magi folder we created:
$ magid -daemon

6) Wait a few minutes and then move to the ~/.magi folder and check to make sure everything appears to be there:
odroid@odroid:~$ cd ~/.magi
odroid@odroid:~/.magi$ ls
blocks database db.log debug.log magi.conf peers.dat wallet.da
t

7) At this point, reboot your XU4 again.

8) When you log back in, we will now update the blocks and database folders in the /.magi folder with the ones downloaded earlier. This will save waiting a considerable amount of time for the full block chain to be pulled down by the wallet.

You can use the GUI to do this. You will need to go into View > Show Hidden Files, for the /.magi to display. Follow these steps:
- Move the m-block-chain.tar.gz file, which was downloaded earlier, into the /.magi folder.
- Rename the existing blocks folder to zblocks and the existing database folder to zdatabase, so they won’t be used anymore.
- Extract the blocks and database folders in the tar.gz file into the /.magi folder to replace the original ones.

9) To make sure everything is ok, launch the magid deamon again to get it up and running:
$ magid -daemon

Wait for a good 15 minutes or so and then check that it’s ok:
$ magid getinfo
{
"version" : "v1.4.5.3",
"protocolversion" : 71064,
"walletversion" : 60000,
"balance" : 0.00000000,
"newmint" : 0.00000000,
"stake" : 0.00000000,
"blocks" : 1603969,
"timeoffset" : 0,
"moneysupply" : 7736663.66134056,
"connections" : 6,
"proxy" : "",
"ip" : "w.x.y.z",
"ipv4" : "w.x.y.z",
"ipv6" : "w.x.y.z",
"difficulty" : {
"proof-of-work" : 0.00026878,
"proof-of-stake" : 0.00024414
},
"testnet" : false,
"keypoololdest" : 1515269501,
"keypoolsize" : 101,
"mininput" : 0.00000000,
"paytxfee" : 0.00010000,
"errors" : ""
}


At this point you can go back into ~/.magi and delete the zblocks and zdatabase folders, which are no longer being used. You can also delete the tar.gz file.

To check where your instance of the block chain is with the master, go to this website:
https://chainz.cryptoid.info/xmg/
Compare the ‘Up To Block’ number at the top of the webpage with the “blocks” value in the output. You should be no more than one or two blocks behind. If you are, just give it another 15 minutes and then check again – you should be closer.

10) We now want to get magid to run as a service in the background, so it automatically comes online each time the XU4 is rebooted. This ensures that you are always staking, if this is want to want to do.

Firstly we need to create a service file:
$ cd ~
$ sudo touch /lib/systemd/system/magid.service

Now we need to open the file and configure it:
$ sudo nano /lib/systemd/system/magid.service

And copy this content into the file:
[Unit]
Description=Coin Magi daemon services
After=tlp-init.service

[Service]
PIDFile=/home/odroid/.magi/magi.pid
RemainAfterExit=yes
ExecStart=/usr/bin/magid -daemon
Restart=on-failure
RestartSec=15
User=ordoid

[Install]
WantedBy=multi-user.target


We then need to enable autorun:
$ sudo systemctl enable magid.service

11) To test that this service has been setup correctly, perform the following:
- Reboot the XU4
- After login, wait 5 minutes.
- Check that the magid service is up and running:
$ systemclt status magid

In the event you want to stop magid running as a service anymore, simply use:
$ sudo systemctl disable magid

12) Final steps, we want to encrpyt the wallet, to avoid being stolen:
First check that magid is up and running with no issues:
$ magid getinfo
{
"version" : "v1.4.5.3",
……….
"balance" : 0.00000,
"errors" : ""
}

Now to actually encrypt – where YOUR_PASSWORD is a suitably strong password that you have made up and won’t forget:
$ magid encryptionwallet YOUR_PASSWORD

And then reboot the XU4 again:
$ sudo reboot

13) You should backup your wallet on a regular basis so you don’t lose your crypto currency. A good naming convention is to use a filename like YYYYMMDD_wallet.dat where the YYYY is the year, MM is the month and the DD is the day or backup:
$ magid backupwallet ~/YYYYMMDD_wallet.dat

This will put the wallet backup in your home directory. You should then move it off your XU4 somewhere else, for safe keeping.

14) Final step is to stake. Magi Coin, as well s bring Proof Of Work is Proof Of Stake – you will earn XMG just by having some coin in your wallet and your wallet being online. In order to do this, you need to unlock your wallet, but for staking only:
$ magid walletpassphrase YOUR_PASSWORD 9999999 true

While I’m not sure about Magi Coin, the M-Wallet and the XU4, but for another cyrpto currency I have, each time the box is restarted, to need to unlock my wallet for taking again.

Some useful magid commands:
- magid getaddresses : this tells you what your wallet id/address is (or are if you have multiple)
- magid getnewaddress : to create an additional wallet address
- magid listtransactions : shows the most recent transactions to and from your wallet



Installing/Compiling M-CPUMiner

1) First you need to move to where the M-CPUMiner files are:
$ cd ~/m-cpuminer-v2

2) Once in that folder, you need to kick off the compiling process. Now this is going to take some time, so after you have kicked it off, just walk away for about 30 minutes or so:
$ ./autogen.sh && ./configure CFLAGS="-O2 -mtune=cortex-a15.cortex-a7 -mfpu=neon" CXXFLAGS="-O2 -mtune=cortex-a15.cortex-a7 -mfpu=neon" && make

The above string, is what I used, which seemed to work ok. However based on some further reading, I’m likely to try using “-O3” instead of “-O2” in the CFLAGS and CXXFLAGS string. It would also appear you get better performance with a number of processor tasks if -mfpu is set to “vfpv3-d16” instead of “neon” - however as the GitHub page for M-CPUMiner-V2 specifically mentions using “neon”, I’d likely keep this the same.

3) While this is compiling, you should find yourself a Mining Pool and sign up.
What is a mining pool? https://en.wikipedia.org/wiki/Mining_pool
What mining pools are available for Magi Coin (XMG)? https://poolinfo.systms.org/

As I stated up front, I know VERY little about this stuff, however I signed up to ‘Bull Mining’ because they always seem to be up with the closest block and their efficiency number is pretty strong. However check out the forums and see what other people are using. I’m certain the probably one pool is good one month and then not as good the next. However I would be inclined to try a few, but pick one and stick with it.

4) Once the compiling of the M-CPUMiner-V2 software is complete, I would be included to reboot the XU4 at this point:
$ sudo reboot

5) You need to use m-minerd in the ~/m-cpuminer-v2 folder to execute the software. However if you’d like to run it from anywhere, which is really handy:
$ cd ~/m-cpuminer-v2
$ sudo make install


6) I use the following command to call the m-minerd executable and configure it for mining:
$ m-minerd -t 6 -o stratum+tcp://MyMiningPoolURL:MyPort -u MyLogin.MyWorker -p MyPassword

So to clarify:
- -t 6 : this option limits the amount of cores m-minerd uses. The XU4 has 8 cores however I throttled it down to 6 to avoid overloading the unit and because we also have the M-Wallet running in the background as well.
- MyMiningPoolURL : use the exact URL your Mining Pool requests that you use, for example for ‘Bull Mining’ is xmg.bullmining.com .
- MyPort : this is the port number your Mining Pool requests that you use, for example for ‘Bull Mining’ it is 3333 .
- MyLogin : when signing up with the Mining Pool, you usually provide/create a User ID. This is what you’d use here.
- MyWorker : some people haver numerous “workers” under their mining pool account, like one for each mining rig they have. Put the worker name you wish to use here.
- MyPassword : this is the password you assigned that particular worker.

7) All going well, you will see the m-minerd make a connection to your mining pool – this can take a couple of attempts – and then the hash rates of your “work” starting to come through. Give it a few minutes, but then login into your mining pools website and check that it is registering your work – it will show you the hash rate you are achieving and what you’re contributing to the pool.

8) You need to leave the terminal window open for m-minerd to continue running.


Conclusion
Hopefully this guide saves you a lot of hunting around. It took me the better part of two days to work all this out. And the reason for typing it up… it looks like I have to do it all over again due to the original M-Wallet I installed (v1.4.5.2) no longer working properly and I can’t seem to find a way to upgrade to the new one (v1.4.5.3) without starting from scratch.
BuckoNZ
 
Posts: 2
Joined: Sun Jan 07, 2018 10:27 am
languages_spoken: english
ODROIDs: XU4

Re: MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU

Unread postby moon.linux » Wed Jan 10, 2018 3:36 am

Good cool
moon.linux
 
Posts: 1080
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Re: MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU

Unread postby mcwinston » Wed Jan 17, 2018 7:36 am

at first: AWESOME TUTORIAL!

do you know how to start the miner via ssh?
it works for me until i close putty^^

I tried to put the corresponding command into rc.local, but not sure, if i put in the right section...
Since my miner is already running, i can't copy the current content of rc.local
Do you have any idea?

thank you
mcwinston
 
Posts: 1
Joined: Tue Jan 16, 2018 5:10 pm
languages_spoken: english
ODROIDs: XU4

Re: MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU

Unread postby rooted » Wed Jan 17, 2018 7:45 am

mcwinston wrote:at first: AWESOME TUTORIAL!

do you know how to start the miner via ssh?
it works for me until i close putty^^

I tried to put the corresponding command into rc.local, but not sure, if i put in the right section...
Since my miner is already running, i can't copy the current content of rc.local
Do you have any idea?

thank you
Use tmux is my advice
User avatar
rooted
 
Posts: 4941
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU

Unread postby hominoid » Wed Jan 17, 2018 9:44 am

mcwinston wrote:at first: AWESOME TUTORIAL!

do you know how to start the miner via ssh?
it works for me until i close putty^^

I tried to put the corresponding command into rc.local, but not sure, if i put in the right section...
Since my miner is already running, i can't copy the current content of rc.local
Do you have any idea?

thank you


Many people use screen for this purpose.
Code: Select all
apt-get install screen

You can invoke it on it's own in a ssh, issue your command then use exit or ctrl a ctrl d to close the window; or use it in detached mode in a command line for inclusion in /etc/rc.local e.g.
Code: Select all
screen -dm "m-minerd -t 6 -o stratum+tcp://MyMiningPoolURL:MyPort -u MyLogin.MyWorker -p MyPassword"

To revive it in the future open any ssh shell on the computer its running
Code: Select all
screen -r

or if you have mulitple instances of screen you can name them:
Code: Select all
screen -dmS myname "m-minerd -t 6 -o stratum+tcp://MyMiningPoolURL:MyPort -u MyLogin.MyWorker -p MyPassword"

and use the name to restore it:
Code: Select all
screen -r myname

See man pages for further info, -dm can work differently depending on other switches and use.
hominoid
 
Posts: 164
Joined: Tue Feb 28, 2017 3:55 am
Location: Lake Superior Basin, USA
languages_spoken: english
ODROIDs: C2, XU4, MC1, N1

Re: MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU

Unread postby ZooloZ » Sun Jan 21, 2018 12:48 pm

What kind of hashrate are you getting on the XU4? I am just wondering if I should change me current X86_64 setup using a Celeron processor over to the XU4.

Thanks
ZooloZ
 
Posts: 1
Joined: Sun Jan 21, 2018 12:43 pm
languages_spoken: english
ODROIDs: C1

Re: MINING MAGI COIN (XMG) ON A ODROID XU4 WITH UBUNTU

Unread postby BuckoNZ » Sat Mar 24, 2018 7:58 am

ZooloZ wrote:What kind of hashrate are you getting on the XU4? I am just wondering if I should change me current X86_64 setup using a Celeron processor over to the XU4.


I'm actually not doing this any more - the fan was constantly going to keep the CPU temp down and it was starting to make more noise after a couple of months. If you want to use the XU4 for this purpose, I would definitely go with the Heat Sink option over the fan. Although some of the data I've seen indicates the fan does a better job at cooling and therefore you get better performance from the CPU, at least the heat sink won't fail - you don't have to worry about it.

Anyway, from memory, i think I was getting an average hash rate of about 16 mh/s? Something like that. It would often be in single digits and then be in the twenties, however on average it was somewhere in the mid-teens, as I recall.
BuckoNZ
 
Posts: 2
Joined: Sun Jan 07, 2018 10:27 am
languages_spoken: english
ODROIDs: XU4


Return to Projects

Who is online

Users browsing this forum: No registered users and 2 guests