Compiling Optiboot

It looks like you're using optiboot v4.4. Try it with the latest optiboot source. It doesn't use -mshort-calls. It even automatically deals with the different tool paths between Arduino IDE versions: optiboot/Makefile at master · Optiboot/optiboot · GitHub

It compiles without errors with the new version, thanks a lot!

I was using the version that came with the Arduino IDE 1.6.8. Is there any reason why they don't include a newer version of Optiboot with the IDE, it's a bit pointless to include an old version that isn't even compatible with the included avr-gcc version and expects the wrong directory structure ...

Glad to hear!
The Arduino IDE includes the old version because that's the version that they used for the Arduino Uno's optiboot bootloader. They're using the old version for the Arduino bootloaders because that one works fine and I think the developers have the theory of "If it ain't broke...". The only release since v4.4 on the optiboot repository is v6.2, which is "Not a production release".

(also, the Arduino IDE distribution no longer includes all of the tools necessary to build (and version of) optiboot. There's no "make" for instance. :frowning: )

westfw, do you know why they stopped including those tools? make and rm were the only two missing for me on Windows.

do you know why they stopped including those tools?

The old IDE simply included WINAVR, which in turn included a whole bunch of other tools designed to give the user a full development environment on windows.
WINAVR hasn't been updated since 2010, and isn't likely to be updated. So to get a newer compiler (and full control of it), the new IDE includes petty much only the gcc-related tools themselves, built by the Arduino team from source (IIRC.) (although, it's the same set of tools that Atmel includes in their "command line tools for xxx" distributions.) (Sigh. WINAVR was a very convenient set of tools...)

Hi!

I am trying to change the baudrade when I am uploading code to my Uno. I am doing this by changing it in optiboot.c. But when trying to compile I get the following message.

C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\optiboot>........\tools\avr\bin\make OS=windows ENV=arduino uno
File path not found

I have tried everything posted in this thread and I have been googling for hours but can't find a solution.

Does anyone have the same problem or a solution?

https://tttapa.github.io/Arduino/ATmega328P/Custom-frequency.html

The "make" command is a Linux thing and optiboot is built in a way that the IDE does not handle so it needs some different build tools that are controlled with the Makefile.

I think the only real best option is to use Linux which has the native tools, however, there are a few ways to run Linux:

Windows Subsystem for Linux

Ubuntu on PC hardware

Raspibian on a Raspberry Pi

Normally I have an old junk computer running one of the Ubuntu flavors that are happy on it (e.g. Xubuntu or Lubuntu).

Anyway whatever sort of Linux you go with then you need to install the software packages.

sudo apt-get update
sudo apt-get install make git picocom gcc-avr binutils-avr gdb-avr avr-libc avrdude
sudo usermod -a -G dialout your_user_name
git clone https://github.com/Optiboot/optiboot
cd optiboot
make

Did I forget anything?

Old versions of the Arduino IDE (1.0.6 and older I think) came with make. New IDE versions do not, as we discussed above. You can get make for Windows from an old copy of the Arduino IDE, which you can download here:

or you can get it from winavr:
http://winavr.sourceforge.net/

So no, Linux is absolutely not necessary. I compile bootloaders all the time using Windows.

I start with a 1.0.6 arduino IDE install (.zip package, not installed), and then replace the compiler and compiler supplied libraries with the ones from the latest version of the IDE (or from Atmel Studio).

WinAVR looks dodgy to me, I know it had its day, but its day has passed.

Those packages in Ubuntu and Raspibin are from Debian, and for me have been reliable and up to date.

Lots of GNU tools for Windows here, including make.

As was mentioned above, I'm also using old v1.0.6 with replaced toolchain (gcc v 4.9.2 - make is missing in this one) and with old make.exe v3.81 (from the toolchain with gcc v4.7.2). It works fine for me.
Eventually, here is a link for how to build yourself and for Win download: avr-gcc 4.9.2 and avr-libc 1.8.1 compiled for Windows | Andys Workshop.

It's not THAT bad.
Install any relatively recent version of the Arduino IDE.
Install the GnuWin Make for windows (ie from Make for Windows) (use the "setup" version to make sure all the right dlls are installed too.)
Open a command prompt window. Make sure that "make.exe" works (I don't think the installer for make adds the gnuwin directory to the path.)
Execute the really neat and horribly ugly .BAT file described here: install-avr-tools | Hackaday.io (download from here GitHub - WestfW/Arduino-avr-tools-install: Given Windows with some version of Arduino installed, set the paths to allow using avr-gcc/etc from the command line.
Connect to the ...optiboot/bootloaders/optiboot directory where the source code lives.

Then you should be able to issue "make whatever" command to do the compile...

Oh, admittedly it might be nice if more of this happened semi-automatically, and if the .bat file looked for GnuWin, and it might be a bit ... overwhelming ... if you've never used a "Command Prompt" window before, but it still ought to be better than "learn enough linux to throw away your windows box."

Ok, I've made it easier.
If you download the new omake.bat from optiboot/omake.bat at master · Optiboot/optiboot · GitHub (with or without the rest of the most recent optiboot), it is smart enough to go out and find avr-gcc in most of the likely location and version combinations before running the compile.
You still have to have Arduino and make installed somewhere, but you no longer have to fiddle with paths. So:

  • Install Arduino
  • Install the gnuwin Make.
  • get the new omake.bat and/or the rest of the current optiboot tree.
  • In a command-line window, connect to the directory that contains optiboot.c (...\bootloaders\optiboot, usually.)
  • Issue the desired build command using omake instead of make, ie: ".\omake.bat atmega32 BAUD_RATE=19200" or whatever....

Thank you all for answers!

I tried what westfw suggested and nothing really happened. Then I installed an older version of Arduino and the make failed and got the following message:

"C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot>.\omake.bat atmega328 BAUD_RATE=19200
avr-gcc already installed at C:\Program Files\avr8-gnu-toolchain\bin\avr-gcc.exe
'DEBUG' is not recognized as an internal or external command,
operable program or batch file.
avr-gcc (AVR_8_bit_GNU_Toolchain_3.5.4_1709) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

process_begin: CreateProcess(NULL, bash baudcheck.tmp.sh, ...) failed.
make (e=2): File not found.
make: [baudcheck] Fel 2 (ignoreras)
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L -DBAUD_RATE=19200 -DLED_START_FLASHES=3 -c -o optiboot.o optiboot.c
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L -DBAUD_RATE=19200 -DLED_START_FLASHES=3 -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -nostartfiles -nostdlib -o optiboot_atmega328.elf optiboot.o -lc
avr-size optiboot_atmega328.elf
text data bss dec hex filename
464 0 0 464 1d0 optiboot_atmega328.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega328.elf optiboot_atmega328.hex
avr-objdump -h -S optiboot_atmega328.elf > optiboot_atmega328.lst
Acces denied.
make: *** [optiboot_atmega328.lst] error"

"C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\optiboot>.\omake.bat atmega328
:
Acces denied.

You may need to copy the optiboot directory to somewhere that is writeable by non-admin users.
I think windows will object (these days) to actually writing files under the "C:\Program Files" location.

Sigh. It also looks like it needs some more modifications to work on 64bit windows :frowning: