View previous topic :: View next topic |
Author |
Message |
acjacques
Joined: 24 Feb 2019 Posts: 13 Location: Rio de Janeiro
|
Posted: Sat Jun 29, 2019 5:29 pm Post subject: Corrupted Bootloader when programming ATmega328p |
|
|
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 |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Sun Jun 30, 2019 11:59 pm Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Jul 01, 2019 10:13 am Post subject: |
|
|
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 |
|
|
acjacques
Joined: 24 Feb 2019 Posts: 13 Location: Rio de Janeiro
|
Posted: Mon Jul 01, 2019 12:12 pm Post subject: |
|
|
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 |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Mon Jul 01, 2019 11:21 pm Post subject: |
|
|
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 |
|
|
acjacques
Joined: 24 Feb 2019 Posts: 13 Location: Rio de Janeiro
|
Posted: Tue Jul 02, 2019 2:16 am Post subject: |
|
|
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 |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Tue Jul 02, 2019 6:30 am Post subject: |
|
|
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 |
|
|
|