BootloadHID for ATMega324p

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
muntablues
Posts: 4
Joined: Tue Mar 03, 2009 1:42 pm

BootloadHID for ATMega324p

Post by muntablues » Thu May 26, 2011 1:56 pm

Hi

I am trying to get BootloadHID example working on my Mega324P.

First of all, the µC works fine with USBasp and HIDKeys example, so I think HW should be ok. Problem is that USBasp is not really soupported for WIN7 x64 (driver issue). So I would like to use BootloadHID example.

Here is what I have changed:

bootloaderconfig:

Code: Select all

#define USB_CFG_IOPORTNAME      D
/* This is the port where the USB bus is connected. When you configure it to
 * "B", the registers PORTB, PINB and DDRB will be used.
 */
#define USB_CFG_DMINUS_BIT      3
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
 * This may be any bit in the port.
 */
#define USB_CFG_DPLUS_BIT       2

...

#ifndef __ASSEMBLER__   /* assembler cannot parse function definitions */
#include <util/delay.h>

static inline void  bootLoaderInit(void)
{
    PORTB = 1 << 0; /* activate pull-up for key */
    _delay_us(10);  /* wait for levels to stabilize */
}

#define bootLoaderCondition()   ((PINB & (1 << 0)) == 0)   /* True if jumper is set */

#endif


makefile:

Code: Select all

DEVICE = atmega324p
BOOTLOADER_ADDRESS = 7000
F_CPU = 12000000
FUSEH = 0xD8
FUSEL = 0xff


main:

Code: Select all

int __attribute__((noreturn)) main(void)
{
    bootLoaderInit();
    odDebugInit();
    uchar* data = "HELLO";
    DBG1(0x00, data, 5);
    DBG1(0x00, 0, 0);
...
}


compile output:

Code: Select all

C:\Temp\bootloadHID.2010-07-29\firmware>make
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega324p -DF_CPU=12000000 -DDEBUG_LEVEL=2
  -c main.c -o main.o
In file included from main.c:22:
usbdrv/oddebug.c:15:2: warning: #warning "Never compile production devices with
debugging enabled"
main.c: In function 'main':
main.c:224: warning: pointer targets in initialization differ in signedness
main.c: At top level:
usbdrv/usbdrv.h:211: warning: 'usbFunctionDescriptor' used but never defined
usbdrv/usbdrv.h:218: warning: 'usbSetInterrupt' declared 'static' but never defi
ned
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega324p -DF_CPU=12000000 -DDEBUG_LEVEL=2
  -o main.bin usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o -Wl,--section-start=.te
xt=7000
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
avr-size main.bin
   text    data     bss     dec     hex filename
   2184      16      49    2249     8c9 main.bin


The rest is like in example already given.

Here is the serial debug output:

Code: Select all

þ00: 48 45 4c 4c 4f
00:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:




So I think the bootloader starts, but is not possible to do the usb connection. I have tried with an ATMega32 but the result is the same, no connection to PC.

I have no idea what is going wrong, so please give me a hint...

regards

MB

TeknoJuce
Posts: 1
Joined: Fri May 27, 2011 12:12 am

Re: BootloadHID for ATMega324p

Post by TeknoJuce » Sat May 28, 2011 10:41 pm

Hi muntablues,

Try this...

Code: Select all

DEVICE = atmega324p
BOOTLOADER_ADDRESS = 7800
F_CPU = 12000000
FUSEH = 0xDA
FUSEL = 0xF7

muntablues
Posts: 4
Joined: Tue Mar 03, 2009 1:42 pm

Re: BootloadHID for ATMega324p

Post by muntablues » Tue May 31, 2011 11:38 pm

Hi TeknoJuce

I have to use 7000 because I use the latest winavr gcc and there the bootloader is bigger then 2kB.

As I said, I think the µc is starting correct, otherwise the debug output would not be send over uart...

MB

Post Reply