aboutsummaryrefslogtreecommitdiff
path: root/hexedit
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-07-12 23:40:38 -0500
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-07-12 23:40:38 -0500
commitd6ff9f5bda85206d163f02f7cc78e47968c434ce (patch)
treeaf3e8a4a6c8229e28f7f7c48da06276073e63d98 /hexedit
parent17d59ac15b87588de2228aa768e99b5bbca4561c (diff)
Fix automated serial input
Diffstat (limited to 'hexedit')
-rw-r--r--hexedit/Makefile41
-rw-r--r--hexedit/main.s13
-rw-r--r--hexedit/pico_ram_only.ld14
-rw-r--r--hexedit/slowcat.c11
4 files changed, 25 insertions, 54 deletions
diff --git a/hexedit/Makefile b/hexedit/Makefile
index a42b16a..d1cfa5b 100644
--- a/hexedit/Makefile
+++ b/hexedit/Makefile
@@ -1,5 +1,5 @@
PICO = /dev/disk/by-label/RPI-RP2
-PICO_CONSOLE = /dev/ttyUSB0
+DEVICE = /dev/ttyUSB0
.PHONY: build
build: hexedit.oe
@@ -7,44 +7,31 @@ build: hexedit.oe
hexedit.oe: hexedit.bin
od -An -v hexedit.bin | sed "s/^ //" | tr " " "\n" > hexedit.oe
-hexedit.bin: hexedit.o
- arm-none-eabi-ld -T pico_bin.ld -o hexedit.bin hexedit.o
- arm-none-eabi-objcopy -O binary hexedit.bin
+hexedit.bin: hexedit.elf
+ arm-none-eabi-objcopy -O binary hexedit.elf hexedit.bin
-objects = hexedit.o main.o
+hexedit.elf: pico_bin.ld hexedit.o
+ arm-none-eabi-ld -T pico_bin.ld -o hexedit.elf hexedit.o
-$(objects): %.o: %.s
- arm-none-eabi-as -o $@ $<
-
-hexedit.uf2: hexedit.elf
- ../elf/elf2uf2 hexedit.elf hexedit.uf2
-
-hexedit.elf: $(objects)
- arm-none-eabi-ld -T pico_ram_only.ld -o hexedit.elf $(objects) ../setup/setup.so
+hexedit.o: hexedit.s
+ arm-none-eabi-as -o hexedit.o hexedit.s
.PHONY: clean
clean:
- rm -f hexedit.elf hexedit.uf2 hexedit.bin hexedit.oe *.o
+ rm -f hexedit.elf hexedit.bin hexedit.oe hexedit.o slowcat
.PHONY: dump
dump: hexedit.bin
@od hexedit.bin
.PHONY: serial
-serial: $(PICO_CONSOLE) hexedit.oe
- cat hexedit.oe | tr "\n" "\r" > PICO_CONSOLE
- echo -n "G" > PICO_CONSOLE
+serial: $(DEVICE) hexedit.oe slowcat
+ cat hexedit.oe | tr "\n" "\r" | ./slowcat | picocom -b 115200 -q $(DEVICE)
+ @echo
+ echo -n "G" | picocom -b 115200 -q $(DEVICE)
+ @echo
-$(PICO_CONSOLE):
+$(DEVICE):
@echo Serial device not found
@echo Connect USB cable from USB-UART bridge
@false
-
-.PHONY: flash
-flash: $(PICO) hexedit.uf2
- cat hexedit.uf2 > $(PICO)
-
-$(PICO):
- @echo "RPI-RP2 bootloader drive not found"
- @echo Connect the pico with USB cable while holding bootsel button
- @false
diff --git a/hexedit/main.s b/hexedit/main.s
deleted file mode 100644
index 0b49339..0000000
--- a/hexedit/main.s
+++ /dev/null
@@ -1,13 +0,0 @@
-.syntax unified
-.cpu cortex-m0plus
-.thumb
-
-.type main, %function
-.global main
-
-main:
- bl start_xosc
- bl setup_clocks
- bl setup_gpio
- bl setup_uart
- b SETUP
diff --git a/hexedit/pico_ram_only.ld b/hexedit/pico_ram_only.ld
deleted file mode 100644
index 1185af5..0000000
--- a/hexedit/pico_ram_only.ld
+++ /dev/null
@@ -1,14 +0,0 @@
-ENTRY(main)
-
-MEMORY {
- FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2M
- SRAM(rwx) : ORIGIN = 0x20000000, LENGTH = 264K
-}
-
-SECTIONS {
- .text : {
- main.o(.text);
- *(.text);
- . = ALIGN(4);
- } > SRAM
-}
diff --git a/hexedit/slowcat.c b/hexedit/slowcat.c
new file mode 100644
index 0000000..67725d4
--- /dev/null
+++ b/hexedit/slowcat.c
@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <stdint.h>
+
+int main() {
+ uint8_t byte;
+ while (read(STDIN_FILENO, &byte, 1)) {
+ write(STDOUT_FILENO, &byte, 1);
+ usleep(10000);
+ }
+ return 0;
+}