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

Unable to compile U2F (chopstx) #17

Open
shouya opened this issue Sep 20, 2018 · 2 comments
Open

Unable to compile U2F (chopstx) #17

shouya opened this issue Sep 20, 2018 · 2 comments

Comments

@shouya
Copy link

shouya commented Sep 20, 2018

Sorry for posting this issue here since im-tomu/chopstx doesn't have an issue tracker.

I was trying to build the u2f source code for my Tomu but the following error prevents it from building the binary:

arm-none-eabi-gcc -c -mcpu=cortex-m0plus -O3 -Os -fstack-usage -ffunction-sections -fdata-sections -fno-common -Wall -Wextra -Wstrict-prototypes -Wa,-alms=build/bn.lst -DMAKE_ENTRY_PUBLIC -DUSE_SYS3 -DFREE_STANDING -DMHZ=21 -mthumb -mno-thumb-interwork -DTHUMB -MD -MP -MF .dep/bn.o.d -I. -I.. bn.c -o build/bn.o
In file included from bn.c:134:0:
bn-thumb1.h: In function ‘bn256_mul_thumb1’:
bn-thumb1.h:32:1: error: ‘asm’ operand has impossible constraints
 asm (                                                      \
 ^
bn-thumb1.h:78:4: note: in expansion of macro ‘MULADD’
    MULADD(at[0], at[8]);
    ^~~~~~

As I checked the source code, MULADD is defined as follows:

#define MULADD(i, j)                                       \
asm (                                                      \
   "ldr r1, %[_i]         \n\t"                            \
   "ldr r2, %[_j]         \n\t"                            \
   "uxth r6, r1           \n\t"                            \
   "uxth r7, r2           \n\t"                            \
   "lsr r1, r1, #16       \n\t"                            \
   "lsr r2, r2, #16       \n\t"                            \
                                                           \
   "mov r0, r6            \n\t"                            \
   "mul r0, r0, r7        \n\t"                            \
   "mul r6, r6, r2        \n\t"                            \
   "mul r2, r2, r1        \n\t"                            \
   "mul r1, r1, r7        \n\t"                            \
                                                           \
   "mov r7, #0            \n\t"                            \
   "add %0, %0, r0        \n\t"                            \
   "adc %1, %1, r2        \n\t"                            \
   "adc %2, %2, r7        \n\t"                            \
                                                           \
   "lsl r0, r6, #16       \n\t"                            \
   "lsr r2, r6, #16       \n\t"                            \
   "add %0, %0, r0        \n\t"                            \
   "adc %1, %1, r2        \n\t"                            \
   "adc %2, %2, r7        \n\t"                            \
                                                           \
   "lsl r0, r1, #16       \n\t"                            \
   "lsr r2, r1, #16       \n\t"                            \
   "add %0, %0, r0        \n\t"                            \
   "adc %1, %1, r2        \n\t"                            \
   "adc %2, %2, r7        \n\t"                            \
                                                           \
   :"=l"(c0), "=l"(c1), "=l"(c2)                           \
   : "0"(c0), "1"(c1), "2"(c2), [_i] "m" (i), [_j] "m" (j) \
   : "r0", "r1", "r2", "r6", "r7", "cc");

I guess it could be some instructions/registers not supported by this chip, but I have no further clue on what to do with it. I have little experience with embedded programming, so I don't know if this situation is very trivial and have simple solutions.

Here's my gcc version:

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (Gentoo 7.3.0-r3 p1.4) 7.3.0

And my full make log: output.log

A little help would be appreciated!

@shouya
Copy link
Author

shouya commented Sep 20, 2018

I'm building it with a clean compiler on a clean system, by following the exact instructions on https://tomu.im/. I've tried compiling some other examples and they all works fine. It only fails for chopstx, for which I guess it could be an issue in this project.

@crazyquark
Copy link

Have you tried this:
https://groups.google.com/forum/#!topic/tomu-discuss/HtlArkEWhCo
Towards the end of the thread there is a talk about installing other libnew packages

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

2 participants