Tiny 2040 on-board led C programming

Hello, I am trying to write the blinke on-board led example for the Tiny 2040. I am using C programming language, and my code is built with CMake.

However NMake gives a LNK1181 error, and a U1077 errors (please note that I was able to make the led blink example work using this as a template pico-examples/blink.c at master · raspberrypi/pico-examples · GitHub).

I am wondering whether I have to create my own libraries for this project (it seems to me that the problem is in the code somewhere).

I am using this blink example as a template (pico-examples/blink.c at master · raspberrypi/pico-examples · GitHub).

And I am using this as a reference my include headers (pico-sdk/pimoroni_tiny2040.h at master · raspberrypi/pico-sdk · GitHub).

Please help me find guidance on how to make my project work ( I am reading this reference C docs - get started, tutorials, reference. | Microsoft Learn, but I guess I lack knowledge, because I did not find an answer to my question).

Just want to confirm, this is a Pimoroni Tiny2040?
I ask because there is also a Waveshare RP2040 Tiny.

It’s a little hard to tell without seeing your project files; LNK1181 is a “file not found” error from the linker, so at a guess I’d say your CMakeLists.txt file is probably off - the actual error message text will give you a better idea of exactly where the problem lies.

Yes, it is Pimoroni Tiny 2040.

Sorry, here are the details:

  1. Code from tiny2040_RGB_blink.c
 * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
 * SPDX-License-Identifier: BSD-3-Clause

#include "pico/stdlib.h"
#include <stdio.h>

#define PIMORONI_TINY2040_8MB

#define TINY2040_LED_R_PIN 18
#define TINY2040_LED_G_PIN 19
#define TINY2040_LED_B_PIN 20

int main(){
    const uint LED_PIN_R = TINY2040_LED_R_PIN;
    const uint LED_PIN_G = TINY2040_LED_G_PIN;
    const uint LED_PIN_B = TINY2040_LED_B_PIN;
    gpio_set_dir(LED_PIN_R, GPIO_OUT); 
    gpio_set_dir(LED_PIN_G, GPIO_OUT);
    gpio_set_dir(LED_PIN_B, GPIO_OUT);
    while (true) {
        gpio_put(LED_PIN_R, 1);
        gpio_put(LED_PIN_R, 0);
        gpio_put(LED_PIN_G, 1);
        gpio_put(LED_PIN_G, 0);
        gpio_put(LED_PIN_B, 1);
        gpio_put(LED_PIN_B, 0);
  1. CMakeLists.txt
cmake_minimum_required(VERSION 3.13)

#initialize pico-sdk from GIT
#(note this can come from environment, CMake cache etc.)

#initialize the SDK based on PICO_SDK_PATH
#note: this must happen before the project()


project(tiny2040_RGB_blink C CXX ASM)


#initialize the Raspberry Pi Pico SDK

//# add url via pico_set_program_url
//# example_auto_set_url(tiny2040_RGB_blink)


//# pull in common dependencies
target_link_libraries(tiny2040_RGB_blink pico_stdlib)

//# create map/bin/hex file etc.
  1. Output in Developer Command Prompt after executing ‘nmake’ command
[  1%] Performing build step for 'ELF2UF2Build'
[100%] Built target elf2uf2
[  2%] No install step for 'ELF2UF2Build'
[  4%] Completed 'ELF2UF2Build'
[ 11%] Built target ELF2UF2Build
[ 13%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
cl : Command line warning D9021 : no action performed
[ 14%] Linking ASM executable bs2_default.elf
Microsoft (R) Incremental Linker Version 14.35.32215.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'CMakeFiles\bs2_default.dir\compile_time_choice.S.obj'

Please note that there is also a NMake fatal error U1077 in the output (for some reason it did not write entire output to .txt file after executing nmake > PATH/TO/OUTPUT.TXT).

Strangely today after starting VSCode from Developer Comand Prompt (executing ‘code’ command) the project has been built successfully.

Unfortunately I cannot verify if my .uf2 file works as intended because my Tiny 2040 stopped working (does not respond to boot and reset) after I desoldered debug pin headers yesterday.

I would still appreciate any guidance regarding flaws in my project.

If you enclose code in triple backticks ( ``` ) it stops the forum trying to apply formatting to it and makes everything more readable - I’ve added them into the above post for you :)

If you click the Preformatted Text option, the </>, it sets it all up for you.

1 Like

Great, thank you hel!

Thank you alphanumeric!