Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Include version info/date into compilation output

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 115
Location: Graz

austria.gif
PostPosted: Tue Feb 23, 2021 2:23 pm    Post subject: Include version info/date into compilation output Reply with quote

Sometimes, one wants to include the firmware version, build dates etc at a fixed position into the binary output, to be used by bootloaders for example.
In Bascom, there is no equivalent to the assembler instruction .org, which does that.
Also, just placing this info via Data statements before your application code does not work, because there is no control over the generated prologue code.

But you can define the interrupt vector table, which is placed at the very beginning of the compilation output, so by defining the address for an interrupt which is not used in the application (preferably the associated peripheral/interrupt flag is deactivated so it does not generate this interrupt), it is possible to include 2 (3 for devices > 64K) bytes of data/int per hijacked interrupt:

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 48
$swstack = 32
$framesize = 64

Const Firmware_version = &HABBA
On Aci Firmware_version

End


Results in following .hex-file, I've marked the included version data (byte order reversed):
Quote:
:100000000C94340018950000189500001895000015
:10001000189500001895000018950000189500002C
:10002000189500001895000018950000189500001C
:10003000189500001895000018950000189500000C
:1000400018950000189500001895000018950000FC
:100050001895000018950000189500000C94BAAB94
:1000600018950000189500008FEF8DBFC0EDE8E8EF
:100070004E2E88E08EBFD8E0F8E05F2EA89584B7BA
:10008000082E877F84BF88E1992780936000909332
:100090006000EEEFF7E0A0E0B1E088278D933197A4
:1000A000E9F76624F894FFCF3197F1F70895689443
:0A00B00062F80895E89462F80895DC
:00000001FF


Maybe this is of help for someone.

Br

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
six1

Bascom Expert



Joined: 27 Feb 2009
Posts: 553

germany.gif
PostPosted: Wed Feb 24, 2021 7:26 am    Post subject: Reply with quote

! .org &H21AB
_________________
For technical reasons, the signature is on the back of this message.
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 115
Location: Graz

austria.gif
PostPosted: Wed Feb 24, 2021 8:18 am    Post subject: Reply with quote

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 48
$swstack = 32
$framesize = 64

Const Firmware_version = &HABBA
On Aci Firmware_version

!nop
!nop
!nop
!nop
!nop
!nop
!nop
!nop
!nop
!nop
!nop
!.org &h52

End

Data &HAB , &HCD

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5157
Location: Holland

blank.gif
PostPosted: Mon Mar 01, 2021 9:17 pm    Post subject: Reply with quote

Nice hack indeed. Very Happy . Thanks for sharing.

See also $reduceivr

There is the .org but since the vector table is created before that it is not usable to use that for putting code into the vector table.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum