Skip to content

Commit 368e6b9

Browse files
committed
Fix the sram size in linker script
Signed-off-by: Douglas Reis <doreis@lowrisc.org>
1 parent 7558edd commit 368e6b9

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

sw/legacy/link.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ OUTPUT_ARCH(riscv)
66

77
MEMORY
88
{
9-
/* 256 KiB should be enough for anybody... */
10-
ram : ORIGIN = 0x00100000, LENGTH = 0x3F000 /* 252 KiB */
11-
stack : ORIGIN = 0x0013F000, LENGTH = 0x01000 /* 4 KiB */
9+
/* 128 KiB */
10+
ram : ORIGIN = 0x00100000, LENGTH = 0x1F000 /* 124 KiB */
11+
stack : ORIGIN = ORIGIN(ram) + LENGTH(ram), LENGTH = 0x01000 /* 4 KiB */
1212
}
1313

1414
/* Stack information variables */

sw/legacy/test/memory_test.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
#include "timer.h"
1717

1818
#define TEST_DATA (0xDEADBEEF)
19-
#define TEST_SIZE ((224 * 1024) / 4)
19+
// Total ram size minus space for .text and .rodata
20+
#define TEST_SIZE_BYTES (0x1F000 - 0x7000)
21+
#define TEST_SIZE_WORDS TEST_SIZE_BYTES / 4
2022

21-
static uint32_t test_array[TEST_SIZE];
23+
static uint32_t test_array[TEST_SIZE_WORDS];
2224

2325
int pass() {
2426
puts("Passed");
@@ -38,28 +40,28 @@ int main(void) {
3840
uart_init(DEFAULT_UART);
3941

4042
putstr("memory_test running...");
41-
puthex(TEST_SIZE * 4);
43+
puthex(TEST_SIZE_BYTES);
4244
puts(" bytes");
4345

4446
// Simple word write/read test of most of the RAM; some RAM is used by the
4547
// code itself, global static and stack...
46-
for (int i = 0; i < TEST_SIZE; i++) {
48+
for (int i = 0; i < TEST_SIZE_WORDS; i++) {
4749
test_array[i] = TEST_DATA + i;
4850
}
4951
// Read back data and check it is correct
50-
for (int i = 0; i < TEST_SIZE; i++) {
52+
for (int i = 0; i < TEST_SIZE_WORDS; i++) {
5153
if (test_array[i] != TEST_DATA + i) {
5254
return fail();
5355
}
5456
}
5557

5658
// Byte read/write test
5759
uint8_t *btest = (uint8_t *)test_array;
58-
for (int i = 0; i < TEST_SIZE; i++) {
60+
for (int i = 0; i < TEST_SIZE_WORDS; i++) {
5961
btest[i * 4 + (i & 3)] ^= i;
6062
}
6163
// Read back data and check it is correct
62-
for (int i = 0; i < TEST_SIZE; i++) {
64+
for (int i = 0; i < TEST_SIZE_WORDS; i++) {
6365
uint32_t orig = TEST_DATA + i;
6466
uint32_t mod = orig ^ (uint8_t)i << (8 * (i & 3));
6567
if (test_array[i] != mod) {

0 commit comments

Comments
 (0)