With two weeks tinkering I've managed to get some C-code running on the microprocessor. This involved building a cross-compiler and tool-chain for ARM ELF binary format, compiling sample code, setting up non-root access to the JTAG interface dongle and configuring a debugger, OpenOCD, for programming. In detail:
NAME = demoh103_blink_rom CC = arm-elf-gcc LD = arm-elf-ld -v AR = arm-elf-ar AS = arm-elf-as CP = arm-elf-objcopy OD = arm-elf-objdump CFLAGS = -I./ -c -fno-common -O0 -g -mcpu=cortex-m3 -mthumb AFLAGS = -ahls -mapcs-32 -o crt.o LFLAGS = -Tstm_h103_blink_rom.cmd -nostartfiles CPFLAGS = -Obinary ODFLAGS = -S all: test clean: -rm a.lst main.lst main.o main.out main.hex main.map stm32f10x_rcc.o stm32f10x_gpio.o test: main.out $(CP) $(CPFLAGS) main.out main.bin $(OD) $(ODFLAGS) main.out > main.list main.out: main.o stm32f10x_rcc.o stm32f10x_gpio.o stm_h103_blink_rom.cmd $(LD) $(LFLAGS) -o main.out main.o stm32f10x_rcc.o stm32f10x_gpio.o crt.o: crt.s $(AS) $(AFLAGS) crt.s > crt.lst stm32f10x_rcc.o: stm32f10x_rcc.c $(CC) $(CFLAGS) stm32f10x_rcc.c stm32f10x_gpio.o: stm32f10x_gpio.c $(CC) $(CFLAGS) stm32f10x_gpio.c main.o: main.c $(CC) $(CFLAGS) main.c
arm-elf-gcc -I./ -c -fno-common -O0 -g -mcpu=cortex-m3 -mthumb main.c arm-elf-gcc -I./ -c -fno-common -O0 -g -mcpu=cortex-m3 -mthumb stm32f10x_rcc.c arm-elf-gcc -I./ -c -fno-common -O0 -g -mcpu=cortex-m3 -mthumb stm32f10x_gpio.c arm-elf-ld -v -Tstm_h103_blink_rom.cmd -nostartfiles -o main.out main.o stm32f10x_rcc.o stm32f10x_gpio.o GNU ld (GNU Binutils) 2.18 + coff-avr-patch (20050630) arm-elf-objcopy -Obinary main.out main.bin arm-elf-objdump -S main.out > main.list [chris@chris-desktop stm-h103]$ arm-elf-size main.out text data bss dec hex filename 3996 0 12 4008 fa8 main.out
--file /usr/share/openocd/scripts/interface/olimex-jtag-tiny.cfg
Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Open On-Chip Debugger > reset init JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3) JTAG Tap/device matched JTAG tap: stm32.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1) JTAG Tap/device matched target state: halted target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe > flash erase_sector 0 0 127 erased sectors 0 through 127 on flash bank 0 in 0.033968s > flash write_bank 0 main.bin 0 wrote 3996 byte from file main.bin to flash bank 0 at offset 0x00000000 in 0.260933s (14.955348 kb/s) > reset init JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3) JTAG Tap/device matched JTAG tap: stm32.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1) JTAG Tap/device matched target state: halted target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x00000010 > resume > And lo, behold LED flasher. In the old days I could have built this using a 555 chip and got change from a quid... |
