diff options
Diffstat (limited to 'hexedit')
| -rw-r--r-- | hexedit/Makefile | 18 | ||||
| -rw-r--r-- | hexedit/hexedit.s | 42 | ||||
| -rw-r--r-- | hexedit/main.s | 7 | ||||
| -rw-r--r-- | hexedit/pico_persist.ld (renamed from hexedit/pico_ram_only.ld) | 8 | ||||
| -rw-r--r-- | hexedit/uart.s | 32 | 
5 files changed, 41 insertions, 66 deletions
| diff --git a/hexedit/Makefile b/hexedit/Makefile index 2ff0812..d862c25 100644 --- a/hexedit/Makefile +++ b/hexedit/Makefile @@ -1,21 +1,21 @@  all: build -build: echo.uf2 +build: hexedit.uf2 -echo.uf2: echo.elf -	../elf/elf2uf2 echo.elf echo.uf2 +hexedit.uf2: hexedit.elf +	../elf/elf2uf2 hexedit.elf hexedit.uf2 -objects = main.o uart.o +objects = main.o uart.o hexedit.o -echo.elf: $(objects) -	arm-none-eabi-ld -T pico_ram_only.ld -o echo.elf $(objects) ../setup/setup.so +hexedit.elf: $(objects) +	arm-none-eabi-ld -T pico_persist.ld -o hexedit.elf $(objects) ../setup/setup.so  $(objects): %.o: %.s  	arm-none-eabi-as -o $@ $<  clean: -	rm echo.elf echo.uf2 *.o +	rm hexedit.elf hexedit.uf2 *.o -flash: echo.uf2 +flash: hexedit.uf2  	[ -h /dev/disk/by-label/RPI-RP2 ] || sleep 3s -	cat echo.uf2 > /dev/disk/by-label/RPI-RP2 +	cat hexedit.uf2 > /dev/disk/by-label/RPI-RP2 diff --git a/hexedit/hexedit.s b/hexedit/hexedit.s index 0bc03a9..26bc84b 100644 --- a/hexedit/hexedit.s +++ b/hexedit/hexedit.s @@ -2,24 +2,34 @@  .cpu cortex-m0plus  .thumb +.equ SRAM_BASE, 0x20000000 +  .type hexedit, %function  .global hexedit  hexedit: -  ldr r2, =0x20000100 -  movs r1, 0 -getchar: +  ldr r6, =SRAM_BASE +  adds r5, r6, 1 +10: +  movs r4, 0 +20:    bl uart_recv -  cmp r0, 'g -  beq stop -  subs r0, '0 // The ASCII char '0' -  bmi next -  lsls r1, 4 -  adds r1, r0 -  b getchar -next: -  ldr r0, [r2, 0] -  adds r2, 4 -  b hexedit -stop: -  b 0x20000100 +  cmp r0, '\r +  beq 30f +  cmp r0, 'G +  beq 40f +  bl uart_send +  subs r0, '0 +  lsls r4, 3 +  adds r4, r0 +  b 20b +30: +  movs r0, '\r +  bl uart_send +  movs r0, '\n +  bl uart_send +  strh r4, [r6] +  adds r6, 2 +  b 10b +40: +  bx r5 diff --git a/hexedit/main.s b/hexedit/main.s index 5e294d4..f2f6126 100644 --- a/hexedit/main.s +++ b/hexedit/main.s @@ -2,6 +2,8 @@  .cpu cortex-m0plus  .thumb +.section .entry, "ax" +  .type main, %function  .global main @@ -10,7 +12,4 @@ main:    bl setup_clocks    bl setup_gpio    bl setup_uart -1: -  bl uart_recv -  bl uart_send -  b 1b +  b hexedit diff --git a/hexedit/pico_ram_only.ld b/hexedit/pico_persist.ld index eb2450e..32cc42f 100644 --- a/hexedit/pico_ram_only.ld +++ b/hexedit/pico_persist.ld @@ -1,13 +1,11 @@ -ENTRY(main) -  MEMORY {    FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2M -  SRAM(rwx) : ORIGIN = 0x20000000, LENGTH = 264K +  SRAM(rx) : ORIGIN = 0x20041f00, LENGTH = 252  }  SECTIONS {    .text : { +    *(.entry)      *(.text) -    . = ALIGN(4); -  } > SRAM +  } >SRAM AT>FLASH  } diff --git a/hexedit/uart.s b/hexedit/uart.s index b845c8b..e79cbdc 100644 --- a/hexedit/uart.s +++ b/hexedit/uart.s @@ -31,35 +31,3 @@ uart_recv:    bne 1b    ldrb r0, [r1, UARTDR_OFST]    bx lr - -.type send_hex, %function -.global send_hex - -send_hex: -  push {lr} -  movs r4, r0 -  movs r0, '0 -  bl uart_send -  movs r0, 'x -  bl uart_send -  movs r5, 8 // eight nibbles in a word -0: -  movs r0, 28 // rotate left 4 -  rors r4, r0 -  movs r0, 0xF // lowest nibble mask -  ands r0, r4 -  cmp r0, 0x9 // number or letter? -  bhi 1f -  adds r0, '0 -  b 2f -1: -  adds r0, ('A - 0xA) -2: -  bl uart_send -  subs r5, 1 -  bne 0b -  movs r0, '\r -  bl uart_send -  movs r0, '\n -  bl uart_send -  pop {pc} | 
