libtomcrypt in IAR

305 views
Skip to first unread message

Mahajan, Vipul

unread,
Nov 14, 2013, 2:40:13 AM11/14/13
to lib...@googlegroups.com

Hi,

 

Can anyone help me using libtomcrypt in IAR?

I have added all source files in IAR project and the code is compiling properly. The functions are also getting called but the interesting part is, it result in hardfault when I run in free mode but if I do single stepping the functions are working fine. So something related to memory fetch or speed is there my rest of the code is working fine but only libtomcrypt functions are causing problem. So was looking for IAR compatible libtomcrypt.

 

Please suggest.

 

Thanks & Regards,

Vipul Mahajan

 


P PLEASE CONSIDER OUR ENVIRONMENT BEFORE PRINTING THIS EMAIL.

This e-mail (including any attachments) is confidential and may be legally privileged. If you are not an intended recipient or an authorized representative of an intended recipient, you are prohibited from using, copying or distributing the information in this e-mail or its attachments. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete all copies of this message and any attachments. Thank you.

Derek Godfrey

unread,
Nov 14, 2013, 9:25:01 AM11/14/13
to <libtom@googlegroups.com>
Can't really help you as is, but I am curious what IAR is.

-Derek
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
---
You received this message because you are subscribed to the Google Groups "LibTom Projects" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libtom+un...@googlegroups.com<mailto:libtom+un...@googlegroups.com>.
To post to this group, send email to lib...@googlegroups.com<mailto:lib...@googlegroups.com>.
Visit this group at http://groups.google.com/group/libtom.
For more options, visit https://groups.google.com/groups/opt_out.

Bill Priest

unread,
Nov 15, 2013, 10:56:20 PM11/15/13
to lib...@googlegroups.com
Hi Vipul,
I've used IAR ARM for PolarSSL (encryption) and it pretty much
worked out of the box. You don't say what processor you are using;
the processsor is especially 8/16 bit are more likely to have issues
than 32 bit processors like ARM. When I developed using IAR I always
used their Simulator to debug software before getting on the hardware.
Your description sounds like a stack or hardware/memory timing issue
to me (are you using external memory or internal on-chip?).

My 2 cents,

Bill
> --
> *** Please reply-to-all at all times ***
> *** (do not pretend to know who is subscribed and who is not) ***
> *** Please avoid top-posting. ***
> ---
> You received this message because you are subscribed to the Google Groups
> "LibTom Projects" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to libtom+un...@googlegroups.com.
> To post to this group, send email to lib...@googlegroups.com.

varun.r...@gmail.com

unread,
Nov 19, 2013, 3:22:12 AM11/19/13
to lib...@googlegroups.com
Hi Bill,

Vipul and myself are working on this issue. Thanks for your reply.
Let me elaborate.

We first tried to compile and run things on Visual studio environment. Since there is an existing workspace for that, it worked out of the box. However when we ported on IAR, code compiled and can be executed but only by single-stepping, if kept free running, we are stuck with Hard-fault exception of ARM.

We are using following environment.

IAR IDE: Version 6.60
Controller: TMPM36BF10FG (from Toshiba, ARM Cortex - M3)
Code and Data memory used: All on-chip

Also we noticed that for Visual studio environment following are the macros used in default environment.

_DEBUG
LTM_DESC
WIN32
_LIB
LTC_SOURCE
USE_LTM

We believe none of the macro are relevant for IAR IDE. 
LTM_DESC, LTC_SOURCE and USE_LTM are related to math libraries and IAR can have it's own, hence are of no use. _DEBUG and _LIB are also irrelevant for now.

For IAR, we further used following two macros
#define ARGTYPE  3
#define LTC_NO_FAST

But still no luck.

Do you have a workspace for IAR. It will be great if you can share that. It will help us to have reference for IAR environment.

Regards,
Varun

Bill Priest

unread,
Nov 19, 2013, 8:55:53 AM11/19/13
to lib...@googlegroups.com
Hi Vipul,
I'm at work now and don't have access to my IAR workspace as it is
on my home computer. I should be able to get something to you tonight
after my kids are in bed (10 or 11 pm CST). IIRC the heap and stack
by default are fairly small; you might try increasing the size;
additionally are you using the Simulator or an eval board? I'd debug
on the Simulator first (plus you can increase the size of the RAM
passed the "normal" amount on the chip).

Bill

Bill Priest

unread,
Nov 20, 2013, 1:26:50 AM11/20/13
to lib...@googlegroups.com
Hi Vipul,
I'm built all the library files (except the tests). I built w/
LTC_SOURCE and only had a small # of warnings (I looked at them and
they aren't likely to cause a problem). When I just use LTC_NO_FAST
and ARGTYPE=3 then I got a lot of warnings about implicit/missing
prototypes (these can cause real problems; stack corruption and other
nasty stuff).

Of course I don't know if the files you are using/linking with have
these issues or not. I'd be a little wary of initially using IAR's
library versus tommath's library as the IAR libraries might not be a
"drop in" replacement.

I enabled multibyte char (you didn't mention this) and signed char in
the Project Options Language 2 tab (this is more like most compilers).

I got rid of most of the warnings (most are intuitively obvious); the
ones that I didn't fix were
der_encode_utf8_string.c
der_encode_utf8_string(const wchar_t *in ..)
if (in[x] < 0 || in[x] > 0x1FFFF)
pointless comparison of unsigned integer with zero
pointless integer comparison, the result is always false

similar warnings in der_length_utf8_string.c

(5 warnings total)

AFAICT wchar_t is an unsigned short int on IAR; not sure what it is
expected to be. I've never used UTF8 w/ encryption; these warnings
don't look like they would cause a problem.

Let me know a test that you are having issues with (or that uses the
encryption/decryption that you are trying to use) and I'll compile,
build, and run it. I used PolarSSL with IAR on an embedded ARM core
and it worked well (in many ways it is similar to tomcrypt). I chose
PolarSSL as it was delivered as part of the board support package for
the processor I was using (I was going to use tomcrypt until I found
it).
In general most of these packages require that the data to be
encrypted be padded out to some "arbitrary" boundary; this is the only
gotcha that I remember.

Note with IAR using file I/O you'll need to add heap space (I never
used file I/O after testing with the Simulator as the JTAG I/F was
missing from most of the boards and it was a PITA to get someone to
put one on the board and keep it working (I don't recommend debugging
this way; but I have > 15 years w/ ARMs so I can get by).

Good Luck,

Bill

On Tue, Nov 19, 2013 at 2:22 AM, <varun.r...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages