About the boot loader

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
apollononnno

About the boot loader

Post by apollononnno » Fri Jul 18, 2008 6:23 am

Hi all
I compiled the following with avrstudio4.
The target is "Internal RC12MHz" and "D+-PC0,D-PC1" as for "atmega168p" It
aims at USB connection and "bootloader" of (PCint8 PCICR-PCIE1(1) PCIFR-
PCIF1(1) PCMSK1-PCINT8(0) 5 0x0008 PCINT1).

usbdrv.h
#ifndef USB_INTR_ENABLE /* allow user to override our default */
# if defined GIMSK
# define USB_INTR_ENABLE GIMSK//?
# elif defined EIMSK
# define USB_INTR_ENABLE EIMSK//PCMSK1-PCINT8(0)
# else
# define USB_INTR_ENABLE GICR//?
# endif
#endif
#ifndef USB_INTR_ENABLE_BIT /* allow user to override our default */
# define USB_INTR_ENABLE_BIT INT0//PCINT8
# endif

usbdrvasm.S

makefile
F_CPU = 12000000
DEVICE = atmega168
BOOTLOADER_ADDRESS = 3800
FUSEOPT = $(FUSEOPT_168)
LOCKOPT = -U lock:w:0x2f:m

usbconfig-prototype.h & bootloaderconfig.h
#define USB_CFG_IOPORTNAME C
#define USB_CFG_DMINUS_BIT 1
#define USB_CFG_DPLUS_BIT 0
/* #define USB_CFG_PULLUP_IOPORTNAME C */
/* #define USB_CFG_PULLUP_BIT 1 */

USBaspLoader.2008-02-05
EasyLogger.2008-02-28
However, it returns the following mistakes.
gcc plug-in: Error: Object file not found on expected location C:\avrs\EasyLogger. What should 2008-02-28\EasyLogger.2008-02-28\cfirmware\ceasyogger.elf I note?
Do you concretely make it like any though I want to build in "osccal.c"?
kyoji

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Fri Jul 18, 2008 4:08 pm

I never tried gcc with avrstudio, so I can't comment on that. If you use WinAVR, you can use our standard Makefiles.

Adding osccal.c may become tight due to the 2kB restriction for boot loaders.

To use the Pin Change Interrupt, you need to change the last section of usbconfig.h:

Code: Select all

/* ----------------------- Optional MCU Description ------------------------ */

/* The following configurations have working defaults in usbdrv.h. You
 * usually don't need to set them explicitly. Only if you want to run
 * the driver on a device which is not yet supported or with a compiler
 * which is not fully supported (such as IAR C) or if you use a differnt
 * interrupt than INT0, you may have to define some of these.
 */
/* #define USB_INTR_CFG            MCUCR */
/* #define USB_INTR_CFG_SET        ((1 << ISC00) | (1 << ISC01)) */
/* #define USB_INTR_CFG_CLR        0 */
/* #define USB_INTR_ENABLE         GIMSK */
/* #define USB_INTR_ENABLE_BIT     INT0 */
/* #define USB_INTR_PENDING        GIFR */
/* #define USB_INTR_PENDING_BIT    INTF0 */
/* #define USB_INTR_VECTOR         SIG_INTERRUPT0 */


I have not done this myself, but I remember that people here in the forum did. Please search the archives.

apolllononnno

About the method

Post by apolllononnno » Sat Jul 19, 2008 5:13 am

Thank you for Mr. christian.

The method of settlement was obtained.
It doesn't make an error of it by safely passing if "Ceasyogger.elf (The content is empty)" is put in the corresponding holder, and "ceasyogger.elf" disappears.

Does it operate only one time at the first start or sometimes operate
and correct "OSCCAL"?

I copied \cfirmware\libs-device\osccal.h and \cfirmware\libs-device\
osccal.c onto the corresponding holder.
To build in "OSCCAL", do you make it like any?

I look for the archive further.
kyoji

apolllononnno

The later change

Post by apolllononnno » Sat Jul 19, 2008 6:24 am

I made the first aim "mega168p, 12MHz, D+_PC0, D-_PC1, the boot loader" which I used "OSCCAL" for.
I compiled original "EasyLogger.2008-02-28" in avrstudio4 for the study and I compiled it replacing with "mega168p-12MHz" to be next and succeeded.
When add "OSCCAL" afterwards; "main.c:" 250: error: static declaration of 'calibrateOscillator' follows non-static declaration "libs-device/osccal.h:" 44:00 error: I became the error of previous declaration of 'calibrateOscillator' was here.
I stopped it once here and I compiled original "USBaspLoader.2008-02-05" "mega168p-12MHz" and succeeded.
It is changed "D+_PC0, D-_PC1" to be next
#define USB_CFG_IOPORTNAME C
#define USB_CFG_DMINUS_BIT 1
#define USB_CFG_DPLUS_BIT 0
/* #define USB_CFG_PULLUP_IOPORTNAME C */
/* #define USB_CFG_PULLUP_BIT One */
I changed を of it and succeeded in compiling it.
When add "osccal.c" just before "int main(void)" in "main.c" afterwards; "main.c:" (.text+0x524): I become the error of undefined reference to `usbMeasureFrameLength'.

kyoji

aploononnno

About the direction of the change

Post by aploononnno » Tue Jul 22, 2008 6:36 am

I examined it about an interrupt.
I start an action by the upward movement of the "INT0" signal by the original.
I catch even the change of either direction in "PCINT8" which I hope for.
How do you do the handling of this case?
kyoji

/* #define USB_INTR_CFG MCUCR / IVSEL? IVCE?*/
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) / EICRA?INT0↑ */
/* #define USB_INTR_CFG_CLR 0 */
/* #define USB_INTR_ENABLE GIMSK / PCMSK1*/
/* #define USB_INTR_ENABLE_BIT INT0 / PCINT8*/
/* #define USB_INTR_PENDING GIFR / PCIFR*/
/* #define USB_INTR_PENDING_BIT INTF0 / PCIF1*/

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Tue Jul 22, 2008 11:37 am

I'm not sure I understand what you are asking...

Looking at the code: You still have those defines commented out. But I see that you have already found the appropriate values for the defines. I have not checked them, but you obviously understood the concept.

Regarding interrupt edge sensitivity: The driver should work with any edge (rising / falling / both). Just try it.

apollononnno

Is the result good in this?

Post by apollononnno » Tue Jul 22, 2008 3:27 pm

Thank you for an answer.

I have made a mistake in the name letter of this forum.
In addition, the ID name has been wrong, too.
Is there the method to redo being right?

I did not find the item which fell under "1".
I validated "2" and got a result of compiling it.
However, I was not "three" negative results in that, but watched a slightly bad part.
Do not I need to pay attention to this item?

1
/* #define USB_INTR_CFG MCUCR / IVSEL? IVCE? */
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) / EICRA?INT0 */
2
#define USB_INTR_CFG_CLR 0
#define USB_INTR_ENABLE PCMSK1
#define USB_INTR_ENABLE_BIT PCINT8
#define USB_INTR_PENDING PCIFR
#define USB_INTR_PENDING_BIT PCIF1
3
usbdrv/usbdrv.h:198: warning: 'usbFunctionDescriptor' used but never defined
4
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
avr-size main.hex
text data bss dec hex filename
0 2520 0 2520 9d8 main.hex
Build succeeded with 1 Warnings...

I intend I add "OSCCAL", and to try RC12MHz.
I do not know the position that is necessary for the addition.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Tue Jul 22, 2008 4:26 pm

For the Pin Change thing, see the end of this thread:

http://forums.obdev.at/viewtopic.php?t=1067&start=15

This was on the tiny45, but it's still an example for using the pin change interrupt.

A different issue: The osccal routine is too big for a 2 k boot loader. Your code size is ~ 2.5 k, too much for the boot section. You'll probably find a different way to calibrate the oscillator or otherwise reduce the code size.

apollononnno
Rank 1
Rank 1
Posts: 25
Joined: Wed Jul 23, 2008 5:31 am
Location: JAPAN

About size.

Post by apollononnno » Wed Jul 23, 2008 11:54 am

You compiled it.
It is the firm ware which I download it, and unfolded.
Going astray "size mega168_12mhz.hex"
text data bss dec hex filename
0 2028 0 2028 7ec mega168_12mhz.hex
It is displayed.

I downloaded it.
I did "make" of "USBaspLoader.2008-02-05" in "WinAVR-20080512" and compiled it.
"main.hex" is displayed as follows.
"size main.hex"
text data bss dec hex filename
0 2392 0 2392 958 main.hex.

As for it, memory consumption changes.

Did you compile it in "WinAVR", which version?

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Wed Jul 23, 2008 12:11 pm

I compiled this with gcc 3.4.6. If you use WinAVR, you must use a rather old version (before the switch to gcc 4).

apollononnno
Rank 1
Rank 1
Posts: 25
Joined: Wed Jul 23, 2008 5:31 am
Location: JAPAN

Is there any hint?

Post by apollononnno » Fri Jul 25, 2008 3:15 am

C:\avrs\usbtest\USBaspLoader.2008-02-05\USBaspLoader.2008-02-05\firmware>avr-gcc
-v
Reading specs from C:/WinAVR-20060421/lib/gcc/avr/3.4.6/specs
Configured with: ../gcc-3.4.6/configure --prefix=/c/WinAVR --target=avr --enable
-languages=c,c++ --with-dwarf2 --enable-win32-registry=WinAVR --disable-nls
Thread model: single
gcc version 3.4.6

C:\avrs\usbtest\USBaspLoader.2008-02-05\USBaspLoader.2008-02-05\firmware>make
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
avr-size main.hex
text data bss dec hex filename
0 2392 0 2392 958 main.hex

I tried the above.
However, I did not become "2028".

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Tue Jul 29, 2008 12:29 pm

Did you choose the same options for the boot loader (same emulation level) as when you do a "make allhexfiles"? Other than that, you might use a different version of avr-libc (although I doubt that this make such a great difference).

apollononnno
Rank 1
Rank 1
Posts: 25
Joined: Wed Jul 23, 2008 5:31 am
Location: JAPAN

Some programs are breaks. (I am tired and am absent)

Post by apollononnno » Tue Jul 29, 2008 1:32 pm

I am assigned to a different result being given and do not doubt it.
My age has exceeded 60, but my technology and knowledge are still unripe.
Perhaps I think with the result that I be accompanied and forget some kind of options and compile. (I am unripe in optional contents).
Like you, I wish that I want to arrive at a satisfactory result early.

A story changed and went to Vienna by a sightseeing tour six years ago.
I asked an unknown person the place of "association of music friend" in Japanese.
The person taught it in English.
Association of music friend was near immediately, but was under construction.

I asked Grandfather of "the key shop" a key elsewhere and bought "a key" and "door metal fittings".
It was Japanese and German then that two people talked.

Post Reply