• Najnowsze pytania
  • Bez odpowiedzi
  • Zadaj pytanie
  • Kategorie
  • Tagi
  • Zdobyte punkty
  • Ekipa ninja
  • IRC
  • FAQ
  • Regulamin
  • Książki warte uwagi

Kod AVR się nie kompiluje

Object Storage Arubacloud
0 głosów
212 wizyt
pytanie zadane 16 kwietnia 2020 w Mikrokontrolery przez Mavimix Dyskutant (8,390 p.)

Programuję Atmegę8 w CodeBlocks. Zacząłem używać biblioteki (?) V-USB. Z tego co zrozumiałem, wystarczy wkleić pliki v-usb do folderu z projektem, i zainkludować odpowiednie pliki do programu. Podczas próby kompilacji programu (gotowego, ściągniętego ze strony) pojawia się błąd:

||=== Build: Release in test2 (compiler: GNU GCC Compiler for AVR) ===|
usbdrvasm.S|17|warning: "__SFR_OFFSET" redefined [enabled by default]|
c:\program files (x86)\atmel\avr tools\avr toolchain\avr\include\avr\sfr_defs.h|172|note: this is the location of the previous definition|
usbdrvasm.S|65|error: expected identifier or '(' before '.' token|
usbdrvasm.S|67|error: stray '@' in program|
usbdrv.h|617|error: operator '*' has no left operand|
usbdrvasm.S|73|note: in expansion of macro 'USB_INTR_PENDING'|
usbdrvasm.S|81|warning: "usbTxLen1" redefined [enabled by default]|
usbdrv.h|663|note: this is the location of the previous definition|
usbdrvasm.S|82|warning: "usbTxBuf1" redefined [enabled by default]|
usbdrv.h|664|note: this is the location of the previous definition|
usbdrvasm.S|83|warning: "usbTxLen3" redefined [enabled by default]|
usbdrv.h|665|note: this is the location of the previous definition|
usbdrvasm.S|84|warning: "usbTxBuf3" redefined [enabled by default]|
usbdrv.h|666|note: this is the location of the previous definition|
usbdrvasm.S|87|error: expected identifier or '(' before '--' token|
usbdrvasm.S|88|error: unknown type name 'Utility'|
usbdrvasm.S|89|error: expected identifier or '(' before '--' token|
usbdrvasm.S|220|error: unknown type name 'This'|
usbdrvasm.S|220|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'is'|
usbdrvasm.S|220|error: unknown type name 'is'|
usbdrv.h|320|error: expected declaration specifiers or '...' before '(' token|
usbdrvasm.S|222|note: in expansion of macro 'usbCrc16'|
usbdrvasm.S|223|error: unknown type name 'argPtr'|
usbdrvasm.S|223|error: expected '=', ',', ';', 'asm' or '__attribute__' before '+' token|
usbdrvasm.S|127|error: unknown type name 'r22'|
usbdrvasm.S|224|note: in expansion of macro 'argLen'|
usbdrvasm.S|224|error: expected '=', ',', ';', 'asm' or '__attribute__' before '/' token|
usbdrvasm.S|225|error: unknown type name 'temp'|
usbdrvasm.S|225|error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token|
usbdrvasm.S|137|error: unknown type name 'r18'|
usbdrvasm.S|226|note: in expansion of macro 'byte'|
usbdrvasm.S|226|error: expected '=', ',', ';', 'asm' or '__attribute__' before '/' token|
usbdrvasm.S|138|error: unknown type name 'r19'|
usbdrvasm.S|227|note: in expansion of macro 'bitCnt'|
usbdrvasm.S|228|error: unknown type name 'poly'|
usbdrvasm.S|228|error: expected '=', ',', ';', 'asm' or '__attribute__' before '+' token|
usbdrvasm.S|141|error: unknown type name 'r23'|
usbdrvasm.S|229|note: in expansion of macro 'scratch'|
usbdrvasm.S|230|error: unknown type name 'resCrc'|
usbdrvasm.S|230|error: expected '=', ',', ';', 'asm' or '__attribute__' before '+' token|
usbdrvasm.S|136|error: unknown type name 'x'|
usbdrvasm.S|231|note: in expansion of macro 'ptr'|
usbdrvasm.S|231|error: expected '=', ',', ';', 'asm' or '__attribute__' before '/' token|
usbdrvasm.S|127|warning: data definition has no type or storage class [enabled by default]|
usbdrvasm.S|239|note: in expansion of macro 'argLen'|
usbdrvasm.S|127|warning: type defaults to 'int' in declaration of 'r22' [-Wimplicit-int]|
usbdrvasm.S|239|note: in expansion of macro 'argLen'|
usbdrvasm.S|239|error: initializer element is not constant|
usbdrvasm.S|239|error: expected ',' or ';' before ':' token|
usbdrvasm.S|240|error: unknown type name 'loop'|
usbdrvasm.S|240|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'with'|
usbdrvasm.S|240|error: unknown type name 'with'|
usbdrvasm.S|246|error: unknown type name 'carry'|
usbdrvasm.S|246|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'always'|
usbdrvasm.S|246|error: unknown type name 'always'|
usbdrvasm.S|252|error: expected identifier or '(' before numeric constant|
usbdrvasm.S|252|error: unknown type name 'this'|
usbdrvasm.S|252|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'iterates'|
usbdrvasm.S|259|error: unknown type name 'Thanks'|
usbdrvasm.S|259|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Reimar'|
usbdrvasm.S|259|error: unknown type name 'Reimar'|
usbdrv.h|328|error: expected declaration specifiers or '...' before '(' token|
usbdrvasm.S|263|note: in expansion of macro 'usbCrc16Append'|
usbdrvasm.S|264|error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token|
usbdrvasm.S|358|error: expected identifier or '(' before '--' token|
usbdrvasm.S|359|error: unknown type name 'Now'|
usbdrvasm.S|359|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'the'|
usbdrvasm.S|359|error: unknown type name 'the'|
usbdrvasm.S|360|error: expected identifier or '(' before '--' token|
usbdrvasm12.inc|35|error: expected '=', ',', ';', 'asm' or '__attribute__' before '-' token|
usbdrvasm12.inc|35|warning: missing terminating ' character [enabled by default]|
usbdrvasm12.inc|35|error: missing terminating ' character|
usbdrvasm12.inc|36|error: unknown type name 'interrupt'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 8 warning(s) (0 minute(s), 0 second(s)) ===|

Program:

/* Name: main.c
 * Project: HID-Test
 * Author: Christian Starkjohann
 * Creation Date: 2006-02-02
 * Tabsize: 4
 * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH
 * License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
 * This Revision: $Id$
 */

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>

///Trzy ponizej dodane przeze mnie
#include "usbdrv.c"
#include "oddebug.c"
#include "usbdrvasm.S"

#include "usbdrv.h"
#include "oddebug.h"





/* ----------------------- hardware I/O abstraction ------------------------ */

/* pin assignments:
PB0	Key 1
PB1	Key 2
PB2	Key 3
PB3	Key 4
PB4	Key 5
PB5 Key 6

PC0	Key 7
PC1	Key 8
PC2	Key 9
PC3	Key 10
PC4	Key 11
PC5	Key 12

PD0	USB-
PD1	debug tx
PD2	USB+ (int0)
PD3	Key 13
PD4	Key 14
PD5	Key 15
PD6	Key 16
PD7	Key 17
*/

static void hardwareInit(void)
{
uchar	i, j;

    PORTB = 0xff;   /* activate all pull-ups */
    DDRB = 0;       /* all pins input */
    PORTC = 0xff;   /* activate all pull-ups */
    DDRC = 0;       /* all pins input */
    PORTD = 0xfa;   /* 1111 1010 bin: activate pull-ups except on USB lines */
    DDRD = 0x07;    /* 0000 0111 bin: all pins input except USB (-> USB reset) */
	j = 0;
	while(--j){     /* USB Reset by device only required on Watchdog Reset */
		i = 0;
		while(--i); /* delay >10ms for USB reset */
	}
    DDRD = 0x02;    /* 0000 0010 bin: remove USB reset condition */
    /* configure timer 0 for a rate of 12M/(1024 * 256) = 45.78 Hz (~22ms) */
    TCCR0 = 5;      /* timer 0 prescaler: 1024 */
}

/* ------------------------------------------------------------------------- */

#define NUM_KEYS    17

/* The following function returns an index for the first key pressed. It
 * returns 0 if no key is pressed.
 */
static uchar    keyPressed(void)
{
uchar   i, mask, x;

    x = PINB;
    mask = 1;
    for(i=0;i<6;i++){
        if((x & mask) == 0)
            return i + 1;
        mask <<= 1;
    }
    x = PINC;
    mask = 1;
    for(i=0;i<6;i++){
        if((x & mask) == 0)
            return i + 7;
        mask <<= 1;
    }
    x = PIND;
    mask = 1 << 3;
    for(i=0;i<5;i++){
        if((x & mask) == 0)
            return i + 13;
        mask <<= 1;
    }
    return 0;
}

/* ------------------------------------------------------------------------- */
/* ----------------------------- USB interface ----------------------------- */
/* ------------------------------------------------------------------------- */

static uchar    reportBuffer[2];    /* buffer for HID reports */
static uchar    idleRate;           /* in 4 ms units */

const PROGMEM char usbHidReportDescriptor[35] = {   /* USB report descriptor */
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x06,                    // USAGE (Keyboard)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x05, 0x07,                    //   USAGE_PAGE (Keyboard)
    0x19, 0xe0,                    //   USAGE_MINIMUM (Keyboard LeftControl)
    0x29, 0xe7,                    //   USAGE_MAXIMUM (Keyboard Right GUI)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
    0x75, 0x01,                    //   REPORT_SIZE (1)
    0x95, 0x08,                    //   REPORT_COUNT (8)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0x95, 0x01,                    //   REPORT_COUNT (1)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x25, 0x65,                    //   LOGICAL_MAXIMUM (101)
    0x19, 0x00,                    //   USAGE_MINIMUM (Reserved (no event indicated))
    0x29, 0x65,                    //   USAGE_MAXIMUM (Keyboard Application)
    0x81, 0x00,                    //   INPUT (Data,Ary,Abs)
    0xc0                           // END_COLLECTION
};
/* We use a simplifed keyboard report descriptor which does not support the
 * boot protocol. We don't allow setting status LEDs and we only allow one
 * simultaneous key press (except modifiers). We can therefore use short
 * 2 byte input reports.
 * The report descriptor has been created with usb.org's "HID Descriptor Tool"
 * which can be downloaded from http://www.usb.org/developers/hidpage/.
 * Redundant entries (such as LOGICAL_MINIMUM and USAGE_PAGE) have been omitted
 * for the second INPUT item.
 */

/* Keyboard usage values, see usb.org's HID-usage-tables document, chapter
 * 10 Keyboard/Keypad Page for more codes.
 */
#define MOD_CONTROL_LEFT    (1<<0)
#define MOD_SHIFT_LEFT      (1<<1)
#define MOD_ALT_LEFT        (1<<2)
#define MOD_GUI_LEFT        (1<<3)
#define MOD_CONTROL_RIGHT   (1<<4)
#define MOD_SHIFT_RIGHT     (1<<5)
#define MOD_ALT_RIGHT       (1<<6)
#define MOD_GUI_RIGHT       (1<<7)

#define KEY_A       4
#define KEY_B       5
#define KEY_C       6
#define KEY_D       7
#define KEY_E       8
#define KEY_F       9
#define KEY_G       10
#define KEY_H       11
#define KEY_I       12
#define KEY_J       13
#define KEY_K       14
#define KEY_L       15
#define KEY_M       16
#define KEY_N       17
#define KEY_O       18
#define KEY_P       19
#define KEY_Q       20
#define KEY_R       21
#define KEY_S       22
#define KEY_T       23
#define KEY_U       24
#define KEY_V       25
#define KEY_W       26
#define KEY_X       27
#define KEY_Y       28
#define KEY_Z       29
#define KEY_1       30
#define KEY_2       31
#define KEY_3       32
#define KEY_4       33
#define KEY_5       34
#define KEY_6       35
#define KEY_7       36
#define KEY_8       37
#define KEY_9       38
#define KEY_0       39

#define KEY_F1      58
#define KEY_F2      59
#define KEY_F3      60
#define KEY_F4      61
#define KEY_F5      62
#define KEY_F6      63
#define KEY_F7      64
#define KEY_F8      65
#define KEY_F9      66
#define KEY_F10     67
#define KEY_F11     68
#define KEY_F12     69

static const uchar  keyReport[NUM_KEYS + 1][2] PROGMEM = {
/* none */  {0, 0},                     /* no key pressed */
/*  1 */    {MOD_SHIFT_LEFT, KEY_A},
/*  2 */    {MOD_SHIFT_LEFT, KEY_B},
/*  3 */    {MOD_SHIFT_LEFT, KEY_C},
/*  4 */    {MOD_SHIFT_LEFT, KEY_D},
/*  5 */    {MOD_SHIFT_LEFT, KEY_E},
/*  6 */    {MOD_SHIFT_LEFT, KEY_F},
/*  7 */    {MOD_SHIFT_LEFT, KEY_G},
/*  8 */    {MOD_SHIFT_LEFT, KEY_H},
/*  9 */    {MOD_SHIFT_LEFT, KEY_I},
/* 10 */    {MOD_SHIFT_LEFT, KEY_J},
/* 11 */    {MOD_SHIFT_LEFT, KEY_K},
/* 12 */    {MOD_SHIFT_LEFT, KEY_L},
/* 13 */    {MOD_SHIFT_LEFT, KEY_M},
/* 14 */    {MOD_SHIFT_LEFT, KEY_N},
/* 15 */    {MOD_SHIFT_LEFT, KEY_O},
/* 16 */    {MOD_SHIFT_LEFT, KEY_P},
/* 17 */    {MOD_SHIFT_LEFT, KEY_Q},
};

static void buildReport(uchar key)
{
/* This (not so elegant) cast saves us 10 bytes of program memory */
    *(int *)reportBuffer = pgm_read_word(keyReport[key]);
}

uchar	usbFunctionSetup(uchar data[8])
{
usbRequest_t    *rq = (void *)data;

    usbMsgPtr = reportBuffer;
    if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){    /* class request type */
        if(rq->bRequest == USBRQ_HID_GET_REPORT){  /* wValue: ReportType (highbyte), ReportID (lowbyte) */
            /* we only have one report type, so don't look at wValue */
            buildReport(keyPressed());
            return sizeof(reportBuffer);
        }else if(rq->bRequest == USBRQ_HID_GET_IDLE){
            usbMsgPtr = &idleRate;
            return 1;
        }else if(rq->bRequest == USBRQ_HID_SET_IDLE){
            idleRate = rq->wValue.bytes[1];
        }
    }else{
        /* no vendor specific requests implemented */
    }
	return 0;
}

/* ------------------------------------------------------------------------- */

int	main(void)
{
uchar   key, lastKey = 0, keyDidChange = 0;
uchar   idleCounter = 0;

	wdt_enable(WDTO_2S);
    hardwareInit();
	odDebugInit();
	usbInit();
	sei();
    DBG1(0x00, 0, 0);
	for(;;){	/* main event loop */
		wdt_reset();
		usbPoll();
        key = keyPressed();
        if(lastKey != key){
            lastKey = key;
            keyDidChange = 1;
        }
        if(TIFR & (1<<TOV0)){   /* 22 ms timer */
            TIFR = 1<<TOV0;
            if(idleRate != 0){
                if(idleCounter > 4){
                    idleCounter -= 5;   /* 22 ms in units of 4 ms */
                }else{
                    idleCounter = idleRate;
                    keyDidChange = 1;
                }
            }
        }
        if(keyDidChange && usbInterruptIsReady()){
            keyDidChange = 0;
            /* use last key and not current key status in order to avoid lost
               changes in key status. */
            buildReport(lastKey);
            usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
        }
	}
	return 0;
}

/* ------------------------------------------------------------------------- */

Widzę, że jest to błąd składni, ale dlaczego on się pojawia? Źle zainkludowałem bibliotekę?

1 odpowiedź

+1 głos
odpowiedź 16 kwietnia 2020 przez adrian17 Ekspert (344,860 p.)
wybrane 19 kwietnia 2020 przez Mavimix
 
Najlepsza

#include "usbdrvasm.S"

Jest błąd składni, bo próbujesz include'ować plik asemblera, co... wiele sensu nie ma ;)

To trzeba osobno przerzucić przez kompilatora i dolinkować.

komentarz 16 kwietnia 2020 przez adrian17 Ekspert (344,860 p.)
C::B można używać do samego pisania, ale w tym konkretnym przypadku bym budował make'iem z ręki. Albo można spróbować zrobić projekt AVRowy w C::B i z ręki dodać do projektu te pliki, inspirując się tym make'iem? Trudno mi powiedzieć.
komentarz 16 kwietnia 2020 przez Mavimix Dyskutant (8,390 p.)
Ok, dzięki. Ostatnie pytanie: co oznacza komunikat "make.exe: *** Brak reguł do wykonania obiektu `Release'"? Błąd pojawia się niezależnie od środowiska.
komentarz 16 kwietnia 2020 przez adrian17 Ekspert (344,860 p.)
Brzmi jakbyś próbował używać C::B (który ma targety debug, release) na makefile'u z tego projektu, który z natury ich nie ma.
komentarz 17 kwietnia 2020 przez Mavimix Dyskutant (8,390 p.)
Ok, dzięki za pomoc.
komentarz 19 kwietnia 2020 przez Mavimix Dyskutant (8,390 p.)
Zainstalowałem Linuxa na VirtualBoxie i wszystko się kompiluje. Jeszcze raz dzięki.

Podobne pytania

0 głosów
1 odpowiedź 309 wizyt
pytanie zadane 14 listopada 2020 w Mikrokontrolery przez Mavimix Dyskutant (8,390 p.)
0 głosów
1 odpowiedź 392 wizyt
pytanie zadane 19 lutego 2020 w Mikrokontrolery przez Mavimix Dyskutant (8,390 p.)
0 głosów
1 odpowiedź 495 wizyt
pytanie zadane 3 marca 2017 w Mikrokontrolery przez Mavimix Dyskutant (8,390 p.)

92,563 zapytań

141,416 odpowiedzi

319,596 komentarzy

61,948 pasjonatów

Motyw:

Akcja Pajacyk

Pajacyk od wielu lat dożywia dzieci. Pomóż klikając w zielony brzuszek na stronie. Dziękujemy! ♡

Oto polecana książka warta uwagi.
Pełną listę książek znajdziesz tutaj.

Akademia Sekuraka

Kolejna edycja największej imprezy hakerskiej w Polsce, czyli Mega Sekurak Hacking Party odbędzie się już 20 maja 2024r. Z tej okazji mamy dla Was kod: pasjamshp - jeżeli wpiszecie go w koszyku, to wówczas otrzymacie 40% zniżki na bilet w wersji standard!

Więcej informacji na temat imprezy znajdziecie tutaj. Dziękujemy ekipie Sekuraka za taką fajną zniżkę dla wszystkich Pasjonatów!

Akademia Sekuraka

Niedawno wystartował dodruk tej świetnej, rozchwytywanej książki (około 940 stron). Mamy dla Was kod: pasja (wpiszcie go w koszyku), dzięki któremu otrzymujemy 10% zniżki - dziękujemy zaprzyjaźnionej ekipie Sekuraka za taki bonus dla Pasjonatów! Książka to pierwszy tom z serii o ITsec, który łagodnie wprowadzi w świat bezpieczeństwa IT każdą osobę - warto, polecamy!

...