Trying to find a smaller function for writing flash page

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

Is there a smaller version for an ASM function that writes a page of FLASH? Currently, I use the one from ATmega128 datasheet - page 275.

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

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

see earlier question in your other thread. What's the problem with the bootloader size and mega128. You have loads of space. What does your bootloader do....that means you need so much memory.

check .lss file.....maybe all the memory is used for scanf or printf or something like that.
Can you cut down here?

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

The examples for subroutines given in datasheets are good and optimized. You may try to write your own as I did, but that didn't save me a lot of flash or execution cycles. Some operations for writing in flash are neccessary => don't miss them.

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

sorry, it is mega8... not mega128 (my mistake... I'm a little tired after a hard week; indeed I looked over datasheet of mega128, but it's not very different from the one for mega8 :-).
need optimization badly :-)

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

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

well, I checked:
- no printf / scanf there;
- checked "optimized for size ";
.... strictly necessary header(s) included, etc.
I mainly use C... I'm not good at asm (at all :-( )

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

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

Do you really need to squeeze your bootloader in to 512 words?
You can assign upto 4096 words to the bootloader in the mega128.

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

Well... as I told you before (mea culpa) it's about mega8 in fact...
And the BL uses encryption.

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

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

groenhen wrote:
sorry, it is mega8... not mega128 (my mistake... I'm a little tired after a hard week; indeed I looked over datasheet of mega128, but it's not very different from the one for mega8 :-).
need optimization badly :-)

well in your earlier post it was mega128......and now you say mega8. How can you expect people to help if you don't even know what chip you're using.

and on the mega 8 you can have a bootloader with 1024 bytes.
I read it in the data sheet

You can't fit an elephant into a fridge..so you are fighting a losing battle. If the mega8 doesn't have enough memory, why f*** about trying to save a few bytes, when you can just use a bigger device.

What happens if you want to add something in the future: odear it won't fit!..........so now I have to use a bigger device anyway and spend another day working out what my over optimised code is doing (because you will forget in six months time).

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

- I don't have to apologize again because, from this point of view (generated code), it is the same situation: mega8 or mega128, the write flash function is 99% the same! There are ONLY 2 (two) differences: the page size and the SPMCR register...
You know I'm right! :-)
BTW: Don't be so harsh :-) Life itself is harsh enough; why make it worse?
- Now: why 512w? Because I need more space for the application; as you already said: I want to make sure there is plenty of space in the app. section in case my client will ask me (maybe, in the future) to add some new feature. BTW: 512w = 1024 bytes ! :-)
- About the "elephant": it's not MY elephant :-) ... it's the client's! If the client wants mega8, well... it's his decision; it's NOT up to me. I'm not in the position to "negotiate" with the client. Some issues are already established and all I have to do is to do my job as well as I can, not to change the client's project. There are costs matters, the PCB is already finalized, etc, etc.
- If I want to add something in the future... well, as I said before, it will definitely be in the app. section (that's why I reserved some space there), not in the BL section.
Ok, thx for your advices!
***
In Orient, there is a saying: "We have to find the solution, not the guilty"...

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

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

Sorry...I said you can have a bootloader of 1024 bytes......I meant 1024 words.