B4R Question Cannot install Attiny board

Martin Larsen

Active Member
Licensed User
Longtime User
I am facing a problem installing support for Attiny85 in B4R.

I am programming Attiny85 using the USBASP programmer. For Windows you first need to install the driver, I used a Windows 7 driver from https://sparks.gogo.co.nz/usbasp_drivers.html

Then install the board JSON file for Attiny: http://drazzy.com/package_drazzy.com_index.json

1.png


Now go to the board manager and install ATTinyCore:

2.png


Finally choose the board and the correct settings. For a plain Attiny85 without extra hardware you should choose 1 MHz internal clock.

3.png


All this works fine from Arduino. I can upload the blink sketch shown in the background.

As you can see from the image above, this programmer (USBASP) doesn't show up as a serial port. It is disabled. But it works fine. No problems here.

But not so in B4R:

4.png


B4R insists that I fill out the serial port.

I am pretty sure it would work fine if I could just submit the dialog.

Is there a way to persuade B4R to continue? Maybe editing an ini file instead?
 

janderkan

Well-Known Member
Licensed User
Longtime User
The UsbAsp driver is not installed as a comport.
The Avrdude program communicate directly with the programmer.
You should just make a small batch file to program the Tiny.
It could look like this:
B4X:
@Echo off

:choice
set /P c=Are you ready to burn [Y/N]?
if /I "%c%" EQU "" goto :burn
if /I "%c%" EQU "Y" goto :burn
if /I "%c%" EQU "N" goto :end
goto :choice


:burn
C:\AvrDude\avrdude -C C:\avrdude.conf -c USBasp -p m328pb -U flash:w:C:\2Work\Toilet2\Objects\bin\src.ino.hex:i
goto :choice

:end
exit
You can see the exact command line in Arduino if you enabled the verbose output in settings.


Anmærkning 2020-07-06 201137.jpg


Jan fra Blokhus
 
Upvote 0

Martin Larsen

Active Member
Licensed User
Longtime User
Thanks! The output from Arduino IDE is:

B4X:
C:\Users\IEUser\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\IEUser\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -pattiny85 -cusbasp -Pusb -Uflash:w:C:\Users\IEUser\AppData\Local\Temp\arduino_build_742586/AttinyBlink.ino.hex:i

If I edit this line to

B4X:
C:\Users\IEUser\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\IEUser\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -pattiny85 -cusbasp -Pusb -Uflash:w:d:\B4R\Source\Test\Objects\bin\src.ino.hex:i

the upload process itself works. No errors.

But the led on my little Attiny85 board doesn't blink. It does when uploaded from Arduino.

Are there some other steps involved?

Also, can the batch file be run automatically from B4R?

This is the test code:
B4X:
Sub Process_Globals
    Public led As Pin
    Public t As Timer
End Sub

Private Sub AppStart
    led.Initialize(1, led.MODE_OUTPUT)
    t.Initialize("tick", 500)
    t.Enabled = True
End Sub

Private Sub tick
    Dim state As Boolean = led.DigitalRead
    led.DigitalWrite(Not(state))
End Sub

C:
void setup() {           
  pinMode(1, OUTPUT); 
}

void loop() {
  digitalWrite(1, HIGH);
  delay(500);
  digitalWrite(1, LOW);
  delay(500);
}
Martin fra Amager
 
Last edited:
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Never tried the Attiny, an Esp8266 cost the same :)
Code looks OK, the only thing could be a translation of pin numbers somewhere.
You could try to minimize the code :) and try different pin numbers.
B4X:
Sub Process_Globals
    Public led As Pin
    Public t As Timer
    Dim state As Boolean = False
End Sub

Private Sub AppStart
    led.Initialize(1, led.MODE_OUTPUT)
    t.Initialize("tick", 500)
    t.Enabled = True
End Sub

Private Sub tick
    state = Not(state)
    led.DigitalWrite(state)
End Sub

Jan
 
Upvote 0

Martin Larsen

Active Member
Licensed User
Longtime User
Never tried the Attiny, an Esp8266 cost the same

I know. But I have a bunch of these Attinys and I have always had a special love of them because they are so - tiny! - and because you take a chip and attach it to a voltage between 2.7 and 5.5 volt and there you go - nothing else is needed. They can be places everywhere because of the small size and by using deep sleep they can run almost forever on a 3.3V battery :)

It's not mandatory for me to get it working with Attiny85. After all, it's just an intermediate state as I am going to upgrade to ESP8266 anyway. But I would love to try the B4R version of my autowater sketch in my current setup with the pump and remote control. If I can make it run on Attiny85, all I have to do is to replace the chip and try it out.

the only thing could be a translation of pin numbers somewhere.

I am also thinking about the pin numbers.
 
Upvote 0

Martin Larsen

Active Member
Licensed User
Longtime User
I am wondering what the board selection actually does. If I with an Arduino attached to COM3 compile and upload the sketch, it uploads fine (to the Arduino). Only the led does not flash because it is attached to pin 13 on the Arduino and not 1 as on my Attiny dev board.

If I on the other hand change the board to Attiny85, still with Arduino attached to COM3, I can submit the dialog. But now the sketch will not compile:

B4X:
In file included from D:\B4R\Source\Test\Objects\src\src.ino:1:0:
B4RDefines.h:11:10: fatal error: Client.h: No such file or directory
#include <Client.h>
          ^~~~~~~~~~
compilation terminated.

This has obviously nothing to do with the programmer, so what is going on? Why is Client.h missing now?

This observation suggests that it is not as simple as uploading the binary manually with avrdude. Something in the compilation also depends on the chip.

EDIT: I think this is what is going on:

B4R doesn't use AttinyCore (C:\Users\IEUser\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.3.3\cores\tiny) but compiles with the full ATmega328 core. That compiles fine but it won't work with Attiny. That's why the led doesn't blink. When I then select Attiny85 (still with Arduino on COM3 so I can submit the dialog) it actually tries to use AttinyCore but that has not Client.h file. And B4RDefines.h tries to load Client.h. Probably, B4R doesn't know how to deal with AttinyCore.

If my assumption is correct, is there anything to do about it? It would be awesome if Attiny could be programmed with B4R.
 
Last edited:
Upvote 0
Top