Handling fuses in BitBurner

Hi,

first brief intro:

  • working with mikroPascal-IDE AVR ( by mikroe )
  • using ARDUINO 2560 and 328p ( onboard CH340 )
  • in robotic, 3D-cam
  • using XLoader for programming

I'm about to programmstandalone chips AND/OR by ISP.

Got the setup reeady: HEX-file, USBtinyISP, cable and Arduno328p-NANO
Cables is conencted correct, pinnnig is ok.

Now, I'm at the BitBurner programm:

AVRdude:

  • AVR Device: ATMEGA328p(m328p)
  • Programmer: USBtiny simple USB...(usbtiny)

AVR memories:

  • Flash:selected a working HEX-file
  • memory Programmer: flash only

Now here's the AVR-Fuses-section:

What do I need to do, so that I can flash over and over again?
I don't want to lock (or whatever) my chips/boards!

Default it shows:



bb fuses A.jpg

Uploading via ISP erases the bootloader. Are you OK with that?

Tnx for answer.

When bootloader is ereased, can I still use BitBurner and USBtinyISP to put HEX-files into the chip?

Kind regards.

Yes.

Using the same path you can also reinstall the bootloader.

Thanks a lot!

I'm new to this, but this is the only way I can understand it!

Your answer, refers it directly to my question about the fuses?

I mean, when I keep it as:

..it will be ok?

Kind regards!

bb fuses B.jpg

It only erases the bootloader if you erase the flash. Many ISP programs have a checkbox to enable/disable the erase-before-program. Since you have the memory Programmer: flash only option selected I guess there will be no erase.

The low fuses look like default values to me. What does your high and extended fuses look like?

LightuC:
Many ISP programs have a checkbox to enable/disable the erase-before-program.

Excellent. This should be a fun experiment.

I did the experiment and as I said the bootloader does not get erased when programming via isp:
I used the Atmega168P with a 1024 word bootloader (the arduino bootloader). Before programming the bootloader via isp I erased the flash. The bootloader will be placed at word address 0x1C00, which equals byte address 0x3800:

0000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0010 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0020 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0030 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0040 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0050 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0060 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0070 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0080 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 
0090 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 
[...]
3800 0C94341C0C94511C0C94511C0C94511C 
3810 0C94511C0C94511C0C94511C0C94511C 
3820 0C94511C0C94511C0C94511C0C94511C
3830 0C94511C0C94511C0C94511C0C94511C 
3840 0C94511C0C94511C0C94511C0C94511C 
3850 0C94511C0C94511C0C94511C0C94511C
3860 0C94511C0C94511C11241FBECFEFD4E0
3870 DEBFCDBF11E0A0E0B1E0EEEAFFE302C0

Now I uploaded a simple program using the isp programmer with the erase-flash before programming option disabled:

0000 0C9434000C943E000C943E000C943E00 
0010 0C943E000C943E000C943E000C943E00
0020 0C943E000C943E000C943E000C943E00
0030 0C943E000C943E000C943E000C943E00
0040 0C943E000C943E000C943E000C943E00
0050 0C943E000C943E000C943E000C943E00
0060 0C943E000C943E0011241FBECFEFD8E0 
0070 DEBFCDBF0E9440000C9445000C940000
0080 CF93DF93CDB7DEB7FFCFF894FFCFFFFF
0090 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 
[....]
3800 0C94341C0C94511C0C94511C0C94511C
3810 0C94511C0C94511C0C94511C0C94511C
3820 0C94511C0C94511C0C94511C0C94511C 
3830 0C94511C0C94511C0C94511C0C94511C
3840 0C94511C0C94511C0C94511C0C94511C
3850 0C94511C0C94511C0C94511C0C94511C
3860 0C94511C0C94511C11241FBECFEFD4E0
3870 DEBFCDBF11E0A0E0B1E0EEEAFFE302C0

As you can see, by unchecking the option to erase the flash before programming only the part of flash memory that the new program will occupy is changed.

LightuC:
As you can see, by unchecking the option to erase the flash before programming only the part of flash memory that the new program will occupy is changed.

You missed a step (and a critical concept).

But, it doesn't matter. I suspect @BlueCobalt will figure it out. If they don't, they can always ask for help.

Ohhh, I didn't get that he wanted to burn a new bootloader, I'm sorry. But standalone atmegas don't have a bootloader anyways, do they?

Hi, meanwhile found some info about the fuses extendend, low high).

And found this in BitBurner, inlcuding LOCKBIT.

LightuC:
Ohhh, I didn't get that he wanted to burn a new bootloader, I'm sorry. But standalone atmegas don't have a bootloader anyways, do they?

I found that too, when was seraching for info.
Proberly, I have to write a bootloader to the NANO.
( normaly my NANO is programmed by USB via ch340 onboard )

But ok, I got at the point that I placed arguments -F -D in BitBurner, this results in:

AVRdude -U "lfuse:w:0x20:m" -U "hfuse:w:0x5F:m" -U "efuse:w:0xFF:m" -U "lock:w:0xFF:m" -s -c usbtiny -p m328p -F -D

avrdude.exe: initialization failed, rc=-1
avrdude.exe: AVR device initialized and ready to accept instructions
avrdude.exe: Device signature = 0x000000
avrdude.exe: Yikes! Invalid device signature.
avrdude.exe: Expected signature for ATMEGA328P is 1E 95 0F

avrdude.exe done. Thank you.

Did some googling first but I don't get it...

What's the best way to move on?

Thanks in advance! This kinda things are very hard for me to learn, thank you all for pacience!!!

OffTopic: Coding itself goes smooth! For those interested, some projects:

Learning Lazarus-RS232-Arduino:

My RobotArm:

3D-cam:

For more, just check my complete youtube channel.

The NANO powered by USB.

The jumper removed fromUSBtinyISP.

BlueCobalt:
But ok, I got at the point that I placed arguments -F ...

Do not use -F (force). It serves one useful purpose that you are extremely unlikely to ever encounter and it makes troubleshooting more difficult.

BlueCobalt:
But ok, I got at the point that I placed arguments -D ...

Do not use -D (disable erase). Flash memory has to be erased before it can be programmed. -D serves a specific purpose that you are unlikely to ever encounter.

BlueCobalt:
What's the best way to move on?

Remove -F and -D. Add -v -v -v (very verbose output). Post the output.

Post your fuse settings.

Hi.

More happening now!

AVR: ATMEGA328p(m328p)
Prog.: USBtiny.../(usbtiny)
Arguments: -v -v -v

Flash: "a functioning HEX-file"

Results in:

Executing AVRdude..
avrdude.exe: Version 5.11.1, compiled on Oct 1 2012 at 13:18:15
** Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/**
** Copyright (c) 2007-2009 Joerg Wunsch**
** System wide configuration file is "C:\Program Files (x86)\BitSuite Productions\BitBurner AVR Programmer\avrdude.conf"**
** Using Port : lpt1**
** Using Programmer : usbtiny**
** AVR Part : ATMEGA328P**
** Chip Erase delay : 9000 us**
** PAGEL : PD7**
** BS2 : PC2**
** RESET disposition : dedicated**
** RETRY pulse : SCK**
** serial program mode : yes**
** parallel program mode : yes**
** Timeout : 200**
** StabDelay : 100**
** CmdexeDelay : 25**
** SyncLoops : 32**
** ByteDelay : 0**
** PollIndex : 3**
** PollValue : 0x53**
** Memory Detail :**
** Block Poll Page Polled**
** Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack**
** ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------**
** eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff**
** Block Poll Page Polled**
** Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack**
** ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------**
** flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff**
** Block Poll Page Polled**
** Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack**
** ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------**
** lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00**
** Block Poll Page Polled**
** Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack**
** ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------**
** hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00**
** Block Poll Page Polled**
** Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack**
** ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------**
** efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00**
** Block Poll Page Polled**
** Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack**
** ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------**
** lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00**
** Block Poll Page Polled**
** Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack**
** ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------**
** calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00**
** Block Poll Page Polled**
** Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack**
** ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------**
** signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00**
** Programmer Type : USBtiny**
** Description : USBtiny simple USB programmer, USBtinyISP - Inexpensive USB AVR Programmer**
avrdude.exe: programmer operation not supported
avrdude.exe: Using SCK period of 10 usec
CMD: [ac 53 00 00] [00 00 00 00]
CMD: [ac 53 00 00] [00 00 00 00]
avrdude.exe: initialization failed, rc=-1
** Double check connections and try again, or use -F to override**
** this check.**
avrdude.exe done. Thank you.

Before posting here, I played around with some fuses, gave same 'failed'.

Posted later:
!!! just noticed the LPT. had set it to USB before...1 moment...

Still the same.
( NANO is ok, flashed with XLoader over the USB/ch340 as quick test)

Have you...

BlueCobalt:
Double check connections and try again

Have you disabled auto-reset on the board you are using as a programmer? (I believe that is your NANO.)

OK!

Watched a video about USBtinyISp to NANO: problems with the NANO, the UNO went ok.

So, I replaced the NANO for my UNO...et voila!
First time succeful!

( tested with working code, and before each time writing, I chanegd the code a bit to see it on
outputpins to oscilloscope )

Multiple times ok!

Removed -v -v -v, ok!

Removed UNO and connected NANO: fail...
Second NANO failed, too.

For the moment:
First, gonna experiment to see what the effect is of the its in low,high extended byte.
( e.g. CKDIV and SUC_CKSEL '; what will happen to my code? timing is now ok, a 10Hz square wave )

Later contineuing NANO and more important: DIY pcb with 328p (SMD) on it and ISP.
Project 3D-cam! protoype allready functioning.

This is the prototype with lots of extra connectors for testing etc etc .
Version 2.0 will be with the nesessary funtional connectors, including ISP.
And wil be completely in small SMD-parts, easely to fit in 'matchbox-size!