ATtiny841 core - testers wanted

The ATtiny841 is a really nifty chip. At a price only slightly above that of the Tiny84, you get dual hardware UARTs, ADC on every pin, I2C, SPI, and SIX, count 'em, SIX PWM outputs.

It all comes in the SOIC-14 package we all know and love, and since it's release, it's been the most appealing of the small tinys for many applications. Except that there wasn't any working Arduino core for it... until now!

http://drazzy.com/e/tiny841.shtml

Status:

  • Program over ISP or serial via Optiboot
  • Optiboot works, at cost of 640 bytes
  • Serial and Serial1 work.
  • INPUT_PULLUP works
  • millis and micros work
  • analogRead() works
  • PWM works on all 6 channels.
  • EEPROM works.
  • tone is untested.
  • Hardware SPI works
  • Hardware I2C slave with WireS library
  • Software I2C master with SoftI2CMaster library
  • Pin change interrupts work

Status updated 6/9

Anyone want to give it a spin and let me know what doesn't work?

841 breakout boards for sale on Tindie

Not having a t841 it may be a while before I can help with testing.

But, I can help with these two...

Something is wrong with the upload process - it's SLOOOOOOW using Arduino-as-ISP. There seems to be a very long period of time at the start of upload where it engages in some sort of repetitive action, before eventually going ahead and uploading the compiled sketch.

Did you disable auto-reset? With a capacitor?

After uploading, the IDE complains that pagel and bs2 need to be defined in avrdude.conf. I can find no documentation that explains what those two settings mean or how to determine their correct values. I suspect this is related to the slow uploads

They are used for parallel programming (check the m328 datasheet). ATtiny processors do not support parallel programming so there are no correct values. The warnings are the symptom of a bug in AVRDUDE. They can be ignored.

Aaaha! So they're for parallel programming only, which is why I couldn't find any mention of them in the tiny8x datasheets. So the values that are specified for the other tinys in avrdude.conf are just bogus, presumably there just to make AVRdude stop whining... Okay then!

Disable autoreset? I'll try that tonight, thanks

Just ordered two boards from tindie. Will give it a try when they arrive.

I hope to have some 841 chips to play with next week and will be happy to test.

It looks like you are using 1.0.6, any reason not to switch to 1.6 now that is the recommended release?

Yeah, I'm using 1.0.6. I see a lot of posts on these forums about things not working with 1.5.x or not working with 1.6 - so I stick with the version that people seem to say works - nobody seems to be saying that something or another doesn't work with 1.0.6. Also, some build tools included in 1.0.6 are not included in 1.6 (see http://forum.arduino.cc/index.php?topic=304207.0 ). I am not really familiar with what the differences all are between the two versions, so I picked the one that people seem to indicate works, rather than the one that people have problems with.

Note that (i think even with 1.6) you need to update the compiler toolchain to make stuff for the tiny841 build.

I'm not sure how big a deal it is to move a core from 1.0.6 to 1.6 - I'd like to have my cores work on both versions. Maybe I'll try to get 1.6 installed somewhere and see what needs to be done to make things build on it.

(also, personal biases also went into my decision with 1.0.6, though I wouldn't have picked it if it didn't still seem to have a big following - I need the same version on all my systems, so it doesn't matter which of my systems I happen to compile on. But some of the systems are agonizingly slow, and some run XP, so the older version seemed a safer choice)

Thanks for clarifying. If you are comfortable with 1.0.6, then go with that to get things going.

Works with 1.6.0 - and without having to update the toolchain! Neat.

I committed a few changes that should fix the usual compatibility issues.

Disabling autoreset does not change the behavior. Issue is less pressing since USBAsp does work.

DrAzzy:
Works with 1.6.0 - and without having to update the toolchain! Neat.

I committed a few changes that should fix the usual compatibility issues.

I would like to begin testing by following the documentation for setting up the environment. The README file refers to the ATTiny chips that shimniok’s fork supports but are not in this repo’s boards.txt Do you want to make this repo a superset of shimniok’s boards, or just support the 841? Either way, I suggest the README file is updated to cover the steps for installation of the boards supported by this repo.

Do you still want to focus on the 1.06 Arduino release or would 1.6 be a better choice given that you have it working and it has the correct tool chain and is the current official release?

What I have for installation instructions is in README.md - I have not written it up nicely. I didn’t even think about there being a README not just README.md (Shimniok didn’t modify it either, as you can see). I’ll update the READMEs to write out the installation process. I don’t think I’m very good at documenting things, in general; Nobody seems to understand what I write for documentation (this has been a long-standing sore-point with me - I’ve rewritten the installation instructions for my AI (AzzyAI, for an old MMO) so many times, but 90+% of support inquiries are about how to extract a zip file and put the contents into a folder, so clearly I don’t know how to explain that to people)

Edit - I’ve updated the READMEs

I don’t intend to maintain support for the other parts - I expect they’ll work, but I haven’t changed anything about them, and there are plenty of cores for them, none of which are any worse, and some of which may be better. That’s my feeling on that. I think the tinyx4/x5 can even be supported on 1.6.0 without a custom core. So yeah - I intend to support only the 841/441. I may try to merge in the 1634 core (rambo’s - however he reorganized the files, so the merge is more difficult), since the two chips very similar, and both really awesome.

Am I missing something regarding 1.0.6 vs 1.6? Both are fully supported.
As I understand it, now that I’ve made those trivial changes, 1.0.6 and 1.6.0 should both work without issue; I agree that 1.6.0 is a better choice, since you don’t have to update the toolchain. I mean, after you update the toolchain on 1.0.6, you get an identical binary to what you get out of 1.6 (in my tests).

I think all that’s needed is a note to clarify the need for putting everything in an “avr” folder on 1.6.0, but not doing that on 1.0.6 right? (right next to the explanation about how you need to update the toolchain if using 1.0.6, but not 1.6.0)

I’m going to see if I can get Optiboot working on this tonight or tomorrow. Having a hardware UART makes optiboot a lot more attractive. I think it can be crammed into 9 64-byte erase pages, so you’d have like 7.4k of flash left with optiboot, which isn’t bad at all, and being able to program over serial, then pop over to the monitor is mighty convenient.

Am I missing something regarding 1.0.6 vs 1.6? Both are fully supported.

No, but supporting both requires some extra testing and as the best place to get the tools is probably from 1.6, I would be tempted to just focus on that. But its your call.

I'm going to see if I can get Optiboot working on this tonight or tomorrow.

I think Optiboot support would be a big plus.

Yeah. Optiboot is giving me a hard time, not sure why yet. It's running, and DTR is resetting it, but that's all it does - it's not responding to serial communication (though it's configuring the UART)

Optiboot works!

Also fixed a bad issue with avrdude.conf - it wasn't reading the efuse right.

Great to see you are making good progress. I have made some breakouts so I can begin testing. The pic shows my 3.3v/8MHz and 5v/16MHz boards (one with a ICSP adapter plugged in). Unfortunately, I am getting averdude verification errors.

I have a full plate with other things today so will hopefully get this working tomorrow.

Nice!

Do you have the latest version of the avrdude.conf entry? I just updated it a few hours ago. The old one got verification errors on the efuse. I am still very confused as to how I didn't notice that...

Nice core! I was able to get my t841 (using the Bot Thoughts breakout board) working great with Optiboot.

I am using IDE 1.6.1, updated to avrdude v6.1. I did had to make some mods to the boards.txt file. The separate bootloader.path is no longer used. And also had to add the lock bits for burn bootloader.

###########################################################################
attiny841at16.name=ATtiny841 @ 16 MHz  (external crystal; 4.3 V BOD)

#attiny841at16.upload.using=tiny:arduinoisp
#attiny841at16.upload.using=tiny:dragon
attiny841at16.upload.using=tiny:avrispv2
attiny841at16.upload.tool=arduino:avrdude
attiny841at16.upload.maximum_size=8192

# Frequency 16.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms
# Brown-out detection level at VCC=4.3 V
# Preserve EEPROM memory through the Chip Erase cycle
# Serial program downloading (SPI) enabled

attiny841at16.bootloader.tool=arduino:avrdude
attiny841at16.bootloader.low_fuses=0xEE
attiny841at16.bootloader.high_fuses=0xD4
attiny841at16.bootloader.extended_fuses=0xFF
attiny841at16.bootloader.unlock_bits=0xFF
attiny841at16.bootloader.lock_bits=0xFF
attiny841at16.bootloader.file=empty/empty841at16.hex

attiny841at16.build.mcu=attiny841
attiny841at16.build.f_cpu=16000000L
attiny841at16.build.core=tiny


###########################################################################
###########################################################################
attiny841at8.name=ATtiny841 @ 8 MHz  (internal oscillator; BOD disabled)

#attiny841at8.upload.using=tiny:arduinoisp
#attiny841at8.upload.using=tiny:dragon
attiny841at8.upload.using=tiny:avrispv2
attiny841at8.upload.maximum_size=8192
attiny841at8.upload.tool=arduino:avrdude

# Frequency 8.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms
# Brown-out detection level disabled
# Preserve EEPROM memory through the Chip Erase cycle
# Serial program downloading (SPI) enabled

attiny841at8.bootloader.tool=arduino:avrdude
attiny841at8.bootloader.low_fuses=0xE2
attiny841at8.bootloader.high_fuses=0xD7
attiny841at8.bootloader.extended_fuses=0xFF
attiny841at8.bootloader.unlock_bits=0xFF
attiny841at8.bootloader.lock_bits=0xFF
attiny841at8.bootloader.file=empty/empty841at8.hex

attiny841at8.build.mcu=attiny841
attiny841at8.build.f_cpu=8000000L
attiny841at8.build.core=tiny

###########################################################################
attiny841at16opti.name=ATtiny841 @ 16 MHz  (external crystal; Optiboot, 4.3v BoD)

attiny841at16opti.upload.protocol=arduino
attiny841at16opti.upload.speed=115200
attiny841at16opti.upload.maximum_size=7552
attiny841at16opti.upload.tool=arduino:avrdude

# Frequency 16.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms
# Brown-out detection level at VCC=4.3 V
# Preserve EEPROM memory through the Chip Erase cycle
# Serial program downloading (SPI) enabled

attiny841at16opti.bootloader.tool=arduino:avrdude
attiny841at16opti.bootloader.low_fuses=0xEE
attiny841at16opti.bootloader.high_fuses=0xD4
attiny841at16opti.bootloader.extended_fuses=0xFE
attiny841at16opti.bootloader.unlock_bits=0xFF
attiny841at16opti.bootloader.lock_bits=0xFF
attiny841at16opti.bootloader.file=optiboot/optiboot_attiny841at16.hex

attiny841at16opti.build.mcu=attiny841
attiny841at16opti.build.f_cpu=16000000L
attiny841at16opti.build.core=tiny


###########################################################################
###########################################################################
attiny841at8opti.name=ATtiny841 @ 8 MHz  (internal oscillator; Optiboot)

attiny841at8opti.upload.protocol=arduino
attiny841at8opti.upload.speed=115200
attiny841at8opti.upload.maximum_size=7552
attiny841at8opti.upload.tool=arduino:avrdude

# Frequency 8.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms
# Brown-out detection level disabled
# Preserve EEPROM memory through the Chip Erase cycle
# Serial program downloading (SPI) enabled

attiny841at8opti.bootloader.tool=arduino:avrdude
attiny841at8opti.bootloader.low_fuses=0xE2
attiny841at8opti.bootloader.high_fuses=0xD7
attiny841at8opti.bootloader.extended_fuses=0xFE
attiny841at8opti.bootloader.unlock_bits=0xFF
attiny841at8opti.bootloader.lock_bits=0xFF
attiny841at8opti.bootloader.file=optiboot/optiboot_attiny841at8.hex

attiny841at8opti.build.mcu=attiny841
attiny841at8opti.build.f_cpu=8000000L
attiny841at8opti.build.core=tiny

Also the t841 has a flash page size of 8 words so the addressing bits need to be changed in avrdude.conf.

     memory "flash"
         paged           = yes;
         size            = 8192;
         page_size       = 16;
         num_pages       = 512;
         min_write_delay = 4500;
         max_write_delay = 4500;
         readback_p1     = 0xff;
         readback_p2     = 0xff;
         read_lo         = "  0   0   1   0    0   0   0   0",
                           "  0   0   0   0  a11 a10  a9  a8",
                           " a7  a6  a5  a4   a3  a2  a1  a0",
                           "  o   o   o   o    o   o   o   o";

         read_hi         = "  0   0   1   0    1   0   0   0",
                           "  0   0   0   0  a11 a10  a9  a8",
                           " a7  a6  a5  a4   a3  a2  a1  a0",
                           "  o   o   o   o    o   o   o   o";

         loadpage_lo     = "  0   1   0   0    0   0   0   0",
                           "  0   0   0   x    x   x   x   x",
                           "  x   x   x   x    x  a2  a1  a0",
                           "  i   i   i   i    i   i   i   i";

         loadpage_hi     = "  0   1   0   0    1   0   0   0",
                           "  0   0   0   x    x   x   x   x",
                           "  x   x   x   x    x  a2  a1  a0",
                           "  i   i   i   i    i   i   i   i";

         writepage       = "  0   1   0   0    1   1   0   0",
                           "  0   0   0   0  a11 a10  a9  a8",
                           " a7  a6  a5  a4   a3   x   x   x",
                           "  x   x   x   x    x   x   x   x";

         mode            = 0x41;
         delay           = 10;
         blocksize       = 16;
         readsize        = 256;
       ;

Thanks for the fix for avrdude.conf - I wonder how it could have ever worked at all before. But it did...

That change to boards.txt breaks 1.0.6.
1.0.6 doesn't work if you include a folder in bootloader.file (it doesn't write the flash - just erases the chip), but 1.6.0 doesn't work without the folder in bootloader.file

Do you know if there's any way that works in both versions? i do not want to have to make two branches to support the two most popular versions of the IDE.

Works like a charm! Well done!

From the REAME:

SPI is untested - but should work. Registers are identical to the mega328.

I tried, it does work.

Only I found it weird that it did not find SPI.h. Since the SPI lib is a lib in the IDE’s avr architecture directory (in the libraries folder which is a sibling of the cores folder) I expected the IDE to find it over there. Well, it does not.

I am aware that there is a new 1.6.0 library spec, but I can’t figure out how this use case (use the standard avr SPI lib with another core) is supposed to work.

I have put the tiny core in /hardware/tiny-841, so I also tried to put the SPI lib in /hardware/tiny-841/avr/libraries/SPI. That does not work either.

So I copied /hardware/arduino/avr/libraries/SPI over to /libraries/SPI. That is the only location I have found working. However this cannot be the purpose because the lib is architecture dependent, this will cause problems when compiling for the due.

Anyone has an idea?

Further, I also added SPI pin definitions to pins_arduino.h:

#define SS      3
#define MISO    5
#define MOSI    4
#define SCK     6

I hooked up an nRF2401 to the SPI pins and could successfully run the “fake BLE advertising” sketch, Serial.print() inclusive. Great!

boards.txt has '..upload.using=tiny:avrispv2' enabled for the non optiboot boards.
I needed to comment these out to select a programmer and upload using the IDE tools menu.