Fix peripheral addresses, improve memory testing
authorJean THOMAS <git0@pub.jeanthomas.me>
Wed, 29 Jul 2020 16:09:47 +0000 (18:09 +0200)
committerJean THOMAS <git0@pub.jeanthomas.me>
Wed, 29 Jul 2020 16:09:47 +0000 (18:09 +0200)
examples/firmware/link.ld
examples/firmware/main.c

index 1cc22fe6d9c08ee6cc900d56cdd35b50e831dace..b8ef93bf9da5cf4a46224d080e91f24bd329fe9f 100644 (file)
@@ -3,8 +3,8 @@ ENTRY(_start)
 
 MEMORY
 {
-       rom : ORIGIN = 0x00007000, LENGTH = 0x1000
-       ram : ORIGIN = 0x00004000, LENGTH = 0x1000
+       rom : ORIGIN = 0x00000000, LENGTH = 0x1000
+       ram : ORIGIN = 0x00001000, LENGTH = 0x1000
 }
 
 SECTIONS
index 79849dec0b8e05585a0eac40c79fc06c291b5270..85d59bcfeff54bfbd2ad1e0e4ceb7e07d076fd2b 100644 (file)
@@ -28,7 +28,7 @@ struct uart_regs {
 
 void uart_write(char c)
 {
-       struct uart_regs *regs = 0x5000;
+       struct uart_regs *regs = 0x2000;
        while (!read32(&regs->tx_rdy));
        write32(&regs->tx_data, c);
 }
@@ -78,11 +78,11 @@ int main(void) {
                uart_writestr("Writing to 0x");
                uart_writeuint32(&ram[i]);
                uart_write('\n');
-               ram[i] = 0xDEADBEEF;
+               ram[i] = 0xDEAF0000 | i*4;
        }
 
        for (size_t i = 0; i < 1000; i++) {
-               if (ram[i] != 0xDEADBEEF) {
+               if (ram[i] != (0xDEAF0000 | i*4)) {
                        uart_writestr("fail : *(0x");
                        uart_writeuint32(&ram[i]);
                        uart_writestr(") = ");