Some advice on updating sketch from pendrive

Hi, I wonder if this is possible. I've been told you can load a sketch on a micro sd card and use some commands via ssh to flash the 32u4.

Is it possible to do this via usb. I am wondering if anyone knows the commands to do this.

What I am looking for is

When the USB is mounted
if file ending .hex exists
upload to 32u4 without merging with bootloader

Would be great for easy end use firmward update of embedded system

If you run

run-avrdude PATH_TO_HEX

the hex will be flashed as is

Ok, that AVR dude command brings me closer. So can I ask

The .hex file generated from the IDE. I take it that is without the bootloader.
It seems that something gets run on the yun as its uploaded. some kind of merge with bootloader instruction
Will the command run-avrdude PATH_TO_HEX just flash the exact hex as is and will it just run. does it need anything else

Secondly as the IDE seems to know that a yun with bootloader would have only 28k, is there a way of amending to boards.txt file so that the ide allows it to compile a 32k sketch. i.e the ide will know that 32k is the maximum free memory size of the yun without bootloader. I can then in theory just take the hex file and run run-avrdude PATH_TO_HEX and get my 32k firmware onto the yun via usb

What shoudl the exact value in boards.txt be?

IDE calls merge-sketch-with-bootloader.lua before run-avrdude
merge-sketch-with-bootloader.lua will add the bootloader section to the sketch given as first argument

merge-sketch-with-bootloader.lua /tmp/sketch.hex

so just mounting the usb with the hex file on it and running run-avrdude PATH_TO_HEX will flash the 32u4 with just the sketch no bootloader at all.

Ok
Question 1.) will the sketch then run or does it need a bootloader at all
Question 2.) How do we amend the ide to allwo it to compile a sketch of 32k. I assume at the moment there is something probably in boards.txt which says. You can only fit 28k in because I have to leave space for the bootloader

From another post on the forum. Would love some confirmation on whether 32768 is the correct maximum value for the Yún or if its something more obscure for some other reason.

Step 1.) Edit the board.txt file to add another Yún called Arduino Yún - 32k

The line determinining the maximum program memory for the yun seems to be yunB.upload.maximum_size=32768

Insert the parts between the #'s into the boards.txt file

##############################################################
yunB.name=Arduino Yún - 32k
yunB.upload.via_ssh=true
yunB.vid.0=0x2341
yunB.pid.0=0x0041
yunB.vid.1=0x2341
yunB.pid.1=0x8041
yunB.upload.tool=avrdude
yunB.upload.protocol=avr109
yunB.upload.maximum_size=32768
yunB.upload.maximum_data_size=2560
yunB.upload.speed=57600
yunB.upload.disable_flushing=true
yunB.upload.use_1200bps_touch=true
yunB.upload.wait_for_upload_port=true
yunB.bootloader.tool=avrdude
yunB.bootloader.low_fuses=0xff
yunB.bootloader.high_fuses=0xd8
yunB.bootloader.extended_fuses=0xfb
yunB.bootloader.file=caterina/Caterina-Yun.hex
yunB.bootloader.unlock_bits=0x3F
yunB.bootloader.lock_bits=0x2F
yunB.build.mcu=atmega32u4
yunB.build.f_cpu=16000000L
yunB.build.vid=0x2341
yunB.build.pid=0x8041
yunB.build.usb_product="Arduino Yun"
yunB.build.board=AVR_YUN
yunB.build.core=arduino
yunB.build.variant=yun
yunB.build.extra_flags={build.usb_flags}
##############################################################
  1. restart the Arduino Ide
  2. from list of boards ---> Arduino Yún - 32k
  3. compile the code, not upload (remember to check in the preferences option to see the compile process)
  4. wait until compile has finished and copy the path to where the .hex file is located
  5. copy the .hex file to SD yun
  6. connect via ssh to yun (ssh root@your_yun_name.local)
  7. cd /mnt/usb (This is the only bit I am not sure on. I am not at my yun at the moment)
  8. run-avrdude your_compiled_file.hex

obviously no more bootloader in atmega (so you can't upload as usual via usb from ide), but.... is simply to restore:

  1. compile a simple sketch as blink (use Standard Yun as board type)
  2. in the same way find the hex and upload it to SD
  3. cd /mnt/sda1
  4. merge-sketch-with-bootloader.lua Blink.cpp.hex
  5. run-avrdude Blink.cpp.hex

...in this way you have again the standard bootloader on atmega and the blink sketch.
After this you can upload again from ide, as usual.

So the question is, will the Yun automount a USB thumbdrive to /mnt/usb

Unless anyone can tell me, I suppose I will need to plug one in and check with a

ls -all /mnt/

External storage is mounted under /mnt/: /mnt/sda1, /mnt/sdb1...