Pinmap not found for peripheral -- Location: 0x8005E77 and rubbish in terminal

When I compile and download my code I get an error:
“Pinmap not found for peripheral – Location: 0x8005E77”

I can only see it on the scope. For an unknown reason my Putty shows rubbish, even at the right settings and speed. I think there is not enough space between the bytes:

image

I created those new files in my project:

/HMC20/PeripheralPinMaps.h:
/HMC20/PinNames.h
/HMC20/PeripheralPins.c
custom_targets.json → where I did at most as possible removes to isolate the problem

Files can be downloaded here for checkup.

Hello,

this error occurs when you use pins from different peripherals.
For example when you use SDA pin from I2C1 and CLK pin from I2C2, this will trigger this exception.

BR, Jan

How can I see that? If you use for instance serial port there is no option to select the number of the port. The pins can be assigned to different ports.

Yes, but that is your responsibility because there is no option how to do it automatically. So you have to look to MCU pinout or to your PeripheralPinMaps.h (if is filled correctly), there is the information (first and second column) from where also Mbed takes the data for comparation at runtime.

BR, Jan

So it means that in that file you have to put every line in comment that you not need in your application? So that every assignment in pinmaps is unique?

Interesting idea but this is not necessary.

I don’t think so. One pin can be assigned for more different peripherals and again it is up to you how you will manage it.

It is simple. When you chose to use BufferedSerial API then you are responsible also to chose correct pins. When is this peripheral initialized then the API look to this table and search what peripheral it is (because some MCUs have up to se 7 UARTs) and which a function this pin has.

Thanks to this the API knows what HALs should be called. That is necasary because HALs are ussually set just for specific peripheral. For example like HAL_RCC_USART1_CLK_ENABLE() and HAL_RCC_USART2_CLK_ENABLE() and so on.

Another benefit is there can be this exception what will prevent your from using wrong pins.

BR, Jan

I double checked all the pin definitions. I enabled only the pinmap definitions I use in my project. I disabled almost all peripherals and cutted in my code to make it compilable again and I still get the same message on the scope. It’s like there is a ‘hidden’ peripheral that is not able to find his pinmap.

In my custom_targets.json I disabled the maximum amount of peripherals:

        "device_has_remove": [
            "ANALOGOUT",
            "CAN",
            "CRC",
            "TRNG",
            "SERIAL_ASYNCH",
            "USTICKER",
            "LPTICKER",
            "RTC",
            "ANALOGIN",
            "I2C",
            "I2CSLAVE",
            "I2C_ASYNC",
            "INTERRUPTIN",
            "PORTIN",
            "PORTINOUT",
            "PORTOUT",
            "PWMOUT",
            "SERIAL",
            "SERIAL_FC",
            "SLEEP",
            "SPI",
            "SPISLAVE",
            "SPI_ASYNCH",
            "STDIO_MESSAGES",
            "WATCHDOG",
            "RESET_REASON"
        ]

A part of what is generated in mbed_config.cmake:

include_guard(GLOBAL)

set(MBED_TOOLCHAIN "GCC_ARM" CACHE STRING "")
set(MBED_TARGET "HMC20" CACHE STRING "")
set(MBED_CPU_CORE "Cortex-M33FE" CACHE STRING "")
set(MBED_C_LIB "std" CACHE STRING "")
set(MBED_PRINTF_LIB "std" CACHE STRING "")
set(MBED_OUTPUT_EXT "" CACHE STRING "")
set(MBED_GREENTEA_TEST_RESET_TIMEOUT "" CACHE STRING "")

list(APPEND MBED_TARGET_SUPPORTED_C_LIBS 
    std
    small
)

list(APPEND MBED_TARGET_SUPPORTED_APPLICATION_PROFILES 
    full
    bare-metal
)

list(APPEND MBED_TARGET_LABELS
    HMC20
    M33
    MCU_STM32
    LIKE_CORTEX_M33
    CORTEX
    Target
    MCU_STM32U5
    CORTEX_M
    MCU_STM32U575xG

    STM32U575xG
    STM
    STM32U5

    FLASHIAP

)

# target
set(MBED_TARGET_DEFINITIONS
    COMPONENT_FLASHIAP=1


    DEVICE_I2C_ASYNCH=1
    DEVICE_FLASH=1
    DEVICE_MPU=1

    TARGET_HMC20
    TARGET_M33
    TARGET_MCU_STM32
    TARGET_LIKE_CORTEX_M33
    TARGET_CORTEX
    TARGET_Target
    TARGET_MCU_STM32U5
    TARGET_CORTEX_M
    TARGET_MCU_STM32U575xG

    TARGET_STM32U575xG
    TARGET_STM
    TARGET_STM32U5



    MBED_ROM_SIZE=0x100000


    MBED_RAM_SIZE=0xc0000
    TARGET_LIKE_MBED
    __MBED__=1
)
...

The exception is triggered directly in constructor or initialization of any API (where are some pins). So which APIs/libraries do you use in your project?

BR, Jan

To splitup complexities I first setup a test project to test all peripherals. I think the issue was that in my orginal project there was some piece of code:

//Create a BufferedSerial object to be used by the system I/O retarget code.
FileHandle* mbed::mbed_override_console(int fd) {
    static BufferedSerial serial_port(USBTX, USBRX, DEBUG_SERIAL_SPEED);
    return &serial_port;
}

Which is conflicting with the new pinmap config.
But I will confirm after I have a reference project with working uart and external clock. Then I can use that config and enable all functionality in my original project one by one.