revoxhere / duino-coin

ᕲ Duino-Coin is a coin that can be mined with almost everything, including Arduino boards.
https://duinocoin.com
MIT License
1.06k stars 518 forks source link

STM error while compiling #468

Closed Moayidd closed 3 years ago

Moayidd commented 3 years ago

I'm trying to compile the Arduino code on an STM32 device but keeping getting the error message

error "ArduinoUniqueID only works on AVR, SAM, SAMD, STM32 and ESP Architecture"

The STM compiles and runs normally for other arduino programs I've defined the STM32 as a Generic STM32F103C series and the upload method as Series as usual.

LDarki commented 3 years ago

Hi, try changing the line 18 of uniqueID.h from

#elif defined(ARDUINO_ARCH_STM32)

to

#elif defined(STM32) || defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)
Moayidd commented 3 years ago

That gut me past the original problem but now I get Arduino: 1.8.13 (Windows 7), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)"

In file included from sketch\sha1.h:24:0, from sketch\sha1.cpp:17: sha1.h:30:1: error: 'ssize_t' does not name a type ssize_t sha1_hasher_write(sha1_hasher_t hasher, const void * buf, size_t count); ^ In file included from D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:26:0: uniqueID.h:84:13: error: 'UniqueIDbuffer' was not declared in this scope uint8_t id[UniqueIDbuffer]; ^ D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino: In function 'void setup()': uniqueID.h:52:29: error: 'class ArduinoUniqueID' has no member named 'id'

define UniqueID (_UniqueID.id + UniqueIDbuffer - UniqueIDsize)

                         ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:48:17: note: in expansion of macro 'UniqueID' IDstring += UniqueID[i]; ^ uniqueID.h:52:34: error: 'UniqueIDbuffer' was not declared in this scope

define UniqueID (_UniqueID.id + UniqueIDbuffer - UniqueIDsize)

                              ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:48:17: note: in expansion of macro 'UniqueID' IDstring += UniqueID[i]; ^ uniqueID.h:52:51: error: 'UniqueIDsize' was not declared in this scope

define UniqueID (_UniqueID.id + UniqueIDbuffer - UniqueIDsize)

                                              ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:48:17: note: in expansion of macro 'UniqueID' IDstring += UniqueID[i]; ^ D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino: In function 'void loop()': Arduino_Code:105:5: error: 'PORTB' was not declared in this scope PORTB = PORTB | B00100000; ^ In file included from sketch\uniqueID.cpp:4:0: uniqueID.h:84:13: error: 'UniqueIDbuffer' was not declared in this scope uint8_t id[UniqueIDbuffer]; ^ exit status 1 'ssize_t' does not name a type This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

LDarki commented 3 years ago

you installed the necessary libraries? like your SMT32 and avr?

Moayidd commented 3 years ago

Yes, the STM32F board libraries are all installed here, naturally the avr libs are too

LDarki commented 3 years ago

Add this to sha1/sha1.h

#include <io.h>
typedef __int8            int8_t;
typedef __int16           int16_t; 
typedef __int32           int32_t;
typedef __int64           int64_t;
typedef unsigned __int8   uint8_t;
typedef unsigned __int16  uint16_t;
typedef unsigned __int32  uint32_t;
typedef unsigned __int64  uint64_t;

#ifdef _WIN64
#define ssize_t __int64
#else
#define ssize_t long
#endif

And this in Arduino_Code.ino

#define PORTB GPIOB
Moayidd commented 3 years ago

Now I'm getting Arduino: 1.8.13 (Windows 7), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)"

In file included from sketch\sha1.h:24:0,

             from sketch\sha1.cpp:17:

sha1.h:26:9: error: '__int8' does not name a type

typedef __int8 int8_t;

     ^

sha1.h:27:9: error: '__int16' does not name a type

typedef __int16 int16_t;

     ^

sha1.h:28:9: error: '__int32' does not name a type

typedef __int32 int32_t;

     ^

sha1.h:29:9: error: '__int64' does not name a type

typedef __int64 int64_t;

     ^

sha1.h:30:27: error: expected initializer before 'uint8_t'

typedef unsigned __int8 uint8_t;

                       ^

sha1.h:31:27: error: expected initializer before 'uint16_t'

typedef unsigned __int16 uint16_t;

                       ^

sha1.h:32:27: error: expected initializer before 'uint32_t'

typedef unsigned __int32 uint32_t;

                       ^

sha1.h:33:27: error: expected initializer before 'uint64_t'

typedef unsigned __int64 uint64_t;

                       ^

In file included from sketch\sha1/sha1.c:17:0,

             from sketch\backend.cpp:23:

sha1.h:26:9: error: '__int8' does not name a type

typedef __int8 int8_t;

     ^

sha1.h:27:9: error: '__int16' does not name a type

typedef __int16 int16_t;

     ^

sha1.h:28:9: error: '__int32' does not name a type

typedef __int32 int32_t;

     ^

sha1.h:29:9: error: '__int64' does not name a type

typedef __int64 int64_t;

     ^

sha1.h:30:27: error: expected initializer before 'uint8_t'

typedef unsigned __int8 uint8_t;

                       ^

sha1.h:31:27: error: expected initializer before 'uint16_t'

typedef unsigned __int16 uint16_t;

                       ^

sha1.h:32:27: error: expected initializer before 'uint32_t'

typedef unsigned __int32 uint32_t;

                       ^

sha1.h:33:27: error: expected initializer before 'uint64_t'

typedef unsigned __int64 uint64_t;

                       ^

In file included from sketch\sha1.h:24:0,

             from D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:23:

sha1.h:26:9: error: '__int8' does not name a type

typedef __int8 int8_t;

     ^

sha1.h:27:9: error: '__int16' does not name a type

typedef __int16 int16_t;

     ^

sha1.h:28:9: error: '__int32' does not name a type

typedef __int32 int32_t;

     ^

sha1.h:29:9: error: '__int64' does not name a type

typedef __int64 int64_t;

     ^

sha1.h:30:27: error: expected initializer before 'uint8_t'

typedef unsigned __int8 uint8_t;

                       ^

sha1.h:31:27: error: expected initializer before 'uint16_t'

typedef unsigned __int16 uint16_t;

                       ^

sha1.h:32:27: error: expected initializer before 'uint32_t'

typedef unsigned __int32 uint32_t;

                       ^

sha1.h:33:27: error: expected initializer before 'uint64_t'

typedef unsigned __int64 uint64_t;

                       ^

In file included from D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:26:0:

uniqueID.h:84:13: error: 'UniqueIDbuffer' was not declared in this scope

uint8_t id[UniqueIDbuffer];

         ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino: In function 'void setup()':

uniqueID.h:52:29: error: 'class ArduinoUniqueID' has no member named 'id'

define UniqueID (_UniqueID.id + UniqueIDbuffer - UniqueIDsize)

                         ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:48:17: note: in expansion of macro 'UniqueID'

 IDstring += UniqueID[i];

             ^

uniqueID.h:52:34: error: 'UniqueIDbuffer' was not declared in this scope

define UniqueID (_UniqueID.id + UniqueIDbuffer - UniqueIDsize)

                              ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:48:17: note: in expansion of macro 'UniqueID'

 IDstring += UniqueID[i];

             ^

uniqueID.h:52:51: error: 'UniqueIDsize' was not declared in this scope

define UniqueID (_UniqueID.id + UniqueIDbuffer - UniqueIDsize)

                                               ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:48:17: note: in expansion of macro 'UniqueID'

 IDstring += UniqueID[i];

             ^

In file included from C:\Users\User\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\cores\maple/wirish.h:57:0,

             from C:\Users\User\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\cores\maple/Arduino.h:30,

             from sketch\Arduino_Code.ino.cpp:1:

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino: In function 'void loop()':

C:\Users\User\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\cores\maple/bit_constants.h:228:19: error: invalid operands of types 'gpio_dev* const' and 'int' to binary 'operator|'

define B00100000 32

               ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:105:21: note: in expansion of macro 'B00100000'

 PORTB = PORTB | B00100000;

                 ^

C:\Users\User\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\cores\maple/bit_constants.h:545:19: error: invalid operands of types 'gpio_dev* const' and 'int' to binary 'operator&'

define B11011111 223

               ^

D:\DUCO2.4.5\Arduino_Code\Arduino_Code.ino:109:21: note: in expansion of macro 'B11011111'

 PORTB = PORTB & B11011111;

                 ^

In file included from sketch\uniqueID.cpp:4:0:

uniqueID.h:84:13: error: 'UniqueIDbuffer' was not declared in this scope

uint8_t id[UniqueIDbuffer];

         ^

exit status 1

'__int8' does not name a type

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Moayidd commented 3 years ago

It might be a file/folder structure problem. I installed/unzipped all the DuinoCoin Code in a separate folder on a separate Drive. Could this be the problem ? If so where should I unzip then DuinoCoin zip file to ?

Moayidd commented 3 years ago

I've placed the unzipped duino-coin files in the appropriate arduino library file structure but I'm still getting the same error.

BastelPichi commented 3 years ago

It might be a file/folder structure problem. I installed/unzipped all the DuinoCoin Code in a separate folder on a separate Drive. Could this be the problem ? If so where should I unzip then DuinoCoin zip file to ?

There may be problems if your file path contains a space.

Moayidd commented 3 years ago

I tried version 2.3 which did not iuclude ArduinoUniqueID.h and the problems vanished except for the PORTB error in Arduino.ino. Defining PORTB as GPIOB as suggested above gave an error so I simply commented out both references to PORTB and the sketch compiled without errors. I think when producing the new code for reading the chipid which used ArduinoUniqueID.h no attempt was made to test it on an STM32 board and hence these errors weren't spotted.

Moayidd commented 3 years ago

Still researching but I'm almost 100% certain that the original error was due to different STM32 Libraries. I'm using the Libraries provided by dan and Im guessing your code was developed using the newer STM32CubeProgrammer Libraries

asovetov commented 3 years ago

Confirm on Arduino code. But work fine on code for arduino Due. with #elif defined(STM32) || defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)

And latest (v2.49) avr-miner

the older one swore at the wrong chipID

P.S. STM32F103C8 0.018s ∙ 5639 H/s @ diff 5 in console, but stm32 (Official AVR Miner (DUCO-S1A) v2.49) 8.00 H/s @ diff 5, 81/81 (100%) in Wallet =((

It is not clear why not to use the hardware crypto built into the stm32 chip. It can count even sha256 fast enough. I think sha1 is not a problem.

Moayidd commented 3 years ago

Actually I finally got it running on 2.45 Arduino.ino code (I hadn't seen 2.49 yet). You need to install a boot loader using STM32CubeProgrammer first then in Arduino IDE use an upload method of HID 2.2 (which you should have installed also). Then it runs with a difficulty of 1000 !!