rp2040

RP2040 Programming without SDK
Log | Files | Refs

commit da7c10f1af1e710db3abf8e85dab3bcd0e74ea0a
parent d0c9e5caf9cdb2f8365c1f108468811566814e4d
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue, 12 Mar 2024 07:09:49 +0900

add section flasgs

Diffstat:
Mex3/Makefile | 2+-
Mex3/main.c | 11+++--------
Mex3/memmap.ld | 2+-
Mex3/proc.s | 12++++++++----
Mex3/start.s | 5++++-
5 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/ex3/Makefile b/ex3/Makefile @@ -2,7 +2,7 @@ CC = arm-none-eabi-gcc AS = arm-none-eabi-as LD = arm-none-eabi-ld OBJCOPY = arm-none-eabi-objcopy -OBJDUMP = arm-none-eabi-objdump +OBJDUMP = arm-none-eabi-objdump -Mforce-thumb BINCRC = ../tools/bincrc BIN2UF2 = ../tools/bin2uf2 diff --git a/ex3/main.c b/ex3/main.c @@ -2,8 +2,10 @@ void init(void); int puts(char *); void printh(void *); void set_alarm(unsigned int); +void proc0(void); extern void proc0_start, proc0_size; +extern char *msg0; // A proc represents a process in execution. typedef struct proc { @@ -31,15 +33,8 @@ main(void) { proc *p0 = (proc *) 0x20041000, *p1 = (proc *) 0x20041100; // sram5 - printh(&proc0_start); - puts("a"); - printh(&proc0_size); - puts("b"); - memcpy((void *)0x20000000, (void *)&proc0_start, (long) &proc0_size); - proc0(); - - puts("c"); + puts(msg0); p0->r[13] = (void *) 0x20000100; // sp p0->r[14] = (void *) 0xdeadbeef; // lr diff --git a/ex3/memmap.ld b/ex3/memmap.ld @@ -22,6 +22,7 @@ SECTIONS .rodata : { *(.rodata) kernel_end = .; + . = ALIGN(4); } > SRAM4 AT > FLASH prog_start = LOADADDR(.text); prog_size = kernel_end - kernel_start; @@ -34,4 +35,3 @@ SECTIONS *(.proc1) } > SRAM AT > FLASH } - diff --git a/ex3/proc.s b/ex3/proc.s @@ -1,19 +1,23 @@ - .section .proc0 + .align 1 + .section .proc0, "a" .global proc0 proc0: ldr r0, msg0 bl puts - bx lr + b proc0 + .align 2 + .global msg0 msg0: .asciz "proc0" - .section .proc1 + .align 1 + .section .proc1, "a" .global proc1 proc1: ldr r0, msg1 bl puts b proc1 - + .align 2 msg1: .asciz "proc1" diff --git a/ex3/start.s b/ex3/start.s @@ -249,7 +249,8 @@ memcpy_loop: blt memcpy_loop pop {r4, pc} - + // void putbyte(char b); + // Putbyte writes b to uart0. putbyte: ldr r3, uart0_base mov r1, #1 @@ -263,6 +264,8 @@ txff: str r0, [r3, #0] // UART: UARTDR bx lr + // char getbyte(void); + // Getbyte reads a byte from uart0. getbyte: ldr r3, uart0_base mov r1, #1