Author Topic: LUFA+CodeBlocks  (Read 610 times)

Offline adolfoe

  • Single posting newcomer
  • *
  • Posts: 3
LUFA+CodeBlocks
« on: September 29, 2018, 02:49:57 am »
Hello,

I am trying to work on a project using the C::B ide with the LUFA USB stack for AVR microcontrollers.

I am using the avr8-gnu-toolchain for windows.

I am trying to adapt the steps from the following page to to C::B: http://www.fourwalledcubicle.com/files/LUFA/Doc/120730/html/_page__exporting_library.html

However I have not been able to find the same options of the AVR studio on the compiler settings options of C::B.

What I have done is the following:

1) I found the -O1 flag on the option and selected it
2) The additional optimization options (-ffunction-section, -fpack-struct and -fshort-enums), I put them under Compiler settings->Other compiler options
3) The options that the pages tell me to add under the GCC compiler Symbols, I added them under the Compiler settings->#defines tab
4) The Linker Optimization options I added (--gc-sections) unde the Linker settings->Other linker options

Questions:
Could someone please let me know if I am doing this correctly, or if I am misinterpreting some step?
Sould I also add the -Wl option to the Other linker options?

Thanks in advance for your help.




Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11200
    • Travis build status
Re: LUFA+CodeBlocks
« Reply #1 on: September 29, 2018, 09:08:21 am »
Looks correct to me.
The --gc-sections option should make the binary smaller. If you remove it then the binary size should rise. If nothing happens add -Wl, in front of it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline adolfoe

  • Single posting newcomer
  • *
  • Posts: 3
Re: LUFA+CodeBlocks
« Reply #2 on: October 03, 2018, 10:28:54 pm »
Hello,

Thanks for your support.

I am experiencing the following problem when I try to compile:

LUFA\CodeTemplates\DeviceTemplate\Descriptors.h|40|fatal error: LUFA/Drivers/USB/USB.h: No such file or directory|

This is triggered by the following line on one of the headers:
      #include <LUFA/Drivers/USB/USB.h>

I have already added the LUFA path to the Compiler Settings->Search Directory

Is there anything else that I am missing?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2065
Re: LUFA+CodeBlocks
« Reply #3 on: October 03, 2018, 10:29:35 pm »

Offline adolfoe

  • Single posting newcomer
  • *
  • Posts: 3
Re: LUFA+CodeBlocks
« Reply #4 on: October 04, 2018, 04:08:41 pm »
Here is the build log:

Code: [Select]
-------------- Build: Release in LUFA-test (compiler: GNU GCC Compiler for AVR)---------------
avr-gcc.exe -Wall -mmcu=at90usb1286 -DF_CPU=16000000UL -Os -std=c11 -IC:\WinAVR\avr\include -IC:\avr8-gnu-toolchain\avr\include -IC:\Users\adolfo1x\Documents\GitHub\USB-FreelancerDevice\LUFA-test\LUFA -c LUFA\CodeTemplates\DeviceTemplate\Descriptors.c -o obj\Release\LUFA\CodeTemplates\DeviceTemplate\Descriptors.o
avr-gcc.exe -Wall -mmcu=at90usb1286 -DF_CPU=16000000UL -Os -std=c11 -IC:\WinAVR\avr\include -IC:\avr8-gnu-toolchain\avr\include -IC:\Users\adolfo1x\Documents\GitHub\USB-FreelancerDevice\LUFA-test\LUFA -c LUFA\CodeTemplates\DeviceTemplate\DeviceApplication.c -o obj\Release\LUFA\CodeTemplates\DeviceTemplate\DeviceApplication.o
avr-gcc.exe -Wall -mmcu=at90usb1286 -DF_CPU=16000000UL -Os -std=c11 -IC:\WinAVR\avr\include -IC:\avr8-gnu-toolchain\avr\include -IC:\Users\adolfo1x\Documents\GitHub\USB-FreelancerDevice\LUFA-test\LUFA -c LUFA\CodeTemplates\HostTemplate\HostApplication.c -o obj\Release\LUFA\CodeTemplates\HostTemplate\HostApplication.o
avr-gcc.exe -Wall -mmcu=at90usb1286 -DF_CPU=16000000UL -Os -std=c11 -IC:\WinAVR\avr\include -IC:\avr8-gnu-toolchain\avr\include -IC:\Users\adolfo1x\Documents\GitHub\USB-FreelancerDevice\LUFA-test\LUFA -c LUFA\Drivers\USB\Class\Device\AudioClassDevice.c -o obj\Release\LUFA\Drivers\USB\Class\Device\AudioClassDevice.o
In file included from LUFA\CodeTemplates\DeviceTemplate\Descriptors.c:38:0:
LUFA\CodeTemplates\DeviceTemplate\Descriptors.h:40:36: fatal error: LUFA/Drivers/USB/USB.h: No such file or directory
#include <LUFA/Drivers/USB/USB.h>
^
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
In file included from LUFA\CodeTemplates\DeviceTemplate\DeviceApplication.c:38:0:
LUFA\CodeTemplates\DeviceTemplate\DeviceApplication.h:44:38: fatal error: LUFA/Platform/Platform.h: No such file or directory
#include <LUFA/Platform/Platform.h>
^
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
In file included from LUFA\CodeTemplates\HostTemplate\HostApplication.c:38:0:
LUFA\CodeTemplates\HostTemplate\HostApplication.h:44:36: fatal error: LUFA/Drivers/USB/USB.h: No such file or directory
#include <LUFA/Drivers/USB/USB.h>
^
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
In file included from LUFA\Drivers\USB\Class\Device\../../Core/USBController.h:150:0,
from LUFA\Drivers\USB\Class\Device\../../Core/USBTask.h:47,
from LUFA\Drivers\USB\Class\Device\../../USB.h:386,
from LUFA\Drivers\USB\Class\Device\AudioClassDevice.h:57,
from LUFA\Drivers\USB\Class\Device\AudioClassDevice.c:38:
LUFA\Drivers\USB\Class\Device\../../Core/AVR8/USBController_AVR8.h:84:5: error: #error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.
#error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.
^
In file included from LUFA\Drivers\USB\Class\Device\../../Core/USBController.h:150:0,
from LUFA\Drivers\USB\Class\Device\../../Core/USBTask.h:47,
from LUFA\Drivers\USB\Class\Device\../../USB.h:386,
from LUFA\Drivers\USB\Class\Device\AudioClassDevice.h:57,
from LUFA\Drivers\USB\Class\Device\AudioClassDevice.c:38:
LUFA\Drivers\USB\Class\Device\../../Core/AVR8/USBController_AVR8.h:114:5: error: #error No PLL prescale value available for chosen F_USB value and AVR model.
#error No PLL prescale value available for chosen F_USB value and AVR model.
^
LUFA\Drivers\USB\Class\Device\../../Core/AVR8/USBController_AVR8.h: In function 'USB_PLL_On':
LUFA\Drivers\USB\Class\Device\../../Core/AVR8/USBController_AVR8.h:330:14: error: 'USB_PLL_PSC' undeclared (first use in this function)
PLLCSR = USB_PLL_PSC;
^
LUFA\Drivers\USB\Class\Device\../../Core/AVR8/USBController_AVR8.h:330:14: note: each undeclared identifier is reported only once for each function it appears in
Process terminated with status 1 (0 minute(s), 0 second(s))
6 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Thanks for your suggestion

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2065
Re: LUFA+CodeBlocks
« Reply #5 on: October 04, 2018, 04:50:30 pm »
I suspect you put lufa in
Quote
C:\Users\adolfo1x\Documents\GitHub\USB-FreelancerDevice\LUFA-test\LUFA
so that that the  path to this USB.h is like following:
Code: [Select]
C:\Users\adolfo1x\Documents\GitHub\USB-FreelancerDevice\LUFA-test\LUFA\Drivers\USB\USB.h
So you have to set the include search path in
Project->Build options->Select project name on the left side->Search directories->Compiler-> Add
Quote
C:\Users\adolfo1x\Documents\GitHub\USB-FreelancerDevice\LUFA-test