How do I build “arduXXX_with_bl.hex” file with Eclipse and Cygwin?

I’ve managed to build ArduCopter with Eclipse and Waf with Cygwin for the board MATEKF405-STD.
However in the build output, I’m not getting the hex file that contains the bootloader. I want to upload this binary to the board via ST Cube Progammer. I was uploading the ‘arducopter.bin’ that was made (was output to: ardupilot\build\MatekF405-STD\bin) but this doesnt work.

I’ve followed the docs to build in eclipse and was also looking at the doc to upload firmware without existing firmware but I’m missing “arduXXX_with_bl.hex” in my build.

The two waf commands I’m using to build in eclipse are:
‘configure --board=MatekF405-STD’
and
‘copter’

Is there another command I have to add or something?

Why on earth you wrestle with Cygwin and Eclipse when there is VS Code and WSL and you can install a full build environment in 10 minutes ?

1 Like

@clinteastwood

Here you go, Link

It will be built automatically once you install the right python module.

New cygwin installs using our script will have that installed by default now.

So i ran

pip3 install intelhex

on cygwin command line

Back in eclipse when I build using copter target, the build process compiles everything but gives me this at the end:

[731/734] Linking build/MatekF405-STD/bin/arducopter
[732/734] Generating bin/arducopter.bin
[733/734] apj_gen build/MatekF405-STD/bin/arducopter.bin
[734/734] Generating bin/arducopter.hex
Traceback (most recent call last):
  File "/cygdrive/c/Users/zinvi/Documents/GitHub/ardupilot/Tools/scripts/make_intel_hex.py", line 4, in <module>
    import intelhex
ModuleNotFoundError: No module named 'intelhex'

Waf: Leaving directory `/cygdrive/c/Users/zinvi/Documents/GitHub/ardupilot/build/MatekF405-STD'
Build failed
 -> task in 'bin/arducopter' failed (exit status 1): 
	{task 123145286642384: build_intel_hex arducopter.bin,MatekF405-STD_bl.bin -> arducopter.hex}
 (run with -v to display more information)
"c:/cygwin64/bin/python3.7m waf -j8 copter" terminated with exit code 1. Build might be incomplete.

19:22:52 Build Finished. 0 errors, 0 warnings. (took 7m:2s.261ms)

It can’t generate the hex file ?

Possibly a Python conflict between the Cygwin Python and Windows Python

Try where python in the Cygwin terminal to list all Python environments in your system. Also the output of ./waf configure --board=MatekF405-STD

Okay so there are two pythons as you said.

where python

gave me

C:\cygwin64\bin\python
C:\Users\zinvi\AppData\Local\Microsoft\WindowsApps\python.exe

The output of ./waf configure --board=MatekF405-STD on cygwin terminal gives:

$ ./waf configure --board=MatekF405-STD
Setting top to                           : /cygdrive/c/Users/zinvi/Documents/github/ardupilot
Setting out to                           : /cygdrive/c/Users/zinvi/Documents/github/ardupilot/build
Autoconfiguration                        : enabled
Setting board to                         : MatekF405-STD
Using toolchain                          : arm-none-eabi
Checking for 'g++' (C++ compiler)        : /cygdrive/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-g++
Checking for 'gcc' (C compiler)          : /cygdrive/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-gcc
Checking for c flags '-MMD'              : yes
Checking for cxx flags '-MMD'            : yes
CXX Compiler                             : g++ 10.2.1
Checking for program 'make'              : /usr/bin/make
Checking for program 'arm-none-eabi-objcopy' : /cygdrive/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-objcopy
Including /cygdrive/c/Users/zinvi/Documents/github/ardupilot/libraries/AP_HAL_ChibiOS/hwdef/MatekF405/hwdef.dat
Removing IMU
Setup for MCU STM32F405xx
Writing hwdef setup in /cygdrive/c/Users/zinvi/Documents/github/ardupilot/build/MatekF405-STD/hwdef.h
Writing DMA map
Generating ldscript.ld
No default parameter file found
Checking for env.py
env set WITH_FATFS=1
env set PROCESS_STACK=0x1C00
env set MAIN_STACK=0x600
env set IOMCU_FW=0
env set PERIPH_FW=0
env set BOARD_FLASH_SIZE=1024
env set EXTERNAL_PROG_FLASH_MB=0
env set CPU_FLAGS=['-mcpu=cortex-m4', '-mfpu=fpv4-sp-d16', '-mfloat-abi=hard', '-DARM_MATH_CM4', '-u_printf_float']
env set CORTEX=cortex-m4
env set APJ_BOARD_ID=125
env set APJ_BOARD_TYPE=STM32F405xx
env set USBID=0x1209/0x5741
env set BOOTLOADER_EMBED=1
env set FLASH_RESERVE_START_KB=64
env set FLASH_TOTAL=983040
env set HAS_EXTERNAL_FLASH_SECTIONS=0
env set CHIBIOS_BUILD_FLAGS=USE_FATFS=yes CHIBIOS_STARTUP_MK=os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk CHIBIOS_PLATFORM_MK=os/hal/ports/STM32/STM32F4xx/platform.mk MCU=cortex-m4 ENV_UDEFS=-DCHPRINTF_USE_FLOAT=1
Enabling ChibiOS asserts                     : no
Disabling Watchdog                           : no
Enabling malloc guard                        : no
Enabling ChibiOS thread statistics           : no
Enabling -Werror                             : yes
Checking for intelhex module:                : disabled
Checking for HAVE_CMATH_ISFINITE             : no
Checking for HAVE_CMATH_ISINF                : no
Checking for HAVE_CMATH_ISNAN                : no
Checking for NEED_CMATH_ISFINITE_STD_NAMESPACE : no
Checking for NEED_CMATH_ISINF_STD_NAMESPACE    : no
Checking for NEED_CMATH_ISNAN_STD_NAMESPACE    : no
Checking for header endian.h                   : not found
Checking for header byteswap.h                 : not found
Checking for HAVE_MEMRCHR                      : no
Configured VSCode Intellisense:                : no
Checking for program 'python'                  : /usr/bin/python
Checking for python version >= 2.7.0           : 3.8.10
Checking for program 'python'                  : /usr/bin/python
Checking for python version >= 2.7.0           : 3.8.10
Source is git repository                       : yes
Update submodules                              : yes
Checking for program 'git'                     : /usr/bin/git
Gtest                                          : STM32 boards currently don't support compiling gtest
Checking for program 'arm-none-eabi-size'      : /cygdrive/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-size
Benchmarks                                     : disabled
Unit tests                                     : disabled
Scripting                                      : disabled
Scripting runtime checks                       : enabled
Debug build                                    : disabled
Coverage build                                 : disabled
SITL 32-bit build                              : disabled
Checking for program 'rsync'                   : /usr/bin/rsync
'configure' finished successfully (9.480s)

The output of ./waf configure --board=MatekF405-STD on Eclipse is slightly different though (python directories and versions are different plus intelhex is disabled on cygwin for some reason):

12:17:35 **** Build of configuration Default for project ardupilot ****
"c:\\cygwin64\\bin\\python3.7m" waf -j8 configure --board=MatekF405-STD 
Setting top to                           : /cygdrive/c/Users/zinvi/Documents/github/ardupilot 
Setting out to                           : /cygdrive/c/Users/zinvi/Documents/github/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : MatekF405-STD 
Using toolchain                          : arm-none-eabi 
Checking for 'g++' (C++ compiler)        : /cygdrive/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-g++ 
Checking for 'gcc' (C compiler)          : /cygdrive/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-gcc 
Checking for c flags '-MMD'              : yes 
Checking for cxx flags '-MMD'            : yes 
CXX Compiler                             : g++ 10.2.1 
Checking for program 'make'              : /usr/bin/make 
Checking for program 'arm-none-eabi-objcopy' : /cygdrive/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-objcopy 
Including /cygdrive/c/Users/zinvi/Documents/github/ardupilot/libraries/AP_HAL_ChibiOS/hwdef/MatekF405/hwdef.dat
Removing IMU
Setup for MCU STM32F405xx
Writing hwdef setup in /cygdrive/c/Users/zinvi/Documents/github/ardupilot/build/MatekF405-STD/hwdef.h
Writing DMA map
Generating ldscript.ld
No default parameter file found
Checking for env.py
env set WITH_FATFS=1
env set PROCESS_STACK=0x1C00
env set MAIN_STACK=0x600
env set IOMCU_FW=0
env set PERIPH_FW=0
env set BOARD_FLASH_SIZE=1024
env set EXTERNAL_PROG_FLASH_MB=0
env set CPU_FLAGS=['-mcpu=cortex-m4', '-mfpu=fpv4-sp-d16', '-mfloat-abi=hard', '-DARM_MATH_CM4', '-u_printf_float']
env set CORTEX=cortex-m4
env set APJ_BOARD_ID=125
env set APJ_BOARD_TYPE=STM32F405xx
env set USBID=0x1209/0x5741
env set BOOTLOADER_EMBED=1
env set FLASH_RESERVE_START_KB=64
env set FLASH_TOTAL=983040
env set HAS_EXTERNAL_FLASH_SECTIONS=0
env set CHIBIOS_BUILD_FLAGS=USE_FATFS=yes CHIBIOS_STARTUP_MK=os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk CHIBIOS_PLATFORM_MK=os/hal/ports/STM32/STM32F4xx/platform.mk MCU=cortex-m4 ENV_UDEFS=-DCHPRINTF_USE_FLOAT=1
Enabling ChibiOS asserts                     : no 
Disabling Watchdog                           : no 
Enabling malloc guard                        : no 
Enabling ChibiOS thread statistics           : no 
Enabling -Werror                             : yes 
Checking for intelhex module:                : OK 
Checking for HAVE_CMATH_ISFINITE             : no 
Checking for HAVE_CMATH_ISINF                : no 
Checking for HAVE_CMATH_ISNAN                : no 
Checking for NEED_CMATH_ISFINITE_STD_NAMESPACE : no 
Checking for NEED_CMATH_ISINF_STD_NAMESPACE    : no 
Checking for NEED_CMATH_ISNAN_STD_NAMESPACE    : no 
Checking for header endian.h                   : not found 
Checking for header byteswap.h                 : not found 
Checking for HAVE_MEMRCHR                      : no 
Configured VSCode Intellisense:                : no 
Checking for program 'python'                  : /usr/bin/python3.7m.exe 
Checking for python version >= 2.7.0           : 3.7.10 
Checking for program 'python'                  : /usr/bin/python3.7m.exe 
Checking for python version >= 2.7.0           : 3.7.10 
Source is git repository                       : yes 
Update submodules                              : yes 
Checking for program 'git'                     : /usr/bin/git 
Gtest                                          : STM32 boards currently don't support compiling gtest 
Checking for program 'arm-none-eabi-size'      : /cygdrive/c/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-size 
Benchmarks                                     : disabled 
Unit tests                                     : disabled 
Scripting                                      : disabled 
Scripting runtime checks                       : enabled 
Debug build                                    : disabled 
Coverage build                                 : disabled 
SITL 32-bit build                              : disabled 
Checking for program 'rsync'                   : /usr/bin/rsync 
'configure' finished successfully (8.608s)

12:17:45 Build Finished. 0 errors, 0 warnings. (took 10s.519ms)

I should also mention I can build arducopter.bin with Eclipse fine no errors (just not the ‘with_bl.hex’ i need). But when running ./waf copter in cygwin I don’t and get the following error:

$ ./waf copter
Waf: Entering directory `/cygdrive/c/Users/zinvi/Documents/github/ardupilot/build/MatekF405-STD'
Checking for env.py
env added WITH_FATFS=1
env added PROCESS_STACK=0x1C00
env added MAIN_STACK=0x600
env added IOMCU_FW=0
env added PERIPH_FW=0
env added BOARD_FLASH_SIZE=1024
env added EXTERNAL_PROG_FLASH_MB=0
env appended CPU_FLAGS=['-mcpu=cortex-m4', '-mfpu=fpv4-sp-d16', '-mfloat-abi=hard', '-DARM_MATH_CM4', '-u_printf_float']
env added CORTEX=cortex-m4
env added APJ_BOARD_ID=125
env added APJ_BOARD_TYPE=STM32F405xx
env added USBID=0x1209/0x5741
env added BOOTLOADER_EMBED=1
env added FLASH_RESERVE_START_KB=64
env added FLASH_TOTAL=983040
env added HAS_EXTERNAL_FLASH_SECTIONS=0
env added CHIBIOS_BUILD_FLAGS=USE_FATFS=yes CHIBIOS_STARTUP_MK=os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk CHIBIOS_PLATFORM_MK=os/hal/ports/STM32/STM32F4xx/platform.mk MCU=cortex-m4 ENV_UDEFS=-DCHPRINTF_USE_FLOAT=1
Padded 16 bytes for bootloader.bin to 14176
Embedding file bootloader.bin:/cygdrive/c/Users/zinvi/Documents/github/ardupilot/Tools/bootloaders/MatekF405-STD_bl.bin
Embedding file font0.bin:libraries/AP_OSD/fonts/font0.bin
Embedding file hwdef.dat:/cygdrive/c/Users/zinvi/Documents/github/ardupilot/build/MatekF405-STD/hw.dat
[3/9] Creating build/MatekF405-STD/hwdef.h
[4/9] Creating build/MatekF405-STD/modules/ChibiOS/include_dirs
[5/9] Compiling libraries/AP_Scripting/generator/src/main.c
[6/9] Processing modules/mavlink/message_definitions/v1.0/ardupilotmega.xml
[7/9] Creating build/MatekF405-STD/ap_version.h
Including /cygdrive/c/Users/zinvi/Documents/github/ardupilot/libraries/AP_HAL_ChibiOS/hwdef/MatekF405/hwdef.dat
Removing IMU
Setup for MCU STM32F405xx
Writing hwdef setup in /cygdrive/c/Users/zinvi/Documents/github/ardupilot/build/MatekF405-STD/hwdef.h
Writing DMA map
Generating ldscript.ld
No default parameter file found

Waf: Leaving directory `/cygdrive/c/Users/zinvi/Documents/github/ardupilot/build/MatekF405-STD'
Build failed
Traceback (most recent call last):
  File "/cygdrive/c/Users/zinvi/Documents/github/ardupilot/modules/waf/waflib/Task.py", line 348, in process
    ret = self.run()
  File "/cygdrive/c/Users/zinvi/Documents/github/ardupilot/Tools/ardupilotwaf/mavgen.py", line 55, in run
    from pymavlink.generator import mavgen
  File "/cygdrive/c/Users/zinvi/Documents/github/ardupilot/modules/mavlink/pymavlink/generator/mavgen.py", line 26, in <module>
    from future import standard_library
ModuleNotFoundError: No module named 'future'

Don’t know if that helps but thought I should include

Ok. You appear to have 2 separate python environments installed (/usr/bin/python3.7m.exe (v3.7.10) and usr/bin/python (v3.8.10)), which is confusing Cygwin.

See Setting up the waf Build Environment on Windows using Cygwin — Dev documentation for instructions on how set the correct links for python.

If your operating system is windows 10, I suggest you can use Ubuntu under the subsystem, which will be more convenient than cygwin. Code is just need an editor, you can use VSC, even the notepad.

Note to others. We got this fixed by deleting cygwin and reinstalling it with the scripts instead.

One of the reasons he was intersested in using Eclipse is that STM has an IDE built on top of Eclipse with built-in debuggers and other tools.

If someone gets those working with ardupilot, STM32CubeIDE could be quite useful for us.

2 Likes

Hi! Please tell me the link on how to do it. Thanks!

I have the same problem now.