Anyone use an Olimexino with the xtal in a socket?

Go To Last Post
38 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I bought a couple 22.1184MHz xtals hoping to get 230.4 and 460.8 working. I can compile and upload using the 16MHz xtal but not the fast ones. I think there is a real ftdi usb chip on this bd, so 328 clk doesn't have anything to do with bootloading does it? Or I guess a 328 just wont run over 20MHz. How the heck does the zombie dude get stuff to run at 25MHz?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bobgardner wrote:

How the heck does the zombie dude get stuff to run at 25MHz?

 

IIRC, he uses external CMOS oscillator drive.

I've run 25MHz SiLabs parts on the bench to 200MHz-in from a CMOS out Si5351, with the right pre-scaler values to keep the core clock at sane levels. I think XMega spec to 125MHz, so are similar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It all starts with a mental vision.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All my Arduino uno usage up to this point used the internal uno bootloader, which works just fine using avrdude at 115200 from a bat file. I got the olimexino because it had the xtal in a socket. I have a uart rx tx prog that works just fine using the 16MHz xtal. Thinks ol Bob... just plug in the 20MHz xtal, edit the uart init to use a different divisor and away we go. Bzzzzt. I guess the bootloader assumes 16MHz. So plan B is: edit and recompile the bl for each faster xtal I want to try? Plan C is just use the avrispmkii and to heck with the bl?

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The boot loader is set for a 16Mhz crystal so changing it will put the kibosh on it working. You could change the settings in it for the faster crystal I suppose, but I admit I have no idea how that would be done.

Plan C is always a reliable option.

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go on. The m328 will work at 20MHz. You can build the bootloader for 20MHz. I would be happy with 22MHz for a hobbyist project.

You can even add a "special" to the Arduino boards.txt file and your Arduino projects will work at 20MHz.
You will need to be careful with third party code. It might be hard coded for 16MHz.

Likewise, you can create Arduino specials with different controllers and speeds. Bear in mind that a third party somewhere might have hard coded for the official chips.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Think Olimex puts optiboot in the olimexino328? So I could make a dir and edit and compile an optiboot22 and an optiboot20 and an optiboot18 and burn one of those, and run all my hi speed comms progs on that board at the new baud rate?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes.

 

Make sure that you provide separate boards.txt entries for each "special".

Then it is just a matter of selecting the correct board in the Arduino IDE.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yo DP... here's my crazy idea... the 'ldi R24, 0x16' instruction to stuff the uart divisor in the UBRR0L reg is at 0x7322 in the optiboot328.hex file. Some smart freak can write a hexpatch.exe prog to say 'put an 0x23 in loc 0x7322 of file optiboot328.hex' then use atprogram.exe in AS7 (thanks Cliff) to load the patched optiboot328.hex, burn it with the 16MHz xtal, change to the 20MHz xtal, (do this once), and burn the 20Mhz app using avrdude or atprogam in a bat file.

Sounds ok so far?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yo DP... here's my crazy idea... the 'ldi R24, 0x16' instruction to stuff the uart divisor in the UBRR0L reg is at 0x7322 in the optiboot328.hex file. Some smart freak can write a hexpatch.exe prog to say 'put an 0x23 in loc 0x7322 of file optiboot328.hex' then use atprogram.exe in AS7 (thanks Cliff) to load the patched optiboot328.hex, burn it with the 16MHz xtal, change to the 20MHz xtal, (do this once), and burn the 20Mhz app using avrdude or atprogam in a bat file.

Sounds ok so far?

20 MHz:

UBRR = (20,000,000 / (8 * 115200)) - 1

     = (20,000,000 / 921,600) - 1

     = 21.7 - 1

     = 20.7

     = 21

     = 0x15

 

22.1184 MHz:

UBRR = (22,118,400 / (8 * 115200)) - 1

     = (22,118,400 / 921,600) - 1

     = 24 - 1

     = 23

     = 0x17

 

Patched .hex files attached.

 

Are there any other frequencies you need?

 

EDIT: typos

 

 

Attachment(s): 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sat. Feb 20, 2016 - 10:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Joey has provided you with the necessary hex files. Store them all in the bootloader directory.
Put a sticky label on each target board. Mark clearly with the special board name.
Select each board in turn. Burn the respective bootloader. (which is specified in boards.txt)
Much the same as how a Uno or Duemilanove is clearly marked on the pcb.
David.

Last Edited: Sat. Feb 20, 2016 - 10:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Except you have an 8 implying 2x mode.... 22.1184 can use 1x mode... div by 16. I think the divisor works out to 11. That changes the 80 e1 at 7322 in the optiboot328.hex to 84 e0, so I patched the hex file and tried to burn it with the avrispmkii and it said 'one of the hex recoeds has a bad checksum'. Crap. Every hex loader I've ever written just ignored the darn checksum. Now I want one that ignores it and it gigs me.

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,

 

Does it matter if it uses U2X or not?

You are using a bootloader with a hard wired link to your PC.

 

I would guess that your PC has got enough disk space to accommodate two extra HEX files.

 

Have you looked at the Boards.txt file ?

It is simple to add the new special boards.  e.g. Bobuino20 and Bobuino22

 

David.

Last Edited: Sat. Feb 20, 2016 - 11:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Except you have an 8 implying 2x mode.... 22.1184 can use 1x mode... div by 16.

Optiboot uses 2x mode:

#ifdef __AVR_ATmega8__
  UCSRA = _BV(U2X); //Double speed mode USART
  UCSRB = _BV(RXEN) | _BV(TXEN);  // enable Rx & Tx
  UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);  // config USART; 8N1
  UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
#else
  UCSR0A = _BV(U2X0); //Double speed mode USART0
  UCSR0B = _BV(RXEN0) | _BV(TXEN0);
  UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
  UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
#endif

Changing to 1x mode would require a second patch.

 

By the way, it's really easy to patch, including handling the new checksum.

 

First, patch the bit that you need to.  Here's the original hex file disassembled:

$ avr-objdump -D -m avr optiboot_atmega328.hex

optiboot_atmega328.hex:     file format ihex

Disassembly of section .sec1:

00007e00 <.sec1>:
    7e00:	11 24       	eor	r1, r1
    7e02:	84 b7       	in	r24, 0x34	; 52
    7e04:	14 be       	out	0x34, r1	; 52
    7e06:	81 ff       	sbrs	r24, 1
    7e08:	f0 d0       	rcall	.+480    	;  0x7fea
    7e0a:	85 e0       	ldi	r24, 0x05	; 5
    7e0c:	80 93 81 00 	sts	0x0081, r24
    7e10:	82 e0       	ldi	r24, 0x02	; 2
    7e12:	80 93 c0 00 	sts	0x00C0, r24
    7e16:	88 e1       	ldi	r24, 0x18	; 24
    7e18:	80 93 c1 00 	sts	0x00C1, r24
    7e1c:	86 e0       	ldi	r24, 0x06	; 6
    7e1e:	80 93 c2 00 	sts	0x00C2, r24
    7e22:	80 e1       	ldi	r24, 0x10	; 16
    7e24:	80 93 c4 00 	sts	0x00C4, r24

We see the opcodes that need to be changed.  Here's the hex file itself:

:107E0000112484B714BE81FFF0D085E080938100F7
:107E100082E08093C00088E18093C10086E0809377
:107E2000C20080E18093C4008EE0C9D0259A86E02C
:107E300020E33CEF91E0309385002093840096BBD3
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
:107E6000A2D0813461F49FD0082FAFD0023811F036
:107E7000013811F484E001C083E08DD089C08234E0
:107E800011F484E103C0853419F485E0A6D080C0E4
:107E9000853579F488D0E82EFF2485D0082F10E0AE
:107EA000102F00270E291F29000F111F8ED06801E7
:107EB0006FC0863521F484E090D080E0DECF843638
:107EC00009F040C070D06FD0082F6DD080E0C81688
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
:107F0000A601A0E0B1E02C9130E011968C91119780
:107F100090E0982F8827822B932B1296FA010C0160
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
:107F80000AD08FE07ACF813511F488E018D01DD067
:107F900080E101D065CF982F8091C00085FFFCCF94
:107FA0009093C60008958091C00087FFFCCF809118
:107FB000C00084FD01C0A8958091C6000895E0E648
:107FC000F0E098E1908380830895EDDF803219F02E
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF

Knowing the layout of the ldi instruction helps:

 

 

So now we patch:

:107E0000112484B714BE81FFF0D085E080938100F7
:107E100080E08093C00088E18093C10086E0809377
:107E2000C2008BE08093C4008EE0C9D0259A86E02C
:107E300020E33CEF91E0309385002093840096BBD3
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
:107E6000A2D0813461F49FD0082FAFD0023811F036
:107E7000013811F484E001C083E08DD089C08234E0
:107E800011F484E103C0853419F485E0A6D080C0E4
:107E9000853579F488D0E82EFF2485D0082F10E0AE
:107EA000102F00270E291F29000F111F8ED06801E7
:107EB0006FC0863521F484E090D080E0DECF843638
:107EC00009F040C070D06FD0082F6DD080E0C81688
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
:107F0000A601A0E0B1E02C9130E011968C91119780
:107F100090E0982F8827822B932B1296FA010C0160
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
:107F80000AD08FE07ACF813511F488E018D01DD067
:107F900080E101D065CF982F8091C00085FFFCCF94
:107FA0009093C60008958091C00087FFFCCF809118
:107FB000C00084FD01C0A8958091C6000895E0E648
:107FC000F0E098E1908380830895EDDF803219F02E
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF

Save, and disassemble the new hex file to verify:

$ avr-objdump -D -m avr optiboot_atmega328_22.1184MHz_1x.hex
BFD: optiboot_atmega328_22.1184MHz_1x.hex:2: bad checksum in Intel Hex file (expected 121, found 119)
avr-objdump: optiboot_atmega328_22.1184MHz_1x.hex: Bad value

So objdump happily tells us what the checksum should be:

:107E0000112484B714BE81FFF0D085E080938100F7
:107E100080E08093C00088E18093C10086E0809379
:107E2000C2008BE08093C4008EE0C9D0259A86E02C
:107E300020E33CEF91E0309385002093840096BBD3
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
:107E6000A2D0813461F49FD0082FAFD0023811F036
:107E7000013811F484E001C083E08DD089C08234E0
:107E800011F484E103C0853419F485E0A6D080C0E4
:107E9000853579F488D0E82EFF2485D0082F10E0AE
:107EA000102F00270E291F29000F111F8ED06801E7
:107EB0006FC0863521F484E090D080E0DECF843638
:107EC00009F040C070D06FD0082F6DD080E0C81688
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
:107F0000A601A0E0B1E02C9130E011968C91119780
:107F100090E0982F8827822B932B1296FA010C0160
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
:107F80000AD08FE07ACF813511F488E018D01DD067
:107F900080E101D065CF982F8091C00085FFFCCF94
:107FA0009093C60008958091C00087FFFCCF809118
:107FB000C00084FD01C0A8958091C6000895E0E648
:107FC000F0E098E1908380830895EDDF803219F02E
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF

It only tells us one error at a time before stopping, so:

$ avr-objdump -D -m avr optiboot_atmega328_22.1184MHz_1x.hex
BFD: optiboot_atmega328_22.1184MHz_1x.hex:3: bad checksum in Intel Hex file (expected 34, found 44)
avr-objdump: optiboot_atmega328_22.1184MHz_1x.hex: Bad value

Another checksum tickle:

:107E0000112484B714BE81FFF0D085E080938100F7
:107E100080E08093C00088E18093C10086E0809379
:107E2000C2008BE08093C4008EE0C9D0259A86E022
:107E300020E33CEF91E0309385002093840096BBD3
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
:107E6000A2D0813461F49FD0082FAFD0023811F036
:107E7000013811F484E001C083E08DD089C08234E0
:107E800011F484E103C0853419F485E0A6D080C0E4
:107E9000853579F488D0E82EFF2485D0082F10E0AE
:107EA000102F00270E291F29000F111F8ED06801E7
:107EB0006FC0863521F484E090D080E0DECF843638
:107EC00009F040C070D06FD0082F6DD080E0C81688
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
:107F0000A601A0E0B1E02C9130E011968C91119780
:107F100090E0982F8827822B932B1296FA010C0160
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
:107F80000AD08FE07ACF813511F488E018D01DD067
:107F900080E101D065CF982F8091C00085FFFCCF94
:107FA0009093C60008958091C00087FFFCCF809118
:107FB000C00084FD01C0A8958091C6000895E0E648
:107FC000F0E098E1908380830895EDDF803219F02E
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF

Verifying:

$ avr-objdump -D -m avr optiboot_atmega328_22.1184MHz_1x.hex

optiboot_atmega328_22.1184MHz_1x.hex:     file format ihex

Disassembly of section .sec1:

00007e00 <.sec1>:
    7e00:	11 24       	eor	r1, r1
    7e02:	84 b7       	in	r24, 0x34	; 52
    7e04:	14 be       	out	0x34, r1	; 52
    7e06:	81 ff       	sbrs	r24, 1
    7e08:	f0 d0       	rcall	.+480    	;  0x7fea
    7e0a:	85 e0       	ldi	r24, 0x05	; 5
    7e0c:	80 93 81 00 	sts	0x0081, r24
    7e10:	80 e0       	ldi	r24, 0x00	; 0
    7e12:	80 93 c0 00 	sts	0x00C0, r24
    7e16:	88 e1       	ldi	r24, 0x18	; 24
    7e18:	80 93 c1 00 	sts	0x00C1, r24
    7e1c:	86 e0       	ldi	r24, 0x06	; 6
    7e1e:	80 93 c2 00 	sts	0x00C2, r24
    7e22:	8b e0       	ldi	r24, 0x0B	; 11
    7e24:	80 93 c4 00 	sts	0x00C4, r24

 

All of this is fine for minor changes.  Obviously it's better to just rebuild for anything more substantial.

 

1x version attached.

 

EDIT: opcodes

 

 

Attachment(s): 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sun. Feb 21, 2016 - 06:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Call me old fashioned but a sticky label or a Sharpie seems an awful lot easier.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That trick with objdump to calc the checksum is clever. I just hooked up the avrispmkii and turned off the bootrst fuse and burned my test program that sets 115200 using 2x mode and 22.1184MHz xtal and all I get in teraterm is binary garbage, so I'm still working on it. Next step is make the xtal leads shorter, make em fit in the olimex socket tighter somehow.

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You've probably already thought about this, but have you tried full swing?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yep. Thanks for thinking about me.

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob's the sultan of swing - a band is playing dixie, double four time! But the crystal aint even whistlin'

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh what a dire fact...

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,

 

I thought that I should practice what I speak. 

Added Two new "Bobuino" descriptions to boards.txt

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

bobuino20.name=Bobuino 20MHz

bobuino20.vid.0=0x2341
bobuino20.pid.0=0x0043
bobuino20.vid.1=0x2341
bobuino20.pid.1=0x0001
bobuino20.vid.2=0x2A03
bobuino20.pid.2=0x0043
bobuino20.vid.3=0x2341
bobuino20.pid.3=0x0243

bobuino20.upload.tool=avrdude
bobuino20.upload.protocol=arduino
bobuino20.upload.maximum_size=32256
bobuino20.upload.maximum_data_size=2048
bobuino20.upload.speed=115200

bobuino20.bootloader.tool=avrdude
bobuino20.bootloader.low_fuses=0xFF
bobuino20.bootloader.high_fuses=0xDE
bobuino20.bootloader.extended_fuses=0x05
bobuino20.bootloader.unlock_bits=0x3F
bobuino20.bootloader.lock_bits=0x0F
bobuino20.bootloader.file=optiboot/optiboot_atmega328_20MHz.hex

bobuino20.build.mcu=atmega328p
bobuino20.build.f_cpu=20000000L
bobuino20.build.board=AVR_UNO
bobuino20.build.core=arduino
bobuino20.build.variant=standard

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

bobuino22.name=Bobuino 22MHz

bobuino22.vid.0=0x2341
bobuino22.pid.0=0x0043
bobuino22.vid.1=0x2341
bobuino22.pid.1=0x0001
bobuino22.vid.2=0x2A03
bobuino22.pid.2=0x0043
bobuino22.vid.3=0x2341
bobuino22.pid.3=0x0243

bobuino22.upload.tool=avrdude
bobuino22.upload.protocol=arduino
bobuino22.upload.maximum_size=32256
bobuino22.upload.maximum_data_size=2048
bobuino22.upload.speed=115200

bobuino22.bootloader.tool=avrdude
bobuino22.bootloader.low_fuses=0xFF
bobuino22.bootloader.high_fuses=0xDE
bobuino22.bootloader.extended_fuses=0x05
bobuino22.bootloader.unlock_bits=0x3F
bobuino22.bootloader.lock_bits=0x0F
bobuino22.bootloader.file=optiboot/optiboot_atmega328_22.1184MHz.hex

bobuino22.build.mcu=atmega328p
bobuino22.build.f_cpu=22118400L
bobuino22.build.board=AVR_UNO
bobuino22.build.core=arduino
bobuino22.build.variant=standard

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

 

1.  I placed an ATmega328P chip in STK500.   With a 20MHz crystal.

2.  Copied Joey's HEX files to C:\Program Files (x86)\Arduino-1.6.6\hardware\arduino\avr\bootloaders\optiboot\optiboot_atmega328_20MHz.hex

3.  Started the Arduino IDE.

4.  Selected the "Bobuino 20MHz" board

5.  Selected STK500 as programmer.

6.  Tools->Burn Bootloader.

7.  Moved the Serial cable from the STK500 CTRL to the RS232 SPARE port.   Disconnect programming ribbon.

8.  Build and Upload any Arduino sketches via the new 20MHz bootloader.

 

You can rinse and repeat with your 22MHz crystal.   I don't think that I have a 22MHz crystal.   I have a 35MHz and a 24MHz crystal.   So I just have to rebuild and rename the relevant bootloaders.    I suggest that you keep all the HEX files in the same directory with explanatory names.

 

David.

 

Edit.   When I went to the Optiboot directory from my Arduino v1.6.6 Release to build a 24MHz variant,   I discovered that the HEX was too big.

@Joey,   how did you build the 20MHz variant ?   It looks as if make used avr-gcc v4.6.2 on my Win7-64 PC.

Last Edited: Mon. Feb 22, 2016 - 03:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

#15 - remind me again why you don't just hex->bin, patch, bin->hex and forget all the Checksum fix up malarkey? ;-)

~$ cat input.hex
:107E00000100000000000000000000000000000071
:107E1000049897000120033D08000A200230D30097
:107E2000642002186900C82001270F00016B01209F
:107E30008C04B020011A0905DC2001138700026BB5
:107E40000107CF00056B0103E7000A6B0101F30096
:107E5000146B0100C700326B01006300646B01000A
:107E60003100C86B01001301F46B01000900014DE2
:107E700001000400024D0100020D056B010001002C
:0A7E8000054D010000000A4D00004E
:0400000300007E007B
:00000001FF
$ avr-objcopy -I ihex -O binary input.hex file.bin
$ hexdump -C file.bin
00000000  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000010  04 98 97 00 01 20 03 3d  08 00 0a 20 02 30 d3 00  |..... .=... .0..|
00000020  64 20 02 18 69 00 c8 20  01 27 0f 00 01 6b 01 20  |d ..i.. .'...k. |
00000030  8c 04 b0 20 01 1a 09 05  dc 20 01 13 87 00 02 6b  |... ..... .....k|
00000040  01 07 cf 00 05 6b 01 03  e7 00 0a 6b 01 01 f3 00  |.....k.....k....|
00000050  14 6b 01 00 c7 00 32 6b  01 00 63 00 64 6b 01 00  |.k....2k..c.dk..|
00000060  31 00 c8 6b 01 00 13 01  f4 6b 01 00 09 00 01 4d  |1..k.....k.....M|
00000070  01 00 04 00 02 4d 01 00  02 0d 05 6b 01 00 01 00  |.....M.....k....|
00000080  05 4d 01 00 00 00 0a 4d  00 00                    |.M.....M..|
0000008a
$ printf '\xA5' | dd conv=notrunc of=file.bin bs=1 seek=$((0x32))
1+0 records in
1+0 records out
1 byte (1 B) copied, 5.1359e-05 s, 19.5 kB/s
$ hexdump -C file.bin
00000000  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000010  04 98 97 00 01 20 03 3d  08 00 0a 20 02 30 d3 00  |..... .=... .0..|
00000020  64 20 02 18 69 00 c8 20  01 27 0f 00 01 6b 01 20  |d ..i.. .'...k. |
00000030  8c 04 a5 20 01 1a 09 05  dc 20 01 13 87 00 02 6b  |... ..... .....k|
00000040  01 07 cf 00 05 6b 01 03  e7 00 0a 6b 01 01 f3 00  |.....k.....k....|
00000050  14 6b 01 00 c7 00 32 6b  01 00 63 00 64 6b 01 00  |.k....2k..c.dk..|
00000060  31 00 c8 6b 01 00 13 01  f4 6b 01 00 09 00 01 4d  |1..k.....k.....M|
00000070  01 00 04 00 02 4d 01 00  02 0d 05 6b 01 00 01 00  |.....M.....k....|
00000080  05 4d 01 00 00 00 0a 4d  00 00                    |.M.....M..|
0000008a
$ avr-objcopy -I binary -O ihex --change-addresses 0x7E00 file.bin output.hex
$ cat output.hex 
:107E00000100000000000000000000000000000071
:107E1000049897000120033D08000A200230D30097
:107E2000642002186900C82001270F00016B01209F
:107E30008C04A520011A0905DC2001138700026BC0
:107E40000107CF00056B0103E7000A6B0101F30096
:107E5000146B0100C700326B01006300646B01000A
:107E60003100C86B01001301F46B01000900014DE2
:107E700001000400024D0100020D056B010001002C
:0A7E8000054D010000000A4D00004E
:0400000300007E007B
:00000001FF

cheeky

 

I did need to know that the input was 0x7E00 based in this of course.

 

(a certain amount of googling was required in the above to remind me about how to use dd as a hex editor and also about the --change-addresses option to rebase a .hex file being created ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David,
I didn't rebuild, I patched the. hex file.
Cliff,
Many ways to skin a cat. I'm aware of your approach and have used it. For one or two patched bytes, I might say my approach is just as easy. For more, yours likely is, although I would use hexedit instead of dd.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, yes of course I could just patch a binary. But on principle I think that you should build from source code.

In fact I think it a bit naughty if you require some special tools to build something.

I could always just build my own ASM bootloader but I doubt if Bob would accept this.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Its something other than the bootloader baud. I have a hex file from a regular old c program that inits the uart to 115200 (2x mode, divisor = 11, 22.1184MHz xtal) and I burn it using as7 and avrispmkII. I also turned off bootrst and turned on fsxtal fuses. Nuthin but garbage. Anyone have an olimexino out there in avr land? 

 

I put the 16MHz xtal back in, reburned the fuses, reburned optiboot16.hex, burned my 16MHz test pgm, everything works as expected. Confusing. 

Imagecraft compiler user

Last Edited: Tue. Feb 23, 2016 - 01:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,

 

Did you try my Boards.txt ?    I can verify that a Bobuino_20 with a 20MHz crystal works just fine.

 

Although I do not have a 22MHz crystal,   I would bet that Joey's Bobuino_22 hex would work fine too.

 

Your "regular old c program that inits the uart to 115200 (2x mode, divisor = 11, 22.1184MHz xtal)" will never work.

 

UBBRL = F_CPU / 16 / 115200 - 1;     //gives 11 for U2X=0

UBBRL = F_CPU / 8 / 115200 - 1;     //gives 23 for U2X=1

 

It is always possible that you have a duff 22MHz crystal.    I would guess that your "old c" program would run at 230400 baud with a good crystal.

 

I just Googled Olimexino-328.    I see that it has useful "jumper links" and space for extra headers.    I also note that the ICSP header is not in the proper place!    So most SPI Shields are not going to work.    In fact they will not even fit on your Olimexino.

 

Incidentally,   although your Olimexino is nearer to a Duemilanove than a Uno,   the Uno bootloader will work fine.   The important trick is to use the IDE to "Burn Bootloader".    If you try burning by hand,   I am certain that you will forget the fuses or lock bits.

 

David.

 

 

Last Edited: Tue. Feb 23, 2016 - 10:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would guess that your "old c" program would run at 230400 baud with a good crystal.

Good catch.

 

But on principle I think that you should build from source code.

I agree.  However, there are circumstances when it is simpler to patch.  For example:

When I went to the Optiboot directory from my Arduino v1.6.6 Release to build a 24MHz variant,   I discovered that the HEX was too big.

@Joey,   how did you build the 20MHz variant ?   It looks as if make used avr-gcc v4.6.2 on my Win7-64 PC.

While I would like to get to the bottom of >>that<< problem, in the meantime we can provide Bob with an appropriate .hex file.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joeymorin wrote:
although I would use hexedit instead of dd.

Me too - difficult to convey that when posting a linear sequence of commands to the forum here though ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello to DP. I think boards.txt has something to do with the arduino ide, which I've only used once or twice. As you know, I'm old and stupid and I only know how to write c programs using one ide that I've been using since 1999. I have been using a bat file and avrdude to put these hex files into my unos and megas, and I bought an olimexino with the xtal in a socket for the express purpose of trying 18.432, 20, 22.1184 MHz xtals, and the last one should be able to hit 230.4 and 460.8 bps in singlespeed mode using a divisor of 16. I think not being able to use a different xtal on a board I bought just for that purpose is a bummer, but I thought maybe some freak from Bulgaria might have an olimexino to confirm the problem. (SW guy always thinks its a HW problem)

 

 

Imagecraft compiler user

Last Edited: Wed. Feb 24, 2016 - 09:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,

We know that you are old. You should be able to manage the Arduino IDE.
Even your C program will produce 115200 baud with the correct value of UBRRL and U2X bit.
But I seriously recommend that you start using the Uno as God intended.
Your main projects might be in C but the Uno is really handy for testing hardware and experimenting with ideas.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

offensive religious reference. Massimo Banzi is not a prophet and his ide is not the result of a divine specification.

 

Imagecraft compiler user

Last Edited: Thu. Feb 25, 2016 - 01:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You do know that you can use a board of Arduino electronics without any of the Arduino software or program loader don't you?

 

If you can only get your brain around one IDE then why not use that to write all your code and use your normal ISP or JTAg/dW programming device to put that code into the CPU on the board?

 

The reason to keep the Arduino IDE and its bootloader is to get access to the wealth of Arduino library software that (arguably) works best when simply used in the Arduino IDE but as you say " the arduino ide, which I've only used once or twice" so it sounds like you are only using the Olimexino simply because it's a cheap and cheerful board full of electronics. So if you aren't interested in using its "Arduino-ness" then just program it with the tools you are familiar with.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are several things in this world that are good:
Motherhood, Apple Pie, Tea, Unix, Arduino, ...
I suspect that there is Divine Intervention in many "good things" in life. Of course I may be wrong.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So to get back to original premise: olimex sells an uno with an xtal in a socket. I have not been able to run any program with an xtal other than 16MHz. If anyone reading this can reproduce this result with an olimexino, please respond.

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK another silly question.. .wouldn't the following be a better place to ask this....

 

https://www.olimex.com/forum/ind...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,

 

There is nothing special about an Olimexino.    I confirmed that you can run Arduino software at 20MHz.   Uploaded via the bootloader posted by Joey.

 

You can insert a 20MHz crystal.   Then burn Joey's 20MHz bootloader into your Olimexino.  

It works for me on my STK500.    It will work for you on your Olimexino board.

 

Likewise,   you can do the same operation with your 22MHz crystal.    Use the HEX from message #10.

 

I would be happier if you used the Arduino IDE for the "Burn Bootloader" operation because it will set the fuses and lockbits.   

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob, have you confirmed that your other crystals work with a bare 328p on a breadboard?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]