atmega2560 - free ram - HMAC SHA1

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, 
Im trying to run this code for hmac sha1 hashing on my mega2560. 

https://github.com/cantora/avr-c...

 

On simulator it is working. On mega2560 it gives inncorect hash. 
I have used more than 90% of flash so i tried to comment out whole main loop, which reduced flash to 15% but it doesnt fix the problem. 

 

Found this code:
 

int freeRam () {
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}

But it always shows 0. 
Have no idea where should I looking for solution. 
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to AVRFreaks!

 

rather then post code snippets, create a complete small program that demos your problem and post that, in that way other freaks can run your program and help you debug it.  Most will find the answer while doing this.

 

jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That function (and variations) is pretty well-known in the Arduino world but I've only used it on smaller AVRs like the 328, 644 and 1284.

 

This article (which is very helpful intro to memory anyway) presents a slightly different function. Worth trying for the 30 seconds it'll cost you. https://learn.adafruit.com/memor....

 

Is the 2560 significantly different to smaller AVRs like the 328P ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For large memory devices, there are "issues" crossing 16-bit address boundary, as I recall. Does the canned hash function deal with that properly?

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!