[SOLVED] Problem compiling RP2040-HAT-C examples

Hi all, sorry for, i think, a noob question. I’m starting to use 5500-pico-evb and I’m trying to compile the examples available in GitHub - Wiznet/RP2040-HAT-C: Ethernet Example for RP2040

Environment: Windows 10 + Visual Studio Code.

I’ve already installed the pico sdk (1.5.1) in its default directory (documents\Pico-v1.5.1)
and I’ve installed the repository RP2040-HAT-C using the command: git clone --recurse-submodules GitHub - Wiznet/RP2040-HAT-C: Ethernet Example for RP2040

Using VS (started using the pico sdk shortcut in the start menu) (pico - Visual Studio Code) I’m able to compile every pico-sdk example.

Using the same enviroment i do:

  1. open folder - opening the root RP2040-HAT-C folder: it’s installed at the same level of pico sdk examples:
    C:\Users\fulvi\Documents\Pico-v1.5.1\RP2040-HAT-C
    C:\Users\fulvi\Documents\Pico-v1.5.1\pico-examples

The cmake generation is this one:

[driver] Switching to kit: Pico ARM GCC
[driver] Removing c:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build/CMakeCache.txt
[driver] Removing c:\Users\fulvi\Documents\Pico-v1.5.1\RP2040-HAT-C\build\CMakeFiles
[main] Configuring project: RP2040-HAT-C 
[proc] Executing command: "C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\cmake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug "-DCMAKE_MODULE_PATH:STRING=C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk-tools" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE "-DCMAKE_TOOLCHAIN_FILE:FILEPATH=C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk/cmake/preload/toolchains/pico_arm_gcc.cmake" -SC:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C -Bc:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- PICO_SDK_PATH = C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/pico-sdk
[cmake] -- Found Git: C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/git/cmd/git.exe (found version "2.39.1.windows.1") 
[cmake] RP2040-HAT-C patch utils found
[cmake] cleaning ioLibrary_Driver...
[cmake] HEAD is now at ce4a7b6 Fix W5100S getIR()
[cmake] ioLibrary_Driver cleaned
[cmake] cleaning mbedtls...
[cmake] HEAD is now at 8df2f8e7b Merge pull request #842 from ARMmbed/mbedtls-3.0.0rc0-pr
[cmake] mbedtls cleaned
[cmake] cleaning pico-extras...
[cmake] HEAD is now at 18de339 pick up new version of pico_sdk_import.cmake - only really relevant to optimize git download of pico-sdk
[cmake] pico-extras cleaned
[cmake] cleaning pico-sdk...
[cmake] HEAD is now at 2e6142b SDK 1.4.0 release
[cmake] pico-sdk cleaned
[cmake] submodules ioLibrary_Driver initialised
[cmake] Running patch C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/patches/01_iolibrary_driver_ftp_client.patch
[cmake] PICO_SDK_PATH is C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/pico-sdk
[cmake] Defaulting PICO_PLATFORM to rp2040 since not specified.
[cmake] -- RP2040-HAT-C SDK version is 2.3.0
[cmake] -- The C compiler identification is GNU 10.3.1
[cmake] -- The CXX compiler identification is GNU 10.3.1
[cmake] -- The ASM compiler identification is GNU
[cmake] -- Found assembler: C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/gcc-arm-none-eabi/bin/arm-none-eabi-g++.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] Build type is Debug
[cmake] Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)
[cmake] Defaulting PICO target board to pico since not specified.
[cmake] Using board configuration from C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/pico-sdk/src/boards/include/boards/pico.h
[cmake] -- Found Python3: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0/python3.10.exe (found version "3.10.11") found components: Interpreter 
[cmake] TinyUSB available at C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
[cmake] Compiling TinyUSB with CFG_TUSB_DEBUG=1
[cmake] cyw43-driver available at C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/pico-sdk/lib/cyw43-driver
[cmake] lwIP available at C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/pico-sdk/lib/lwip
[cmake] Using PICO_EXAMPLES_PATH from environment ('C:\Users\fulvi\Documents\Pico-v1.5.1\pico-examples')
[cmake] -- WIZNET_CHIP = W5100S
[cmake] -- WIZNET_DIR = C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/ioLibrary_Driver
[cmake] -- MBEDTLS_DIR = C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/mbedtls
[cmake] -- PORT_DIR = C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/port
[cmake] -- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS
[cmake] -- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build

But when i try to compile an example always i get:

[main] Building folder: RP2040-HAT-C w5x00_dhcp_dns
[build] Starting build
[proc] Executing command: chcp
[proc] Executing command: "C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\cmake\bin\cmake.EXE" --build c:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build --config Debug --target w5x00_dhcp_dns --
[build] [6/197   0% :: 0.512] Building C object libraries/CMakeFiles/ETHERNET_FILES.dir/ioLibrary_Driver/Ethernet/W5100S/w5100s.c.obj
[build] [7/197   1% :: 0.589] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[build] [8/197   1% :: 0.608] Building C object libraries/CMakeFiles/ETHERNET_FILES.dir/ioLibrary_Driver/Ethernet/socket.c.obj
[build] [9/197   2% :: 0.887] Building C object libraries/CMakeFiles/W5100S_FILES.dir/ioLibrary_Driver/Ethernet/socket.c.obj
[build] [10/197   2% :: 0.940] Building C object libraries/CMakeFiles/W5100S_FILES.dir/ioLibrary_Driver/Ethernet/wizchip_conf.c.obj
[build] [11/197   3% :: 1.157] Linking ASM executable pico-sdk\src\rp2_common\boot_stage2\bs2_default.elf
[build] [12/197   3% :: 1.251] Building C object libraries/CMakeFiles/DNS_FILES.dir/ioLibrary_Driver/Internet/DNS/dns.c.obj
[build] [13/197   4% :: 1.261] Generating bs2_default.bin
[build] [14/197   4% :: 1.290] Building C object libraries/CMakeFiles/DHCP_FILES.dir/ioLibrary_Driver/Internet/DHCP/dhcp.c.obj
[build] [15/197   5% :: 1.517] Linking C static library libraries\libDHCP_FILES.a
[build] [15/197   5% :: 1.525] Linking C static library libraries\libDNS_FILES.a
[build] [15/197   6% :: 1.834] Building C object libraries/CMakeFiles/ETHERNET_FILES.dir/ioLibrary_Driver/Ethernet/wizchip_conf.c.obj
[build] [15/197   6% :: 1.834] Building C object libraries/CMakeFiles/W5100S_FILES.dir/ioLibrary_Driver/Ethernet/W5100S/w5100s.c.obj
[build] [16/197   7% :: 1.843] Generating bs2_default_padded_checksummed.S
[build] [20/197   7% :: 2.358] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/ioLibrary_Driver/src/w5x00_gpio_irq.c.obj
[build] [21/197   8% :: 2.394] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/rp2_common/pico_stdlib/stdlib.c.obj
[build] [22/197   8% :: 2.449] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/rp2_common/hardware_gpio/gpio.c.obj
[build] [23/197   9% :: 2.487] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/ioLibrary_Driver/src/w5x00_spi.c.obj
[build] [24/197   9% :: 2.779] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/rp2_common/pico_platform/platform.c.obj
[build] [25/197  10% :: 2.881] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/rp2_common/hardware_claim/claim.c.obj
[build] [26/197  10% :: 2.904] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/rp2_common/hardware_sync/sync.c.obj
[build] [27/197  11% :: 3.052] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/rp2_common/hardware_irq/irq.c.obj
[build] [28/197  11% :: 3.203] Building ASM object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/rp2_common/hardware_irq/irq_handler_chain.S.obj
[build] [29/197  12% :: 3.352] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/common/pico_sync/lock_core.c.obj
[build] [30/197  12% :: 3.569] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/common/pico_sync/sem.c.obj
[build] [31/197  13% :: 3.704] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/common/pico_time/timeout_helper.c.obj
[build] [32/197  13% :: 3.764] Performing configure step for 'ELF2UF2Build'
[build] FAILED: examples/dhcp_dns/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build/examples/dhcp_dns/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure 
[build] cmd.exe /C "cd /D C:\Users\fulvi\Documents\Pico-v1.5.1\RP2040-HAT-C\build\elf2uf2 && "C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\cmake\bin\cmake.exe" -GNinja C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/libraries/pico-sdk/tools/elf2uf2 && "C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\cmake\bin\cmake.exe" -E touch C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build/examples/dhcp_dns/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure"
[build] -- The C compiler identification is unknown
[build] -- The CXX compiler identification is unknown
[build] CMake Error at CMakeLists.txt:2 (project):
[build]   No CMAKE_C_COMPILER could be found.
[build] 
[build]   Tell CMake where to find the compiler by setting either the environment
[build]   variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
[build]   the compiler, or to the compiler name if it is in the PATH.
[build] 
[build] 
[build] CMake Error at CMakeLists.txt:2 (project):
[build]   No CMAKE_CXX_COMPILER could be found.
[build] 
[build]   Tell CMake where to find the compiler by setting either the environment
[build]   variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
[build]   to the compiler, or to the compiler name if it is in the PATH.
[build] 
[build] 
[build] -- Configuring incomplete, errors occurred!
[build] See also "C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build/elf2uf2/CMakeFiles/CMakeOutput.log".
[build] See also "C:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build/elf2uf2/CMakeFiles/CMakeError.log".
[build] [32/197  14% :: 3.977] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/rp2_common/hardware_timer/timer.c.obj
[build] [32/197  14% :: 4.042] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/common/pico_time/time.c.obj
[build] [32/197  15% :: 4.146] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/common/pico_util/datetime.c.obj
[build] [32/197  15% :: 4.342] Building C object port/CMakeFiles/IOLIBRARY_FILES.dir/__/libraries/pico-sdk/src/common/pico_util/pheap.c.obj
[build] [32/197  16% :: 4.399] Linking C static library libraries\libW5100S_FILES.a
[build] ninja: build stopped: subcommand failed.
[proc] The command: "C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\cmake\bin\cmake.EXE" --build c:/Users/fulvi/Documents/Pico-v1.5.1/RP2040-HAT-C/build --config Debug --target w5x00_dhcp_dns -- exited with code: 1
[driver] Build completed: 00:00:04.542
[build] Build finished with exit code 1

Does anyone have solved this problem that is preventing me to go on ?

Thanks a lot

Edit: some typo

1 Like

I’ve found this discussion that give me the info I need:
https://forums.raspberrypi.com/viewtopic.php?t=350982

The problem I’ve understood is that you need the windows sdk too in order to compile the tools elf2uf2 and pioasm.

Following the thread linked above I’ve downloaded a precompiled version od the tools from here: https://sourceforge.net/projects/rpi-pico-utils/files/v1.3.0/ and saved them into the pico sdk directory:
C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\picotool

Then I’ve added to the file C:\Users\fulvi\Documents\Pico-v1.5.1\RP2040-HAT-C\CMakeLists.txt the following lines (just before the pico_sdk_init() line:

# Avoid building 'pioasm'
add_executable(Pioasm IMPORTED)
set_property(TARGET Pioasm PROPERTY IMPORTED_LOCATION
"C:\\Program Files\\Raspberry Pi\\Pico SDK v1.5.1\\picotool\\pioasm.exe")
set(Pioasm_FOUND 1)

# Avoid building 'elf2uf2'

add_executable(ELF2UF2 IMPORTED)
set_property(TARGET ELF2UF2 PROPERTY IMPORTED_LOCATION
"C:\\Program Files\\Raspberry Pi\\Pico SDK v1.5.1\\picotool\\elf2uf2.exe")
set(ELF2UF2_FOUND 1)

the full file is:

# CMake minimum required version
cmake_minimum_required(VERSION 3.12)

# Pull in SDK (must be before project)
if(NOT DEFINED PICO_SDK_PATH)
    set(PICO_SDK_PATH ${CMAKE_SOURCE_DIR}/libraries/pico-sdk)
    message(STATUS "PICO_SDK_PATH = ${PICO_SDK_PATH}")
endif()

include(rp2040_hat_c-patch.cmake)
include(pico_sdk_import.cmake)
include(rp2040_hat_c_sdk_version.cmake)

# Set project name
set(PROJECT_NAME RP2040-HAT-C)

# Set project informations
project(${PROJECT_NAME} C CXX ASM)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Avoid building 'pioasm'
add_executable(Pioasm IMPORTED)
set_property(TARGET Pioasm PROPERTY IMPORTED_LOCATION
"C:\\Program Files\\Raspberry Pi\\Pico SDK v1.5.1\\picotool\\pioasm.exe")
set(Pioasm_FOUND 1)

# Avoid building 'elf2uf2'

add_executable(ELF2UF2 IMPORTED)
set_property(TARGET ELF2UF2 PROPERTY IMPORTED_LOCATION
"C:\\Program Files\\Raspberry Pi\\Pico SDK v1.5.1\\picotool\\elf2uf2.exe")
set(ELF2UF2_FOUND 1)

# Initialize the SDK
pico_sdk_init()

# Set ethernet chip
set(WIZNET_CHIP W5500)

if(${WIZNET_CHIP} STREQUAL W5100S)
    add_definitions(-D_WIZCHIP_=W5100S)
elseif(${WIZNET_CHIP} STREQUAL W5500)
    add_definitions(-D_WIZCHIP_=W5500)
else()
    message(FATAL_ERROR "WIZNET_CHIP is wrong = ${WIZNET_CHIP}")
endif()

message(STATUS "WIZNET_CHIP = ${WIZNET_CHIP}")

# Set the project root directory if it's not already defined, as may happen if
# the tests folder is included directly by a parent project, without including
# the top level CMakeLists.txt.
if(NOT DEFINED WIZNET_DIR)
    set(WIZNET_DIR ${CMAKE_SOURCE_DIR}/libraries/ioLibrary_Driver)
    message(STATUS "WIZNET_DIR = ${WIZNET_DIR}")
endif()

if(NOT DEFINED MBEDTLS_DIR)
    set(MBEDTLS_DIR ${CMAKE_SOURCE_DIR}/libraries/mbedtls)
    message(STATUS "MBEDTLS_DIR = ${MBEDTLS_DIR}")
endif()

if(NOT DEFINED PORT_DIR)
    set(PORT_DIR ${CMAKE_SOURCE_DIR}/port)
    message(STATUS "PORT_DIR = ${PORT_DIR}")
endif()

# Turn off mbedtls test mode 
set(ENABLE_PROGRAMS OFF CACHE BOOL "Build mbedtls programs")
set(ENABLE_TESTING OFF CACHE BOOL "Build mbedtls testing")
add_definitions(-DMBEDTLS_CONFIG_FILE="${PORT_DIR}/mbedtls/inc/ssl_config.h")
add_definitions(-DSET_TRUSTED_CERT_IN_SAMPLES)

# Hardware-specific examples in subdirectories:
add_subdirectory(examples)

# Add libraries in subdirectories
add_subdirectory(${CMAKE_SOURCE_DIR}/libraries)
add_subdirectory(${MBEDTLS_DIR})
add_subdirectory(${PORT_DIR})

# Set compile options
add_compile_options(
        -Wall
        -Wno-format          # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
        -Wno-unused-function # we have some for the docs that aren't called
        -Wno-maybe-uninitialized
        )

This solved the problem and currently i’m able to compile wiznet’s examples
In the next days i’ll try to run them.

2 Likes

Thank you so much for the great information.

Thank you Fulvietto for saving 3 days of my life! Professional presentation and comprehensive solution!
With best wishes:
Svetlin, eta-sys