Home > Mobile >  Error when compiling code for raspberry pi Pico using MinGW
Error when compiling code for raspberry pi Pico using MinGW

Time:07-18

I am trying to setup the toolchain for programming a raspberry pi pico using the pico_sdk and MinGW. I have followed this guide : here

I am on windows 10, visual studio code. Everything is setup according to the guide.

I get an error -1073741511 with a simple blink code on the make command (mingw32-make). what am I doing wrong ?

CMakeLists.txt :

cmake_minimum_required(VERSION 3.13)
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)

project(blink)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()
add_executable(${PROJECT_NAME} main.c)
target_link_libraries(${PROJECT_NAME} pico_stdlib)
pico_add_extra_outputs(${PROJECT_NAME})

main.c :

#include "pico/stdlib.h"

int main() {
    const uint led_pin = 25;
    gpio_init(led_pin);
    gpio_set_dir(led_pin, GPIO_OUT);

    while (true) {
        gpio_put(led_pin, true);
        sleep_ms(1000);
        gpio_put(led_pin, false);
        sleep_ms(1000);
    }
}

full console output :

myuser MINGW64 ~/Documents/rpi_pico/C/blink/build
$ cmake -G "MinGW Makefiles" ..
Using PICO_SDK_PATH from environment ('C:\VSARM\sdk\pico\pico-sdk')
PICO_SDK_PATH is C:/VSARM/sdk/pico/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
-- Defaulting build type to 'Release' since not specified.
PICO compiler is pico_arm_gcc
-- The C compiler identification is GNU 11.2.1
-- The CXX compiler identification is GNU 11.2.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/VSARM/armcc/11.2-2022.02/bin/arm-none-eabi-gcc.exe
Build type is Release
Defaulting PICO target board to pico since not specified.
Using board configuration from C:/VSARM/sdk/pico/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: C:/Users/myuser/AppData/Local/Programs/Python/Python310/python.exe (found version "3.10.5") found components: Interpreter
TinyUSB available at C:/VSARM/sdk/pico/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
cyw43-driver available at C:/VSARM/sdk/pico/pico-sdk/lib/cyw43-driver
lwIP available at C:/VSARM/sdk/pico/pico-sdk/lib/lwip
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/myuser/Documents/rpi_pico/C/blink/build

myuser MINGW64 ~/Documents/rpi_pico/C/blink/build
$ make
[  1%] Creating directories for 'ELF2UF2Build'
[  2%] No download step for 'ELF2UF2Build'
[  4%] No update step for 'ELF2UF2Build'
[  5%] No patch step for 'ELF2UF2Build'
[  7%] Performing configure step for 'ELF2UF2Build'
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/VSARM/mingw/mingw32/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/VSARM/mingw/mingw32/bin/g  .exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/myuser/Documents/rpi_pico/C/blink/build/elf2uf2
[  8%] Performing build step for 'ELF2UF2Build'
[ 50%] Building CXX object CMakeFiles/elf2uf2.dir/main.cpp.obj
[100%] Linking CXX executable elf2uf2.exe
[100%] Built target elf2uf2
[ 10%] No install step for 'ELF2UF2Build'
[ 11%] Completed 'ELF2UF2Build'
[ 11%] Built target ELF2UF2Build
Scanning dependencies of target bs2_default
[ 13%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[ 14%] Linking ASM executable bs2_default.elf
[ 14%] Built target bs2_default
[ 16%] Generating bs2_default.bin
[ 17%] Generating bs2_default_padded_checksummed.S
[ 17%] Built target bs2_default_padded_checksummed_asm
Scanning dependencies of target blink
[ 19%] Building C object CMakeFiles/blink.dir/main.c.obj
[ 20%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_stdlib/stdlib.c.obj
[ 22%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_gpio/gpio.c.obj
[ 23%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_claim/claim.c.obj
[ 25%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_platform/platform.c.obj
[ 26%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_sync/sync.c.obj
[ 28%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_irq/irq.c.obj
[ 29%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_irq/irq_handler_chain.S.obj
[ 31%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_sync/sem.c.obj
[ 32%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_sync/lock_core.c.obj
[ 34%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_time/time.c.obj
[ 35%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_time/timeout_helper.c.obj
[ 37%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_timer/timer.c.obj
[ 38%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_util/datetime.c.obj
[ 40%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_util/pheap.c.obj
[ 41%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_util/queue.c.obj
[ 43%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_sync/mutex.c.obj
[ 44%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/common/pico_sync/critical_section.c.obj
[ 46%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_uart/uart.c.obj
[ 47%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_divider/divider.S.obj
[ 49%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_runtime/runtime.c.obj
[ 50%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_clocks/clocks.c.obj
[ 52%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_pll/pll.c.obj
[ 53%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_vreg/vreg.c.obj
[ 55%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_watchdog/watchdog.c.obj
[ 56%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/hardware_xosc/xosc.c.obj
[ 58%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_printf/printf.c.obj
[ 59%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_bit_ops/bit_ops_aeabi.S.obj
[ 61%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_bootrom/bootrom.c.obj
[ 62%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_divider/divider.S.obj
[ 64%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_double/double_aeabi.S.obj
[ 65%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_double/double_init_rom.c.obj
[ 67%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_double/double_math.c.obj
[ 68%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_double/double_v1_rom_shim.S.obj
[ 70%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S.obj
[ 71%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_float/float_aeabi.S.obj
[ 73%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_float/float_init_rom.c.obj
[ 74%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_float/float_math.c.obj
[ 76%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_float/float_v1_rom_shim.S.obj
[ 77%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_malloc/pico_malloc.c.obj
[ 79%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_mem_ops/mem_ops_aeabi.S.obj
[ 80%] Building ASM object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_standard_link/crt0.S.obj
[ 82%] Building CXX object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_standard_link/new_delete.cpp.obj
[ 83%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_standard_link/binary_info.c.obj
[ 85%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_stdio/stdio.c.obj
[ 86%] Building C object CMakeFiles/blink.dir/C_/VSARM/sdk/pico/pico-sdk/src/rp2_common/pico_stdio_uart/stdio_uart.c.obj
[ 88%] Linking CXX executable blink.elf
mingw32-make[2]: *** [CMakeFiles\blink.dir\build.make:812: blink.elf] Error -1073741511
mingw32-make[2]: *** Deleting file 'blink.elf'
mingw32-make[1]: *** [CMakeFiles\Makefile2:1384: CMakeFiles/blink.dir/all] Error 2
mingw32-make: *** [Makefile:90: all] Error 2

myuser MINGW64 ~/Documents/rpi_pico/C/blink/build
$

I also get the same error running the make command on the blink example provided in the pico sdk like so :

cd /c/VSARM/sdk/pico/pico-examples/
mkdir build
cd build
cmake -G "MinGW Makefiles" ..
cd blink
make

CodePudding user response:

I was following the exact same guide with exactly the same results today. I finally got it working by switching to a different version of MinGW. In my case I selected "x86_64-12.1.0-release-posix-sjlj-rt_v10-rev3.7z" from https://github.com/niXman/mingw-builds-binaries/releases. I actually have no idea what this posix/win32 and seh/sjlj means but x86_64 should be for AMD processors and i686 for Intel afaik. Hope this works for you too :)

  • Related