View previous topic :: View next topic |
Author |
Message |
Tiny
Joined: 10 Nov 2010 Posts: 101 Location: The Netherlands
|
Posted: Fri Apr 02, 2021 12:37 pm Post subject: Bootloader for xtiny Attiny3217 |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Apr 02, 2021 8:14 pm Post subject: |
|
|
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 |
|
|
Tiny
Joined: 10 Nov 2010 Posts: 101 Location: The Netherlands
|
Posted: Sat Apr 03, 2021 3:24 pm Post subject: |
|
|
Hi Mark
I'm going to work on it next week, thanks for the example and explanation.
Regards Tiny |
|
Back to top |
|
|
Paul_L
Joined: 21 Sep 2012 Posts: 1
|
Posted: Mon Apr 05, 2021 7:55 pm Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Apr 08, 2021 10:26 am Post subject: |
|
|
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 |
|
|
Tiny
Joined: 10 Nov 2010 Posts: 101 Location: The Netherlands
|
Posted: Fri Apr 09, 2021 12:51 pm Post subject: |
|
|
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 |
|
|
|