Open splinedrive opened 4 years ago
Hi @stv0g ,
I was completely surprised when I found the root causes of the problem.
commit f3b1246c862c37108f2a472816e2ed2e5b37e269 Author: Steffen Vogel post@steffenvogel.de Date: Mon Feb 11 23:14:56 2019 +0100
picosoc: added memtest
cmd_memtest() will be called once at the start of the firmware.c But it destroys the _sdata section of e.g. global vars, static vars in function etc. I was debugging with leds your start.s :) and learned a little bit risc v assembler :). It was a good learning process to understand hx8kdemo_sections.lds and start.s how it copies data from _sidata (flash memory, 0x0100000) to _sdata (ram starts at 0x000000) to initialize data. But I do not understand why cmd_memtest() is implemented to destroy data, bss and heap section. I modified the cmd_test only to have something. It will allocate test memory on stack, you can define the size with SIZE_OF_TESTMEM.
@@ -37,10 +37,14 @@ extern uint32_t sram;
+#define SIZE_OF_TESTMEM 50
@@ -295,8 +329,8 @@ void cmd_memtest() int stride = 256; uint32_t state;
@@ -304,13 +338,13 @@ void cmd_memtest() for (int i = 1; i <= cyc_count; i++) { state = i;
for (int word = 0; word < MEM_TOTAL / sizeof(int); word += stride) {
for (int word = 0; word < SIZE_OF_TESTMEM; word += stride) { *(base_word + word) = xorshift32(&state); }
state = i;
for (int word = 0; word < MEM_TOTAL / sizeof(int); word += stride) {
for (int word = 0; word < SIZE_OF_TESTMEM; word += stride) { if (*(base_word + word) != xorshift32(&state)) { print(" FAILED WORD at "); print_hex(4*word, 4); @@ -323,11 +357,11 @@ void cmd_memtest() }
// Byte access
for (int byte = 0; byte < 128; byte++) {
for (int byte = 0; byte < SIZE_OF_TESTMEM4; byte++) { (base_byte + byte) = (uint8_t) byte; }
for (int byte = 0; byte < 128; byte++) {
for (int byte = 0; byte < SIZE_OF_TESTMEM4; byte++) { if ((base_byte + byte) != (uint8_t) byte) { print(" FAILED BYTE at "); print_hex(byte, 4); @@ -342,6 +376,7 @@ void cmd_memtest()
br,
Hirosh.
Hello @cliffordwolf ,
I would like to express my sincere thanks to (yosys, picovr, nextpnr, ...) :) It's a lot of fun.
One question! I have modified firmware.c and i inserted static vars but they doesn't work. Any idea?
br,
HD