multiple UOTGHS handler

I need to replace system uothgs handler with my own.
I cannot find WHERE is the Arduino's uotghs.c file.
This error message is not helpful.
But I did find one elsewhere else, but that is not part of the compilation.

/home/jim/.arduino15/packages/arduino/hardware/sam/1.6.9/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a(uotghs.o): In function `UOTGHS_Handler':
uotghs.c:(.text.UOTGHS_Handler+0x0): multiple definition of `UOTGHS_Handler'
sketch/PAL_37-2-9-16-WEB_CAM_V3_UOTHS.ino.cpp.o:sketch/WEB_CAM_HCD.h:243: first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Due (Programming Port).

Using linux "find" did not find it either.
Any help would be appreciated.

Jim

that's code embedded into libsam_sam3x8e_gcc_rel.a

the repository is here

so you can modify it there and rebuild the libsam_sam3x8e_gcc_rel.a

Thanks,
so the suffix .a stands for what ?
Assembled code?
Not sure I can handle making the .a code , but I'll try.
Thanks again.
Jim

The .a files are static libraries, already compiled - something you would link with your program. that saves compilation time.

if you look in the repository I pointed above, there is hardware/sam/system/libsam/build_gcc

that makefile in there should be able to rebuild the library with a make clean

If I recompile just the libsam I do not need to recompile the whole IDE.
I should than rename / replace the original .a file
Still little scary.
Thanks for all your help.

If you manage to recompile it in a separate place with your codethen just replace the .a with the new .a and give it a try

No need to recompile all the libraries

Worse case scenario if you mess things up is to remove the IDE and reinstall it

Can I ask some more about the Arduino compiling process ?
Or is it out of "programming questions" forum area policy ?

Jim

[
OK, I admit it, I need more assistance .
I have identified the file i need to modify, found the "makes", but now I am stuck.

Obviously I have no clue HOW to use "make".

From doc just "Makefile" in the directory folder should work , but I "command not found".
When i do "make Makefile" i get something about nothing to do for Makefille.
When I do "make Makefile clean ":it does something but obviously not building the file I am after.

For short- what is the correct syntax for "make" to recompile the code I am after.

Thanks.

Jim

I had to delete most of the code , too big to post.

-
-rw-rw-r-- 1 jim jim 1011 Sep  2 08:16 debug.mk
-rw-rw-r-- 1 jim jim 2331 Sep  2 08:16 gcc.mk
-rw-rw-r-- 1 jim jim 5610 Sep  2 08:16 Makefile
-rw-rw-r-- 1 jim jim 1000 Sep  2 08:16 release.mk
-rw-rw-r-- 1 jim jim 6210 Sep  2 08:16 sam3.mk
jim@jim-desktop:~/Downloads/Arduino/hardware/arduino/sam/system/libsam/build_gcc$ gcc.mk
gcc.mk: command not found
jim@jim-desktop:~/Downloads/Arduino/hardware/arduino/sam/system/libsam/build_gcc$ ls -l
total 28
-rw-rw-r-- 1 jim jim 1011 Sep  2 08:16 debug.mk
-rw-rw-r-- 1 jim jim 2331 Sep  2 08:16 gcc.mk
-rw-rw-r-- 1 jim jim 5610 Sep  2 08:16 Makefile
-rw-rw-r-- 1 jim jim 1000 Sep  2 08:16 release.mk
-rw-rw-r-- 1 jim jim 6210 Sep  2 08:16 sam3.mk
jim@jim-desktop:~/Downloads/Arduino/hardware/arduino/sam/system/libsam/build_gcc$ make Makefile
make: Nothing to be done for 'Makefile'.
jim@jim-desktop:~/Downloads/Arduino/hardware/arduino/sam/system/libsam/build_gcc$ make clean Makefile
------------------------------------------------------------------------------------

------------------------------------------------------------------------------------
--- Cleaning __SAM3X8E__ files release_sam3x8e ../../../cores/arduino/libsam_sam3x8e_gcc_rel.a
------------------------------------------------------------------------------------
----------------------------------
target 'debug_sam3x8h/uotghs' doesn't match the target pattern
------------------------------------------------------------------------------------
--- Cleaning __SAM3X8H__ files debug_sam3x8h ../../../cores/arduino/libsam_sam3x8h_gcc_dbg.a
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
jim@jim-desktop:~/Downloads/Arduino/hardware/arduino/sam/system/libsam/build_gcc$

What does make clean and make all do? You might need to set some environment variables (do that on the side - in a directory with a copy of the code from the link above - not within the IDE libraries files system)

BTW - I should have asked before - why do you need to replace it? Seems weird

This is the code in the library

void (*gpf_isr)(void) = (0UL);

void UOTGHS_Handler( void )
{
	if (gpf_isr)
		gpf_isr();
}

So you need to define the gpf_isr function pointer. The default one points to null, have it point to your function and that is what will be called. No need to change the library.

J-M-L:
BTW - I should have asked before - why do you need to replace it? Seems weird

This is the code in the library

void (*gpf_isr)(void) = (0UL);

void UOTGHS_Handler( void )
{
if (gpf_isr)
gpf_isr();
}


So you need to define the `gpf_isr` function pointer. The default one points to null, have it point to your function and that is what will be called. No need to change the library.

I am using part of code build in ATmel Studio and the UOTGHS_Handler( was redefined by the author.
I like what you suggesting and will try it next.
Could you give me a hint how ? Not that handy with pointers.

But i'll take another look at "make" so I can learn something about it.

Much appreciate your help.
Jim

if you have

void blink() {
// your code here
}

then the pointer to your function is just blink so you would do gpf_isr=blink;
in your setup()

I am using part of code build in ATmel Studio and the UOTGHS_Handler( was redefined by the author.
I like what you suggesting and will try it next.

I suggest to look at his code, remove the double definition. his code probably looks like this

void UOTGHS_Handler( void )
{
  // his code is here
}

change the name so that this becomes just a function and give that to the library handler.

void my_special_UOTGHS_Handler( void )
{
  // his code is here
}

....

// at the end of your setup()
...
    gpf_isr= my_special_UOTGHS_Handler;

Thanks , this function pointer is neat.
Works great.

As soon as I redefined it , the double definition of the handler went away.
Not to be cocky, I could probably use same name for the handler.

Many thanks for all your help and patience.

Jim

great! happy coding!