Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Corrupted Bootloader when programming ATmega328p

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

Bascom Member



Joined: 24 Feb 2019
Posts: 10
Location: Rio de Janeiro

brazil.gif
PostPosted: Sat Jun 29, 2019 5:29 pm    Post subject: Corrupted Bootloader when programming ATmega328p Reply with quote

I had 2 processors ATmega328p with corrupted bootloader when programming with Bascom.

The processors were loaded with Arduino bootloader 57600 baud.

I could only recover reprogramming with USBASP thru ICSP.

This have ocurred only in about 0,1 % of my programming tasks.

What would be the cause?

A bad USB contact when uploading ?

(BASCOM-AVR version : 2.0.8.1 )
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2449
Location: Queensland

australia.gif
PostPosted: Sun Jun 30, 2019 11:59 pm    Post subject: Reply with quote

Could be many causes, but a possible protection is program the bootloader, then set the fuses so that writing into the bootloader area is disabled.
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4761
Location: Holland

blank.gif
PostPosted: Mon Jul 01, 2019 10:13 am    Post subject: Reply with quote

so you are using arduino boot loader? maybe it overwrites the application area.
check the file size you try to write to the processor.
or ask on arduino forum.

i can recommend to use the MCS boot loader.
i use it for a long time and never failed me.

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

Bascom Member



Joined: 24 Feb 2019
Posts: 10
Location: Rio de Janeiro

brazil.gif
PostPosted: Mon Jul 01, 2019 12:12 pm    Post subject: Reply with quote

Thanks for suggestion to use MCS Bootloader. I was using Arduino Bootloader because it already come loaded in my chips.
I am a newbie in AVR Bascom and I am in the begining of learning curve. I will try to adapt one bootloader sample to ATmega 328p Crystal 16MHz 57600 baud HW UART and LED at PORTB.5.

But I can't figure how a USB bad contact when loading a program could corrupt the bootloader itself.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2449
Location: Queensland

australia.gif
PostPosted: Mon Jul 01, 2019 11:21 pm    Post subject: Reply with quote

I would doubt its a bad USB contact, USB has a lot of built-in error checking that should at the very least just fail, not receive bad data. But apart from that, it only takes one corrupted address to go through and write into the bootloader, instead of main program area. Setting the bootloader protect fuse will at least prevent that. And yes, as Mark suggests, his bootloader works without any problems.
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
acjacques

Bascom Member



Joined: 24 Feb 2019
Posts: 10
Location: Rio de Janeiro

brazil.gif
PostPosted: Tue Jul 02, 2019 2:16 am    Post subject: Reply with quote

The locking fuse bits of chips were all unprogramed. The corruption was done when uploading a code thru UART to Arduino bootloader. I could not set the locking bits because I am still in development process then I need often upload new testing codes and the UART programing is more convenient.

I also doubt that it was the USB connector bad contact the corruption cause.

Could be a bug during compilation?
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2449
Location: Queensland

australia.gif
PostPosted: Tue Jul 02, 2019 6:30 am    Post subject: Reply with quote

But you can still program the lock bit which disables writing to the bootloader - as long as you are sure the bootloader works ! That does not stop you from loading new application code.

I seriously doubt there is a compiler error - Bascom is very stable for a long time, and certainly I never saw anything like that over 20 years. and 10s of 1000s of program cycles.

I once had an issue with a new program which did overwrite the bootloader, but the fault was mine, for not checking. Since then we always set the lock bits to disable both reading and writing to the bootloader. Also makes it much more difficult for a hacker to upload a false bootloader, or even look at it from a hacked application program.

_________________
Adrian Jansen
Computer language is a framework for creativity
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