From f2f186c3594a922e51abf25b24052c61f833a2bf Mon Sep 17 00:00:00 2001 From: Jacques Comeaux Date: Tue, 4 Jun 2024 19:28:25 -0500 Subject: Rename stage 0 editor --- hexedit/Makefile | 22 ---------------------- hexedit/hexedit.s | 34 ---------------------------------- hexedit/main.s | 18 ------------------ hexedit/pico_persist.ld | 13 ------------- hexedit/uart.s | 33 --------------------------------- octedit/Makefile | 22 ++++++++++++++++++++++ octedit/main.s | 18 ++++++++++++++++++ octedit/octedit.s | 34 ++++++++++++++++++++++++++++++++++ octedit/pico_persist.ld | 13 +++++++++++++ octedit/uart.s | 33 +++++++++++++++++++++++++++++++++ 10 files changed, 120 insertions(+), 120 deletions(-) delete mode 100644 hexedit/Makefile delete mode 100644 hexedit/hexedit.s delete mode 100644 hexedit/main.s delete mode 100644 hexedit/pico_persist.ld delete mode 100644 hexedit/uart.s create mode 100644 octedit/Makefile create mode 100644 octedit/main.s create mode 100644 octedit/octedit.s create mode 100644 octedit/pico_persist.ld create mode 100644 octedit/uart.s diff --git a/hexedit/Makefile b/hexedit/Makefile deleted file mode 100644 index dd70409..0000000 --- a/hexedit/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -all: build - -build: hexedit.uf2 - -hexedit.uf2: hexedit.elf - ../elf/elf2uf2 hexedit.elf hexedit.uf2 - -objects = uart.o main.o hexedit.o - -hexedit.elf: $(objects) - arm-none-eabi-ld -T pico_persist.ld -o hexedit.elf $(objects) ../setup/setup.so - ./checksum_pico_elf.py hexedit.elf - -$(objects): %.o: %.s - arm-none-eabi-as -o $@ $< - -clean: - rm hexedit.elf hexedit.uf2 *.o - -flash: hexedit.uf2 - [ -h /dev/disk/by-label/RPI-RP2 ] || sleep 3s - cat hexedit.uf2 > /dev/disk/by-label/RPI-RP2 diff --git a/hexedit/hexedit.s b/hexedit/hexedit.s deleted file mode 100644 index 0800a3a..0000000 --- a/hexedit/hexedit.s +++ /dev/null @@ -1,34 +0,0 @@ -.syntax unified -.cpu cortex-m0plus -.thumb - -.equ SRAM_BASE, 0x20000000 - -.type hexedit, %function -.global hexedit - -hexedit: - ldr r6, =SRAM_BASE - adds r5, r6, 1 -10: - movs r4, 0 -20: - bl uart_recv - 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: - 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 deleted file mode 100644 index a12b4b3..0000000 --- a/hexedit/main.s +++ /dev/null @@ -1,18 +0,0 @@ -.syntax unified -.cpu cortex-m0plus -.thumb - -.section .entry, "ax" - -.type main, %function -.global main - -main: - bl start_xosc - bl setup_clocks - bl setup_gpio - bl setup_uart - b hexedit - -.section .stage_2_crc -.word 0x00000000 diff --git a/hexedit/pico_persist.ld b/hexedit/pico_persist.ld deleted file mode 100644 index 9c37aba..0000000 --- a/hexedit/pico_persist.ld +++ /dev/null @@ -1,13 +0,0 @@ -MEMORY { - FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2M - SRAM(rx) : ORIGIN = 0x20041f00, LENGTH = 256 -} - -SECTIONS { - .text : { - *(.entry); - *(.text); - . = 252; - *(.stage_2_crc); - } >SRAM AT>FLASH -} diff --git a/hexedit/uart.s b/hexedit/uart.s deleted file mode 100644 index e79cbdc..0000000 --- a/hexedit/uart.s +++ /dev/null @@ -1,33 +0,0 @@ -.syntax unified -.cpu cortex-m0plus -.thumb - -.equ UART0_BASE, 0x40034000 -.equ UARTDR_OFST, 0x00 -.equ UARTFR_OFST, 0x18 - -.type uart_send, %function -.global uart_send - -uart_send: - ldr r1, =UART0_BASE - movs r3, 0b1 << 5 // TX FIFO full -1: - ldr r2, [r1, UARTFR_OFST] - tst r2, r3 - bne 1b - strb r0, [r1, UARTDR_OFST] - bx lr - -.type uart_recv, %function -.global uart_recv - -uart_recv: - ldr r1, =UART0_BASE - movs r3, 0b1 << 4 // RX FIFO empty -1: - ldr r2, [r1, UARTFR_OFST] - tst r2, r3 - bne 1b - ldrb r0, [r1, UARTDR_OFST] - bx lr diff --git a/octedit/Makefile b/octedit/Makefile new file mode 100644 index 0000000..26601c8 --- /dev/null +++ b/octedit/Makefile @@ -0,0 +1,22 @@ +all: build + +build: octedit.uf2 + +octedit.uf2: octedit.elf + ../elf/elf2uf2 octedit.elf octedit.uf2 + +objects = uart.o main.o octedit.o + +octedit.elf: $(objects) + arm-none-eabi-ld -T pico_persist.ld -o octedit.elf $(objects) ../setup/setup.so + ./checksum_pico_elf.py octedit.elf + +$(objects): %.o: %.s + arm-none-eabi-as -o $@ $< + +clean: + rm octedit.elf octedit.uf2 *.o + +flash: octedit.uf2 + [ -h /dev/disk/by-label/RPI-RP2 ] || sleep 3s + cat octedit.uf2 > /dev/disk/by-label/RPI-RP2 diff --git a/octedit/main.s b/octedit/main.s new file mode 100644 index 0000000..6c471ec --- /dev/null +++ b/octedit/main.s @@ -0,0 +1,18 @@ +.syntax unified +.cpu cortex-m0plus +.thumb + +.section .entry, "ax" + +.type main, %function +.global main + +main: + bl start_xosc + bl setup_clocks + bl setup_gpio + bl setup_uart + b octedit + +.section .stage_2_crc +.word 0x00000000 diff --git a/octedit/octedit.s b/octedit/octedit.s new file mode 100644 index 0000000..9445fd8 --- /dev/null +++ b/octedit/octedit.s @@ -0,0 +1,34 @@ +.syntax unified +.cpu cortex-m0plus +.thumb + +.equ SRAM_BASE, 0x20000000 + +.type octedit, %function +.global octedit + +octedit: + ldr r6, =SRAM_BASE + adds r5, r6, 1 +10: + movs r4, 0 +20: + bl uart_recv + 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: + bl uart_send + movs r0, '\n + bl uart_send + strh r4, [r6] + adds r6, 2 + b 10b +40: + bx r5 diff --git a/octedit/pico_persist.ld b/octedit/pico_persist.ld new file mode 100644 index 0000000..9c37aba --- /dev/null +++ b/octedit/pico_persist.ld @@ -0,0 +1,13 @@ +MEMORY { + FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2M + SRAM(rx) : ORIGIN = 0x20041f00, LENGTH = 256 +} + +SECTIONS { + .text : { + *(.entry); + *(.text); + . = 252; + *(.stage_2_crc); + } >SRAM AT>FLASH +} diff --git a/octedit/uart.s b/octedit/uart.s new file mode 100644 index 0000000..e79cbdc --- /dev/null +++ b/octedit/uart.s @@ -0,0 +1,33 @@ +.syntax unified +.cpu cortex-m0plus +.thumb + +.equ UART0_BASE, 0x40034000 +.equ UARTDR_OFST, 0x00 +.equ UARTFR_OFST, 0x18 + +.type uart_send, %function +.global uart_send + +uart_send: + ldr r1, =UART0_BASE + movs r3, 0b1 << 5 // TX FIFO full +1: + ldr r2, [r1, UARTFR_OFST] + tst r2, r3 + bne 1b + strb r0, [r1, UARTDR_OFST] + bx lr + +.type uart_recv, %function +.global uart_recv + +uart_recv: + ldr r1, =UART0_BASE + movs r3, 0b1 << 4 // RX FIFO empty +1: + ldr r2, [r1, UARTFR_OFST] + tst r2, r3 + bne 1b + ldrb r0, [r1, UARTDR_OFST] + bx lr -- cgit v1.2.3