Author Topic: Single FW Binary to run on Multiple Atmel MCU models  (Read 1486 times)

0 Members and 1 Guest are viewing this topic.

Offline Nick NovakTopic starter

  • Contributor
  • Posts: 24
  • Country: ca
Single FW Binary to run on Multiple Atmel MCU models
« on: August 27, 2018, 05:57:45 pm »
I’m currently loading the same firmware binary on multiple device types with different hardware add-ons and switching capability on and off at run time.  I’d like to add another device to the family using a different MCU and maintain the binary compatibility.  The MCUs are obviously very similar Atmel SAMR21E18 vs SAMR21G18, which is just a larger package.

I’m pretty confident this will work from a field update / binary perspective.  I’ll build for the G18 and refrain from accessing hardware that isn’t there on the E18, although I expect the registers are in place. 

The difficulty I see though is trying to debug on the E18, using the E18 headers many of the G18 defines will be missing so my code wouldn’t build.  If I build for the G18 Atmel Studio wont connect to an E18.

Does anybody have any experience doing something like this and want to share their tricks?  With Atmel’s toolset ideally. 

Is there a way to pull in the G18 headers explicitly and convince studio that its targeting an E18 chip?  Or maybe I need my own header that adds the missing G18 defines. 


Nick
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Single FW Binary to run on Multiple Atmel MCU models
« Reply #1 on: August 27, 2018, 07:08:48 pm »
If you refrain from accessing hardware that isn’t there, why would you code not compile due to “missing definitions?”

 

Offline TomS_

  • Frequent Contributor
  • **
  • Posts: 834
  • Country: gb
Re: Single FW Binary to run on Multiple Atmel MCU models
« Reply #2 on: August 28, 2018, 07:07:55 am »
Perhaps you need to use preprocessor directives (#ifdef et al) to include or exclude certain bits of code based on the target platform, like platform specific headers and code?

Although that may go against your single universal binary approach.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13736
  • Country: gb
    • Mike's Electric Stuff
Re: Single FW Binary to run on Multiple Atmel MCU models
« Reply #3 on: August 28, 2018, 09:26:14 am »
Surely the answer is to just build and debug for the largest package, assuming it's a superset so you can just avoid using the bits that aren't on the smaller one ?
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3237
  • Country: gb
Re: Single FW Binary to run on Multiple Atmel MCU models
« Reply #4 on: August 28, 2018, 10:16:02 am »
Surely the answer is to just build and debug for the largest package, assuming it's a superset so you can just avoid using the bits that aren't on the smaller one ?

I think the OP's problem is that he may want to attach a debugger to a design that uses the smaller micro, in which case Atmel Studio will no doubt have a fit as the Device ID won't be correct.

I've not used any of the later versions of Studio, would it be possible to change the target device to the smaller one and connect the debugger without re-building or downloading the binary to the target?
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 825
Re: Single FW Binary to run on Multiple Atmel MCU models
« Reply #5 on: August 28, 2018, 12:16:52 pm »
mv e18header.h e18header.h.bak
copy g18header.h e18header.h

 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3237
  • Country: gb
Re: Single FW Binary to run on Multiple Atmel MCU models
« Reply #6 on: August 29, 2018, 08:24:45 pm »
mv e18header.h e18header.h.bak
copy g18header.h e18header.h

Might be possible but typically a whole family of devices will share a common header with different sections inside enabled when the compiler defines a symbol relating to the target device.
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 825
Re: Single FW Binary to run on Multiple Atmel MCU models
« Reply #7 on: August 29, 2018, 09:42:51 pm »
it appears the differences are in the pio header, and it looks like the only difference is simply the added pin names to the g18

mv (or ren) pio/samr21e18a.h pio/samr21e18a.h.bak
cp (or copy) pio/samr21g18a.h pio/samr21e18a.h

the headers one level up have the same two names, but are identical (except for DEVice ID), and then include the specific pio header
so the above rename will have the e18 including the g18 pio header with the additional pin defines
(could also simply change the include line in the base e18 header to include the g18 pio header instead, tomAto tomOto)

edit-

you may also be able to add to the global build options
-U__SAMR21E18A__ -D__SAMR21G18A__
or __ATSAM..., not sure what is used
then no files need changing

« Last Edit: August 30, 2018, 08:43:48 pm by cv007 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf