Try omitting '-mno-tablejump' from the build.sh file.
So I omitted that part, and when i tried to bootload it did not work properly. I then remembered I commented out your naked main function and so I UNCOMMENTED it and then recompiled and bootloaded and it bootloaded successfully and was able to boot. However, the same error blink occured when i tried to program. Not sure what the problem could be anymore. I even tried to change everything to the internal 8mhz clock and again it successfully boots but cannot actually be reprogrammed.
I was thinking it might help to run the bootloader in the arduino definition and when i changed the chAudioboot.c file to change the definition and then tried to build the project again this is the error I got.
~/Desktop/AudioBoot $ ./build.sh
chAudioBoot.c: In function 'setup':
chAudioBoot.c:98:4: warning: implicit declaration of function 'pinMode' [-Wimplicit-function-declaration]
chAudioBoot.c:98:20: error: 'OUTPUT' undeclared (first use in this function)
chAudioBoot.c:98:20: note: each undeclared identifier is reported only once for each function it appears in
chAudioBoot.c:99:4: error: 'Serial' undeclared (first use in this function)
chAudioBoot.c: In function 'loop':
chAudioBoot.c:104:4: warning: implicit declaration of function 'a_main' [-Wimplicit-function-declaration]
chAudioBoot.c: At top level:
chAudioBoot.c:127:6: warning: conflicting types for 'a_main' [enabled by default]
chAudioBoot.c:104:4: note: previous implicit declaration of 'a_main' was here
chAudioBoot.c:299:1: error: unknown type name 'uint8_t'
chAudioBoot.c:312:1: error: unknown type name 'uint8_t'
chAudioBoot.c: In function 'receiveFrame':
chAudioBoot.c:314:3: error: unknown type name 'uint16_t'
chAudioBoot.c:316:3: error: unknown type name 'uint16_t'
chAudioBoot.c:317:3: error: unknown type name 'uint16_t'
chAudioBoot.c:318:3: error: unknown type name 'uint16_t'
chAudioBoot.c:319:3: error: unknown type name 'uint8_t'
chAudioBoot.c:320:3: error: unknown type name 'uint8_t'
chAudioBoot.c:321:3: error: unknown type name 'uint8_t'
chAudioBoot.c:322:3: error: unknown type name 'uint16_t'
chAudioBoot.c:327:5: error: 'PINB' undeclared (first use in this function)
chAudioBoot.c:327:5: error: 'PB4' undeclared (first use in this function)
chAudioBoot.c:332:3: error: 'TCNT2' undeclared (first use in this function)
chAudioBoot.c:390:5: error: unknown type name 'uint16_t'
chAudioBoot.c:390:19: error: 'uint16_t' undeclared (first use in this function)
chAudioBoot.c:390:28: error: expected ',' or ';' before 'FrameData'
chAudioBoot.c:396:5: error: 'Serial' undeclared (first use in this function)
chAudioBoot.c:407:31: error: 'HEX' undeclared (first use in this function)
chAudioBoot.c:425:26: error: 'true' undeclared (first use in this function)
chAudioBoot.c:426:15: error: 'false' undeclared (first use in this function)
chAudioBoot.c: At top level:
chAudioBoot.c:437:25: error: unknown type name 'uint32_t'
chAudioBoot.c:437:40: error: unknown type name 'uint8_t'
chAudioBoot.c: In function 'runProgramm':
chAudioBoot.c:477:2: error: 'DDRB' undeclared (first use in this function)
chAudioBoot.c:478:2: error: 'DDRC' undeclared (first use in this function)
chAudioBoot.c:479:2: error: 'DDRD' undeclared (first use in this function)
chAudioBoot.c:480:2: warning: implicit declaration of function 'cli' [-Wimplicit-function-declaration]
chAudioBoot.c: In function 'a_main':
chAudioBoot.c:505:3: error: 'Serial' undeclared (first use in this function)
chAudioBoot.c:508:3: error: unknown type name 'uint8_t'
chAudioBoot.c:510:3: error: unknown type name 'uint16_t'
chAudioBoot.c:511:3: error: unknown type name 'uint8_t'
chAudioBoot.c:514:3: error: unknown type name 'uint8_t'
chAudioBoot.c:518:8: error: 'TCNT2' undeclared (first use in this function)
chAudioBoot.c:524:10: warning: implicit declaration of function 'digitalWrite' [-Wimplicit-function-declaration]
chAudioBoot.c:524:10: warning: implicit declaration of function 'digitalRead' [-Wimplicit-function-declaration]
chAudioBoot.c:535:12: error: 'LOW' undeclared (first use in this function)
chAudioBoot.c:541:11: error: 'PINB' undeclared (first use in this function)
chAudioBoot.c:541:11: error: 'PB4' undeclared (first use in this function)
chAudioBoot.c:550:3: error: 'HIGH' undeclared (first use in this function)
rm: audioboot.hex: No such file or directory
avr-objcopy: 'audioboot.elf': No such file
avr-objdump: 'audioboot.hex': No such file
avr-objdump: section '.sec1' mentioned in a -j option, but not found in any input file
It looks like in "Arduino" mode you are expected to compile it inside the IDE, that gives you access to the data types, Serial stuff and so on.
I copied and pasted the original loader into the IDE, changed 3 lines, and it compiled:
#define ARDUINO_PLATFORM // ( with Atmega168 ) bootloader development on arduino plattform // uncommented it
...
#define LEDPORT (1<<DDB5); // was PB5
...
#define INPUTAUDIOPIN (1<<PORTD1) // was PD1
Ive was able to successfully add the arduino verison of the bootloader and same problem of not being able to program it after bootloading. I think we have hit a wall and Im not sure if its worth my time anymore to continue this unless someone else can do some testing. I wish I knew more about bootloaders so I could write my own. I really like the idea of an audio based bootloader since it would be especially attractive in a commerical product and overall is easier to implement 1 wire rather than 6 for ICSP.
Do you know of any other neat bootloaders? I am trying to make my project easier to program than using ICSP, hoping to bring it down to 2 datawires.
The standard bootloader only uses 3 wires: Tx, Rx, Gnd. So when you say 1 wire you mean 2 wires (as you acknowledge).
I'm not sure you are saving a heap by going down this path.
In a commercial product reliability would count for something, and having 1-wire (plus Gnd) means you don't get any acknowledgement so you don't know for sure if you changed the program.
But serial uploading requires a FTDI chip right? Thats like an extra 4 bucks added to my project cost. Im assuming you cannot program through software serial?
Ive was able to successfully add the arduino verison of the bootloader
As mentioned before: If you compile the software with "ARDUINO_PLATFORM" enabled, you will not get a bootloader. This option is meant to compile a debugging platform to check the correct data transmission. If you take a look at the source code, you will understand.
Chris, is there anyway you could please recompile a functional bootloader for the atmega328p chip? Ive been trying for multiple days so far and although i can get it to boot up, I cannot get it to program successfully. I am not sure what the issue is anymore.
Thank you!
sdinnu:
But serial uploading requires a FTDI chip right? Thats like an extra 4 bucks added to my project cost. Im assuming you cannot program through software serial?
You only need an FTDI cable (which you share between multiple targets). You don't need one per board. You could conceivably program through software serial, but what does that save? You still need the FTDI interface.
Doesn't the audio interface add cost anyway?
How often are you planning to reprogram? Just using the ICSP interface (6 wires or not) is the simplest anyway.
yea the main thing that I was hoping to solve by using the audio setup vs serial or icsp is that end users would not require any extra hardware and reprogramming would be extremely simplified since they would not even have to use the arduino IDE or anything since one could simple send out the audio file and people could update their devices. ICSP requires either an arduino as ISP or some external programmer which is added cost. And ftdi, although integrates the hardware in to the final product, still requires someone to use the IDE/avrdude to reprogram the device. Overall, although insigificant for someone experienced, for the nontechy these methods of reprogramming are bit more confusing.
But you are correct in that the devices will not be programmed that often. I mainly want to keep the option open just in case there is a patch that needs to be deployed or updates to code over time.
Also, can you trim the reset button off of the ICSP and just require a manual reset press? This would allow one to wire the ICP pins into say a microusb port which would be alot nicer than the current interface.
You could trim off the power, since presumably the device is internally powered anyway. (Of course the progammer would then need its own power, eg. a battery).
end users would not require any extra hardware ...
Apart from an audio player and some wires? And an interface circuit?
You could make a dedicated ICSP programmer (eg. in a small box with a battery). Load the new code into it in program memory (like my bootloader programmer described here), tell the user to shove in the wire you described, and hit the "program" button, and wait until an LED changes colour (a second later).
The programmer itself would only need to be an Atmega328 (or similar) chip, a couple of capacitors, a resonator, a couple of resistors and LEDs, the box and a switch. Should be able to make it for $20. And you could have a similar socket in the programmer for reprogramming it (with the new firmware).
I'm pretty sure there are commercial devices that do just that, I remember CrossRoads was talking about getting one.
i actually need the power and ground since it will be used to charge my device, so i only have 3 pins left on a microusb which would be used for miso, mosi, and sck. but that means reset would have to be left out. would that not work properly?
An ICSP programmer needs to hold reset low during programming. If you only have 3 pins over better use a normal (serial) bootloader. You will need Rx, Tx, Reset, plus power and Gnd.
yea that makes sense, so either inside my project or outside my project there would have to be some usb->ftdi->ttl converter to be able to do the serial communication that the arduino IDE requires correct?
Aren't we talking about a potential use-case where the user could reprogram it by playing a wav file on their iOS/Android/laptop and an off-the-shelf 3.5mm patch plug?
I could see the attractiveness of that in certain situations!
Or maybe I'm missing a "fatal-flaw" here?
John
yea thats the use case i was thinking. adding the audio circuitry to the final product (not really much since its pretty simple) and then anyone could program it using like a website that plays the audio track. much simpler than using the arduino IDE or some programmer for those people that arent techy's. the only flaw i can see is like Nick mentioned, there is no feedback to ensure the program installed successfully so that could be problematic
I would think that the converter software could test for and reject bad CRC's with an audio return code... with out a great deal of problem but I think only if it was really required to share or more important update user software without the user being able or required to be technically inclined.
Bob
sdinnu:
yea that makes sense, so either inside my project or outside my project there would have to be some usb->ftdi->ttl converter to be able to do the serial communication that the arduino IDE requires correct?
It depends how you are planning to reprogram. If you are going to distribute a "box with firmware upgrade" on it, that would be TTL to TTL, so you wouldn't require that. If you are going to use the existing bootloader and use, say, a laptop, then you would need a FTDI cable, and some adapter to convert it to the mini-USB plug you are planning on.
johncc wrote:
Aren't we talking about a potential use-case where the user could reprogram it by playing a wav file on their iOS/Android/laptop and an off-the-shelf 3.5mm patch plug?
like you mentioned, this guy used the audio bootloader:
http://tadpol.org/projects/AvrianJump.html
sdinnu wrote:
Chris, is there anyway you could please recompile a functional bootloader for the atmega328p chip?
At the moment I have not so much time and I programmed the bootloader almost a year ago, so I forgott many things.
Couldn't you use for the "first shot" an Atmega168 to see if the bootloader fits your needs?
-
If my project has a reset button can the user hold the reset button low while programming or does it have to be done through the ICP programmer?
-
I'm not a 100% sure how ftdi works but im assuming it takes signals from usb and then bit bangs it as a serial connection. Would it be possible to skip this chip and somehow bitbang serial through an audio port.. kinda like this guy? http://robots-everywhere.com/re_wiki/index.php?title=Serial_on_Android_using_the_audio_port