-
Notifications
You must be signed in to change notification settings - Fork 221
Flashing Firmware
Before you get started, ask yourself, do I want version 1 or version 2 of OpenLog firmware?
Version 1:
- Is currently the most stable
- Works with cards up to 2GB
- Works only with FAT16
- Doesn’t drop characters at 57600
- Requires these instructions and steps to update the firmware
Version 2:
- Known to be buggy
- Works with cards up to 8GB
- Works automagically with SD, SDHC, FAT16 and FAT32
- Drops characters at 57600
- Easy to update firmware through Arduino, loading as a sketch
- The Arduino IDE makes it much easier for folks to make changes
The following instructions are for loading v1.61 of the firmware (the latest version) onto an OpenLog. If you want to try out version 2 of OpenLog, download all the OpenLog_v2 files and use the Arduino IDE to bootload the new code onto OpenLog.
Once you get setup to flash OpenLog, it’s so easy and quick, you’ll be developing faster than ever before. But it does take some work up front.
Most general way:
Make a correct connection between the PC and the openLog: Get a MAX232, and connect it to the openlog, find a PC with RS232 port, either an old desktop PC or use some USB to Serial adapter. Link the RX, TX and GND of these components toghether following the pinout indicated by the datasheets (pay attention the the cables and on-the-fly cabling).
Once you get this setupped, take “putty” (or any other simple terminal program, putty is without install) and look for the real/emulated serial port at which COMx happened to be allocated, set the speed at 9600bps (defauld one) and make the connection. Hit some times ctrl+z (depending on the firmware 1 or 3 should be enough) at some time you should get “>” which is the prompt; press “?” plus enter and you should get the menù.
Now, to flash the new firmware, put in the same directory the file avrdude.conf, avrdude.exe, libusb0.dll and main.hex (you can find them downhere in the page). Open a command prompt and cd-your way to this folder. Write on the command line (cut and paste) this line:
avrdude.exe -p atmega328p -P COM1 -c stk500v1 -b 57600 -Cavrdude.conf -U flash:w:main.hex
but DO NOT press enter.
Now, be sure the openLog is connected the the pc via the setup done before and ower it down, now you have a window of 500ms (an eternity in computers) where you have to 1)power up the openLog 2)hit enter at the command prompt to issue the reflash command.
If the timing is right, the flashing process is started and you should read some fancy words and some “###” running inside the command line window.Good! after to process is terminated (no more than 30 seconds) you can power cicle the unit and reconnect via terminal program, and check with the “?” command the new version.
If your timing was not right, simply, powerdown the unit, reload the command on the command line and repeat the procedure until you succeed. I’m not assuring, but it’s really higly unlikely that you can damage the unit while you try to reflash.
STK500 Bootloading method
This comes from the SparkFun tutorial on STK500 bootloading under the Serial bootloading an Arduino board section.
I’m sorry, I use Windows, so much of this will be oriented for WinAVR, Programmer’s Notepad, and avrdude compiled for Arduino 0017 for Windows.
Things you will need:
- OpenLog
- Serial connection – we recommend the FTDI Basic as it is the easiest to hook up over USB
- Power – pull power from an Arduino or from a Breadboard with Power Supply
- Wires – Strip some wire and jam it into the breadboard
The steps to upload new firmware to OpenLog:
- Download avrdude.exe, avrdude.conf, libusb0.dll and the latest firmware HEX (right click and save-as) from the Downloads page. Stick these files into an easy to navigate directory like C:\openlog.
- Wire up the serial connection. Remember TX from the FTDI Basic goes to the RX pin on OpenLog. Read more in the datasheet.
- Attach the contraption to your computer over USB and turn on the power. You will need to check the Device Manager to find out which one it is on. Remember this COM port number. (Grr, this needs a tutorial)
- Now open up a terminal on that COM port with the correct baud rate – the default for OpenLog is 9600bps. I use hyperterminal in Windows XP but Vista doesn’t have a terminal program (way to go Microsoft!) so you may want to check out TeraTerm Pro (just download it).
- Once you have the terminal open, you should see ‘12<’. Good! This means that OpenLog is open for business and ready to receive characters. If you don’t see these characters, check that TX and RX are correctly wired. Make sure you have LEDs turned on, if not check your power connections.
- Once you’ve proven your serial connection, close the terminal window. You can’t have a connection open while you run avrdude.
- Open a command prompt in windows (click Start, then Run, type ‘cmd’ and press enter)
- At the command prompt type:
c:
Enter
cd\openlog
Enter
avrdude.exe -p atmega328p -P COM3 -c stk500v1 -b 57600 -Cavrdude.conf -U flash:w:main.hex
Enter
If you get a can’t open device COM3 error then you have the wrong COM port selected. Replace COM3 with COM(whatever your com port number is). You should see something like:
Writing | ################################################## | 100% 13.17s
avrdude.exe: 22836 bytes of flash written
avrdude.exe: verifying flash memory against main.hex:
avrdude.exe: load data flash data from input file main.hex:
avrdude.exe: input file main.hex auto detected as Intel Hex
avrdude.exe: input file main.hex contains 22836 bytes
avrdude.exe: reading on-chip flash data:
Reading | ################################################## | 100% 9.73s
Yay! You’ve upgraded OpenLog - Once the complete, open up a terminal again, open the COM port and you should see ‘12<’. Good. Press ctrl+z three times to drop to command mode. Now type ‘?’. This will bring up the help menu and will display the version of OpenLog firmware at the top. Something like OpenLog v1.51. Congrats! You’re done!
The major things to know:
- If you don’t have FTDI Basic or the DTR trick, manually reset OpenLog and catch the bootloader at power up. Press return at the command prompt at the same time you power up OpenLog. avrdude should then begin the download. Either power cycle your breadboard or pull/insert one of the power lines (VCC or GND) and OpenLog should reset and then wait for bootload command for a fraction of a second.
- avrdude.exe compiled for Arduino 0017 has the DTR line wiggle built in. Toggling DTR causes Arduinos, and OpenLog to reset. I do not believe the stock avrdude has this feature built in. Therefore, you will need to use the avrdude that comes with Arduino.
- In any case you should have a very recent version of avrdude to support the processor. Check for updates.
- Some users have reported that libusb0.dll needed to be put inside the Win32 directory. Please let us know if this is required for you or not.
- avrdude for linux doesn’t do the DTR toggle so you will have to reset manually.
- If avrdude says it doesn’t recognize the AVR type you also need to get the avrdude.conf file from Arduino in order to support ATmega328.
From a Windows setup, Programmer’s Notepad outputs:
> "make" program_serial
C:\arduino\hardware\tools\avr\bin\avrdude -p atmega328p -P COM3 -c stk500v1 -b 57600 -CC:\arduino\hardware\tools\avr\etc\avrdude.conf -U flash:w:main.hex
For linux, the line is:
avrdude -p atmega328p -P /dev/ttyUSB0 -c stk500v1 -b 57600 -U flash:w:main.hex
Replacing the trailing -U flash… with -t you can enter a “terminal mode” which can diagnose some problems. See the avrdude documentation for more details.
If you try to flash your OpenLog and get this error:
>"make" program_serial
D:\software\Arduino\arduino-0017\arduino-0017\hardware\tools\avr\bin\avrdude -p atmega328p -P COM18 -c stk500v1 -b 57600 -V -CD:\software\Arduino\arduino-0017\arduino-0017\hardware\tools\avr\etc\avrdude.conf -U flash:w:main.hex
avrdude: ser_open(): can't open device "COM18": The system cannot find the file specified.
make: *** [program_serial] Error 1
> Process Exit Code: 2
> Time Taken: 00:00
In the command above the COM port is COM18. On some computers the FTDI COM port will be assigned high numbers that will not work with the avrdude. Open the Device Manager on your Windows machine and find the COM port. Assign another number COM port number less than 10 like COM3 for example. Override the port if already in use but make sure you do not have any other devices connected to it (like a cable plugged in to a COM port).