Re: [avr-gcc-list] Machine Readable Fuse Database

2016-07-21 Thread Paul "LeoNerd" Evans
On Thu, 21 Jul 2016 21:37:03 +0200
Thomas Kopp <20.k...@gmail.com> wrote:

> They actually do - All(or at least most) of the latest xmls (atdfs
> now) for mega and tiny devices contain the defaultvalue for Fuse
> bytes. The attribute is initval. I can't quite remember when they
> were added but it's possible that they were only publicly available
> in Studio 7. 

Oooh; I see. Yes; my XML files are lacking the "initval" field but I
see it in your pasted example below; that looks perfect for me.

> If you don't want studio 7 you can also download the
> tiny and mega packs from http://packs.download.atmel.com/ Does that
> help you?

I see the packs. They appear to be Zip files. Inside those are indeed
the XML files, though they're not called .xml; I see they're .atdf.

But yes - these likely contain the information I need. Thanks muchly.

-- 
Paul "LeoNerd" Evans

leon...@leonerd.org.uk  |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/


pgpD3fHG7PwUW.pgp
Description: OpenPGP digital signature
___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] Machine Readable Fuse Database

2016-07-21 Thread Thomas Kopp
On Jul 16, 2016 3:34 PM, "Paul "LeoNerd" Evans" 
wrote:

>
> The reason this is so, is because I'm using the "devices" XML files
> that are supplied with Atmel Studio to get the fuse values from. Those
> give the name, value and mapping location of every fuse, but don't
> supply the default values.
>
>
>


They actually do - All(or at least most) of the latest xmls (atdfs now) for
mega and tiny devices contain the defaultvalue for Fuse bytes. The
attribute is initval. I can't quite remember when they were added but it's
possible that they were only publicly available in Studio 7. If you don't
want studio 7 you can also download the tiny and mega packs from
http://packs.download.atmel.com/ Does that help you?

Example from AT90CAN64:

  

  
  


  
  
  
  
  
  
  


  
  
  

___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] Machine Readable Fuse Database

2016-07-21 Thread Jim Brooks
This would be so mucj easier if as with microschip it was in the source
files. Aftee all everything else about the configuration of the mci is
jandled tjere so why not fuses.
Jim

On Jul 21, 2016 11:46 AM, "Paul "LeoNerd" Evans" 
wrote:

> On Thu, 21 Jul 2016 22:01:40 +1000
> Erik Christiansen  wrote:
>
> > I wouldn't go to the trouble of a C program, but do it with a lot less
> > lines of awk, but that's just taste.
>
> That's not going to help.
>
> E.g. on the tiny841,
>
> #define LFUSE_DEFAULT(FUSE_SUT_CKSEL0 & FUSE_SUT_CKSEL2 & \
>   FUSE_SUT_CKSEL3 & FUSE_SUT_CKSEL4 & FUSE_CKDIV8)
> #define HFUSE_DEFAULT(FUSE_SPIEN)
> #define EFUSE_DEFAULT(0xFF)
>
> That doesn't help directly, as you need to know the values of those
> individual FUSE_* constants. OK, so they are:
>
> #define FUSE_SUT_CKSEL0  (unsigned char)~_BV(0)
> #define FUSE_SUT_CKSEL1  (unsigned char)~_BV(1)
> #define FUSE_SUT_CKSEL2  (unsigned char)~_BV(2)
> #define FUSE_SUT_CKSEL3  (unsigned char)~_BV(3)
> #define FUSE_SUT_CKSEL4  (unsigned char)~_BV(4)
> ...
>
> Alright. Um we're going to need _BV(). Except that isn't found in this
> file. I'll have to follow the #include chain.
>
> So now I need to understand how #include works. And #define.
>
> And *then* I'm going to have to understand the ~ and & operators, along
> with the << operator of _BV's actual definition.
>
> Or; I could just generate/compile/run the following C program:
>
>   #include 
>   printf("lfuse=%02x:hfuse=%02x:efuse=%02x\n",
> LFUSE_DEFAULt, HFUSE_DEFAULT, EFUSE_DEFAULT);
>
> and out comes the answer directly without my having to do any other
> work.
>
> Big spoiler: I already wrote lots of code for doing exactly this kind
> of "please get me values out of system .h files":
>
>   https://metacpan.org/pod/ExtUtils::H2PM
>
> So in practice I'll just be running that.
>
> --
> Paul "LeoNerd" Evans
>
> leon...@leonerd.org.uk  |  https://metacpan.org/author/PEVANS
> http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/
>
> ___
> AVR-GCC-list mailing list
> AVR-GCC-list@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>
>
___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] Machine Readable Fuse Database

2016-07-21 Thread Paul "LeoNerd" Evans
On Thu, 21 Jul 2016 22:01:40 +1000
Erik Christiansen  wrote:

> I wouldn't go to the trouble of a C program, but do it with a lot less
> lines of awk, but that's just taste.

That's not going to help.

E.g. on the tiny841,

#define LFUSE_DEFAULT(FUSE_SUT_CKSEL0 & FUSE_SUT_CKSEL2 & \
  FUSE_SUT_CKSEL3 & FUSE_SUT_CKSEL4 & FUSE_CKDIV8)
#define HFUSE_DEFAULT(FUSE_SPIEN)
#define EFUSE_DEFAULT(0xFF)

That doesn't help directly, as you need to know the values of those
individual FUSE_* constants. OK, so they are:

#define FUSE_SUT_CKSEL0  (unsigned char)~_BV(0)
#define FUSE_SUT_CKSEL1  (unsigned char)~_BV(1)
#define FUSE_SUT_CKSEL2  (unsigned char)~_BV(2)
#define FUSE_SUT_CKSEL3  (unsigned char)~_BV(3)
#define FUSE_SUT_CKSEL4  (unsigned char)~_BV(4)
...

Alright. Um we're going to need _BV(). Except that isn't found in this
file. I'll have to follow the #include chain.

So now I need to understand how #include works. And #define.

And *then* I'm going to have to understand the ~ and & operators, along
with the << operator of _BV's actual definition.

Or; I could just generate/compile/run the following C program:

  #include 
  printf("lfuse=%02x:hfuse=%02x:efuse=%02x\n",
LFUSE_DEFAULt, HFUSE_DEFAULT, EFUSE_DEFAULT);

and out comes the answer directly without my having to do any other
work.

Big spoiler: I already wrote lots of code for doing exactly this kind
of "please get me values out of system .h files":

  https://metacpan.org/pod/ExtUtils::H2PM

So in practice I'll just be running that.

-- 
Paul "LeoNerd" Evans

leon...@leonerd.org.uk  |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/


pgpdOj4zkdtj1.pgp
Description: OpenPGP digital signature
___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] Machine Readable Fuse Database

2016-07-21 Thread Erik Christiansen
On 16.07.16 14:33, Paul "LeoNerd" Evans wrote:
> I notice that the AVR libc per-part .h files do know these values, in a
> way.
> 
>  $ grep FUSE_DEFAULT /usr/lib/avr/include/avr/iotn84a.h
>  #define LFUSE_DEFAULT (FUSE_CKSEL0 & FUSE_CKSEL2 & FUSE_CKSEL3 & \
>FUSE_SUT0 & FUSE_CKDIV8)
>  #define HFUSE_DEFAULT (FUSE_SPIEN)
>  #define EFUSE_DEFAULT (0xFF)
> 
> It's not *directly* useable as it is, but a C program could read those.
> So technically I could iterate all the .h files and extract default
> values that way. But it feels like quite a long way around.
> 
> Does anyone know of a better source of these?

Given avrdude's fuse "safemode", I thought at first that it might have
the data, but it only checks whether any have changed since program
invocation, AFAICT.

I wouldn't go to the trouble of a C program, but do it with a lot less
lines of awk, but that's just taste.

Erik

___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list