Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Problem Including Bootloader Code in Application Program

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
igortab

Bascom Member



Joined: 08 Oct 2009
Posts: 14
Location: Sydney

australia.gif
PostPosted: Mon Jun 09, 2014 10:30 pm    Post subject: Problem Including Bootloader Code in Application Program Reply with quote

I want to include a compiled bootloader code in to an application program.
This allows factory programming of both in one go as oppose to programming a bootloader and then bootloading the application program

I have been doing this for years with Atmega chips like this:
Code:
$Boot=$F800
$Inc BootLoader,NoSize,"My_BootLoader.bin"

(My_BootLoader.bin file is a binary image of bootloader code only, compiled with Bascom AVR).


However, this doesn't work with Xmega 256A3U:
Code:
$Boot=$20000
$Inc BootLoader,NoSize,"My_BootLoader.bin"

I have also tried:
Code:
$RomStart=$20000
$Inc BootLoader,NoSize,"My_BootLoader.bin"


All I need the compiler to do is to place the code from My_BootLoader.bin file at location $20000

If anyone can help, it would be much appreciated.

(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4736
Location: Holland

blank.gif
PostPosted: Tue Jun 10, 2014 9:22 am    Post subject: Reply with quote

you need to add :

! .ORG $the WORD address of the loader
'put the $Inc here

_________________
Mark
Back to top
View user's profile Visit poster's website
igortab

Bascom Member



Joined: 08 Oct 2009
Posts: 14
Location: Sydney

australia.gif
PostPosted: Tue Jun 10, 2014 11:26 am    Post subject: Reply with quote

Thank you for your help Mark.

Unfortunately, it didn't quite work. While the compiler placed the bootloader code at the right address,
it also placed a lot of data, including application program constants, after the bootloader code.

It also generated an error message: "Program will overwrite bootloader...." as the compiler is not aware
that the code following ! .ORG $20000 is a bootloader code.


I have tested the code with Ver 2.0.7.7 and it works fine with Atmega chips:
Code:
$Boot=$F800
$Inc BootLoader,NoSize,"My_BootLoader.bin"


Is there a reason why it shouldn't work with Xmega chips?
Back to top
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2086

netherlands.gif
PostPosted: Tue Jun 10, 2014 12:10 pm    Post subject: Reply with quote

Did you use the $LOADERSIZE = xxx option in your main program?
_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
igortab

Bascom Member



Joined: 08 Oct 2009
Posts: 14
Location: Sydney

australia.gif
PostPosted: Tue Jun 10, 2014 1:24 pm    Post subject: Reply with quote

Just tried using $LoaderSize in main program but it made no difference.

It's not the error that's the problem as the compiler still generates HEX and BIN files.

It's the fact that the compiler stores constants and other data from the main program
after the bootloader code. This makes the total size of the file bigger than can fit in to flash.

This makes sense (to me) as the compiler is not aware that code following $20000 is a bootloader
and treats it as part of the main program.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4736
Location: Holland

blank.gif
PostPosted: Tue Jun 10, 2014 1:31 pm    Post subject: Reply with quote

please post an example that works for you with atmega. (with all files).
and also a sample for xmega. the inc file can be rubbish, and the main program can be minimal, but i need some real code to look at that contains your used settings.

_________________
Mark
Back to top
View user's profile Visit poster's website
igortab

Bascom Member



Joined: 08 Oct 2009
Posts: 14
Location: Sydney

australia.gif
PostPosted: Wed Jun 11, 2014 8:06 pm    Post subject: Reply with quote

Example files attached.

Please note how "Boot_ATmega128.bas" correctly generates output binary and hex files and "Boot_Xmega256A3U.bas" does not.

Best regards.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4736
Location: Holland

blank.gif
PostPosted: Wed Jun 11, 2014 9:00 pm    Post subject: Reply with quote

The combined use of the old $Boot and $Inc is very nice.
I found the problem and changed it. it will be in the next update.
as a workaround you can merge the hex files.

_________________
Mark
Back to top
View user's profile Visit poster's website
Duesentrieb72

Bascom Member



Joined: 17 Feb 2006
Posts: 37

germany.gif
PostPosted: Fri Feb 27, 2015 9:24 am    Post subject: Reply with quote

Hello Mark,

I'm sorry to ask, but I didn't understand how to include BootLoader code in aplication program right... Sad

I compiled the BootLoader and have the .bin / .hex of it.

Next I put this at the beginning of my application:

$loader = &H30000 ' adress eg. datasheet for ATXmega384C3
$inc Bootloader , Nosize , "MA2_Front_Bootloader_2.bin"

This gives the Error
Error : 344 Line : 2359 Program will overwrite bootloader [ 392854 too long] , in File : C:\PROGRAM FILES (X86)\MCS ELECTRONICS\BASCOM-AVR\LIB\FP_TRIG.LBX
Error : 80 Line : 1360 Code does not fit into target chip , in File : C:\PROGRAM FILES (X86)\MCS ELECTRONICS\BASCOM-AVR\LIB\FP_TRIG.LBX

If I merge the BootLoader code manualy in the bin-file at the right position, everything is fine and works.
But it would be very nice to include the BootLoader automaticaly

µC = ATXmega384C3
Compiler version :2.0.7.8
Compiler build :2.0.7.8.001
IDE version :2.0.7.8.001

Thanks a lot,
Düsentrieb72
Back to top
View user's profile
igortab

Bascom Member



Joined: 08 Oct 2009
Posts: 14
Location: Sydney

australia.gif
PostPosted: Fri Feb 27, 2015 3:41 pm    Post subject: Reply with quote

Put these 2 lines at the very end of your program.

$Boot=$XXXX (XXXX = Bootloader start address in uC memory)
$Inc BootLoader,NoSize,"My_BootLoader.bin"

This is how it used to work.

Best regards,
Igor Tabakov
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4736
Location: Holland

blank.gif
PostPosted: Fri Feb 27, 2015 4:08 pm    Post subject: Reply with quote

exact, have a look at Igors sample that he attached earlier.
_________________
Mark
Back to top
View user's profile Visit poster's website
Duesentrieb72

Bascom Member



Joined: 17 Feb 2006
Posts: 37

germany.gif
PostPosted: Fri Feb 27, 2015 4:19 pm    Post subject: Reply with quote

Hi Igor and Mark,

thanks a lot for your fast reply.
It works... Very Happy

Duesentrieb72
Back to top
View user's profile
hzz

Bascom Member



Joined: 20 Feb 2007
Posts: 255

spain.gif
PostPosted: Sat Jun 08, 2019 12:18 am    Post subject: Including the bootloader with $Boot and $Inc Reply with quote

I have tried to include the compiler as indicated in this thread with version 2.0.8.1 and get the error:

Error : 344 Line : 200 Program will overwrite bootloader [ 256840 too long] , in File : D:\DESARROLLO\Ei_2.26\Main.bas

Just want to know if problem has not been solved in 2.0.8.1 or am I doing something wrong.

Regards
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR 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