View previous topic :: View next topic |
Author |
Message |
Netzman
Joined: 25 Nov 2005 Posts: 127 Location: Graz
|
Posted: Tue Feb 23, 2021 2:23 pm Post subject: Include version info/date into compilation output |
|
|
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 |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Wed Feb 24, 2021 7:26 am Post subject: |
|
|
! .org &H21AB _________________ For technical reasons, the signature is on the back of this message. |
|
Back to top |
|
|
Netzman
Joined: 25 Nov 2005 Posts: 127 Location: Graz
|
Posted: Wed Feb 24, 2021 8:18 am Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Mar 01, 2021 9:17 pm Post subject: |
|
|
Nice hack indeed. . 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 |
|
|
|