View previous topic :: View next topic |
Author |
Message |
MadAl
Joined: 26 Jul 2010 Posts: 48
|
Posted: Fri Oct 01, 2021 10:05 pm Post subject: MCS Bootloader for ATMEGA168P |
|
|
Hi,
I have been using the MCS Bootloader for the ATMEGA328p successfully. Now I tried the ATMEGA168p (as 328 is not available due to semiconductor shortage). I adapted the bootloader accordingly and managed to flash it into the ATMEGA168P. Now comes the weird part. I can bootload my firmware into the ATMEGA only once. A second or subsequent time it won't do it anymore.
If I flash the bootloader again, this process repeats (I can use the bootloader once but after that not anymore). Looks like the bootloader is corrupted by my firmware program. But it is very small (2% for testing). What could be wrong where my same routine/settings work for 328P but not for 168P ?
Fuse settings are F8 D7 EE
thanks
(BASCOM-AVR version : 2.0.8.4 )
Last edited by MadAl on Sat Oct 02, 2021 7:57 am; edited 1 time in total |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Sat Oct 02, 2021 1:38 am Post subject: |
|
|
Have you set the boot loader address with the $loader instruction to the fuse setting
eg 1024 words = 0xC00 512 = 0xE00 256 =0xF00 128 = OxF80
Note the Mega328 is 1024 words = 0x3C00
Regards Paul |
|
Back to top |
|
|
MadAl
Joined: 26 Jul 2010 Posts: 48
|
Posted: Sat Oct 02, 2021 7:47 am Post subject: |
|
|
I've set $loader = $1c00 as already presented in the Bootloader.bas file for this controller. You reckon this value is wrong?
In the fuse settings I also set %1c00 |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Sat Oct 02, 2021 9:01 am Post subject: |
|
|
The data sheet says 1024 words = 0xC00 same as the Mega88 so it seems so.
Regards Paul |
|
Back to top |
|
|
MadAl
Joined: 26 Jul 2010 Posts: 48
|
Posted: Sat Oct 02, 2021 10:22 am Post subject: |
|
|
OK found the problems. There was an issue with the pull up resistor on the reset pin. And the program I tried compiled at 87% which apparently overwrites part of the bootloader space. |
|
Back to top |
|
|
MadAl
Joined: 26 Jul 2010 Posts: 48
|
Posted: Sun Oct 03, 2021 9:07 am Post subject: |
|
|
Value 0C00 now allows multiple bootloading firmware. However a small led flasher firmware doesn't run. When I change back to 1C00 the led flashed happily. So I guess 1C00 is the correct value.
Last edited by MadAl on Sun Oct 03, 2021 11:32 am; edited 1 time in total |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Oct 03, 2021 11:28 am Post subject: |
|
|
the more memory a processor has, the higher the boot location. so logic demands that it is impossible that M88 and M168 have the same boot location. Because the M168 has twice the memory as the M88.
the MCS boot loader uses 1024 words. and when you look in the data sheet for the M88 you find a table. 27.8.14 which states that for the M88 the boot reset location is $C00. That is a word address since all instructions use 16 bit/
Now consider what this means : C00=3072 in dec. In bytes it would be 6144. We use an 8K processor so the boot space would be 8192-6144=2048 bytes. and this is 1024 words. that match the table and should match the fuse byte we set.
when you look in the table for M168 (27.8.1.15) for the same 1024 words you get : 1C00. that is no surprise. And you can do that math again to see it is correct.
For the M328 the location is 3C00
These locations match the values in the bootloader.bas example. _________________ Mark |
|
Back to top |
|
|
MadAl
Joined: 26 Jul 2010 Posts: 48
|
Posted: Sun Oct 03, 2021 11:34 am Post subject: |
|
|
Correct and verified. My program is just too big to fit and is overwriting the boot sector apparently, but that is a totally different (i.e. my) problem. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Oct 03, 2021 11:40 am Post subject: |
|
|
you need mega328 ? how many and which casing?
otherwise send an email to support. as far as i can see there are plenty available. _________________ Mark |
|
Back to top |
|
|
MadAl
Joined: 26 Jul 2010 Posts: 48
|
Posted: Sun Oct 03, 2021 6:16 pm Post subject: |
|
|
I need ATMEGA328P-MMH 28 pins QFN casing |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Oct 03, 2021 8:53 pm Post subject: |
|
|
i see ATMEGA328P-AUR but not MMH. _________________ Mark |
|
Back to top |
|
|
SZTRAD
Joined: 30 Dec 2019 Posts: 165
|
|
Back to top |
|
|
|