Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can the bootloader be used for programming over the serial port? [solved] #1

Closed
a4x4kiwi opened this issue Jan 3, 2013 · 14 comments
Closed

Comments

@a4x4kiwi
Copy link

a4x4kiwi commented Jan 3, 2013

Can the bootloader be used for programming over the serial port?

I have programmed the bootloader and set the fuses using a Dragon, but for convenience I would prefer to program over the boot loader.

FYI I am using the Bravekit AVR-CAN board, and modified the DTR to reset the microcontroller as per the original Arduino designs.

Here are the lines from my customised boards file.

Boards.txt

at90can128.name=AT90CAN128
at90can128.upload.protocol=arduino
at90can128.upload.maximum_size=131072
at90can128.upload.speed=19200

at90can128.bootloader.low_fuses=0xFF
at90can128.bootloader.high_fuses=0x19
at90can128.bootloader.extended_fuses=0xFF
at90can128.bootloader.path=at90can
at90can128.bootloader.file=ATmegaBOOT_168_at90can.hex
at90can128.bootloader.unlock_bits=0x3F
at90can128.bootloader.lock_bits=0xCF

at90can128.build.mcu=at90can128
at90can128.build.f_cpu=16000000L
at90can128.build.core=at90can

@lincomatic
Copy link
Owner

In theory, it should work, though I have not bothered to try it. What happens when you try to do it?

@a4x4kiwi
Copy link
Author

a4x4kiwi commented Jan 4, 2013

Thanks for the quick correspondence!

I get:
Binary sketch size: 3,568 bytes (of a 131,072 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x06

I am triple checking my reset circuit now with a scope, but it looks to be fine.

My test LED blinking program resets when programming is initiated.

Cheers,
Mal.

@a4x4kiwi
Copy link
Author

a4x4kiwi commented Jan 4, 2013

I have used a cap and a diode per http://code.google.com/p/avr-netino/wiki/AddAutoReset modified to suit the AVR-CAN board.

@lincomatic
Copy link
Owner

Two things you can try:

  1. try protocol=stk500 (probably won't work)
  2. try this high fuse setting:

at90can128.bootloader.high_fuses=0x1A

@a4x4kiwi
Copy link
Author

a4x4kiwi commented Jan 4, 2013

WAHOO. What a learning experience! It works. programming over serial. See the following updates.

LED changed in bootloader to suit Bravekit unit and aid debugging
#define LED_DDR DDRE
#define LED_PORT PORTE
#define LED_PIN PINE
#define LED PINE4

Correct settings in boards.txt: (Baud rate, maximum_size and fuse were incorrect above)

##############################################################

at90can128.name=AT90CAN128
at90can128.upload.protocol=arduino
at90can128.upload.maximum_size=122880
at90can128.upload.speed=57600

at90can128.bootloader.low_fuses=0xFF
at90can128.bootloader.high_fuses=0x18
at90can128.bootloader.extended_fuses=0xFF
at90can128.bootloader.path=at90can
at90can128.bootloader.file=ATmegaBOOT_168_at90can.hex
at90can128.bootloader.unlock_bits=0x3F
at90can128.bootloader.lock_bits=0xCF

at90can128.build.mcu=at90can128
at90can128.build.f_cpu=16000000L
at90can128.build.core=at90can

@lincomatic
Copy link
Owner

Thanks for the great work, I will update the distribution after I have tested it

  1. is the change above the only thing you changed in the bootloader?
  2. you said you modified the cap & diode to suit the AVR-CAN, can you tell me the exact mod you did to the circuit?

@lincomatic
Copy link
Owner

I tried this today.. instead of adding the circuit, I just erased the chip, so it would go to the bootloader. I was able to get the bootloader installed, but I always get compare error at 0x0000 when I try to burn a sketch. I am using the original hex file and your fuse settings above.

@lincomatic
Copy link
Owner

got it working now. Had to change makefile LDSECTION to point to where the bootloader section was set

@a4x4kiwi
Copy link
Author

a4x4kiwi commented Jan 5, 2013

I have only been able to program the boot loader via the AVR Studio using
an AVRISP or a DRAGON. the Arduino tools seem to fail. I will continue to
investigate.


email:malcolm@faed.name
mobile:0409 601 747


On 5 January 2013 09:07, lincomatic notifications@github.com wrote:

I tried this today.. instead of adding the circuit, I just erased the
chip, so it would go to the bootloader. I was able to get the bootloader
installed, but I always get compare error at 0x0000 when I try to burn a
sketch. I am using the original hex file and your fuse settings above.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-11901997.

@a4x4kiwi
Copy link
Author

a4x4kiwi commented Jan 5, 2013

Updated Lock bits. The original setting may have prevented the Arduino IDE from programming correctly. It programs with the Dragon and the avrisp

Someone should double check this. I have made them the same as the ATMega1280.
Also the maximum_size I have calculated (128k - 8k) differs from that of the Arduino ID entry for the Mega1280

I am not certain which is correct.

at90can128.name=AT90CAN128

at90can128.upload.protocol=arduino
at90can128.upload.maximum_size=122880
at90can128.upload.speed=57600

at90can128.bootloader.low_fuses=0xFF
at90can128.bootloader.high_fuses=0x18
at90can128.bootloader.extended_fuses=0xFF
at90can128.bootloader.path=at90can
at90can128.bootloader.file=ATmegaBOOT_168_at90can.hex
at90can128.bootloader.unlock_bits=0x3F
at90can128.bootloader.lock_bits=0x0F

at90can128.build.mcu=at90can128
at90can128.build.f_cpu=16000000L
at90can128.build.core=at90can

@lincomatic
Copy link
Owner

Actually, it worked OK for me w/ the old lock bits. But I have the hfuse set to 1E instead ... so that only 1K is wasted on the bootloader. See if what I checked into github works for you. I rebuilt the bootloader with LDSECTION=0x1FC00 to match my adjusted hfuse, so you'll have to burn my new one in before you test.

@lincomatic
Copy link
Owner

I just checked the AT90CAN128 datasheet. Actually, boot section unlocked should be lock=FF and boot section locked should be CF since the top 2 bits are fixed @ 1. But avrdude always reads the top 2 bits as 0. very strange. I guess I'll go ahead and use 3F/0F like you.

@a4x4kiwi
Copy link
Author

a4x4kiwi commented Jan 6, 2013

I was unable to program your boot loader using the IDE.( I can with AVR
Studio)
Looking at your output hex file it is &hFFEA-&hF800 = (dec)2026 bytes long.
This should fit with 2 k. Mine compiles to just a bit over for some reason.
Probably depends on GCC version.

The H fuse should be 1A for a 2k boot loader starting ant F800
Following is my section of boards.txt for your bootloader which works correctly.

aat90can128.name=[bootloader]AT90CAN128
aat90can128.upload.protocol=arduino
aat90can128.upload.maximum_size=133120
aat90can128.upload.speed=57600

aat90can128.bootloader.low_fuses=0xFF
aat90can128.bootloader.high_fuses=0x1A
aat90can128.bootloader.extended_fuses=0xFF
aat90can128.bootloader.path=at90can
aat90can128.bootloader.file=ATmegaBOOT_168_at90can.hex
aat90can128.bootloader.unlock_bits=0x3F
aat90can128.bootloader.lock_bits=0x0F

aat90can128.build.mcu=at90can128
aat90can128.build.f_cpu=16000000L
aat90can128.build.core=at90can


email:malcolm@faed.name
mobile:0409 601 747


On 5 January 2013 17:48, lincomatic notifications@github.com wrote:

I just checked the AT90CAN128 datasheet. Actually, boot section unlocked
should be lock=FF and boot section locked should be CF since the top 2 bits
are fixed @ 1. But avrdude always reads the top 2 bits as 0. very strange.
I guess I'll go ahead and use 3F/0F like you.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-11910896.

@a4x4kiwi
Copy link
Author

a4x4kiwi commented Jan 6, 2013

For anyone using the bravekit:

Install WINAVR

edit the boot loader C file LED definitions and follows

#define LED_DDR DDRE
#define LED_PORT PORTE
#define LED_PIN PINE
#define LED PINE4

from the command prompt in the boot loader folder type:

make clean
make at90can

This will create a new boot loader with the diagnostic LED functioning correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants