rp2040

RP2040 Programming without SDK
Log | Files | Refs

Makefile (826B)


      1 CC = arm-none-eabi-gcc
      2 AS = arm-none-eabi-as
      3 LD = arm-none-eabi-ld
      4 OBJCOPY = arm-none-eabi-objcopy
      5 OBJDUMP = arm-none-eabi-objdump -Mforce-thumb
      6 BINCRC = ../tools/bincrc
      7 BIN2UF2 = ../tools/bin2uf2
      8 
      9 MCPU = -mcpu=cortex-m0plus
     10 ASFLAGS = $(MCPU)
     11 CFLAGS = $(MCPU) -mthumb -ffreestanding -nostartfiles -c
     12 LDFLAGS = --no-relax -nostdlib
     13 
     14 OBJS = boot2.o start.o main.o proc.o
     15 
     16 all: tools a.uf2
     17 
     18 clean:
     19 	rm -f *.o *.elf *.uf2 *.bin
     20 	cd ../tools && make clean
     21 
     22 .s.o:
     23 	$(AS) $(ASFLAGS) -o $@ $<
     24 
     25 .c.o:
     26 	$(CC) $(CFLAGS) -o $@ $<
     27 
     28 a.elf: $(OBJS) memmap.ld
     29 	$(LD) $(LDFLAGS) -o $@ -T memmap.ld $(OBJS)
     30 
     31 a.bin: a.elf
     32 	$(OBJCOPY) -O binary a.elf $@
     33 
     34 a.uf2: a.bin
     35 	$(BINCRC) a.bin a_crc.bin
     36 	$(BIN2UF2) a_crc.bin $@
     37 
     38 flash: all
     39 	mount /dev/disk/by-label/RPI-RP2 /mnt
     40 	cp a.uf2 /mnt
     41 
     42 tools:
     43 	cd ../tools && make
     44 
     45 dump: a.elf
     46 	$(OBJDUMP) -D $<