Pages: 1 2 3 [4] 5 6 7   Go Down
Author Topic: Dumping firmware/software...and/or reflashing??  (Read 24538 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You guys are geniuses ha.

Sorry if I haven't contributed much (anything) this project Mike. You clearly have a greater understanding of all this, but I will certainly be learning.

Quote
Helpful tip: It is possible to download a binary version of the program from the Paintball gun.  You may want to do this early in your project so you have a backup.

Great news about the processor.  That will make your development effort go much more smoothly.

How would you go about doing this and how would you end up using it in the long run?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...It is possible to download a binary version of the program from the Paintball gun...

I tried to read the flash from the device to backup the program, however the data that came out (no errors reported) was essentially blank.  I did notice that there's a lock bit set "PROG_VER_DISABLED", but I have no idea what that means.  I can't seem to find a definition of these lock bits anywhere.  I'm guessing this is why I cannot backup the chip?

I really don't want to lose the original program, so I make have to solder the chip off the board (smiley-eek).  Once my new program is working I won't need to solder anymore boards, but until I know I have a working program, I need to keep the original safe.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I found a description of the lock bit in the Atmel datasheet:

Quote
Further programming and verification of the Flash and EEPROM
is disabled in High-voltage and Serial Programming mode. The
Fuse bits are locked in both Serial and High-voltage
Programming mode.(1) debugWire is disabled.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well...I've bit the bullet so to speak.  I've desoldered the original chip and soldered it to an SOIC-to-DIP adapter, and soldered a shiny new ATtiny44 to the phenom board.  I've also built a test bed around the original chip with LED's and resistors and have correctly identified the trigger (actually uses 2 pins), solenoid, red LED, green LED, and push button.

I would also like to figure out how to use debugWire so I would only have to worry about 3 pins (Vcc, GND, debugWire) rather than the regular 6 (Vcc, GND, RESET, SCK, MISO, MOSI).  I know I have to set a fuse to use it, but I'm not sure what else may be involved (if it will work with my Atmel mkII).

At this point, it's only a matter of writing the appropriate software to drive the new chip in the phenom board.


* DSC_9687.JPG (232.42 KB, 1277x855 - viewed 34 times.)

* DSC_9689.JPG (198.08 KB, 1277x855 - viewed 36 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mike, has anyone told you that you're amazing??? If not, you're amazing haha. What is your "test bed" currently doing? And how did you got about confirming the trigger uses two pins?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

lol...thanks, though I wouldn't have anything if it weren't for the excellent assistence from Coding Badly.

Here's a quick video of my test bed.  Check it out:

http://youtu.be/5TNArp6eyUc
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the red LED maybe have anything to do with the programming mode (setting denounce time and other features??)

I agree, coding badly has been extremely valuable in this project. If I could I'd by him a drink (if he drinks....otherwise a root beer ....I personally would take ge root beer ha)

Great video demonstration btw.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 205
Posts: 12840
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried to read the flash from the device to backup the program, however the data that came out (no errors reported) was essentially blank.  I did notice that there's a lock bit set "PROG_VER_DISABLED", but I have no idea what that means.  I can't seem to find a definition of these lock bits anywhere.  I'm guessing this is why I cannot backup the chip?

Oh bugger!  I completely forgot about the lock-bits.  You will not be able to make a backup.  Sorry about that. 
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 205
Posts: 12840
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would also like to figure out how to use debugWire so I would only have to worry about 3 pins (Vcc, GND, debugWire) rather than the regular 6 (Vcc, GND, RESET, SCK, MISO, MOSI).  I know I have to set a fuse to use it, but I'm not sure what else may be involved (if it will work with my Atmel mkII).

Like TPI this is not the best place for debugWire help.  In my case, I have no idea how to get debugWire working.

The core I mentioned in Reply #36 includes Tiny Debug Serial.  It's similar to Serial available on a normal Arduino.  I also have something better (but still similar to Serial) available.  If you're interested send me a Personal Message with your email address.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 205
Posts: 12840
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
lol...thanks, though I wouldn't have anything if it weren't for the excellent assistence from Coding Badly. ... I agree, coding badly has been extremely valuable in this project. If I could I'd by him a drink (if he drinks....otherwise a root beer ....I personally would take ge root beer ha)

My pleasure.  And, yes, I do occasionally enjoy a beer.  However, I will never ever refuse a...

https://www.google.com/search?q=dr+pepper+cane+sugar&tbm=shop

Don't let anyone try to fool you.  With cane sugar is the only way to make Dr. Pepper!
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 205
Posts: 12840
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


In case I did not mention it earlier: The ATtiny84 is a drop-in replacement for the ATtiny44 with double the memory.  If your new trigger code won't fit you can easily upgrade to a "bigger" processor.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Muhahahahaha!!  smiley-twist

My first version of my new code deployed on the new Attiny44 on the Phenom Board:

http://youtu.be/nh0e4etHXp8

Next, I think I'm going to work on creating a menu system so you can change the firing mode without reprogramming.  At the moment, I've created full auto and three round burst.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

again, you're incredible lol.

Can I see the code you have so far?

Still plan on sharing this with the world and not shutting me out when its done? smiley-wink

As well what are the things I'll need when I am able to program this on my own?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Still plan on sharing this with the world and not shutting me out when its done? smiley-wink

No, now I have it and it's mine!  smiley-twist  j/k

Of course!  At the moment things are a mess, but you're more than welcome to have a look.  I'm programming in the Atmel AVR studio, but things should transfer easily to Arduino if you choose.  I'll paste the code at the end of this post.

...what are the things I'll need when I am able to program this on my own?

You will need an ISP, software that works with the ISP, some jumper wire, code (and/or binary file from me), and really steady hands.  I bought an AVRISP mkII because I was concerned that I wouldn't get another ISP to work.  On hand, I had a cheap USBasp ISP and an Arduino.  I was able to get both the Arduino and the mkII to work.  No luck with the generic USBasp.

I'll post better instructions once I build a proper forum for it.  Perhaps I'll start a blog on it.

Code:
#include <avr/io.h>
#define F_CPU 8000000UL
#include <util/delay.h>

#define HIGH 1
#define LOW 0

int BALLS_PER_SECOND;
int ROUND_DELAY; // delay between shots in ms
int DEBOUNCE;  // Debounce in ms

void initialize() {
BALLS_PER_SECOND = 30;
DEBOUNCE = 8;
ROUND_DELAY = (1000 - DEBOUNCE) / BALLS_PER_SECOND;
}

void delay_ms( int ms ){
for (int i = 0; i < ms; i++) {
_delay_ms(1);
}
}

int getPinMask(int pinNumber) {
if (pinNumber == 2) {
return (1 << 0);
} else if (pinNumber == 3) {
return (1 << 1);
} else if (pinNumber == 4) {
return (1 << 3);
} else if (pinNumber == 5) {
return (1 << 2);
} else if (pinNumber == 6) {
return (1 << 7);
} else if (pinNumber == 7) {
return (1 << 6);
} else if (pinNumber == 8) {
return (1 << 5);
} else if (pinNumber == 9) {
return (1 << 4);
} else if (pinNumber == 10) {
return (1 << 3);
} else if (pinNumber == 11) {
return (1 << 2);
} else if (pinNumber == 12) {
return (1 << 1);
} else if (pinNumber == 13) {
return (1 << 0);
}

return 0;
}

void setInputPin(int pinNumber) {
if (pinNumber >= 2 && pinNumber <= 5) {
DDRB &= ~(getPinMask(pinNumber));
} else if (pinNumber >=6 && pinNumber <= 13) {
DDRA &= ~(getPinMask(pinNumber));
}
}

void setOutputPin(int pinNumber) {
if (pinNumber >= 2 && pinNumber <= 5) {
DDRB |= (getPinMask(pinNumber));
} else if (pinNumber >= 6 && pinNumber <= 13) {
DDRA |= (getPinMask(pinNumber));
}
}

void pinOutput(int pinNumber, int state) {
if (pinNumber >= 2 && pinNumber <= 5) {
if (state == HIGH) {
PORTB |= (getPinMask(pinNumber));
} else {
PORTB &= ~(getPinMask(pinNumber));
}
} else if (pinNumber >= 6 && pinNumber <= 13) {
if (state == HIGH) {
PORTA |= (getPinMask(pinNumber));
} else {
PORTA &= ~(getPinMask(pinNumber));
}
}
}

int pinHasInput(int pinNumber) {
if (pinNumber >= 2 && pinNumber <= 5) {
return (PINB & (getPinMask(pinNumber))) <= 0;
} else if (pinNumber >= 6 && pinNumber <= 13) {
return (PINA & (getPinMask(pinNumber))) <= 0;
} else {
return 0;
}
}

void threeRoundBurst() {
for (int i = 0; i < 3; i++) {
pinOutput(6, HIGH);
delay_ms(DEBOUNCE);
pinOutput(6, LOW);

// don't delay on the last round
if (i < 2) {
delay_ms(ROUND_DELAY);
}
}
}

void fullAuto() {
while (pinHasInput(7)) {
pinOutput(6, HIGH);
delay_ms(DEBOUNCE);
pinOutput(6, LOW);
delay_ms(ROUND_DELAY);
}
}

int main (void) {

initialize();

setOutputPin(12);
setOutputPin(11);
setInputPin(7);
setInputPin(5);
setOutputPin(6);
setInputPin(3);

////////////////////////////////////
// Enable pull up on trigger inputs
////////////////////////////////////

// Trigger
pinOutput(5, HIGH);
pinOutput(7, HIGH);

pinOutput(3, HIGH);
pinOutput(13, HIGH);
pinOutput(10, HIGH);
pinOutput(9, LOW);
pinOutput(8, LOW);
pinOutput(12, LOW);

// turn on green LED
pinOutput(11, HIGH);

while(1) {
if (!pinHasInput(7)) {

delay_ms(DEBOUNCE);
while (!pinHasInput(7)) {
// NOOP
}

// Fire!
//threeRoundBurst();
fullAuto();
}
}
return 1;
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok...The code is a mess (it's been a long time since I've coded in C), but it seems to work.  I want to add one more firing mode, but for now the code supports full-auto, three round burst, and auto-response.  To enter configuration mode, turn off the board, hold the trigger, power on the board and release the trigger after 2 seconds.  The rest of the configuration is very similar to the Tippmann manual.  I'm not allowing Debounce and Dwell to be changed at the moment.

My next task is to setup a blog or other site so I can post some instructions on how to program your own chip.  I'm not sure which programmer you may have, but I'm going to need your help with figuring that part out.  I know I can program the chip with the Atmel AVRISP mkII, but I'd like to find a solution using either the Arduino or another programmer (USBasp) for a lower cost solution.

I've included the latest code and hex dump.

* ATtiny44Phenom.hex (11.26 KB - downloaded 7 times.)
* Phenom.zip (42.44 KB - downloaded 7 times.)
Logged

Pages: 1 2 3 [4] 5 6 7   Go Up
Jump to: