Override core files on a per-project basis

DogP

Well-known member
Hey,

Sorry if this has been discussed before, but I didn't find anything regarding it. Is it possible to override one or more of the so-called "core" files (under hardware\teensy\avr\cores\teensy3 for example), specific to one project... or is this a feature that could be added/would be wanted?. I understand that Arduino is supposed to be easy for novices, so a lot of that stuff gets hidden for simple projects... but I find that I'm modifying several of those files for every project, which to me feels really messy (modifying my "stock" core files), and seems cumbersome when sharing projects with others (especially if they've already modified those files too).

I'm used to IDEs where I add files that I want to use specifically for a project, vs. using only a standard set... I get that the Arduino IDE doesn't really do that, but what I'm thinking of is a way to build a tree local to the project, which would be compiled as if it were in the Arduino directory (either an additional file if it doesn't already exist, or in place of an existing file if it does exist). So, if I had a directory in the folder with my sketch called hardware\teensy\avr\cores\teensy3 with two files usb_joystick.c and usb_gamepad.c ... usb_joystick.c would be compiled instead of the one under the Arduino directory, and usb_gamepad.c would be compiled as if it were in that directory as well (even though one doesn't already exist). But, if I closed that sketch and opened up the simple joystick demo, it'd work as it did originally, as the original files are still intact.

Any thoughts? Am I doing something wrong by always having to change those files? Am I the only one that would find this useful? Can it already be done?

Thanks,
Pat
 
Indeed the Arduino way involves buffers and settings in 'core' files - not sure there is a graceful answer?

Marginally less cumbersome perhaps - but functional? In the 'core' files make an #IFDEF for your altered code versus the stock code.
Then in boards.txt create a new 'speed option' that specifies your custom #define?
teensy31.menu.speed.96opt=96 MHz optimized (overclock)
becomes:
teensy31.menu.speed.96DogP=96 MHz optimized (OC DogP)

You'd still have to hack files - and update them with each TeensyDuinoInstall . . . but if you can get the "teensy31.menu.speed.96DogP.build.flags.optimize=-O" build.flags you want does that work?

Alternatively you could run TWO unzip installs - one is stock and one is 'DogP' - then either restart the IDE - or if your build environment lets you select the build tree . . .
 
Is it possible to override one or more of the so-called "core" files (under hardware\teensy\avr\cores\teensy3 for example), specific to one project...

Not really. Arduino's not designed that way.

or is this a feature that could be added/would be wanted?

Yes, many people have wanted this. It's come up many, many times.

This is the sort of thing which has immediate convenience, but over the long term can have terrible long-term consequences for Arduino as a platform.
 
You'd still have to hack files - and update them with each TeensyDuinoInstall . . . but if you can get the "teensy31.menu.speed.96DogP.build.flags.optimize=-O" build.flags you want does that work?
Hmm... that's an interesting idea. It doesn't exactly solve my problem with this (that I'd like to keep project specific stuff out of my global library... and that I'd like it to be easy to share with others), but it would at least segment my stuff vs. stock stuff. And I guess I could extend that to each project instead of just "DogP" and stock.

Yes, many people have wanted this. It's come up many, many times.

This is the sort of thing which has immediate convenience, but over the long term can have terrible long-term consequences for Arduino as a platform.
Ah, sorry... I guess I missed the previous discussions on it, but I'm glad I'm not alone. ;) I'm not sure what's worse in the long term though... every user having their own incompatible customized "core" libraries that they sorta get locked into using, or each project having a few modified libraries bundled with it, which could become outdated (those libraries have to be distributed with it in some way no matter how it's done... presently in the zip with a readme saying to copy to the cores directory, and back up your original one). Obviously, it'd be ideal if the stock cores were sufficient, but that doesn't seem to be the case for a lot of us.

Maybe what I'm trying to do could be accomplished by modifying the Makefile to copy the files to the directory and back when building... I'm not sure what other consequences that'd have though (I'm guessing the Makefile isn't something that's supposed to be modified by hand, so I assume it'd get overwritten by certain changes in the GUI, etc).

I do a lot of embedded development, but I'll admit, I rarely use the Arduino IDE (the only other thing I used it for was making changes to my RepRap). But I really like what you've got going for USB peripherals, so I'm trying... but maybe I'm just trying to mold it to what I'm used to, rather than changing to think the Arduino way.

I'm guessing you've done several hundred or more projects... how do you keep everything straight?

Anyway, I guess this is turning into more of a discussion, so feel free to bump it over to General Discussion or elsewhere if you'd like.

Thanks,
Pat
 
Back
Top