daniil1
Posts: 3
Joined: Fri Jul 30, 2021 10:31 am

Build project with makefile

Fri Jul 30, 2021 11:27 am

I am trying to build a project "blink" using a makefile. But it throws an unknown error, what am I doing wrong

Here is the makefile itself:

Code: Select all

CXX      = arm-none-eabi-g++.exe
MCU      = -mcpu=cortex-m0plus
FLAG1    = -mthumb -O3 -DNDEBUG -Wl,--build-id=none
SPECS    = --specs=nosys.specs
PICO_SDK = K:\sdk
PICO_EXAMPLES = K:\example
PICO_OBJ = K:\obj

FLAG2    = \
	-Wl,--wrap=sprintf -Wl,--wrap=snprintf -Wl,--wrap=vsnprintf \
	-Wl,--wrap=__clzsi2 -Wl,--wrap=__clzdi2 -Wl,--wrap=__ctzsi2 -Wl,--wrap=__ctzdi2 \
	-Wl,--wrap=__popcountsi2 -Wl,--wrap=__popcountdi2 -Wl,--wrap=__clz -Wl,--wrap=__clzl \
	-Wl,--wrap=__clzll -Wl,--wrap=__aeabi_idiv -Wl,--wrap=__aeabi_idivmod -Wl,--wrap=__aeabi_ldivmod \
	-Wl,--wrap=__aeabi_uidiv -Wl,--wrap=__aeabi_uidivmod -Wl,--wrap=__aeabi_uldivmod -Wl,--wrap=__aeabi_dadd \
	-Wl,--wrap=__aeabi_ddiv -Wl,--wrap=__aeabi_dmul -Wl,--wrap=__aeabi_drsub -Wl,--wrap=__aeabi_dsub \
	-Wl,--wrap=__aeabi_cdcmpeq -Wl,--wrap=__aeabi_cdrcmple -Wl,--wrap=__aeabi_cdcmple -Wl,--wrap=__aeabi_dcmpeq \
	-Wl,--wrap=__aeabi_dcmplt -Wl,--wrap=__aeabi_dcmple -Wl,--wrap=__aeabi_dcmpge -Wl,--wrap=__aeabi_dcmpgt \
	-Wl,--wrap=__aeabi_dcmpun -Wl,--wrap=__aeabi_i2d -Wl,--wrap=__aeabi_l2d -Wl,--wrap=__aeabi_ui2d \
	-Wl,--wrap=__aeabi_ul2d -Wl,--wrap=__aeabi_d2iz -Wl,--wrap=__aeabi_d2lz -Wl,--wrap=__aeabi_d2uiz \
	-Wl,--wrap=__aeabi_d2ulz -Wl,--wrap=__aeabi_d2f -Wl,--wrap=sqrt -Wl,--wrap=cos \
	-Wl,--wrap=sin -Wl,--wrap=tan -Wl,--wrap=atan2 -Wl,--wrap=exp -Wl,--wrap=log -Wl,--wrap=ldexp \
	-Wl,--wrap=copysign -Wl,--wrap=trunc -Wl,--wrap=floor -Wl,--wrap=ceil -Wl,--wrap=round \
	-Wl,--wrap=sincos -Wl,--wrap=asin -Wl,--wrap=acos -Wl,--wrap=atan -Wl,--wrap=sinh -Wl,--wrap=cosh \
	-Wl,--wrap=tanh -Wl,--wrap=asinh -Wl,--wrap=acosh -Wl,--wrap=atanh -Wl,--wrap=exp2 -Wl,--wrap=log2 \
	-Wl,--wrap=exp10 -Wl,--wrap=log10 -Wl,--wrap=pow -Wl,--wrap=powint -Wl,--wrap=hypot -Wl,--wrap=cbrt \
	-Wl,--wrap=fmod -Wl,--wrap=drem -Wl,--wrap=remainder -Wl,--wrap=remquo -Wl,--wrap=expm1 \
	-Wl,--wrap=log1p -Wl,--wrap=fma -Wl,--wrap=__aeabi_lmul -Wl,--wrap=__aeabi_fadd -Wl,--wrap=__aeabi_fdiv \
	-Wl,--wrap=__aeabi_fmul -Wl,--wrap=__aeabi_frsub -Wl,--wrap=__aeabi_fsub -Wl,--wrap=__aeabi_cfcmpeq \
	-Wl,--wrap=__aeabi_cfrcmple -Wl,--wrap=__aeabi_cfcmple -Wl,--wrap=__aeabi_fcmpeq \
	-Wl,--wrap=__aeabi_fcmplt -Wl,--wrap=__aeabi_fcmple -Wl,--wrap=__aeabi_fcmpge -Wl,--wrap=__aeabi_fcmpgt \
	-Wl,--wrap=__aeabi_fcmpun -Wl,--wrap=__aeabi_i2f -Wl,--wrap=__aeabi_l2f -Wl,--wrap=__aeabi_ui2f \
	-Wl,--wrap=__aeabi_ul2f -Wl,--wrap=__aeabi_f2iz -Wl,--wrap=__aeabi_f2lz -Wl,--wrap=__aeabi_f2uiz \
	-Wl,--wrap=__aeabi_f2ulz -Wl,--wrap=__aeabi_f2d -Wl,--wrap=sqrtf -Wl,--wrap=cosf -Wl,--wrap=sinf \
	-Wl,--wrap=tanf -Wl,--wrap=atan2f -Wl,--wrap=expf -Wl,--wrap=logf -Wl,--wrap=ldexpf -Wl,--wrap=copysignf \
	-Wl,--wrap=truncf -Wl,--wrap=floorf -Wl,--wrap=ceilf -Wl,--wrap=roundf -Wl,--wrap=sincosf \
	-Wl,--wrap=asinf -Wl,--wrap=acosf -Wl,--wrap=atanf -Wl,--wrap=sinhf -Wl,--wrap=coshf -Wl,--wrap=tanhf \
	-Wl,--wrap=asinhf -Wl,--wrap=acoshf -Wl,--wrap=atanhf -Wl,--wrap=exp2f -Wl,--wrap=log2f \
	-Wl,--wrap=exp10f -Wl,--wrap=log10f -Wl,--wrap=powf -Wl,--wrap=powintf -Wl,--wrap=hypotf \
	-Wl,--wrap=cbrtf -Wl,--wrap=fmodf -Wl,--wrap=dremf -Wl,--wrap=remainderf -Wl,--wrap=remquof -Wl,--wrap=expm1f \
	-Wl,--wrap=log1pf -Wl,--wrap=fmaf -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=memcpy \
	-Wl,--wrap=memset -Wl,--wrap=__aeabi_memcpy -Wl,--wrap=__aeabi_memset -Wl,--wrap=__aeabi_memcpy4 \
	-Wl,--wrap=__aeabi_memset4 -Wl,--wrap=__aeabi_memcpy8 -Wl,--wrap=__aeabi_memset8

MAP    = -Wl,-Map=blink.elf.map

SKRIPT = -Wl,--script=$(PICO_SDK)/src/rp2_common/pico_standard_link/memmap_default.ld

FLAG3  = \
	-Wl,--gc-sections -Wl,--wrap=printf -Wl,--wrap=vprintf -Wl,--wrap=puts -Wl,--wrap=putchar -Wl,--wrap=getchar

OBJ = blink.c.obj \
	$(PICO_OBJ)/rp2_common/pico_stdlib/stdlib.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_gpio/gpio.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_claim/claim.c.obj \
	$(PICO_OBJ)/rp2_common/pico_platform/platform.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_sync/sync.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_uart/uart.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_divider/divider.S.obj \
	$(PICO_OBJ)/common/pico_time/time.c.obj \
	$(PICO_OBJ)/common/pico_time/timeout_helper.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_timer/timer.c.obj \
	$(PICO_OBJ)/common/pico_sync/sem.c.obj \
	$(PICO_OBJ)/common/pico_sync/lock_core.c.obj \
	$(PICO_OBJ)/common/pico_sync/mutex.c.obj \
	$(PICO_OBJ)/common/pico_sync/critical_section.c.obj \
	$(PICO_OBJ)/common/pico_util/datetime.c.obj \
	$(PICO_OBJ)/common/pico_util/pheap.c.obj \
	$(PICO_OBJ)/common/pico_util/queue.c.obj \
	$(PICO_OBJ)/rp2_common/pico_runtime/runtime.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_clocks/clocks.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_irq/irq.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_irq/irq_handler_chain.S.obj \
	$(PICO_OBJ)/rp2_common/hardware_pll/pll.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_vreg/vreg.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_watchdog/watchdog.c.obj \
	$(PICO_OBJ)/rp2_common/hardware_xosc/xosc.c.obj \
	$(PICO_OBJ)/rp2_common/pico_printf/printf.c.obj \
	$(PICO_OBJ)/rp2_common/pico_bit_ops/bit_ops_aeabi.S.obj \
	$(PICO_OBJ)/rp2_common/pico_bootrom/bootrom.c.obj \
	$(PICO_OBJ)/rp2_common/pico_divider/divider.S.obj \
	$(PICO_OBJ)/rp2_common/pico_double/double_aeabi.S.obj \
	$(PICO_OBJ)/rp2_common/pico_double/double_init_rom.c.obj \
	$(PICO_OBJ)/rp2_common/pico_double/double_math.c.obj \
	$(PICO_OBJ)/rp2_common/pico_double/double_v1_rom_shim.S.obj \
	$(PICO_OBJ)/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S.obj \
	$(PICO_OBJ)/rp2_common/pico_float/float_aeabi.S.obj \
	$(PICO_OBJ)/rp2_common/pico_float/float_init_rom.c.obj \
	$(PICO_OBJ)/rp2_common/pico_float/float_math.c.obj \
	$(PICO_OBJ)/rp2_common/pico_float/float_v1_rom_shim.S.obj \
	$(PICO_OBJ)/rp2_common/pico_malloc/pico_malloc.c.obj \
	$(PICO_OBJ)/rp2_common/pico_mem_ops/mem_ops_aeabi.S.obj \
	$(PICO_OBJ)/rp2_common/pico_standard_link/crt0.S.obj \
	$(PICO_OBJ)/rp2_common/pico_standard_link/binary_info.c.obj \
	$(PICO_OBJ)/rp2_common/pico_stdio/stdio.c.obj \
	$(PICO_OBJ)/rp2_common/pico_stdio_uart/stdio_uart.c.obj

CHECKSUMM = $(PICO_EXAMPLES)\build\pico-sdk\src\rp2_common\boot_stage2\bs2_default_padded_checksummed.S 

CXX_DEFINES = -DLIB_PICO_BIT_OPS=1 \
	-DLIB_PICO_BIT_OPS_PICO=1 \
	-DLIB_PICO_DIVIDER=1 \
	-DLIB_PICO_DIVIDER_HARDWARE=1 \
	-DLIB_PICO_DOUBLE=1 \
	-DLIB_PICO_DOUBLE_PICO=1 \
	-DLIB_PICO_FLOAT=1 \
	-DLIB_PICO_FLOAT_PICO=1 \
	-DLIB_PICO_INT64_OPS=1 \
	-DLIB_PICO_INT64_OPS_PICO=1 \
	-DLIB_PICO_MALLOC=1 \
	-DLIB_PICO_MEM_OPS=1 \
	-DLIB_PICO_MEM_OPS_PICO=1 \
	-DLIB_PICO_PLATFORM=1 \
	-DLIB_PICO_PRINTF=1 \
	-DLIB_PICO_PRINTF_PICO=1 \
	-DLIB_PICO_RUNTIME=1 \
	-DLIB_PICO_STANDARD_LINK=1 \
	-DLIB_PICO_STDIO=1 \
	-DLIB_PICO_STDIO_UART=1 \
	-DLIB_PICO_STDLIB=1 \
	-DLIB_PICO_SYNC=1 \
	-DLIB_PICO_SYNC_CORE=1 \
	-DLIB_PICO_SYNC_CRITICAL_SECTION=1 \
	-DLIB_PICO_SYNC_MUTEX=1 \
	-DLIB_PICO_SYNC_SEM=1 \
	-DLIB_PICO_TIME=1 \
	-DLIB_PICO_UTIL=1 \
	-DPICO_BOARD=\"pico\" \
	-DPICO_BUILD=1 \
	-DPICO_CMAKE_BUILD_TYPE=\"Release\" \
	-DPICO_COPY_TO_RAM=0 \
	-DPICO_CXX_ENABLE_EXCEPTIONS=0 \
	-DPICO_NO_FLASH=0 \
	-DPICO_NO_HARDWARE=0 \
	-DPICO_ON_DEVICE=1 \
	-DPICO_PROGRAM_URL=\"https://github.com/raspberrypi/pico-examples/tree/HEAD/blink\" \
	-DPICO_TARGET_NAME=\"blink\" \
	-DPICO_USE_BLOCKED_RAM=0

CXX_INCLUDES = \
	-I$(PICO_SDK)\src\common\pico_stdlib\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_gpio\include \
	-I$(PICO_SDK)\src\common\pico_base\include \
	-I$(PICO_EXAMPLES)\build\generated\pico_base \
	-I$(PICO_SDK)\src\boards\include \
	-I$(PICO_SDK)\src\rp2_common\pico_platform\include \
	-I$(PICO_SDK)\src\rp2040\hardware_regs\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_base\include \
	-I$(PICO_SDK)\src\rp2040\hardware_structs\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_claim\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_sync\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_uart\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_divider\include \
	-I$(PICO_SDK)\src\common\pico_time\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_timer\include \
	-I$(PICO_SDK)\src\common\pico_sync\include \
	-I$(PICO_SDK)\src\common\pico_util\include \
	-I$(PICO_SDK)\src\rp2_common\pico_runtime\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_clocks\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_irq\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_resets\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_pll\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_vreg\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_watchdog\include \
	-I$(PICO_SDK)\src\rp2_common\hardware_xosc\include \
	-I$(PICO_SDK)\src\rp2_common\pico_printf\include \
	-I$(PICO_SDK)\src\rp2_common\pico_bootrom\include \
	-I$(PICO_SDK)\src\common\pico_bit_ops\include \
	-I$(PICO_SDK)\src\common\pico_divider\include \
	-I$(PICO_SDK)\src\rp2_common\pico_double\include \
	-I$(PICO_SDK)\src\rp2_common\pico_int64_ops\include \
	-I$(PICO_SDK)\src\rp2_common\pico_float\include \
	-I$(PICO_SDK)\src\rp2_common\pico_malloc\include \
	-I$(PICO_SDK)\src\rp2_common\boot_stage2\include \
	-I$(PICO_SDK)\src\common\pico_binary_info\include \
	-I$(PICO_SDK)\src\rp2_common\pico_stdio\include \
	-I$(PICO_SDK)\src\rp2_common\pico_stdio_uart\include

CXX_FLAGS = \
	-mcpu=cortex-m0plus -mthumb -O3 -DNDEBUG -ffunction-sections -fdata-sections -fno-exceptions -fno-unwind-tables \
	-fno-rtti -fno-use-cxa-atexit -std=gnu++17

all:
	$(CXX) $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o blink.c.obj -c blink.c
	$(CXX) $(MCU) $(FLAG1) $(SPECS) $(FLAG2) $(MAP) $(SKRIPT) $(OBJ) -o blink.elf

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29300
Joined: Sat Jul 30, 2011 7:41 pm

Re: Build project with makefile

Fri Jul 30, 2021 11:31 am

I doubt I will be able to help - we use CMake for very good reasons, but some indication of the error (copy of the result of running make?) would be useful. Along with the OS you are using and more details on the setup.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

jayben
Posts: 327
Joined: Mon Aug 19, 2019 9:56 pm

Re: Build project with makefile

Fri Jul 30, 2021 12:03 pm

It is possible to create a working executable using a makefile, but it is quite hard work, and the binary image I've produced is much larger than the cmake version, so I'm currently trying to understand why.

What is the actual error message? I suspect you are being tripped up by some cmake-specifics, or maybe the command line is just too long.

If that is true, a quick way to reduce the length is to put all the -D definitions in a single file (e.g. changing -DLIB_PICO_BIT_OPS_PICO=1 to #define LIB_PICO_BIT_OPS_PICO 1) then using the gcc -include command to force that file to be processed before everything else.

daniil1
Posts: 3
Joined: Fri Jul 30, 2021 10:31 am

Re: Build project with makefile

Fri Jul 30, 2021 12:19 pm

Sorry, while I was solving the problem with the syntax, I forgot to describe the error itself.

I am building a project on windows 10 64 bit. I want to compile a project for Rasbery Pi Pico. The linker displays the error:

Code: Select all

arm-none-eabi / bin / ld.exe: ERROR: Pico second stage bootloader must be 256 bytes in size
I don't want to use cmake, as the PICO library is built on every build. This is a very long time if I need to experiment with connecting different src files

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29300
Joined: Sat Jul 30, 2011 7:41 pm

Re: Build project with makefile

Fri Jul 30, 2021 12:22 pm

daniil1 wrote:
Fri Jul 30, 2021 12:19 pm
I don't want to use cmake, as the PICO library is built on every build. This is a very long time if I need to experiment with connecting different src files
That should not be the case - it should only build the files that have changed, and the SDK files won't be changing.

You are fixing the wrong problem. Fix the Cmake issue; so describe in more detail what you think the problem is and how is happens.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

jayben
Posts: 327
Joined: Mon Aug 19, 2019 9:56 pm

Re: Build project with makefile

Fri Jul 30, 2021 1:11 pm

daniil1 wrote:
Fri Jul 30, 2021 12:19 pm
Sorry, while I was solving the problem with the syntax, I forgot to describe the error itself.

I am building a project on windows 10 64 bit. I want to compile a project for Rasbery Pi Pico. The linker displays the error:

Code: Select all

arm-none-eabi / bin / ld.exe: ERROR: Pico second stage bootloader must be 256 bytes in size
I don't want to use cmake, as the PICO library is built on every build. This is a very long time if I need to experiment with connecting different src files
I had that problem, and I think it was because I hadn't used the correct linker script. The link line I'm using is:

Code: Select all

$(BIN): lib $(SRC)
	$(CC) $(CFLAGS) --specs=nosys.specs -Wl,--build-id=none -Wl,--script=$(SDK_SRC)/rp2_common/pico_standard_link/memmap_default.ld -Wl,--gc-sections blink.c.obj -L./ -lpico -Wl,-Map=$(MAP) -o $(BIN) bs2_default_padded_checksummed.S
..where libpico.a is a library containing all the object files.

However I (as the most ardent supporter of simpler build systems) have to admit that cmake shouldn't be rebuilding everything when one of the source files is changed - you have an error in its configuration.

WizIO
Posts: 105
Joined: Mon Feb 22, 2021 8:34 am
Location: Sofia
Contact: Website

Re: Build project with makefile

Fri Jul 30, 2021 1:15 pm

the error:
the bootloader ( boot stage 2 ) is not compiled or not exist for the linker

or use some precompiled bootloaders
https://github.com/Wiz-IO/framework-wiz ... /main/boot

daniil1
Posts: 3
Joined: Fri Jul 30, 2021 10:31 am

Re: Build project with makefile

Fri Jul 30, 2021 2:09 pm

You are right, I programmed the deletion of the output files myself. But I would still like to collect the PICO library separately and then link it with the project. And if that doesn't work, so much the better. This makes it possible to connect to the project only those objects that are necessary for the work of a particular project. Write your own makefile - it is great to control the output file

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29300
Joined: Sat Jul 30, 2011 7:41 pm

Re: Build project with makefile

Fri Jul 30, 2021 2:26 pm

daniil1 wrote:
Fri Jul 30, 2021 2:09 pm
You are right, I programmed the deletion of the output files myself. But I would still like to collect the PICO library separately and then link it with the project. And if that doesn't work, so much the better. This makes it possible to connect to the project only those objects that are necessary for the work of a particular project. Write your own makefile - it is great to control the output file
I'd suggest writing your own CMake files to do what you want, should fit in much better with the system. Much easier to trying to redo the entire CMake system in make (which CMake translates to anyway)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 863
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Build project with makefile

Fri Jul 30, 2021 2:27 pm

Yeah, you are almost certainly trying to fix the wrong problem (which is none of our business, but then again you are opening yourself up to a world of hurt and fragility). The cmake only rebuilds files when it needs to (i.e. you change the files, you change the headers they depend on, or you change the compile options). This can of course happen as a result of you changing the dependent libraries since they inject defines into the build.

If you were using make I'd just say "add -j" to do a parallel build, but you can't do that with nmake. you can however use ninja which is about 10x faster for me on windows.

Of course unless you are building the entirety of pico-examples, I'm surprised it is slow for you anyway.

hippy
Posts: 10523
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Build project with makefile

Fri Jul 30, 2021 2:37 pm

daniil1 wrote:
Fri Jul 30, 2021 12:19 pm
I don't want to use cmake, as the PICO library is built on every build.
That seems to be a common motif when it comes to criticism of using 'cmake' but I haven't experienced it myself.

In my experience 'cmake' hasn't rebuilt anything it doesn't need to rebuild. Sometimes more can need rebuilding on a change than one might have expected but only because it's a more significant change than one had anticipated. Perhaps there are some cases where more may get rebuilt than strictly necessary but that's not been my experience.

If there is an issue then perhaps someone experiencing it could provide an example of 'cmake' rebuilding stuff when it shouldn't so it can be replicated and investigated, accepted as an issue or dismissed as not.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 863
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Build project with makefile

Fri Jul 30, 2021 2:46 pm

yes, i guess there is some nuance here. the SDK code is itself recompiled when you make certain structural/config changes to what you are building (or include paths) or build defines. This is because the SDK is designed to be customizable on a per application basis, and you get a different/optimized set of code based on what you have chosen/what other libraries you have included

This may be surprising if you are used to a monolithic static library, however once again it shouldn't happen that much, and there aren't that many files that the SDK is usually pulling in.

hippy
Posts: 10523
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Build project with makefile

Fri Jul 30, 2021 3:25 pm

kilograham wrote:
Fri Jul 30, 2021 2:46 pm
yes, i guess there is some nuance here.
I think so. If one is repeatedly adding and removing files during development, changing options, then a lot more may be rebuilt on every step to make the result optimal than would be when one has a pre-built library where the linker decides what to keep and discard.

That's seems to me a consequence of the design goal - optimal result - and working that way.

Adding files, simply not calling their routines rather than taking them out, when not strictly needed at a step, should mean a lot less rebuilding at each step.

MicroPython builds can be painful because MicroPython keeps a database of strings and allocated ID's, a small change can mean the database changes, which means everything depending on that databases needs to be rebuilt and that often explodes to 'everything'. Providing one doesn't affect that database, everything is a quick rebuild, only the thing edited and related being rebuilt.

I suppose it comes down to "I'd rather have a sub-optimal build and faster build times than an optimal build which rebuilds more frequently and takes longer".

I can empathise with the desire to keep a sub-optimal build which supports A, B and C as is, even if some or all are not required, because they will be later; continually re-building to keep optimal becoming a nuisance, which is perhaps the basis for criticism of the 'cmake' approach.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29300
Joined: Sat Jul 30, 2011 7:41 pm

Re: Build project with makefile

Fri Jul 30, 2021 3:56 pm

We are horribly spoilt nowadays when it comes to build times! When I was a lad, just after punch cards didn't become a thing, we still had to wait for a considerable time (many minutes, sometimes hours) to get any Pascal compile results out of the MicroVAX we used at University. In the end I moved to the BBC Micro Pascal system. Much quicker.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

ejolson
Posts: 8021
Joined: Tue Mar 18, 2014 11:47 am

Re: Build project with makefile

Fri Jul 30, 2021 4:15 pm

daniil1 wrote:
Fri Jul 30, 2021 12:19 pm
Sorry, while I was solving the problem with the syntax, I forgot to describe the error itself.

I am building a project on windows 10 64 bit. I want to compile a project for Rasbery Pi Pico. The linker displays the error:

Code: Select all

arm-none-eabi / bin / ld.exe: ERROR: Pico second stage bootloader must be 256 bytes in size
I don't want to use cmake, as the PICO library is built on every build. This is a very long time if I need to experiment with connecting different src files
I'm glad you figured out the problem with the linker. The project

https://github.com/Wiz-IO/framework-wiz ... e/main/SDK

appears to be a proof of concept in which the standard Pico SDK is reorganised to make it easier to use with make. I haven't looked at the details, but my impression is the include files have been automatically copied to a single include directory and the library precompiled into a single file.

Presumably this means only one directory is needed for headers and only one library for the routines they declare. It would be interesting to know if this alternative build system works and whether the resulting executables are the same size.

lurk101
Posts: 868
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Build project with makefile

Fri Jul 30, 2021 4:18 pm

kilograham wrote:
Fri Jul 30, 2021 2:46 pm
yes, i guess there is some nuance here. the SDK code is itself recompiled when you make certain structural/config changes to what you are building (or include paths) or build defines. This is because the SDK is designed to be customizable on a per application basis, and you get a different/optimized set of code based on what you have chosen/what other libraries you have included
I don't know how many times you'll need to repeat this before it sinks in?

BTW. The entirety of pico-examples compiles in 15 seconds on my Ubuntu box. Any project I've done so far on Pi4 has built in under a 30 seconds. I don't think build times are a legitimate concern.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29300
Joined: Sat Jul 30, 2011 7:41 pm

Re: Build project with makefile

Fri Jul 30, 2021 4:21 pm

lurk101 wrote:
Fri Jul 30, 2021 4:18 pm
I don't know how many times you'll need to repeat this before it sinks in?
Lots. Lots and lots.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

hippy
Posts: 10523
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Build project with makefile

Fri Jul 30, 2021 4:57 pm

lurk101 wrote:
Fri Jul 30, 2021 4:18 pm
BTW. The entirety of pico-examples compiles in 15 seconds on my Ubuntu box. Any project I've done so far on Pi4 has built in under a 30 seconds. I don't think build times are a legitimate concern.
It takes over 9 minutes to build 'pico-examples' on my Pi 3B (non-plus). Adding -j4 got that down to about a third, and gave me my first exposure to the 'ooh, that's hot' thermometer on my desktop.

A clean build of MicroPython takes over 3 minutes. With -j4 that falls to just over 2 minutes, so, as a whole, not so well suited to multi-core as the C and Pico SDK parts are.

On the other hand, a clean build of something simple like an out of tree "hello_usb" is just 45 seconds, reducing to 27 with -j4.

And most times I'm not doing clean builds. They usually zing along, a couple of seconds if nothing has changed.

Whether build times are problematic comes down to what one is doing, prepared to accept or put up with, how much money one is willing to throw at bringing them down.

I'm not complaining because I can live with what I get.

User avatar
jahboater
Posts: 7308
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Build project with makefile

Fri Jul 30, 2021 5:39 pm

jamesh wrote:
Fri Jul 30, 2021 3:56 pm
We are horribly spoilt nowadays when it comes to build times! When I was a lad, just after punch cards didn't become a thing, we still had to wait for a considerable time (many minutes, sometimes hours) to get any Pascal compile results out of the MicroVAX we used at University.
When I learned Pascal at University, we handed the punched cards in during the afternoon and the next day we received a printout with the results.
Made you learn not to make careless mistakes ....


User avatar
nick.mccloud
Posts: 1280
Joined: Sat Feb 04, 2012 4:18 pm

Re: Build project with makefile

Sun Aug 01, 2021 7:35 pm

jamesh wrote:
Fri Jul 30, 2021 3:56 pm
When I was a lad, just after punch cards didn't become a thing, we still had to wait for a considerable time (many minutes, sometimes hours) to get any Pascal compile results out of the MicroVAX we used at University.
jahboater wrote: When I learned Pascal at University, we handed the punched cards in during the afternoon and the next day we received a printout with the results.
Punched cards? Luxury! Toggle switches on the Altair 8800. And if you tell the kids today that 640KB is enough, they don't believe you.
Pico/RP2040 ≠ Arduino
Pico = hot rod kit car, Arduino = hot rod kit car wrapped in cotton wool with buoyancy aids & parachute

ejolson
Posts: 8021
Joined: Tue Mar 18, 2014 11:47 am

Re: Build project with makefile

Sun Aug 01, 2021 8:52 pm

nick.mccloud wrote:
Sun Aug 01, 2021 7:35 pm
jamesh wrote:
Fri Jul 30, 2021 3:56 pm
When I was a lad, just after punch cards didn't become a thing, we still had to wait for a considerable time (many minutes, sometimes hours) to get any Pascal compile results out of the MicroVAX we used at University.
jahboater wrote: When I learned Pascal at University, we handed the punched cards in during the afternoon and the next day we received a printout with the results.
Punched cards? Luxury! Toggle switches on the Altair 8800. And if you tell the kids today that 640KB is enough, they don't believe you.
Where did you get an Altair 8800 with 640KB?

Return to “General”