baerwolf / USBaspLoader

An (V)USB bootloader firmware for AVR-MCUs emulating the popular USBasp for programming itself
Other
178 stars 146 forks source link

Build error when doing a 'make' in USBaspLoader-master/ #11

Closed electronut closed 10 years ago

electronut commented 10 years ago

I am getting the following build error when doing a 'make' in USBaspLoader-master/.

I am using OS X 10.9.2, with the latest CrossPack-AVR 20130-12-16. It has Avr-gcc version 4.8.1.

I couldn't find where in the project usbasploader is defined.

In file included from updater.c:8:0: usbasploader.h:20:61: error: expected expression before '>>' token extern const const uint16_t usbasploader[SIZEOF_new_firmware>>1] PROGMEM; ^ usbasploader.h:21:39: error: 'usbasploader' undeclared here (not in a function) const uint8_t _newfirmware = (void)&usbasploader; ^

baerwolf commented 10 years ago

Hi electronut.

Did you call the global makefile first? It seems the error happened during building the updater firmware. Most likely because you executed the make inside the update subdirectory without building the usbaspload bootloader firmware first.

Am I right? Perhaps you can attach the full build log as .txt or sth?

BR Stephan

electronut commented 10 years ago

Hello,

Actually I did a 'make' from the top level first, and then tried it from updater. Just to be sure, I just deleted the whole directory re-installed, and tried again. My log is below. (I am not quite sure how to attach a .txt file in the comments here.)

Thanks

Mahesh

moksha:USBaspLoader-master mahesh$ make . . ======>BUILDING BOOTLOADER FIRMWARE . main.c:132:1: warning: optimization may eliminate reads and/or writes to register variables [-Wvolatile-register-var] volatile register uint8_t stayinloader asm("r17"); ^ In file included from usbdrv/usbdrv.c:10:0, from main.c:46: usbdrv/usbdrv.h:223:24: warning: 'usbFunctionDescriptor' used but never defined [enabled by default] USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest _rq); ^ . . . !!!ATTANTION!!! (data+text) MUST fit into your MCUs bootloader section . text data bss dec hex filename 1972 6 54 2032 7f0 main.elf . . . . . ======>BUILDING BOOTLOADER UPDATER (EXPERIMENTAL) . stat: illegal option -- c usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...] In file included from updater.c:8:0: usbasploader.h:20:61: error: expected expression before '>>' token extern const const uint16_t usbasploader[SIZEOF_new_firmware>>1] PROGMEM; ^ usbasploader.h:21:39: error: 'usbasploader' undeclared here (not in a function) const uint8_t *newfirmware = (void)&usbasploader; ^ updater.c:53:4: warning: #warning I do not know where new "bootloaderdo_spm" is located - assuming "NEW_BOOTLOADERADDRESS+(funcaddrbootloader__do_spm % SPM_PAGESIZE)" [-Wcpp]

warning I do not know where new "bootloaderdo_spm" is located - assuming "NEW_BOOTLOADERADDRESS+(funcaddrbootloader__do_spm % SPM_PAGESIZE)"

^

updater.c:61:4: warning: #warning "TEMP_SPM_PAGEADR" is not defined explicitly - will choose END OF FLASH ! [-Wcpp]

warning "TEMP_SPM_PAGEADR" is not defined explicitly - will choose END OF FLASH !

^

updater.c:116:26: error: operator '<=' has no left operand

if (SIZEOF_new_firmware <= (TEMP_SPM_BLKSIZE + (NEW_SPM_ADDRESS - NEW_BOOTLOADER_ADDRESS)))

                      ^

updater.c:121:26: error: operator '>' has no left operand

if (SIZEOF_new_firmware > ((FLASHEND+1)-NEW_BOOTLOADER_ADDRESS))

                      ^

updater.c: In function 'main': updater.c:308:35: error: expected expression before ';' token for (i=0;i<SIZEOF_new_firmware;i+=2) { ^ updater.c:314:7: error: 'a' undeclared (first use in this function) a=pgm_read_word(FULLCORRECTFLASHADDRESS(&new_firmware[i])); ^ updater.c:314:7: note: each undeclared identifier is reported only once for each function it appears in updater.c:315:7: error: 'b' undeclared (first use in this function) b=pgm_read_word(NEW_BOOTLOADER_ADDRESS+i); ^ updater.c:350:34: error: expected expression before ';' token for (;i<SIZEOF_new_firmware;i+=SPM_PAGESIZE) { ^ make[1]: * [updater.o] Error 1 make: * [do_updater] Error 2

baerwolf commented 10 years ago

It seems the MACRO "SIZEOF_new_firmware" is not defined. Normally it becomes defined externally by the Makefile, which checks first the size of the bootloader firmware and sets "SIZEOF_new_firmware" to this size in bytes.

"-DSIZEOF_new_firmware=$(shell stat -c %s usbasploader.raw)"

Therefor the "stat" command is used. It seems your stat doesn't support the -c option. (Maybe try -f instead ???) For now you can work this arround by giving the macro the correct size of the usbasploader.raw. Then execute "make" from the "updater" firmware again. This should finish building the updater.

However your ISP flashable firmware already succeeded building, and can be used (firmware/main.hex).

BR Stephan

electronut commented 10 years ago

OK, I got it to work using this:

stat -f "%z"

Looks like OS X version of stat behaves differently.

Thank you so much for your prompt replies!

baerwolf commented 10 years ago

I am glad I could help. Also I am open to suggestions, how to make the build system more platform independent.

If you like USBaspLoader, please give it a github star ;-)

BR Stephan

electronut commented 10 years ago

Could we do something like this in the updater Makefile?

STAT := stat -c %s
OS := $(shell uname)
ifeq ($(OS), Darwin)
# stat option is different for OS X
    STAT := stat -f "%z"
endif

I am not an expert on Makefile syntax, but this could be helpful for folks building on OS X. A more sophisticated approach might be to use Autotools. Again, I am not an expert here.

But it's a great project, and I just gave it a star. ;-) I will be using it for my new project to create a low cost wireless sensor node, and of course I will be giving you credit and exposure. You can see some of my work here: http://electronut.in/

baerwolf commented 10 years ago

Perhaps checking "stat" for successful return and executing different dialects in case of failure may be the more successful approach. In case none "stat" is successful "(FLASH_END+1)-BOOLOADER_ADDRESS" could be used.