Undefined constants

Extension to help with bootloaders

  • 1
  • 2
  • Page 2 of 2
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1372
Registered: 03 / 2005
Subject:

Re: Undefined constants

 · 
Posted: 21.02.2014 - 16:59  ·  #9
@Harold

Hi. Yes, that is one of the possible methods. There are others too. I am not saying it can't be done, just that my suggestion would provide more readable, easier to maintain code.

@Rolf

I don't dispute anything that you say, but by using $PHASE you can put just about anything anywhere, and there is at least one person out there prepared to think outside the box, and, as I understand it, this very good design you speak of already exists (not, I hasten to add, written by me ;-).)

At any event this seems to have developed into a heated debate on the relative merits and possibilities of bootloaders, rather than an idea for the compiler, which is where it started.
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: Undefined constants

 · 
Posted: 21.02.2014 - 17:26  ·  #10
@Rolf:
Hi Rolf, we discussed that subject long ago in the topic "Updating Bootloader via Flash-Write" - and I used the means and possibilities you provided in the compiler. I know that section of the handbook, it is well marked in my old manual dating from 2007. Well, the example code is still there for download.
I attach a little memory map here that explains the design. A sketch can explain better than many words.
That design is based completely on your ideas, handbook and compiler, the only thing I changed, is the memory position of the flash write section for re-writing the bootloader. Since the crucial part requires only about 230 Bytes, I did not want to waste the rest of the unused boot area, so I placed it almost into the middle of the boot area, thus leaving almost 4 K boot area for the main application. (I was very short of memory in that project)

@Harald_K: A nice alternative to FlashPtr, I will try it. Thanks!

PS: The sketch is for a 128 K ATMega
You must be logged in or your permissions are to low to see this Attachment(s).
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Undefined constants

 · 
Posted: 21.02.2014 - 17:53  ·  #11
@Harald,
this code (Z-pointer, LPM) only works with AVRs < 128kB. With larger Flash the RampZ register must also be set to the desired 64k flash page.

@Michael,
I don't see any difference between my posting above and yours (SPM and Boot). You also have a small "bootloader" which always stays there and it can be called from everywhere.

@Merlin,
I don't see any further possibility to support your intention except with iData and/or BootTraps.

rolf
Harald_K
 
Avatar
 
Subject:

Re: Undefined constants

 · 
Posted: 21.02.2014 - 20:12  ·  #12
ok, so lets do it this way:

1. you declare a normal const at the desired address:

const
CPULoaderVersion[$3FFFA] : word = $1234;

and put the statement

w := CPULoaderVersion;

in your code where you need it.

then you compile your project

from the IDE, use Datei / Öffnen / and select the .asm-File the Compiler has generated.

then scroll to the lines the compiler has produced for your w := ... statement,
mark them
copy them to the clipboard

switch back to your pascal source (at the line containing the w := .. statement

insert the text from the clipboard

put the asm; endasm; around it

prefix the const-declaration by //

replace the symbolic addresses of your constant by the physical adress in the RAMPZ / Z - statements.


so the compiler has done everything for you, selects the appropriate RAMPZ / Z / (E)LPM for your AVR etc.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1372
Registered: 03 / 2005
Subject:

Re: Undefined constants

 · 
Posted: 21.02.2014 - 20:26  ·  #13
Thank you Harold.

I do things this way too, sometimes. But the whole point of my suggestion was to avoid this sort of thing.

If the suggestion is no good, for whatever reasons, then that is really no problem for me. It was just a suggestion.

But thank you again for your input and help.
  • 1
  • 2
  • Page 2 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   92   106 · Page-Gen-Time: 0.02732s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI