HOw to download existing code from Uno board?

I have several versions of a sketch I am working with and want to ensure I am editing the right sketch by downloading the existing code from my Uno R3 board. I cannot find a 'Download' command in the IDE. I know version management is a thing but i haven't implemented it yet… Anyway I think it is a cool way to know what I have loaded. Please assist, thanks in advance.

You can use AVRdude to pull the info off the chip, but it's not code anymore. It's been compiled and linked and turned into machine executable language.

I took a course on decompiling binary. If I had my drothers, I'drother rewrite the program than decompile binary.

I had a horrible feeling that was the case. Thanks

Cheers, Allan

You can try to find an AVR decompiler after extracting the hex file / assembly from your microcontroller. It will give you C code but it will not have any resemblance with your sketch.

I had the same issue and being less rigorous that I ought to be started to get a bit confused. On a sketch that needs long-term maintenance I therefore have a VERSION variable that I update on each revision, and VERSION is printed out on reset. It would be cool if the IDE could implement something to automate this but I guess it isn't necessarily intended to save programmers from themselves!

You could use the __FILE__ and __DATE__ defines to print out the file being compiled and the date it was compiled. You could then use your backup system to get the file as it was when the compile happened.

You do have file backup system, right? :slight_smile:

1 Like

To get round this problem I use this method so whenever I plug a board in it gives me some tips.
Copy the title and paste as "save as". Here's an example...

#define title "ESP32_SCANNER_220831A "
#define board "First attempt to move nano to esp32."
#define notes "Basic scanner with HardwareSerial moved to gpio 16,17."
#define codemine "put an http address here for online code source"
#include "LibPrintf.h" 
// And then in setup....
  Serial.begin(115200);
  printf("\n........................................................................\n");
  printf(" Title: %s\n board: %s\n Notes: %s\n Code source: %s\n",title,board,notes,codemine);
  printf(".........................................................................\n"); 

// Works great for me

Thanks for your reply. Backup is handled by OneDrive. I have avoided using Sve As because it creates new folders and all when all I want is a means of using the latest version. As noted earlier, I think I’ll put version marks within the doc, Date and Version, to identify.

Cheers, Allan

Good advice - put the version marks within the doc.

Cheers, Allan

I generally embed date in the filename, and save with unique filenames only on revisions. For example, interim saves have Node4_20220903a (a increments to z, then aa, etc.), and save a working version as Node4_20220903k_FirstWorkingIICLCD. That way, important milestones are flagged, and interim development can be deleted tomorrow with impunity. Quite different from what most use, but works for me. This is across CAD, Arduino, Word, Excel, and other development areas, so I have a consistency of approach that has served me well across the eons. Old habits die hard - I started doing this with date codes as soon as we were able to move away from 8.3 filename formats. My employer didn't see the utility of revision control software, "too expensive", so we made do other ways.
C

I like this one - the board reports its version on startup. As I’ve noted elsewhere, using Save As creates a bunch of folders etc that I have already found confuses not only me but also the compiler. Back up by Select All/Copy/Paste into a Notepad .TXT flat file is safer in my view. Then a single archive folder can contain the records.
Maybe we could get responses these compiled into an FAQ guidance?

Cheers, Allan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.