BootTest im AVR BootTraps Demo mit Optimiser nicht brauchbar

Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

BootTest im AVR BootTraps Demo mit Optimiser nicht brauchbar

 · 
Posted: 02.08.2018 - 17:56  ·  #1
Das Demo "AVR BootTraps"
Code

{$PHASE BootBlock $0F000}
const
  Boot[$1FFF0] : word = $AA55;

procedure BootTest;
begin
  // the very first procedure called in the boot
  // ....
  ASM: JMP    SYSTEM.VectTab;
end;

würde mit Optimiser nicht funktionieren, weil der Sprung
Code

ASM: JMP    SYSTEM.VectTab;

vom Optimiser zu einem
Code

JMP       SYSTEM.RESET

wird

Ersteres ist ein Sprung nach 0h, letzteres ist ein ungewisser Sprung.
Das Problem ist, dass die Position von System.Reset nach einem FlashDownload
sich ändert und der Bootloader dann zur Falschen Stelle springt.
Bitte Demo und Compiler-Handbuch Seite 185
Code

 SetVectTabBoot(false); // vector table on address 0
 ASM: JMP SYSTEM.VectTab; // absolute address $0000 = RESET vector

verbessern. Vorschlag: {$VALIDATE $} benutzen.

Auszug .lst file:
Code

0256   F000                                    .PHASE     01E000h BOOT
0257   F012                                    .ORG       01E024h, BOOT
0258   F012                                    
0259   F012                                    .FUNC     BootTest, 00025h, 00020h
0260   F012                                    .VALID
0261   F012            BootTrapCheck.BootTest:
0262   F012                                    .RETURNS   0
0263   F012                                    .BLOCK    38
0264   F012                                    .LINE     41
0265   0053                                    .BRANCH   20, SYSTEM.RESET
0266   F012   940C0053                         JMP       SYSTEM.RESET
0267   F014                                    .ENDBLOCK 42
0268   F014                                    .LINE     42
0269   F014                                    .ENDFUNC  42
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: BootTest im AVR BootTraps Demo mit Optimiser nicht brauchbar

 · 
Posted: 02.08.2018 - 19:05  ·  #2
Hallo Thomas
dass ein Punkt für Merlin! !
rolf
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: BootTest im AVR BootTraps Demo mit Optimiser nicht brauchbar

 · 
Posted: 02.08.2018 - 20:32  ·  #3
Hallo Rolf und alle Mitlesenden,
ich finde der Optimiser macht das richtig. Dieser kann nicht wissen, dass ein ein FlashDownload die Vektortabelle ändert.
Es besteht auch grundsätzlich die Gefahr, das Trap Sprünge durch den Optimiser ausgehebelt werden. Daher empfehle ich diese auch mit VALIDATE zu kompelieren. Soweit ich mich erinnere, hatte ich in der Vergangenheit Probleme mit Traps und Optimiser ohne den Gebrauch von VALIDATE. Vielleicht sollte man in der Dokumentation den Gebrauch von VALIDATE bei Traps empfehlen oder sogar zwingend vorschreiben.
Ich bin auf Merlins Input gespannt.

Gruß

Beispiel Trap mit VALIDATE
Code

{$VALIDATE $} // Der Trap soll auf keinem Fall weg optimiert werden
procedure FlashDownloader_Trap; Trap;
begin
  FlashDownLoader;
end; 
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1362
Registered: 03 / 2005
Subject:

Re: BootTest im AVR BootTraps Demo mit Optimiser nicht brauchbar

 · 
Posted: 06.08.2018 - 07:57  ·  #4
Hello Thomas.

You make a very good point, and one that I had not thought of. It is easy to resolve, though, and I will do that in the next release of optimiser.

This only affects boot-loaders, of course, but I don't think that I can limit it to that. It would be too complex. I can limit it to System.Reset, but it is probably safest to avoid the optimisation for any jump to any vector in any vector table, that is what I plan to do.

I do not believe that users should take have to take special care just because they are using the optimiser. Of course they can but if they don't (e.g. a newbie) it should not cause their program to fail.

Regards
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: BootTest im AVR BootTraps Demo mit Optimiser nicht brauchbar

 · 
Posted: 08.08.2018 - 10:01  ·  #5
Quote
You make a very good point

Thanks, In my case the bootloader sometimes works and sometimes not. Thus, I was encouraged to discover the reason.

Regards,
Thomas
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: BootTest im AVR BootTraps Demo mit Optimiser nicht brauchbar

 · 
Posted: 08.08.2018 - 15:12  ·  #6
I will Do an update this evening
rolf
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   110   124 · Page-Gen-Time: 0.024469s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI