Atmega8A - Internal 8MHZ oscillator minicore bootloader Error not in sync

I have an ATMega8A with Minicore bootloader installed. it is 8MHZ internal. i can program the chip using UNO board and Arduino 2.2.1 IDE.
i am trying with VSCode / platformIO with below ini file:
[env:atmega8minicore8mhzinternal]
platform = atmelavr
framework = arduino
board = ATmega8
board_build.f_cpu = 8000000L
upload_protocol = arduino
board_upload.speed = 38400

but getting error as programmer not in sync.
Following is my verbose output. tried upload speed 9600, 19200, 57600 etc

Executing task in folder test: C:\Users\Toshiba.platformio\penv\Scripts\platformio.exe run --verbose --target upload --environment atmega8minicore8mhzinternal

Processing atmega8minicore8mhzinternal (platform: atmelavr; framework: arduino; board: ATmega8; board_build.f_cpu: 8000000L; upload_protocol: arduino; board_upload.speed: 38400; upload_flags: -e)
------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: …
PLATFORM: Atmel AVR (4.1.0) > ATmega8/A
HARDWARE: ATMEGA8 8MHz, 1KB RAM, 8KB Flash
DEBUG: Current (simavr) External (simavr)
PACKAGES:

  • framework-arduino-avr-minicore @ 2.2.1
  • tool-avrdude @ 1.70100.0 (7.1.0)
  • toolchain-atmelavr @ 1.70300.191015 (7.3.0)
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 8 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode

MethodWrapper([“checkprogsize”], [“.pio\build\atmega8minicore8mhzinternal\firmware.elf”])
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 0.9% (used 9 bytes from 1024 bytes)
Flash: [ ] 3.7% (used 284 bytes from 7680 bytes)
.pio\build\atmega8minicore8mhzinternal\firmware.elf :

section size addr
.text 284 0
.data 0 8388704
.bss 9 8388704
.comment 17 0
.note.gnu.avr.deviceinfo 60 0
.debug_aranges 64 0
.debug_info 1538 0
.debug_abbrev 1142 0
.debug_line 258 0
.debug_str 378 0
Total 3750
avr-objcopy -O ihex -R .eeprom .pio\build\atmega8minicore8mhzinternal\firmware.elf .pio\build\atmega8minicore8mhzinternal\firmware.hex
([“upload”], [“.pio\build\atmega8minicore8mhzinternal\firmware.hex”])
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
BeforeUpload([“upload”], [“.pio\build\atmega8minicore8mhzinternal\firmware.hex”])
Auto-detected: COM6
avrdude -e -v -p atmega8 -C C:\Users\Toshiba.platformio\packages\tool-avrdude\avrdude.conf -c arduino -b 38400 -D -P COM6 -U flash:w:.pio\build\atmega8minicore8mhzinternal\firmware.hex:i

avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

     System wide configuration file is {link not allowed}

     Using Port                    : COM6
     Using Programmer              : arduino
     Overriding Baud Rate          : 38400

avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 1 of 10: not in sync: resp=0x00

Since i can program the same chip using Arduino IDE, looks loke some ini is missing in PlatformIO. pl help…

No one can help? i tried every possible ini values, getting no where!! issue is on PlatformIO only as Arduino IDE works like a charm.

I have a very similar problem. I killed an Arduino Pro Mini with ATmega328P chip (i.e. the original) which got replaced with ATmega328PB chip. I was able to get blink working there via ArduinoIDE and MiniCore, but I’m totally lost how to get it working with PlatformIO. Although MiniCore states that it supports PlatformIO (link to MiniCore).

I would also be super grateful for any hints/pointers.

i couldn’t make it work as no one has idea on this issue. platformIO not able to communicate in 8MHZ internal so i switched to 16MHZ external cystal with minicore and completed the project. even Arduino IDE has issue sometime upload the image. But when i used lilypad 8 mhz both platformIo and Arduino IDE uploaded flawlwesly. you can try using lillypad 8Mhz internal bootloader. try Gammon Forum : Electronics : Microprocessors : How to make an Arduino-compatible minimal board as this worked earlier for my project with lilypad, only issue was, the bootloader is larger than Minicore

Thanks for the reply @sekar1959!
I was finally to program my ATmega328PB with PlatformIO. I’ll write the steps, maybe it will help someone.
First I needed to write bootloader on the chip. It was my first time to come across a chip without bootloader. It was quite simple to do with another Arduino board (also Pro Mini) and Arduino IDE.
Then I realized why my PlatformIO configuration wasn’t working - my Atmel AVR library was slightly outdated. Now at least upload_protocol = urclock didn’t cause complaints.
And finally I understood that there are still some configuration values need adjusting, but I don’t know the values. So I turned Arduino IDE compile/upload to verbose mode and this gave me the values that I needed to tweak in PlatformIO ini file.
Success! :slight_smile:

further reserching on this, found the cause is UART needs stable frequency. the internal oscilator accuracy is ±10% but can be brought down to ±2% using this application note

and the internal osc is very much supply voltage and temparature dependent!
Clipboard-1
i am using li-Ion battry so the frequency varies with supply votage so UART dosnt sync. Earlier in my old project i used 5V regulated supply hence there was not much issue.
so conculsion is either recalibrate the osc for your working voltage or keep the device at 25degC with 5V regulated supply.
FUrther ATMEGA8 and ATMEGA328 having completly different calibrated value load at at starting. for ATMEGA8, During Reset, the 1MHz value is automatically loaded into the OSCCAL Register. If other frequencies are used, the calibration value has to be loaded manually.
For ATMEGA328 it is 8Mhz calibration is used