Author Topic: Convert moteino from 5V to 3.3V and flash issue  (Read 1058 times)

drewpolek

  • NewMember
  • *
  • Posts: 13
Convert moteino from 5V to 3.3V and flash issue
« on: October 18, 2021, 03:30:52 PM »
Hello, I'm new on this forum, so forgive me for any kind of mistakes.

I have strange issue with my Moteino board. I ordered 10 pcs of 5V version. Then I decided to change fuses from external oscillator to internal 8MHz and power it with 3.3V for battery save. Every single device has only additional SPI FLASH memory included. There are no RFM modules.

For flashing optibootloader and fuses I used Visual Studio Code with Platformio extension. There is nothing special, Platformio just makes avrdude calls easier. So I created configuration for 3.3V:
Code: [Select]
[env:moteino8mhz]
platform = atmelavr
board = moteino8mhz
framework = arduino
upload_speed = 57600

[env:moteino8mhz_fuses_usbasp]
platform = atmelavr
board = moteino8mhz
framework = arduino
upload_protocol = usbasp
upload_port = /dev/ttyUSB1
board_fuses.lfuse = 0xD2
board_fuses.hfuse = 0xDC
board_fuses.efuse = 0xFE
board_bootloader.file = bootloader/Dualoptiboot_v5.0_atmega328_8mhz_57600baud_BlinkD9.hex
board_bootloader.lfuse = 0xD2
board_bootloader.hfuse = 0xDC
board_bootloader.efuse = 0xFE

Bootloader was flashed by USBasp (SPI connection) with success. Then I tried to flash simple blink D9 app by FTDI FT232 adapter with 3.3V jumper activated:
- VCC 3.3V(ftdi) -> 3.3V pin (moteino) - I tested also 5V (ftdi) -> Vin (moteino ftdi pins)
- GND (ftdi) -> GND (moteino)
- RX (ftdi) -> TX (moteino)
- TX (ftdi) -> RX (moteino)
- DTR (ftdi) -> DTR (moteino)

Then I got following errors:
Code: [Select]
Processing moteino8mhz (platform: atmelavr; board: moteino8mhz; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/moteino8mhz.html
PLATFORM: Atmel AVR (3.2.0) > LowPowerLab Moteino (8Mhz)
HARDWARE: ATMEGA328P 8MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - tool-avrdude 1.60300.200527 (6.3.0)
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/moteino8mhz/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   2.9% (used 936 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Auto-detected: /dev/ttyUSB1
Uploading .pio/build/moteino8mhz/firmware.hex
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x94
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x80
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x94
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x90
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x94
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x90
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x94
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x90
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x94
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x80

avrdude done.  Thank you.

The wirdest thing is that 6/10 of received modules was flashed successfully. 4 of them failed with above issue.
Then I decided to revert optiboot to original version and try to flash the same firmware with following configuration:
Code: [Select]
[env:moteino]
platform = atmelavr
board = moteino
framework = arduino

[env:moteino_fuses_usbasp]
platform = atmelavr
board = moteino
framework = arduino
upload_protocol = usbasp
upload_port = /dev/ttyUSB1
board_fuses.lfuse = 0xDE
board_fuses.hfuse = 0xDC
board_fuses.efuse = 0xFD
board_bootloader.file = bootloader/DualOptiboot_V5.0_atmega328_BlinkD9.hex
board_bootloader.lfuse = 0xDE
board_bootloader.hfuse = 0xDC
board_bootloader.efuse = 0xFD

And surprisingly it was possible to flash blinking app. When I switched to first (3.3V bootloader and fuses) I had the same issue again.
I tried two different FTDI boards with the same, faulty results. So I guess these 4 Moteino has some on-board issues (maybe soldering issue).

So I have question for more experienced users. What can I check on these 4 boards to fix this issue?

Best regards!

drewpolek

  • NewMember
  • *
  • Posts: 13
Re: Convert moteino from 5V to 3.3V and flash issue
« Reply #1 on: October 18, 2021, 07:42:48 PM »
Finally found solution for that issue.

Unfortunately, flashing via UART requires as less transmit protocol errors as possible. When switching from 16MHz ext. oscillator to 8MHz internal and flashing DualOptiboot for 3.3V with baud 57600 caused transmission errors. Every internal AVR oscillator needs to be calibrated. In my case 4 of received boards has decalibrated value. That caused transfer errors. I build another version of DualOptiboot with baud 38400 and flashing works fine every time.
Code: [Select]
sudo make atmega328 AVR_FREQ=8000000L BAUD_RATE=38400

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Convert moteino from 5V to 3.3V and flash issue
« Reply #2 on: October 19, 2021, 08:50:40 AM »
There is no 5V Moteino :-)
Only:
- Moteino with LDO regulator (runs at 3.3v / 16mhz) and the bootloader baud is 115200
- Moteino-8mhz which has no LDO and runs at 8mhz internal oscillator and is intended for voltages lower than 3.3v, bootloader baud is 57600

drewpolek

  • NewMember
  • *
  • Posts: 13
Re: Convert moteino from 5V to 3.3V and flash issue
« Reply #3 on: October 19, 2021, 04:36:01 PM »
Thanks for the answer :) As far as I remember running 3.3V with 16MHz is not recommended officially :) Btw. you are right, I named it in strange way, so it caused misunderstandings.