Copy HEX from Uno to Nano issue

Trying to get a copy of GRBL to run on a Nano clone with a 3drive shield.
Have an Uno running correctly and have used AVRDude to copy the flash image to a file.
Nano will compile and program, but nothing comes out of the serial port.
Have tried direct USB connection and RX/TX to FT1232 board.
Have confirmed that the Nano will output serial both ways as well.
Nano bootloader has been set as an Uno, otherwise the image is too big to fit.
Both are using the 328P MCU.
Serial chip on nano is a CH340, but that should really only matter to the PC I'm connecting it to.

Nano works for everything else, just not this.
Also tried to copy the Uno hex file directly into the Nano using AVRDude.

After the hex copy, dumped the Nano flash back to separate file and compared.
Found differences.

Why?
Working Uno flash file has data in the 0x7800-0x7AC0 range while the Nano dump has all FF's in this range.

This section is the only piece that is different.
What is it? Why would it prevent the Nano from talking on the serial?
Why didn't it copy over from the Uno hex file?

20780000739FB00DA11D621F839FA00D611D221F749F3327A00D611D231F849F600D211D24
:20782000822F762F6A2F11249F5750409AF0F1F088234AF0EE0FFF1FBB1F661F771F881F97
:2078400091505040A9F79E3F510580F00C94983A0C948A3B5F3FE4F3983ED4F38695779564
:207860006795B795F795E7959F5FC1F7FE2B880F911D9695879597F908950E94573BE8F014
:207880009E37E8F09639B8F49E3848F4672F782F8827985FF9CF86957795679593959539EA
:2078A000D0F3B62FB1706B0F711D811D20F487957795679593950C949E3A0C94B93A0C944E
:2078C0008A3B9F930E94013B0F9007FCEE5F0C943B3B19F416F40C94C73A0C94B93A0E94E1
:2078E000573BB8F39923C9F3B6F39F57550B87FF0E94BE3C0024A0E640EA9001805856958A
:20790000979528F4805C660F771F881F20F026173707480730F4621B730B840B2029312966
:207920004A2BA69517940794202531254A2758F7660F771F881F20F026173707480730F446
:20794000620B730B840B200D311D411DA09581F7B901842F9158880F9695879508959B01BA
:20796000AC010C94D03B0E94713B30F09F3710F40C948A3B0C949E3A0C94B93A9150504086
:20798000660F771F881FD2F708959F938F937F936F93FF93EF939B01AC010E94D03BEF91DD
:2079A000FF910E94CA3A2F913F914F915F910C94D03B991B79E004C0991F961708F0961BA7
:2079C000881F7A95C9F780950895AA1BBB1B51E107C0AA1FBB1FA617B70710F0A61BB70B4A
:2079E000881F991F5A95A9F780959095BC01CD010895A1E21A2EAA1BBB1BFD010DC0AA1F3D
:207A0000BB1FEE1FFF1FA217B307E407F50720F0A21BB30BE40BF50B661F771F881F991F13
:207A20001A9469F760957095809590959B01AC01BD01CF010895052E97FB1EF400940E9483
:207A4000323D57FD07D00E94F93C07FC03D04EF40C94323D50954095309521953F4F4F4F2D
:207A60005F4F089590958095709561957F4F8F4F9F4F0895EE0FFF1F0590F491E02D099470
:207A80000E944B3DA59F900DB49F900DA49F800D911D11240895A29FB001B39FC001A39F54
:207AA000700D811D1124911DB29F700D811D1124911D0895FB01DC0104C08D9101908019F7
:207AC00021F441505040C8F7881B990B0895F894FFCFFFFFFFFFFFFFFFFFFFFFFFFFFFFF81

Did you actually burn the UNO bootloader to the Nano?

Seeing as the Uno and Nano Classic use exactly the same processor, then there is no reason why it should not fit.

Arduino IDE will not take the GRBL code if the device is set as a Nano - with either of the bootloaders.
Google search said something about old ROM code that they didn't want to fix, and just burn as an Uno.

I think you misunderstood what you were being told here. On the other hand it cold just be rubbish. Can you post the link to where you got that from please.

@david_2018
Reasonably sure I did.
Set up 4 of these and did a bootload burn on all 4.
Pretty sure I set it as Uno... I suppose I can always got back and do it again just to be sure.

Still doesn't explain why the HEX write was different. Made sure to have AVRDude erase first and it still has that separate section.

I may have misspoken the context.. but the result is the same. Nano has a different bootloader than Uno, even though the chips are the same.

.... and now the Uno is throwing an error code.
FML... it was working.
grumble

Separate issue though. Not gonna bring it up here, just need to pull it back out again and rewrite.

Sometimes, DIY is a real PITA. :slight_smile:

Look at these official data sheets
Nano

Uno R3

Look at them and tell me where you see there are 1536 more bytes of flash memory in the Nano than the Uno.

They are the same chip!

They both have 32K of flash memory.

@Grumpy_Mike
I know this.. and you know this.
Arduino IDE does not know this.

Go download the GRBL code and see for yourself.
It compiles to 31346 bytes, which is 97% of the Uno memory.
If you try to burn that while set as a Nano, it says 102% and will not write.

Got a link to that?

@Grumpy_Mike

Downloaded it but it just consists of rubbish and therefore will not compile as anything.

config.h
coolant_control.c
coolant_control.h
cpu_map.h
defaults.h
eeprom.c
eeprom.h
examples
gcode.c
gcode.h
grbl.h
jog.c
jog.h
limits.c
limits.h
main.c
motion_control.c
motion_control.h
nuts_bolts.c
nuts_bolts.h
planner.c
planner.h
print.c
print.h
probe.c
probe.h
protocol.c
protocol.h
report.c
report.h
serial.c
serial.h
settings.c
settings.h
spindle_control.c
spindle_control.h
stepper.c
stepper.h
system.c
system.h

@Grumpy_Mike
In the examples directory is the INO file.
Load that and compile. Don't edit anything.

And I get on verification

Arduino: 1.8.19 (Mac OS X), B
Alternatives for grbl.h: []
grblUpload:27:10: fatal error: grbl.h: No such file or directoryResolveLibrary(grbl.h)

-> candidates: [] #include <grbl.h>

      ^~~~~~~~

compilation terminated.
exit status 1
grbl.h: No such file or directory

@Grumpy_Mike
You put the entire GRBL directory in the Arduino library directory.
Open the INO file in the grbl/examples and compile/upload.

I promise you, it is a valid sketch and it all works properly.
and that if you have the IDE set for NANO, it will not upload. But if you have it set for Uno, it will.

The nano has the bootloader size set to 2k, even if it has the “new” 512byte optiboot bootloader. Thus, it has LESS usable flash….

That is because the upload.maximum_size for the Nano is set to 30720 but for the Uno it is 32265.
You can modify the boards.txt file and change it to 32265 for the Nano, then it should work.

FYI: The regular bootloader for the Uno and Nano are the same.

I have grbl running on two nanos although ISTR that they both are from a batch than needs the "old bootloader" selected in the IDE.
I do not recall having to do anything special to get them to work.

Or do as @chaos0711, and many others, have done and burn the bootloader to the Nano with the board selection set to UNO. Just have to remember to always select UNO as the board type when compiling for that Nano.