avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Jim Brooks
Subject: Re: [avr-gcc-list] Machine Readable Fuse Database
Date: Thu, 21 Jul 2016 11:49:18 -0700

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" <address@hidden> wrote:
On Thu, 21 Jul 2016 22:01:40 +1000
Erik Christiansen <address@hidden> 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 <avr/io.h>
  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

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

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]