Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

MCS Bootloader for ATMEGA168P

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

Bascom Member



Joined: 26 Jul 2010
Posts: 48

blank.gif
PostPosted: Fri Oct 01, 2021 10:05 pm    Post subject: MCS Bootloader for ATMEGA168P Reply with quote

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
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sat Oct 02, 2021 1:38 am    Post subject: Reply with quote

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
View user's profile
MadAl

Bascom Member



Joined: 26 Jul 2010
Posts: 48

blank.gif
PostPosted: Sat Oct 02, 2021 7:47 am    Post subject: Reply with quote

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
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sat Oct 02, 2021 9:01 am    Post subject: Reply with quote

The data sheet says 1024 words = 0xC00 same as the Mega88 so it seems so.
Regards Paul
Back to top
View user's profile
MadAl

Bascom Member



Joined: 26 Jul 2010
Posts: 48

blank.gif
PostPosted: Sat Oct 02, 2021 10:22 am    Post subject: Reply with quote

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
View user's profile
MadAl

Bascom Member



Joined: 26 Jul 2010
Posts: 48

blank.gif
PostPosted: Sun Oct 03, 2021 9:07 am    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Sun Oct 03, 2021 11:28 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
MadAl

Bascom Member



Joined: 26 Jul 2010
Posts: 48

blank.gif
PostPosted: Sun Oct 03, 2021 11:34 am    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Sun Oct 03, 2021 11:40 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
MadAl

Bascom Member



Joined: 26 Jul 2010
Posts: 48

blank.gif
PostPosted: Sun Oct 03, 2021 6:16 pm    Post subject: Reply with quote

I need ATMEGA328P-MMH 28 pins QFN casing
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Sun Oct 03, 2021 8:53 pm    Post subject: Reply with quote

i see ATMEGA328P-AUR but not MMH.
_________________
Mark
Back to top
View user's profile Visit poster's website
SZTRAD

Bascom Member



Joined: 30 Dec 2019
Posts: 165

blank.gif
PostPosted: Mon Oct 04, 2021 7:07 am    Post subject: Reply with quote

Hi
if you need them badly, they have them here.

https://www.win-source.net/microchip-technology-atmega328p-mmh.html

https://www.gtelec.com/index.php?option=com_searchproduct&view=detailswithsku&virtuemart_product_sku=ATMEGA328P-MMH

http://rfq.rxicsource.com/h5/#/pages/rxicsource/quote?part=ATMEGA328P-MMH

Tough times for manufacturers and developers.

Here's a general overview of official vendor stock.

https://octopart.com/atmega328p-mmh-microchip-77760217#PriceAndStock

RS
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