Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archlinux ARM build error #11

Closed
ghost opened this issue Mar 15, 2015 · 15 comments
Closed

Archlinux ARM build error #11

ghost opened this issue Mar 15, 2015 · 15 comments

Comments

@ghost
Copy link

ghost commented Mar 15, 2015

3.14.33-2-ARCH #1 SMP Mon Feb 16 13:40:54 MST 2015 armv7l GNU/Linux

I would like to run mintcoind 247 on my Cubox but I'm getting the following build error:

scrypt_mine.cpp:32:23: fatal error: xmmintrin.h: No such file or directory
 #include <xmmintrin.h>
                       ^
compilation terminated.
makefile.unix:176: recipe for target 'obj/scrypt_mine.o' failed
make: *** [obj/scrypt_mine.o] Error 1
@doged
Copy link

doged commented Apr 6, 2015

this change to your .pro should work

feldenthorne/Diamond@0104675#diff-95108e0b0a2682866f3a99ead07809d2

@ghost
Copy link
Author

ghost commented Apr 6, 2015

Thanks for the link
Trying to build the cli:
makefile.unix

# Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

USE_UPNP:=0
USE_IPV6:=1
USE_LEVELDB:=1

LINK:=$(CXX)

DEFS=-DBOOST_SPIRIT_THREADSAFE

DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))

TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)

LMODE = dynamic
LMODE2 = dynamic
ifdef STATIC
    LMODE = static
    ifeq (${STATIC}, all)
        LMODE2 = static
    endif
else
    TESTDEFS += -DBOOST_TEST_DYN_LINK
endif

# for boost 1.37, add -mt to the boost libraries
LIBS += \
 -Wl,-B$(LMODE) \
   -l boost_system$(BOOST_LIB_SUFFIX) \
   -l boost_filesystem$(BOOST_LIB_SUFFIX) \
   -l boost_program_options$(BOOST_LIB_SUFFIX) \
   -l boost_thread$(BOOST_LIB_SUFFIX) \
   -l db_cxx$(BDB_LIB_SUFFIX) \
   -l ssl \
   -l crypto

ifndef USE_UPNP
    override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
    LIBS += -l miniupnpc
    DEFS += -DUSE_UPNP=$(USE_UPNP)
endif

ifneq (${USE_IPV6}, -)
    DEFS += -DUSE_IPV6=$(USE_IPV6)
endif

LIBS+= \
 -Wl,-B$(LMODE2) \
   -l z \
   -l dl \
   -l pthread


# Hardening
# Make some classes of vulnerabilities unexploitable in case one is discovered.
#
    # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
    # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
    # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
    HARDENING=-fno-stack-protector

    # Stack Canaries
    # Put numbers at the beginning of each stack frame and check that they are the same.
    # If a stack buffer if overflowed, it writes over the canary number and then on return
    # when that number is checked, it won't be the same and the program will exit with
    # a "Stack smashing detected" error instead of being exploited.
    HARDENING+=-fstack-protector-all -Wstack-protector

    # Make some important things such as the global offset table read only as soon as
    # the dynamic linker is finished building it. This will prevent overwriting of addresses
    # which would later be jumped to.
    LDHARDENING+=-Wl,-z,relro -Wl,-z,now

    # Build position independent code to take advantage of Address Space Layout Randomization
    # offered by some kernels.
    # see doc/build-unix.txt for more information.
    ifdef PIE
        HARDENING+=-fPIE
        LDHARDENING+=-pie
    endif

    # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
    # the source such overflowing a statically defined buffer.
    HARDENING+=-D_FORTIFY_SOURCE=2
#


DEBUGFLAGS=-g

# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only
# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.
xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
    $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)

# If we have an arm device, we can't use sse2, so define as thumb
# Otherwise, assume sse2 exists
# xCPUARCH is passed in as a define (xCPUARCH=armv7l)
ifeq ($(xCPUARCH),armv7l)
    xCXXFLAGS+=-mthumb -DNOSSE
else
#    xCXXFLAGS+=-msse2
endif

# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only
# adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work.
xLDFLAGS=$(LDHARDENING) $(LDFLAGS)

OBJS= \
    obj/alert.o \
    obj/version.o \
    obj/checkpoints.o \
    obj/netbase.o \
    obj/addrman.o \
    obj/crypter.o \
    obj/key.o \
    obj/db.o \
    obj/init.o \
    obj/irc.o \
    obj/keystore.o \
    obj/main.o \
    obj/net.o \
    obj/protocol.o \
    obj/bitcoinrpc.o \
    obj/rpcdump.o \
    obj/rpcnet.o \
    obj/rpcmining.o \
    obj/rpcwallet.o \
    obj/rpcblockchain.o \
    obj/rpcrawtransaction.o \
    obj/script.o \
    obj/sync.o \
    obj/util.o \
    obj/wallet.o \
    obj/walletdb.o \
    obj/noui.o \
    obj/kernel.o \
    obj/pbkdf2.o \
    obj/scrypt_mine.o \
    obj/scrypt-x86.o \
    obj/scrypt-x86_64.o \
    obj/scrypt-arm.o

all: mintcoind

#
# LevelDB support
#
ifeq (${USE_LEVELDB}, 1)
LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) -DUSE_LEVELDB
DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
OBJS += obj/txdb-leveldb.o
leveldb/libleveldb.a:
    @echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd ..;
obj/txdb-leveldb.o: leveldb/libleveldb.a
endif
ifneq (${USE_LEVELDB}, 1)
OBJS += obj/txdb-bdb.o
endif

test check: test_mintcoin FORCE
    ./test_mintcoin

# auto-generated dependencies:
-include obj/*.P
-include obj-test/*.P

obj/build.h: FORCE
    /bin/sh ../share/genbuild.sh obj/build.h
version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO

obj/scrypt-x86.o: scrypt-x86.S
    $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<

obj/scrypt-x86_64.o: scrypt-x86_64.S
    $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<

obj/scrypt-arm.o: scrypt-arm.S
    $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<

obj/%.o: %.cpp
    $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
    @cp $(@:%.o=%.d) $(@:%.o=%.P); \
      sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
          -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
      rm -f $(@:%.o=%.d)

mintcoind: $(OBJS:obj/%=obj/%)
    $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)

TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))

obj-test/%.o: test/%.cpp
    $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
    @cp $(@:%.o=%.d) $(@:%.o=%.P); \
      sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
          -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
      rm -f $(@:%.o=%.d)

test_mintcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
    $(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(xLDFLAGS) $(LIBS)

clean:
    -rm -f mintcoind test_mintcoin
    -rm -f obj/*.o
    -rm -f obj-test/*.o
    -rm -f obj/*.P
    -rm -f obj-test/*.P
    -rm -f obj/build.h

FORCE:

got this error

g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/jason/tmp/mintc
oin/src -I/home/jason/tmp/mintcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/jason/tmp/mintcoin/src/leveldb/include -DUSE_LEVELDB -I/ho
me/jason/tmp/mintcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOU
RCE=2  -MMD -MF obj/util.d -o obj/util.o util.cpp
util.cpp: In function ‘long int hex2long(const char*)’:
util.cpp:493:43: warning: array subscript has type ‘char’ [-Wchar-subscripts]
   ret = (ret << 4) | hextable[*hexString++];
                                           ^

g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/jason/tmp/mint$oin/src -I/home/jason/tmp/mintcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/jason/tmp/mintcoin/src/leveldb/include -DUSE_LEVELDB -I/h$me/jason/tmp/mintcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SO$RCE=2  -MMD -MF obj/wallet.d -o obj/wallet.o wallet.cpp
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/jason/tmp/mint$oin/src -I/home/jason/tmp/mintcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/jason/tmp/mintcoin/src/leveldb/include -DUSE_LEVELDB -I/h$me/jason/tmp/mintcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SO$RCE=2  -MMD -MF obj/walletdb.d -o obj/walletdb.o walletdb.cpp
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/jason/tmp/mint$oin/src -I/home/jason/tmp/mintcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/jason/tmp/mintcoin/src/leveldb/include -DUSE_LEVELDB -I/h$me/jason/tmp/mintcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SO$RCE=2  -MMD -MF obj/noui.d -o obj/noui.o noui.cpp
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/jason/tmp/mint$
oin/src -I/home/jason/tmp/mintcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/jason/tmp/mintcoin/src/leveldb/include -DUSE_LEVELDB -I/h$
me/jason/tmp/mintcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SO$
RCE=2  -MMD -MF obj/kernel.d -o obj/kernel.o kernel.cpp
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/jason/tmp/mint$
oin/src -I/home/jason/tmp/mintcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/jason/tmp/mintcoin/src/leveldb/include -DUSE_LEVELDB -I/h$
me/jason/tmp/mintcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SO$
RCE=2  -MMD -MF obj/pbkdf2.d -o obj/pbkdf2.o pbkdf2.cpp
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/jason/tmp/mintc
oin/src -I/home/jason/tmp/mintcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/jason/tmp/mintcoin/src/leveldb/include -DUSE_LEVELDB -I/ho
me/jason/tmp/mintcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOU
RCE=2  -MMD -MF obj/scrypt_mine.d -o obj/scrypt_mine.o scrypt_mine.cpp
scrypt_mine.cpp:32:23: fatal error: xmmintrin.h: No such file or directory
 #include <xmmintrin.h>
                       ^
compilation terminated.
makefile.unix:188: recipe for target 'obj/scrypt_mine.o' failed
make: *** [obj/scrypt_mine.o] Error 1

@kamronk
Copy link

kamronk commented Apr 12, 2015

I'm having the exact same error as OP :/

Any info I can provide to help?

@ghost
Copy link
Author

ghost commented Apr 25, 2015

Bump

@CryptoMommy
Copy link

I am trying to recruit help on this stay tuned.

@CryptoMommy
Copy link

I received this from RoboGuy - Msse2 is only for x86. It tells the compiler to use special hardware instructions to make repetitive operations faster. I do not have an arm device but you can probably just remove this flag.

does this make sense to you?

@kamronk
Copy link

kamronk commented May 12, 2015

Yes it does :) ill give it shot
On May 12, 2015 5:02 PM, "Jessica Hartman" notifications@github.com wrote:

I received this from RoboGuy - Msse2 is only for x86. It tells the
compiler to use special hardware instructions to make repetitive operations
faster. I do not have an arm device but you can probably just remove this
flag.

dues this make sense to you?


Reply to this email directly or view it on GitHub
#11 (comment)
.

@doged
Copy link

doged commented May 12, 2015

feldenthorne/Diamond@0104675#diff-95108e0b0a2682866f3a99ead07809d2

check that out, also have a look at my repo, in github.com/doged/raspi

look at the makefile.unix changes we made to get a successful compile on ARM, by comparing it to the dogedsource/src/makefile.unix original.

ill keep an eye on this thread,

dogeddev aka justinvforvendetta aka sunerok =]

@ghost
Copy link
Author

ghost commented May 13, 2015

doged - Thank you for the info.
Modified the files, put scrypt-arm.S in src and got cli built on arm 👍 - now downloading the chain

I'm not a coder so I hope this hack does not mess up the MINT blockchain

makefile.unix for arm

# Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

USE_UPNP:=0
USE_IPV6:=1
USE_LEVELDB:=1

LINK:=$(CXX)

DEFS=-DBOOST_SPIRIT_THREADSAFE

DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))

TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)

LMODE = dynamic
LMODE2 = dynamic
ifdef STATIC
    LMODE = static
    ifeq (${STATIC}, all)
        LMODE2 = static
    endif
else
    TESTDEFS += -DBOOST_TEST_DYN_LINK
endif

# for boost 1.37, add -mt to the boost libraries
LIBS += \
 -Wl,-B$(LMODE) \
   -l boost_system$(BOOST_LIB_SUFFIX) \
   -l boost_filesystem$(BOOST_LIB_SUFFIX) \
   -l boost_program_options$(BOOST_LIB_SUFFIX) \
   -l boost_thread$(BOOST_LIB_SUFFIX) \
   -l db_cxx$(BDB_LIB_SUFFIX) \
   -l ssl \
   -l crypto

ifndef USE_UPNP
    override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
    LIBS += -l miniupnpc
    DEFS += -DUSE_UPNP=$(USE_UPNP)
endif

ifneq (${USE_IPV6}, -)
    DEFS += -DUSE_IPV6=$(USE_IPV6)
endif

LIBS+= \
 -Wl,-B$(LMODE2) \
   -l z \
   -l dl \
   -l pthread


# Hardening
# Make some classes of vulnerabilities unexploitable in case one is discovered.
#
    # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
    # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
    # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
    HARDENING=-fno-stack-protector

    # Stack Canaries
    # Put numbers at the beginning of each stack frame and check that they are the same.
    # If a stack buffer if overflowed, it writes over the canary number and then on return
    # when that number is checked, it won't be the same and the program will exit with
    # a "Stack smashing detected" error instead of being exploited.
    HARDENING+=-fstack-protector-all -Wstack-protector

    # Make some important things such as the global offset table read only as soon as
    # the dynamic linker is finished building it. This will prevent overwriting of addresses
    # which would later be jumped to.
    LDHARDENING+=-Wl,-z,relro -Wl,-z,now

    # Build position independent code to take advantage of Address Space Layout Randomization
    # offered by some kernels.
    # see doc/build-unix.txt for more information.
    ifdef PIE
        HARDENING+=-fPIE
        LDHARDENING+=-pie
    endif

    # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
    # the source such overflowing a statically defined buffer.
    HARDENING+=-D_FORTIFY_SOURCE=2
#


DEBUGFLAGS=-g

# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only
# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.
xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
    $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)

# If we have an arm device, we can't use sse2, so define as thumb
# Otherwise, assume sse2 exists
# xCPUARCH is passed in as a define (xCPUARCH=armv7l)
ifeq ($(xCPUARCH),armv7l)
 xCXXFLAGS+=-marm -DNOSSE
else
 xCXXFLAGS+=-marm -DNOSSE
endif

# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only
# adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work.
xLDFLAGS=$(LDHARDENING) $(LDFLAGS)

OBJS= \
    obj/alert.o \
    obj/version.o \
    obj/checkpoints.o \
    obj/netbase.o \
    obj/addrman.o \
    obj/crypter.o \
    obj/key.o \
    obj/db.o \
    obj/init.o \
    obj/irc.o \
    obj/keystore.o \
    obj/main.o \
    obj/net.o \
    obj/protocol.o \
    obj/bitcoinrpc.o \
    obj/rpcdump.o \
    obj/rpcnet.o \
    obj/rpcmining.o \
    obj/rpcwallet.o \
    obj/rpcblockchain.o \
    obj/rpcrawtransaction.o \
    obj/script.o \
    obj/sync.o \
    obj/util.o \
    obj/wallet.o \
    obj/walletdb.o \
    obj/noui.o \
    obj/kernel.o \
    obj/pbkdf2.o \
    obj/scrypt_mine.o \
    obj/scrypt-x86.o \
    obj/scrypt-x86_64.o \
    obj/scrypt-arm.o

all: mintcoind

#
# LevelDB support
#
ifeq (${USE_LEVELDB}, 1)
LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) -DUSE_LEVELDB
DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
OBJS += obj/txdb-leveldb.o
leveldb/libleveldb.a:
    @echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd ..;
obj/txdb-leveldb.o: leveldb/libleveldb.a
endif
ifneq (${USE_LEVELDB}, 1)
OBJS += obj/txdb-bdb.o
endif

test check: test_mintcoin FORCE
    ./test_mintcoin

# auto-generated dependencies:
-include obj/*.P
-include obj-test/*.P

obj/build.h: FORCE
    /bin/sh ../share/genbuild.sh obj/build.h
version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO

obj/scrypt-x86.o: scrypt-x86.S
    $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<

obj/scrypt-x86_64.o: scrypt-x86_64.S
    $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<

obj/scrypt-arm.o: scrypt-arm.S
    $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<

obj/%.o: %.cpp
    $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
    @cp $(@:%.o=%.d) $(@:%.o=%.P); \
      sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
          -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
      rm -f $(@:%.o=%.d)

obj/%.o: %.c
    $(CXX) -c $(xCXXFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $<
    @cp $(@:%.o=%.d) $(@:%.o=%.P); \
    sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
        -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
    rm -f $(@:%.o=%.d)

mintcoind: $(OBJS:obj/%=obj/%)
    $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)

TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))

obj-test/%.o: test/%.cpp
    $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
    @cp $(@:%.o=%.d) $(@:%.o=%.P); \
      sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
          -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
      rm -f $(@:%.o=%.d)

test_mintcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
    $(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(xLDFLAGS) $(LIBS)

clean:
    -rm -f mintcoind test_mintcoin
    -rm -f obj/*.o
    -rm -f obj-test/*.o
    -rm -f obj/*.P
    -rm -f obj-test/*.P
    -rm -f obj/build.h

FORCE:

scrypt_mine.cpp for arm

/*-
 * Copyright 2009 Colin Percival, 2011 ArtForz, 2011 pooler, 2013 Balthazar
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * This file was originally written by Colin Percival as part of the Tarsnap
 * online backup system.
 */

#include <stdlib.h>
#include <stdint.h>

// Here, we need to check if we're compiling for an ARM processor. If we are, we
// need to make sure we don't try to use SSE instructions
extern "C" {
#ifndef NOSSE
#ifndef NO_ASM
include <xmmintrin.h>
#endif
#endif
}


#include "scrypt_mine.h"
#include "pbkdf2.h"

#include "util.h"
#include "net.h"

extern bool fShutdown;
extern bool fGenerateBitcoins;

extern CBlockIndex* pindexBest;
extern uint32_t nTransactionsUpdated;

// Here, we need to check to see what type of processor we're using
// because x86 and x64 have different buffer size requirements.
// We're assuming ARM processors fall in with i386 processors
// because I can't think of a good reason to automatically go with a
// larger buffer, given the lower RAM and swap file sizes for ARM boards
// compared to x86 boards.
// In case this is an issue, see the following URL for help determining
// a good buffer size:
// https://github.com/pooler/cpuminer/blob/4611186cb88eec76f22a88565675473b2eeade28/scrypt.c#L502-510
// It basically recommends SCRYPT_BUFFER_SIZE = (sizeof(int) * SCRYPT_MAX_WAYS * 128 + 63)
#if defined(__x86_64__)

#define SCRYPT_3WAY
#define SCRYPT_BUFFER_SIZE (3 * 131072 + 63)

extern "C" int scrypt_best_throughput();
extern "C" void scrypt_core(uint32_t *X, uint32_t *V);
extern "C" void scrypt_core_2way(uint32_t *X, uint32_t *Y, uint32_t *V);
extern "C" void scrypt_core_3way(uint32_t *X, uint32_t *Y, uint32_t *Z, uint32_t *V);

#elif ( defined(__i386__)||defined(__arm__) )

#define SCRYPT_BUFFER_SIZE (131072 + 63)

extern  "C" void scrypt_core(uint32_t *X, uint32_t *V);

#endif

void *scrypt_buffer_alloc() {
    return malloc(SCRYPT_BUFFER_SIZE);
}

void scrypt_buffer_free(void *scratchpad)
{
    free(scratchpad);
}

/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output
   scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes
   r = 1, p = 1, N = 1024
 */

static void scrypt(const void* input, size_t inputlen, uint32_t *res, void *scratchpad)
{
    uint32_t *V;
    uint32_t X[32];
    V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));

    PBKDF2_SHA256((const uint8_t*)input, inputlen, (const uint8_t*)input, sizeof(block_header), 1, (uint8_t *)X, 128);

    scrypt_core(X, V);

    PBKDF2_SHA256((const uint8_t*)input, inputlen, (uint8_t *)X, 128, 1, (uint8_t*)res, 32);
}

void scrypt_hash(const void* input, size_t inputlen, uint32_t *res, void *scratchpad)
{
    return scrypt(input, inputlen, res, scratchpad);
}

#ifdef SCRYPT_3WAY
static void scrypt_2way(const void *input1, const void *input2, size_t input1len, size_t input2len, uint32_t *res1, uint32_t *res2, void *scratchpad)
{
    uint32_t *V;
    uint32_t X[32], Y[32];
    V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));

    PBKDF2_SHA256((const uint8_t*)input1, input1len, (const uint8_t*)input1, input1len, 1, (uint8_t *)X, 128);
    PBKDF2_SHA256((const uint8_t*)input2, input2len, (const uint8_t*)input2, input2len, 1, (uint8_t *)Y, 128);

    scrypt_core_2way(X, Y, V);

    PBKDF2_SHA256((const uint8_t*)input1, input1len, (uint8_t *)X, 128, 1, (uint8_t*)res1, 32);
    PBKDF2_SHA256((const uint8_t*)input2, input2len, (uint8_t *)Y, 128, 1, (uint8_t*)res2, 32);
}

static void scrypt_3way(const void *input1, const void *input2, const void *input3,
   size_t input1len, size_t input2len, size_t input3len, uint32_t *res1, uint32_t *res2, uint32_t *res3,
   void *scratchpad)
{
    uint32_t *V;
    uint32_t X[32], Y[32], Z[32];
    V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));

    PBKDF2_SHA256((const uint8_t*)input1, input1len, (const uint8_t*)input1, input1len, 1, (uint8_t *)X, 128);
    PBKDF2_SHA256((const uint8_t*)input2, input2len, (const uint8_t*)input2, input2len, 1, (uint8_t *)Y, 128);
    PBKDF2_SHA256((const uint8_t*)input3, input3len, (const uint8_t*)input3, input3len, 1, (uint8_t *)Z, 128);

    scrypt_core_3way(X, Y, Z, V);

    PBKDF2_SHA256((const uint8_t*)input1, input1len, (uint8_t *)X, 128, 1, (uint8_t*)res1, 32);
    PBKDF2_SHA256((const uint8_t*)input2, input2len, (uint8_t *)Y, 128, 1, (uint8_t*)res2, 32);
    PBKDF2_SHA256((const uint8_t*)input3, input3len, (uint8_t *)Z, 128, 1, (uint8_t*)res3, 32);
}
#endif

unsigned int scanhash_scrypt(block_header *pdata, void *scratchbuf,
    uint32_t max_nonce, uint32_t &hash_count,
    void *result, block_header *res_header)
{
    hash_count = 0;
    block_header data = *pdata;
    uint32_t hash[8];
    unsigned char *hashc = (unsigned char *) &hash;

#ifdef SCRYPT_3WAY
    block_header data2 = *pdata;
    uint32_t hash2[8];
    unsigned char *hashc2 = (unsigned char *) &hash2;

    block_header data3 = *pdata;
    uint32_t hash3[8];
    unsigned char *hashc3 = (unsigned char *) &hash3;

    int throughput = scrypt_best_throughput();
#endif

    uint32_t n = 0;

    while (true) {

        data.nonce = n++;

#ifdef SCRYPT_3WAY
        if (throughput >= 2 && n < max_nonce) {
            data2.nonce = n++;
            if(throughput >= 3)
            {
                data3.nonce = n++;
                scrypt_3way(&data, &data2, &data3, 80, 80, 80, hash, hash2, hash3, scratchbuf);
                hash_count += 3;

                if (hashc3[31] == 0 && hashc3[30] == 0) {
                    memcpy(result, hash3, 32);
                    *res_header = data3;

                    return data3.nonce;
                }
            }
            else
            {
                scrypt_2way(&data, &data2, 80, 80, hash, hash2, scratchbuf);
                hash_count += 2;
            }

            if (hashc2[31] == 0 && hashc2[30] == 0) {
                memcpy(result, hash2, 32);

                return data2.nonce;
            }
        } else {
            scrypt(&data, 80, hash, scratchbuf);
            hash_count += 1;
        }
#else
        scrypt(&data, 80, hash, scratchbuf);
        hash_count += 1;
#endif
        if (hashc[31] == 0 && hashc[30] == 0) {
            memcpy(result, hash, 32);

            return data.nonce;
        }

        if (n >= max_nonce) {
            hash_count = 0xffff + 1;
            break;
        }
    }

    return (unsigned int) -1;
}

@kamronk
Copy link

kamronk commented Jun 15, 2015

I finally got mintcoind built! But I get this error when I try to
start up the daemon:

root@bigsmall:~/Mintcoin-Desktop-Wallet/src# ./mintcoind
mintcoind: main.cpp:2585: bool LoadBlockIndex(bool): Assertion
`block.GetHash() == (!fTestNet ? hashGenesisBlock :
hashGenesisBlockTestNet)' failed.
Aborted

Any ideas?

On Wed, May 13, 2015 at 2:00 PM, iHashFury notifications@github.com wrote:

doged - Thank you for the info.
Modified the files, put scrypt-arm.S in src and got cli built on arm [image:
👍] - now downloading the chain

I'm not a coder so I hope this hack does not mess up the MINT blockchain

makefile.unix for arm

Copyright (c) 2009-2010 Satoshi Nakamoto

Distributed under the MIT/X11 software license, see the accompanying

file COPYING or http://www.opensource.org/licenses/mit-license.php.

USE_UPNP:=0
USE_IPV6:=1
USE_LEVELDB:=1

LINK:=$(CXX)

DEFS=-DBOOST_SPIRIT_THREADSAFE

DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))

TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)

LMODE = dynamic
LMODE2 = dynamic
ifdef STATIC
LMODE = static
ifeq (${STATIC}, all)
LMODE2 = static
endif
else
TESTDEFS += -DBOOST_TEST_DYN_LINK
endif

for boost 1.37, add -mt to the boost libraries

LIBS +=
-Wl,-B$(LMODE)
-l boost_system$(BOOST_LIB_SUFFIX)
-l boost_filesystem$(BOOST_LIB_SUFFIX)
-l boost_program_options$(BOOST_LIB_SUFFIX)
-l boost_thread$(BOOST_LIB_SUFFIX)
-l db_cxx$(BDB_LIB_SUFFIX)
-l ssl
-l crypto

ifndef USE_UPNP
override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
LIBS += -l miniupnpc
DEFS += -DUSE_UPNP=$(USE_UPNP)
endif

ifneq (${USE_IPV6}, -)
DEFS += -DUSE_IPV6=$(USE_IPV6)
endif

LIBS+=
-Wl,-B$(LMODE2)
-l z
-l dl
-l pthread

Hardening

Make some classes of vulnerabilities unexploitable in case one is discovered.

# This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
# -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
# see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
HARDENING=-fno-stack-protector
# Stack Canaries
# Put numbers at the beginning of each stack frame and check that they are the same.
# If a stack buffer if overflowed, it writes over the canary number and then on return
# when that number is checked, it won't be the same and the program will exit with
# a "Stack smashing detected" error instead of being exploited.
HARDENING+=-fstack-protector-all -Wstack-protector

# Make some important things such as the global offset table read only as soon as
# the dynamic linker is finished building it. This will prevent overwriting of addresses
# which would later be jumped to.
LDHARDENING+=-Wl,-z,relro -Wl,-z,now

# Build position independent code to take advantage of Address Space Layout Randomization
# offered by some kernels.
# see doc/build-unix.txt for more information.
ifdef PIE
    HARDENING+=-fPIE
    LDHARDENING+=-pie
endif

# -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
# the source such overflowing a statically defined buffer.
HARDENING+=-D_FORTIFY_SOURCE=2

DEBUGFLAGS=-g

CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only

adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.

xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter
$(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)

If we have an arm device, we can't use sse2, so define as thumb

Otherwise, assume sse2 exists

xCPUARCH is passed in as a define (xCPUARCH=armv7l)

ifeq ($(xCPUARCH),armv7l)
xCXXFLAGS+=-marm -DNOSSE
else
xCXXFLAGS+=-marm -DNOSSE
endif

LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only

adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work.

xLDFLAGS=$(LDHARDENING) $(LDFLAGS)

OBJS=
obj/alert.o
obj/version.o
obj/checkpoints.o
obj/netbase.o
obj/addrman.o
obj/crypter.o
obj/key.o
obj/db.o
obj/init.o
obj/irc.o
obj/keystore.o
obj/main.o
obj/net.o
obj/protocol.o
obj/bitcoinrpc.o
obj/rpcdump.o
obj/rpcnet.o
obj/rpcmining.o
obj/rpcwallet.o
obj/rpcblockchain.o
obj/rpcrawtransaction.o
obj/script.o
obj/sync.o
obj/util.o
obj/wallet.o
obj/walletdb.o
obj/noui.o
obj/kernel.o
obj/pbkdf2.o
obj/scrypt_mine.o
obj/scrypt-x86.o
obj/scrypt-x86_64.o
obj/scrypt-arm.o

all: mintcoind

LevelDB support

ifeq (${USE_LEVELDB}, 1)
LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) -DUSE_LEVELDB
DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
OBJS += obj/txdb-leveldb.o
leveldb/libleveldb.a:
@echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd ..;
obj/txdb-leveldb.o: leveldb/libleveldb.a
endif
ifneq (${USE_LEVELDB}, 1)
OBJS += obj/txdb-bdb.o
endif

test check: test_mintcoin FORCE
./test_mintcoin

auto-generated dependencies:

-include obj/.P
-include obj-test/
.P

obj/build.h: FORCE
/bin/sh ../share/genbuild.sh obj/build.h
version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO

obj/scrypt-x86.o: scrypt-x86.S
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $&lt;

obj/scrypt-x86_64.o: scrypt-x86_64.S
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $&lt;

obj/scrypt-arm.o: scrypt-arm.S
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $&lt;

obj/%.o: %.cpp
$(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P);
sed -e 's/#.//' -e 's/^[^:]: *//' -e 's/ *$$//'
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) &gt;&gt; $(@:%.o=%.P);
rm -f $(@:%.o=%.d)

obj/%.o: %.c
$(CXX) -c $(xCXXFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P);
sed -e 's/#.//' -e 's/^[^:]: *//' -e 's/ *$$//'
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) &gt;&gt; $(@:%.o=%.P);
rm -f $(@:%.o=%.d)

mintcoind: $(OBJS:obj/%=obj/%)
$(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)

TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))

obj-test/%.o: test/%.cpp
$(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $&lt;
@cp $(@:%.o=%.d) $(@:%.o=%.P);
sed -e 's/#.//' -e 's/^[^:]: *//' -e 's/ *$$//'
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) &gt;&gt; $(@:%.o=%.P);
rm -f $(@:%.o=%.d)

test_mintcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
$(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(xLDFLAGS) $(LIBS)

clean:
-rm -f mintcoind test_mintcoin
-rm -f obj/.o
-rm -f obj-test/
.o
-rm -f obj/.P
-rm -f obj-test/
.P
-rm -f obj/build.h

FORCE:

scrypt_mine.cpp for arm

/*-

  • Copyright 2009 Colin Percival, 2011 ArtForz, 2011 pooler, 2013 Balthazar
  • All rights reserved.
    *
  • Redistribution and use in source and binary forms, with or without
  • modification, are permitted provided that the following conditions
  • are met:
    1. Redistributions of source code must retain the above copyright
  • notice, this list of conditions and the following disclaimer.
    1. Redistributions in binary form must reproduce the above copyright
  • notice, this list of conditions and the following disclaimer in the
  • documentation and/or other materials provided with the distribution.
  • THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  • ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  • IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  • ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  • FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  • DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  • OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  • HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  • LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  • OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  • SUCH DAMAGE.
    *
  • This file was originally written by Colin Percival as part of the Tarsnap
  • online backup system.
    */

#include <stdlib.h>
#include <stdint.h>

// Here, we need to check if we're compiling for an ARM processor. If we are, we
// need to make sure we don't try to use SSE instructions
extern "C" {
#ifndef NOSSE
#ifndef NO_ASM
include <xmmintrin.h>
#endif
#endif
}

#include "scrypt_mine.h"
#include "pbkdf2.h"

#include "util.h"
#include "net.h"

extern bool fShutdown;
extern bool fGenerateBitcoins;

extern CBlockIndex* pindexBest;
extern uint32_t nTransactionsUpdated;

// Here, we need to check to see what type of processor we're using
// because x86 and x64 have different buffer size requirements.
// We're assuming ARM processors fall in with i386 processors
// because I can't think of a good reason to automatically go with a
// larger buffer, given the lower RAM and swap file sizes for ARM boards
// compared to x86 boards.
// In case this is an issue, see the following URL for help determining
// a good buffer size:
// https://github.com/pooler/cpuminer/blob/4611186cb88eec76f22a88565675473b2eeade28/scrypt.c#L502-510
// It basically recommends SCRYPT_BUFFER_SIZE = (sizeof(int) * SCRYPT_MAX_WAYS * 128 + 63)
#if defined(x86_64)

#define SCRYPT_3WAY
#define SCRYPT_BUFFER_SIZE (3 * 131072 + 63)

extern "C" int scrypt_best_throughput();
extern "C" void scrypt_core(uint32_t *X, uint32_t *V);
extern "C" void scrypt_core_2way(uint32_t *X, uint32_t *Y, uint32_t *V);
extern "C" void scrypt_core_3way(uint32_t *X, uint32_t *Y, uint32_t *Z, uint32_t *V);

#elif ( defined(i386)||defined(arm) )

#define SCRYPT_BUFFER_SIZE (131072 + 63)

extern "C" void scrypt_core(uint32_t *X, uint32_t *V);

#endif

void *scrypt_buffer_alloc() {
return malloc(SCRYPT_BUFFER_SIZE);
}

void scrypt_buffer_free(void *scratchpad)
{
free(scratchpad);
}

/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output
scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes
r = 1, p = 1, N = 1024
*/

static void scrypt(const void* input, size_t inputlen, uint32_t *res, void *scratchpad)
{
uint32_t *V;
uint32_t X[32];
V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));

PBKDF2_SHA256((const uint8_t*)input, inputlen, (const uint8_t*)input, sizeof(block_header), 1, (uint8_t *)X, 128);

scrypt_core(X, V);

PBKDF2_SHA256((const uint8_t*)input, inputlen, (uint8_t *)X, 128, 1, (uint8_t*)res, 32);

}

void scrypt_hash(const void* input, size_t inputlen, uint32_t *res, void *scratchpad)
{
return scrypt(input, inputlen, res, scratchpad);
}

#ifdef SCRYPT_3WAY
static void scrypt_2way(const void *input1, const void *input2, size_t input1len, size_t input2len, uint32_t *res1, uint32_t *res2, void *scratchpad)
{
uint32_t *V;
uint32_t X[32], Y[32];
V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));

PBKDF2_SHA256((const uint8_t*)input1, input1len, (const uint8_t*)input1, input1len, 1, (uint8_t *)X, 128);
PBKDF2_SHA256((const uint8_t*)input2, input2len, (const uint8_t*)input2, input2len, 1, (uint8_t *)Y, 128);

scrypt_core_2way(X, Y, V);

PBKDF2_SHA256((const uint8_t*)input1, input1len, (uint8_t *)X, 128, 1, (uint8_t*)res1, 32);
PBKDF2_SHA256((const uint8_t*)input2, input2len, (uint8_t *)Y, 128, 1, (uint8_t*)res2, 32);

}

static void scrypt_3way(const void *input1, const void *input2, const void *input3,
size_t input1len, size_t input2len, size_t input3len, uint32_t *res1, uint32_t *res2, uint32_t *res3,
void *scratchpad)
{
uint32_t *V;
uint32_t X[32], Y[32], Z[32];
V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));

PBKDF2_SHA256((const uint8_t*)input1, input1len, (const uint8_t*)input1, input1len, 1, (uint8_t *)X, 128);
PBKDF2_SHA256((const uint8_t*)input2, input2len, (const uint8_t*)input2, input2len, 1, (uint8_t *)Y, 128);
PBKDF2_SHA256((const uint8_t*)input3, input3len, (const uint8_t*)input3, input3len, 1, (uint8_t *)Z, 128);

scrypt_core_3way(X, Y, Z, V);

PBKDF2_SHA256((const uint8_t*)input1, input1len, (uint8_t *)X, 128, 1, (uint8_t*)res1, 32);
PBKDF2_SHA256((const uint8_t*)input2, input2len, (uint8_t *)Y, 128, 1, (uint8_t*)res2, 32);
PBKDF2_SHA256((const uint8_t*)input3, input3len, (uint8_t *)Z, 128, 1, (uint8_t*)res3, 32);

}
#endif

unsigned int scanhash_scrypt(block_header *pdata, void *scratchbuf,
uint32_t max_nonce, uint32_t &hash_count,
void *result, block_header *res_header)
{
hash_count = 0;
block_header data = *pdata;
uint32_t hash[8];
unsigned char *hashc = (unsigned char *) &hash;

#ifdef SCRYPT_3WAY
block_header data2 = *pdata;
uint32_t hash2[8];
unsigned char *hashc2 = (unsigned char *) &hash2;

block_header data3 = *pdata;
uint32_t hash3[8];
unsigned char *hashc3 = (unsigned char *) &hash3;

int throughput = scrypt_best_throughput();

#endif

uint32_t n = 0;

while (true) {

    data.nonce = n++;

#ifdef SCRYPT_3WAY
if (throughput >= 2 && n < max_nonce) {
data2.nonce = n++;
if(throughput >= 3)
{
data3.nonce = n++;
scrypt_3way(&data, &data2, &data3, 80, 80, 80, hash, hash2, hash3, scratchbuf);
hash_count += 3;

            if (hashc3[31] == 0 && hashc3[30] == 0) {
                memcpy(result, hash3, 32);
                *res_header = data3;

                return data3.nonce;
            }
        }
        else
        {
            scrypt_2way(&data, &data2, 80, 80, hash, hash2, scratchbuf);
            hash_count += 2;
        }

        if (hashc2[31] == 0 && hashc2[30] == 0) {
            memcpy(result, hash2, 32);

            return data2.nonce;
        }
    } else {
        scrypt(&data, 80, hash, scratchbuf);
        hash_count += 1;
    }

#else
scrypt(&data, 80, hash, scratchbuf);
hash_count += 1;
#endif
if (hashc[31] == 0 && hashc[30] == 0) {
memcpy(result, hash, 32);

        return data.nonce;
    }

    if (n >= max_nonce) {
        hash_count = 0xffff + 1;
        break;
    }
}

return (unsigned int) -1;

}


Reply to this email directly or view it on GitHub
#11 (comment)
.

Kamron K.
| LinkedIn http://www.linkedin.com/pub/kamron-kennedy/2a/143/5 | Facebook
http://www.facebook.com/profile.php?id=100000156226446 | Google+
https://plus.google.com/118353359104281949586/posts |
(517) 763-6972

@presstab
Copy link
Contributor

You probably have a corrupted database. Remove everything except wallet.dat from your data directory and start syncing from scratch.

@ghost
Copy link
Author

ghost commented Jul 18, 2015

Getting this error again on the new wallet.

/bin/sh ../share/genbuild.sh obj/build.h
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/jason/tmp/Mintcoin-Desktop-Wallet/src -I/home/jason/tmp/Mintcoin-Desktop-Wallet/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/jason/tmp/Mintcoin-Desktop-Wallet/src/leveldb/include -DUSE_LEVELDB -I/home/jason/tmp/Mintcoin-Desktop-Wallet/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2  -marm -DNOSSE -MMD -MF obj/scrypt_mine.d -o obj/scrypt_mine.o scrypt_mine.cpp
scrypt_mine.cpp:32:23: fatal error: xmmintrin.h: No such file or directory
compilation terminated.
makefile.unix:188: recipe for target 'obj/scrypt_mine.o' failed
make: *** [obj/scrypt_mine.o] Error 1

I have updated makefile.unix, scrypt-arm.S and scrypt_mine.cpp as before

@justinvforvendetta
Copy link

have you tried deleting everything previously created in the /obj folder?

@ghost
Copy link
Author

ghost commented Jul 19, 2015

deleted /obj and got same error.

Will try starting again from scratch and modify the files

@ghost
Copy link
Author

ghost commented Jul 19, 2015

All good - built and running 247.

Also started my first git repo for the change src files.

https://github.com/iPerky/Mintcoind_Cubox_archlinuxARM.git

Thanks for info and help

@ghost ghost closed this as completed Jul 19, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants