Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Bootloader for xtiny Attiny3217

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

Bascom Member



Joined: 10 Nov 2010
Posts: 101
Location: The Netherlands

netherlands.gif
PostPosted: Fri Apr 02, 2021 12:37 pm    Post subject: Bootloader for xtiny Attiny3217 Reply with quote

Hello,

I'm looking for a example for a bootloader for the attiny3217

in the samples directory I don't see an example for a bootloader that can work wit the atting3217.

Does anyone already have experience with this

Thanks in advance

Tiny

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

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Fri Apr 02, 2021 8:14 pm    Post subject: Reply with quote

I attached a boot loader for the 816.
you best read the comment since it all works different compared to what we were used to.
The rest of the comment is from the loader code. the loader code itself is more or less as usual.

' The xtiny has a different memory lay out
' Normal AVR starts with normal application code and the boot code is placed at the end of memory.
' XTINY starts with BOOT memory. So we always start in BOOT mode.
' With the BOOTEND fuse we can set the size of the BOOT area.
' A value of 1 will give a size of 256 bytes, a value of 2 gives 512 bytes, etc.
' In this example we use less than 1024 bytes so we set the fuse to 4.

' After the optional boot space there is the APPLICATION CODE
' And after the APPLICATION CODE there is the APPLICATION DATA
' When you dont want a boot loader you set the bootend fuse to 0.
' your app will use the boot and application code
' When you want a boot loader, you determine the size of the boot loader and then
' set the fuse to the proper size
' With a boot loader, the code simply checks if the #123 data is received.
' If so, it starts the loading. If not it continues.
' It is similar to the normal AVR boot loading. The normal AVR boot starts after the normal space.
' # There is one important difference. With normal AVR all the code start at &H0000.
' For the loader we then use the $LOADER directive to place the code at the proper address
' For XTINY the boot loader starts at &H0000 thus is considred a normal application without specific switches
' Your normal code must now be located after the bootloader. This means you need to instruct the compiler to place the code
' at a different address. We use $ROMSTART for this purpose.
' Remember that AVR has word address. WHich means that each address uses 2 bytes of memory.



'this loader takes less than 1024 bytes so the BOOT FUSE is set to 4.
'do NOT FORGET that your normal app must use $ROMSTART=&H200 in that case : halve of the bytes size of the loader

'one other thing : the reset pin works in UPDI mode by default. so your chip will not reset when you do not change the fuse
'but there are other ways of reset such as soft reset, bod and wd.

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

Bascom Member



Joined: 10 Nov 2010
Posts: 101
Location: The Netherlands

netherlands.gif
PostPosted: Sat Apr 03, 2021 3:24 pm    Post subject: Reply with quote

Hi Mark

I'm going to work on it next week, thanks for the example and explanation.

Regards Tiny
Back to top
View user's profile Visit poster's website
Paul_L

Bascom Member



Joined: 21 Sep 2012
Posts: 1

usa.gif
PostPosted: Mon Apr 05, 2021 7:55 pm    Post subject: Reply with quote

Hi Tiny,

I was testing this example code in a 3216 last week. You will need to make a slight modification to make it work in your 3217.

Be advised that the 3216 and 3217 have 128 byte flash page size, and the example code writes 64 bytes (twice) in the "writepages" sub. I removed the 3 lines of code (or comment them out as shown below) and the bootloader works great.

Code:

'      If J = 64 Then                                        ' do the page write here
'         Gosub Page_erase_write
'      End If
 


Regards,
Paul
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Apr 08, 2021 10:26 am    Post subject: Reply with quote

thanks for the update.
I changed it to this :

Code:
      #if Page_size = 64
         If J = 64 Then                                        ' do the page write here
            Gosub Page_erase_write
         End If
      #endif
 

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

Bascom Member



Joined: 10 Nov 2010
Posts: 101
Location: The Netherlands

netherlands.gif
PostPosted: Fri Apr 09, 2021 12:51 pm    Post subject: Reply with quote

Thanks Mark,

I changed the boot loader to work with rs485

'The loader takes less than 1280 bytes so the BOOT FUSE is set to 5.
'do NOT FORGET that your normal app must use $ROMSTART=&H280 in that case : halve of the bytes size of the loader

Regards Tiny
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 -> 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