Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better documentation for compiling optiboot_flash #8

Open
mcuee opened this issue Dec 10, 2022 · 14 comments
Open

Better documentation for compiling optiboot_flash #8

mcuee opened this issue Dec 10, 2022 · 14 comments

Comments

@mcuee
Copy link

mcuee commented Dec 10, 2022

It will be good to have a bit better documentation to let the user know how to build the hex file.

Right now the build scripts work out of the box for macOS and Linux. But it does not seem to work under Windows.

@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

Maybe the following page can be a good start.
https://github.com/Optiboot/optiboot/wiki/CompilingOptiboot

Under Windows I can use git bash and Arduino toolchain to build the hex files from Optiboot github, including the following.
https://github.com/Optiboot/optiboot/blob/master/optiboot/bootloaders/optiboot/makeall.mcudude.sh

However, the same environment does not work for optiboot_flash.

I am able to use MSYS2 as well for optiboot, but it does not seem to work with optiboot_flash.

@mcuee mcuee changed the title Better documentation for how to build the hex files Better documentation for compiling optiboot_flash Dec 10, 2022
@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

Please also refer to the following.

@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

Under MSYS2: it does not work at all.

$ mingw32-make
ERROR
This makefile is trying to execute the makeall build script.
Windows CMD.exe does not support Unix shell scripts.
You need a Unix environment to run makeall.

$ make
Microsoft Windows [Version 10.0.22621.819]
(c) Microsoft Corporation. All rights reserved.

C:\work\avr\avrdude_test\others\optiboot_flash>

@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

Same for git bash.

$ make
ERROR
This makefile is trying to execute the makeall build script.
Windows CMD.exe does not support Unix shell scripts.
You need a Unix environment to run makeall.

@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

Single hex build is mostly okay with CMD.exe but it has the same issue as optiboot, because of baudcheck.tmp.sh.

PS C:\work\avr\avrdude_test\others\optiboot_flash> make atmega8 AVR_FREQ=16000000L BAUD_RATE=115200 LED=B5 LED_START_FLASHES=2 UART=0
if not exist "bootloaders\atmega8\16000000L" mkdir bootloaders\atmega8\16000000L
-n Using avr-gcc\
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -dumpversion
7.3.0
"\nUART = UART0\tLED_PIN = B5\t LED_FLASHES = 2\t SUPPORT_EEPROM = 0\t COPY_FLASH_PAGES = 0"
"\x1B[1m\x1B[4m"
process_begin: CreateProcess(NULL, sh baudcheck.tmp.sh, ...) failed.
make (e=2): The system cannot find the file specified.
make: [Makefile:1400: baudcheck] Error 2 (ignored)
"\x1B[0m"
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega8 -DF_CPU=16000000L -DOPTIBOOT_CUSTOMVER=1 -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5     -DUART=0   -c -o optiboot_flash.o optiboot_flash.c
optiboot_flash.c:314:2: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
 #warning BAUD_RATE error greater than 2%
  ^~~~~~~
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega8 -DF_CPU=16000000L -DOPTIBOOT_CUSTOMVER=1 -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5     -DUART=0 -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version -Wl,--relax -nostartfiles -o bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf optiboot_flash.o
ECHO is off.
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-size bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf
   text    data     bss     dec     hex filename
    454       0       0     454     1c6 bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.hex
"\nOutput file name: bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.hex"
rm bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf optiboot_flash.o

@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

Single hex file build works well under git bash.

$ make atmega8 AVR_FREQ=16000000L BAUD_RATE=115200 LED=B5 LED_START_FLASHES=2 UART=0
if not exist "bootloaders\atmega8\16000000L" mkdir bootloaders\atmega8\16000000L
-n Using avr-gcc\
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -dumpversion
7.3.0
"\nUART = UART0\tLED_PIN = B5\t LED_FLASHES = 2\t SUPPORT_EEPROM = 0\t COPY_FLASH_PAGES = 0"
"\x1B[1m\x1B[4m"
BAUD RATE CHECK: Desired: 115200 Real: 117647 UBRRL = 16 Difference: 2.1 %"\x1B[0m"
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega8 -DF_CPU=16000000L -DOPTIBOOT_CUSTOMVER=1 -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5     -DUART=0   -c -o optiboot_flash.o optiboot_flash.c
optiboot_flash.c:314:2: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
 #warning BAUD_RATE error greater than 2%
  ^~~~~~~
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega8 -DF_CPU=16000000L -DOPTIBOOT_CUSTOMVER=1 -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5     -DUART=0 -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version -Wl,--relax -nostartfiles -o bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf optiboot_flash.o
ECHO is off.
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-size bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf
   text    data     bss     dec     hex filename
    454       0       0     454     1c6 bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.hex
"\nOutput file name: bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.hex"
rm bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf optiboot_flash.o

@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

Single hex file build also works under MSYS2 but I can not use make. I can use only mingw32-make.

$ mingw32-make atmega8 AVR_FREQ=16000000L BAUD_RATE=115200 LED=B5 LED_START_FLASHES=2 UART=0
if not exist "bootloaders\atmega8\16000000L" mkdir bootloaders\atmega8\16000000L
-n Using avr-gcc\
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -dumpversion
7.3.0
"\nUART = UART0\tLED_PIN = B5\t LED_FLASHES = 2\t SUPPORT_EEPROM = 0\t COPY_FLASH_PAGES = 0"
"\x1B[1m\x1B[4m"
BAUD RATE CHECK: Desired: 115200 Real: 117647 UBRRL = 16 Difference: 2.1 %"\x1B[0m"
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega8 -DF_CPU=16000000L -DOPTIBOOT_CUSTOMVER=1 -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5     -DUART=0   -c -o optiboot_flash.o optiboot_flash.c
optiboot_flash.c:314:2: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
 #warning BAUD_RATE error greater than 2%
  ^~~~~~~
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega8 -DF_CPU=16000000L -DOPTIBOOT_CUSTOMVER=1 -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5     -DUART=0 -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version -Wl,--relax -nostartfiles -o bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf optiboot_flash.o
ECHO is off.
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-size bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf
   text    data     bss     dec     hex filename
    454       0       0     454     1c6 bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf
"C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b"/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.hex
"\nOutput file name: bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.hex"
rm bootloaders/atmega8/16000000L/optiboot_flash_atmega8_UART0_115200_16000000L_B5.elf optiboot_flash.o

@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

If I delete the check to enable makeall under git bash, it failed.

 Welcome to MCUdude's optiboot_flash build script!

Do you want to delete all previous files and folders (y/n)? y


You're about to build a total of 9856 hex files. This is probably going to take a while.
Are you sure you want to do this?


Press enter to run script!



Deleting all previous generated files and empty folders
make[1]: Entering directory 'C:/work/avr/avrdude_test/others/optiboot_flash'
find . -name "*.o" -exec rm {} \;
find: missing argument to `-exec'
make[1]: *** [Makefile:1417: clean_all] Error 1
make[1]: Leaving directory 'C:/work/avr/avrdude_test/others/optiboot_flash'
make: *** [Makefile:242: all] Error 2


@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

BTW, MegaCoreX optiboot_x seems to be fine.

MINGW64 /c/work/avr/avrdude_test/others/MegaCoreX/megaavr/bootloaders/optiboot/bootloaders/mega0/115200
$ ./hexls
452 496 o9.0 -.s-.-r-- Optiboot_mega0_UART0_ALT_115200_A7.hex
450 496 o9.0 -.s-.-r-- Optiboot_mega0_UART0_DEF_115200_A7.hex
452 496 o9.0 -.s-.-r-- Optiboot_mega0_UART1_ALT_115200_A7.hex
450 496 o9.0 -.s-.-r-- Optiboot_mega0_UART1_DEF_115200_A7.hex
452 496 o9.0 -.s-.-r-- Optiboot_mega0_UART2_ALT_115200_A7.hex
450 496 o9.0 -.s-.-r-- Optiboot_mega0_UART2_DEF_115200_A7.hex
452 496 o9.0 -.s-.-r-- Optiboot_mega0_UART3_ALT_115200_A7.hex
450 496 o9.0 -.s-.-r-- Optiboot_mega0_UART3_DEF_115200_A7.hex
click for detailed build log
$ sh makeall
Using Compiler at: /c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=A0 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf optiboot_x.c
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf
   text    data     bss     dec     hex filename
    504       9       0     513     201 bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf
Using Compiler at: /c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=A4 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf optiboot_x.c
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf
   text    data     bss     dec     hex filename
    506       9       0     515     203 bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf
Using Compiler at: /c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=B0 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf optiboot_x.c
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf
   text    data     bss     dec     hex filename
    504       9       0     513     201 bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf
Using Compiler at: /c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=B4 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf optiboot_x.c
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf
   text    data     bss     dec     hex filename
    506       9       0     515     203 bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf
Using Compiler at: /c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=C0 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf optiboot_x.c
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf
   text    data     bss     dec     hex filename
    504       9       0     513     201 bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf
Using Compiler at: /c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=C4 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf optiboot_x.c
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf
   text    data     bss     dec     hex filename
    506       9       0     515     203 bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf
Using Compiler at: /c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=F0 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf optiboot_x.c
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf
   text    data     bss     dec     hex filename
    504       9       0     513     201 bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf
Using Compiler at: /c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=F4 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf optiboot_x.c
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf
   text    data     bss     dec     hex filename
    506       9       0     515     203 bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf
/c/Users/xiaof/AppData/Local/Arduino15/packages/DxCore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino4b/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf

@mcuee
Copy link
Author

mcuee commented Dec 10, 2022

Another good reference for Windows can be from DxCore. It works for DxCore optiboot_dx and megaTinyCore optiboot_x.
https://github.com/SpenceKonde/DxCore/blob/master/megaavr/bootloaders/optiboot_dx/README.md

Results:
SpenceKonde/megaTinyCore#870

@mcuee
Copy link
Author

mcuee commented Dec 11, 2022

BTW, no issues for Linux, I just need to modify Makefile to use the right toolchain.

mcuee@UbuntuSwift3:~/build/avr/optiboot_flash$ git diff
diff --git a/Makefile b/Makefile
index 6d8fb505..3ff8442c 100755
--- a/Makefile
+++ b/Makefile
@@ -67,7 +67,7 @@ else
        endif
        ifeq ($(UNAME_S),Linux)
          # Replace ArduinoInstallPath with the actual path
-               TOOLROOT = ArduinoInstallPath/hardware/tools/avr
+               TOOLROOT = /home/mcuee/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7
        endif
 endif

mcuee@UbuntuSwift3:~/build/avr/optiboot_flash$ ./makeall 
...
 Build 10640 of 10640 
Target 112 of 112 
Sub build 95 of 95 
 make atmega8535 AVR_FREQ=1000000L BAUD_RATE=9600 LED=B7 LED_START_FLASHES=2 UART=0 
Using avr-gcc 7.3.0

UART = UART0	LED_PIN = B7	 LED_FLASHES = 2	 SUPPORT_EEPROM = 0	 COPY_FLASH_PAGES = 0
\x1B[1m\x1B[4m
BAUD RATE CHECK: Desired: 9600 Real: 9615 UBRRL = 12 Difference: 0.1 %\x1B[0m

   text	   data	    bss	    dec	    hex	filename
    450	      0	      0	    450	    1c2	bootloaders/atmega8535/1000000L/optiboot_flash_atmega8535_UART0_9600_1000000L_B7.elf

Output file name: bootloaders/atmega8535/1000000L/optiboot_flash_atmega8535_UART0_9600_1000000L_B7.hex


 COMPILATION SUCCESSFUL! 





 Done! 

@mcuee
Copy link
Author

mcuee commented Dec 11, 2022

Another good reference for Windows can be from DxCore. It works for DxCore optiboot_dx and megaTinyCore optiboot_x. https://github.com/SpenceKonde/DxCore/blob/master/megaavr/bootloaders/optiboot_dx/README.md

Results: SpenceKonde/megaTinyCore#870

I can make it work under Windows as well for optiboot_x for MegaCoreX with some tweaks.

PS C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex> cat .\omake.bat
..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino %*
PS C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex> cat .\makeall.bat
REM Build for 115200 baud
call omake mega0 UARTTX=A0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
call omake mega0 UARTTX=A4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
call omake mega0 UARTTX=B0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
call omake mega0 UARTTX=B4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
call omake mega0 UARTTX=C0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
call omake mega0 UARTTX=C4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
call omake mega0 UARTTX=F0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
call omake mega0 UARTTX=F4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

PS C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex> cat .\Makefile
# Makefile for AVR Mega-0 (4809), Tiny-0, and Tiny-1 version of Optiboot
# Bill Westfield, 2019
# $Id$
#
# Edit History
# Sep-2019 refactor from the normal AVR Makefile.
# * Copyright 2013-2019 by Bill Westfield.  Part of Optiboot.
# * This software is licensed under version 2 of the Gnu Public Licence.
# * See optiboot.c for details.

HELPTEXT = "\n"
#----------------------------------------------------------------------
#
# program name should not be changed...
PROGRAM    = optiboot_x
MF:= $(MAKEFILE_LIST)

# export symbols to recursive makes (for ISP)
export

# defaults
MCU_TARGET = atmega4809

LDSECTIONS  = -Wl,-section-start=.text=0 \
              -Wl,--section-start=.application=0x200 \
              -Wl,--section-start=.version=0x1fe

BAUD_RATE=115200

# If we have a PACKS directory specified, we should use it...
ifeq ($(ENV), arduino)
# For Arduino, we assume that we're connected to the optiboot directory
# included with the arduino distribution, which means that the full set
# of avr-tools are "right up there" in standard places.
# (except that in 1.5.x, there's an additional level of "up")
TESTDIR := $(firstword $(wildcard ../../../tools/*))
ifeq (,$(TESTDIR))
# Arduino 1.5.x tool location compared to optiboot dir
  TOOLROOT = ../../../../tools
else
# Arduino 1.0 (and earlier) tool location
  TOOLROOT = ../../../tools
endif
GCCROOT = $(TOOLROOT)/avr/bin/

ifeq ($(OS), windows)
# On windows, SOME of the tool paths will need to have backslashes instead
# of forward slashes (because they use windows cmd.exe for execution instead
# of a unix/mingw shell?)  We also have to ensure that a consistent shell
# is used even if a unix shell is installed (ie as part of WINAVR)
fixpath = $(subst /,\,$1)
SHELL = cmd.exe
SH = sh
endif

else ifeq ($(ENV), arduinodev)
# Arduino IDE source code environment.  Use the unpacked compilers created
# by the build (you'll need to do "ant build" first.)
ifeq ($(OS), macosx)
TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools
endif
ifeq ($(OS), windows)
TOOLROOT = ../../../../build/windows/work/hardware/tools
endif

GCCROOT = $(TOOLROOT)/avr/bin/
AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf

else
GCCROOT =
AVRDUDE_CONF =
endif

#
# End of build environment code.


CC         = $(GCCROOT)avr-gcc
RCC        = $(abspath $(CC))
#$(info wildcard ("$(wildcard $(CC))",""))
ifndef PRODUCTION
$(info Using Compiler at: ${RCC})
endif


# If we have a PACKS directory specified, we should use it...
ifdef PACKS
PACK_OPT= -I $(PACKS)/include/ -B $(PACKS)/gcc/dev/$(TARGET)
ifndef PRODUCTION
$(info   and Chip-defining PACKS at ${PACKS})
endif
endif


OPTIMIZE = -Os -fno-split-wide-types -mrelax

# Override is only needed by avr-lib build system.

override CFLAGS  = -g -Wall $(OPTIMIZE)
override LDFLAGS = $(LDSECTIONS) -Wl,--relax -nostartfiles -nostdlib

OBJCOPY        = $(GCCROOT)avr-objcopy
OBJDUMP        = "$(GCCROOT)avr-objdump"
SIZE           = $(GCCROOT)avr-size

include parse_options.mk

.PRECIOUS: optiboot_%.elf

ifndef PRODUCTION
LISTING= $(OBJDUMP) -S
else
LISTING= @true
endif



#---------------------------------------------------------------------------
# "Chip-level Platform" targets.
# A "Chip-level Platform" compiles for a particular chip, but probably does
# not have "standard" values for things like clock speed, LED pin, etc.
# Makes for chip-level platforms should usually explicitly define their
# options like: "make atmega4809 UARTTX=A4 LED=D0"
#---------------------------------------------------------------------------
#
# Mega0, tiny0, tiny1 don't really have any chip-specific requirements.
#
# Note about fuses:
#  The fuses are defined in the source code.  There are 9!
#  Be sure to use a programmer that will program the fuses from the object file.
#
#---------------------------------------------------------------------------
#

include parse_options.mk

.PRECIOUS: optiboot_%.elf

ifndef PRODUCTION
LISTING= $(OBJDUMP) -S
else
LISTING= @true
endif

ifeq ($(SKIP_BOOTLOADER_ON_POR), 0)
START_APP_ON_POR=0
else
START_APP_ON_POR=1
endif

ifeq ($(UARTTX), A0)
UART=0
UARTMUX=DEF
endif
ifeq ($(UARTTX), B0)
UART=3
UARTMUX=DEF
endif
ifeq ($(UARTTX), C0)
UART=1
UARTMUX=DEF
endif
ifeq ($(UARTTX), F0)
UART=2
UARTMUX=DEF
endif
ifeq ($(UARTTX), A4)
UART=0
UARTMUX=ALT
endif
ifeq ($(UARTTX), B4)
UART=3
UARTMUX=ALT
endif
ifeq ($(UARTTX), C4)
UART=1
UARTMUX=ALT
endif
ifeq ($(UARTTX), F4)
UART=2
UARTMUX=ALT
endif


#---------------------------------------------------------------------------
# "Chip-level Platform" targets.
# A "Chip-level Platform" compiles for a particular chip, but probably does
# not have "standard" values for things like clock speed, LED pin, etc.
# Makes for chip-level platforms should usually explicitly define their
# options like: "make atmega4809 UARTTX=A4 LED=D0"
#---------------------------------------------------------------------------
#
# Mega0, tiny0, tiny1 don't really have any chip-specific requirements.
#
# Note about fuses:
#  The fuses are defined in the source code.  There are 9!
#  Be sure to use a programmer that will program the fuses from the object file.
#
#---------------------------------------------------------------------------
#



optiboot_%.hex: optiboot_%.elf
        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@

%.hex: %.elf
        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@

%.elf:  optiboot_x.c FORCE
        $(CC) $(CFLAGS) $(CPU_OPTIONS) $(LED_OPTIONS) $(UART_OPTIONS) $(COMMON_OPTIONS) $(POR) $(LDFLAGS) $(PACK_OPT) -mmcu=$(TARGET) -o $@ $<
        $(SIZE) $@


#---------------------------------------------------------------------------
# "Board-level Platform" targets.
# A "Board-level Platform" implies a manufactured platform with a particular
# AVR_FREQ, LED, and so on.  Parameters are not particularly changable from
# the "make" command line.
# Most of the board-level platform builds should envoke make recursively
#  appropriate specific options
#---------------------------------------------------------------------------


mega0: TARGET=atmega4809
mega0: bootloaders/mega0/$(BAUD_RATE)/Optiboot_mega0_UART$(UART)_$(UARTMUX)_$(BAUD_RATE)_$(LED).hex


#---------------------------------------------------------------------------
#
# Generic build instructions
#

FORCE:

#windows "rm" is dumb and objects to wildcards that don't exist
clean:
        @touch  __temp_.o __temp_.elf __temp_.lst __temp_.map
        @touch  __temp_.sym __temp_.lss __temp_.eep __temp_.srec
        @touch __temp_.bin __temp_.hex __temp_.tmp.sh
        rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.tmp.sh

clean_asm:
        rm -rf *.lst

%.lst: %.elf FORCE
        $(OBJDUMP) -h -S $< > $@

%.srec: %.elf FORCE
        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@

%.bin: %.elf FORCE
        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@

PS C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex> .\makeall.bat

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>REM Build for 115200 baud

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>call omake mega0 UARTTX=A0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino mega0 UARTTX=A0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
Using Compiler at: C:/work/arduino/arduino-1.0.6-windows/arduino-1.0.6/hardware/tools/avr/bin/avr-gcc
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=A0 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf optiboot_x.c
../../../tools/avr/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf
   text    data     bss     dec     hex filename
    504       9       0     513     201 bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART0_DEF_115200_A7.elf

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>call omake mega0 UARTTX=A4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino mega0 UARTTX=A4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
Using Compiler at: C:/work/arduino/arduino-1.0.6-windows/arduino-1.0.6/hardware/tools/avr/bin/avr-gcc
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=A4 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf optiboot_x.c
../../../tools/avr/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf
   text    data     bss     dec     hex filename
    506       9       0     515     203 bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART0_ALT_115200_A7.elf

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>call omake mega0 UARTTX=B0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino mega0 UARTTX=B0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
Using Compiler at: C:/work/arduino/arduino-1.0.6-windows/arduino-1.0.6/hardware/tools/avr/bin/avr-gcc
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=B0 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf optiboot_x.c
../../../tools/avr/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf
   text    data     bss     dec     hex filename
    504       9       0     513     201 bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.elf

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>call omake mega0 UARTTX=B4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino mega0 UARTTX=B4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
Using Compiler at: C:/work/arduino/arduino-1.0.6-windows/arduino-1.0.6/hardware/tools/avr/bin/avr-gcc
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=B4 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf optiboot_x.c
../../../tools/avr/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf
   text    data     bss     dec     hex filename
    506       9       0     515     203 bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART3_ALT_115200_A7.elf

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>call omake mega0 UARTTX=C0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino mega0 UARTTX=C0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
Using Compiler at: C:/work/arduino/arduino-1.0.6-windows/arduino-1.0.6/hardware/tools/avr/bin/avr-gcc
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=C0 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf optiboot_x.c
../../../tools/avr/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf
   text    data     bss     dec     hex filename
    504       9       0     513     201 bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART1_DEF_115200_A7.elf

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>call omake mega0 UARTTX=C4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino mega0 UARTTX=C4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
Using Compiler at: C:/work/arduino/arduino-1.0.6-windows/arduino-1.0.6/hardware/tools/avr/bin/avr-gcc
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=C4 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf optiboot_x.c
../../../tools/avr/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf
   text    data     bss     dec     hex filename
    506       9       0     515     203 bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART1_ALT_115200_A7.elf

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>call omake mega0 UARTTX=F0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino mega0 UARTTX=F0 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
Using Compiler at: C:/work/arduino/arduino-1.0.6-windows/arduino-1.0.6/hardware/tools/avr/bin/avr-gcc
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=F0 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf optiboot_x.c
../../../tools/avr/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf
   text    data     bss     dec     hex filename
    504       9       0     513     201 bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART2_DEF_115200_A7.elf

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>call omake mega0 UARTTX=F4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1

C:\work\arduino\arduino-1.0.6-windows\arduino-1.0.6\hardware\arduino\bootloaders\optiboot_x_megacorex>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino mega0 UARTTX=F4 TIMEOUT=1 LED=A7 BAUD_RATE=115200 SKIP_BOOTLOADER_ON_POR=1
Using Compiler at: C:/work/arduino/arduino-1.0.6-windows/arduino-1.0.6/hardware/tools/avr/bin/avr-gcc
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax  -DWDTTIME=1  -DLED_START_FLASHES=3  -DLED=A7   -DUARTTX=F4 -DBAUD_RATE=115200       -DSTART_APP_ON_POR -Wl,-section-start=.text=0 -Wl,--section-start=.application=0x200 -Wl,--section-start=.version=0x1fe -Wl,--relax -nostartfiles -nostdlib  -mmcu=atmega4809 -o bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf optiboot_x.c
../../../tools/avr/bin/avr-size bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf
   text    data     bss     dec     hex filename
    506       9       0     515     203 bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.hex
rm bootloaders/mega0/115200/Optiboot_mega0_UART2_ALT_115200_A7.elf

@mcuee
Copy link
Author

mcuee commented Dec 13, 2022

The problem is rather steange, both uder git bash or MSYS2.

$ mingw32-make clean_lst
find . -name "*.lst" -exec rm {} \;
find: missing argument to `-exec'
mingw32-make: *** [Makefile:1430: clean_lst] Error 1

$ find . -name "*.lst" -exec rm {} \;
(this is okay).

@mcuee
Copy link
Author

mcuee commented Dec 13, 2022

Finally found the solution for this one. The following patch works under git bash or MSYS2. But makeall still failed.

$ git diff
diff --git a/Makefile b/Makefile
index 6d8fb505..8fda4e6b 100755
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,7 @@ SH := bash
 # This directory should contain a folder bin, which again contains avr-gcc
 # Leave the path empty (but keep the "" 's) to use pre-installed avr build tools (Crosspack AVR etc.)
 #CUSTOM_TOOLROOT = "~/Library/Arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2"
+CUSTOM_TOOLROOT = "C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino6"^M

 # Set default tool path based on OS if custom toolpath isn't specified
 ifeq ($(OS),Windows_NT)
@@ -56,9 +57,9 @@ ifeq ($(OS),Windows_NT)
        # of forward slashes (because they use windows cmd.exe for execution instead
        # of a unix/mingw shell?)  We also have to ensure that a consistent shell
        # is used even if a unix shell is installed (ie as part of WINAVR)
-       TOOLROOT = /some/windows/path
+       TOOLROOT = "C:\Users\xiaof\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino6"
        fixpath = $(subst /,\,$1)
-       SHELL = cmd.exe
+       SHELL = sh
        SH = sh
 else
        UNAME_S := $(shell uname -s)
@@ -230,16 +231,16 @@ endif
 #.PRECIOUS: %.elf

 # Run build script if this makefile is executed without parameters
-ifeq ($(OS),Windows_NT)
-all:
-       @echo ERROR
-       @echo This makefile is trying to execute the makeall build script.
-       @echo Windows CMD.exe does not support Unix shell scripts.
-       @echo You need a Unix environment to run makeall.
-else
+#ifeq ($(OS),Windows_NT)
+#all:
+#      @echo ERROR
+#      @echo This makefile is trying to execute the makeall build script.
+#      @echo Windows CMD.exe does not support Unix shell scripts.
+#      @echo You need a Unix environment to run makeall.
+#else
 all:
        ./makeall
-endif
+#endif

 #-------------------------------------------------------------------------------------------------------
 # "Chip-level Platform" targets.

Build log:

 Welcome to MCUdude's optiboot_flash build script!

Do you want to delete all previous files and folders (y/n)? y


You're about to build a total of 9856 hex files. This is probably going to take a while.
Are you sure you want to do this?


Press enter to run script!



Deleting all previous generated files and empty folders
make[1]: Entering directory '/c/work/avr/avrdude_test/others/optiboot_flash'
find . -name "*.o" -exec rm {} \;
find . -name "*.elf" -exec rm {} \;
find . -name "*.map" -exec rm {} \;
find . -name "*.sym" -exec rm {} \;
find . -name "*.lss" -exec rm {} \;
find . -name "*.eep" -exec rm {} \;
find . -name "*.srec" -exec rm {} \;
find . -name "*.bin" -exec rm {} \;
find . -name "*.tmp.sh" -exec rm {} \;
find . -name "*.hex" -exec rm {} \;
find . -name "*.lst" -exec rm {} \;
make[1]: Leaving directory '/c/work/avr/avrdude_test/others/optiboot_flash'





 Build 1 of 9856
Target 1 of 112
Sub build 1 of 88
 make atmega8 AVR_FREQ=24000000L BAUD_RATE=1000000 LED=B5 LED_START_FLASHES=2 UART=0
sh: -c: line 2: syntax error: unexpected end of file
make[1]: *** [Makefile:1410: maketargetdir] Error 2


 COMPILATION FAILED!
...
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant