#define SDRAM_BANK_ADDR ((uint32_t)(0x70000000))
......
*(double *)(SDRAM_BANK_ADDR) = o; for (count = 0; count < 10000000; count++) { }; /* Delay */ p = *(double *)(SDRAM_BANK_ADDR); printf("%d\n",p);up_hardfault: PANIC!!! Hard fault: 40000000up_assert: Assertion failed at file:armv7-m/up_hardfault.c line: 148up_registerdump: R0: 00000016 70000000 00989680 00000001 00000000 00000000 00000000 38001e90up_registerdump: R8: 00000000 00000000 00000000 00000000 00000000 38001e90 0801710d 08017132up_registerdump: xPSR: 81000000 BASEPRI: 000000f0 CONTROL: 00000000up_registerdump: EXC_RETURN: ffffffe9up_dumpstate: sp: 38001d18up_dumpstate: stack base: 38001ed0up_dumpstate: stack size: 000007e4up_stackdump: 38001d00: 38001ed0 38001d18 38001d00 38001d00 38001d18 38001dbc 00000000 00000000up_stackdump: 38001d20: 38001d28 0800156f 38001d18 380012b0 000007e4 38001ed0 38001d48 08001635up_stackdump: 38001d40: 00000094 38001d58 00000094 080180e4 38001d58 080024a3 38001d60 00000000up_stackdump: 38001d60: 38001dbc 00000003 00000007 00000080 f0000001 000000f0 38001d80 08002cc9up_stackdump: 38001d80: 38001dbc 00000003 38001d90 00000003 00000000 08002469 38001da0 08002447up_stackdump: 38001da0: 38001dbc 00000003 0000000a 00000000 38001e90 08001ae9 08019f94 38001e90up_stackdump: 38001dc0: 000000f0 00000000 00000000 00000000 38001e90 00000000 00000000 00000000up_stackdump: 38001de0: 00000000 ffffffe9 00000000 00000000 00000000 00000000 00000000 00000000up_stackdump: 38001e00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000up_stackdump: 38001e20: 00000000 00000000 00000016 70000000 00989680 00000001 00000000 0801710dup_stackdump: 38001e40: 08017132 81000000 00000000 00000000 00000000 00000000 00000000 00000000up_stackdump: 38001e60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000up_stackdump: 38001e80: 00000000 00000000 00000000 cc000ccc 38001ed4 00000001 9999999a 3fb99999up_stackdump: 38001ea0: cccccccd 401ccccc 00000000 00000001 38001eb8 08003309 00000000 00000000up_stackdump: 38001ec0: 380012b0 00000001 00000000 00000000 560ce8ef 38001edc 00000000 6e6f6e3c
*(double *)(SDRAM_BANK_ADDR) = o;
8017120: f04f 41e0 mov.w r1, #1879048192 ; 0x70000000
8017124: e9d7 2304 ldrd r2, r3, [r7, #16]
8017128: e9c1 2300 strd r2, r3, [r1]
for (count = 0; count < 10000000; count++) {
801712c: 2300 movs r3, #0
801712e: 61fb str r3, [r7, #28]
8017130: e002 b.n 8017138 <hello_main+0xf8>
8017132: 69fb ldr r3, [r7, #28] <------------- at this place
8017134: 3301 adds r3, #1
8017136: 61fb str r3, [r7, #28]
8017138: 69fb ldr r3, [r7, #28]
801713a: 4a24 ldr r2, [pc, #144] ; (80171cc <hello_main+0x18c>)
801713c: 4293 cmp r3, r2
801713e: dbf8 blt.n 8017132 <hello_main+0xf2>
}; /* Delay */
p = *(double *)(SDRAM_BANK_ADDR);
8017140: f04f 43e0 mov.w r3, #1879048192 ; 0x70000000
8017144: e9d3 2300 ldrd r2, r3, [r3]
8017148: e9c7 2302 strd r2, r3, [r7, #8]--
You received this message because you are subscribed to the Google Groups "NuttX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nuttx+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nuttx/aa9a8207-b481-4afa-8084-f713aaa87195%40googlegroups.com.
up_hardfault: Hard Fault:up_hardfault: IRQ: 3 regs: 0x38001dbcup_hardfault: BASEPRI: 000000f0 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000000up_hardfault: CFAULTS: 00000400 HFAULTS: 40000000 DFAULTS: 0000000a BFAULTADDR: 00000000 AFAULTS: 00000000
up_hardfault: PANIC!!! Hard fault: 40000000up_assert: Assertion failed at file:armv7-m/up_hardfault.c line: 148
up_registerdump: R0: 00000016 c0000000 00989680 00000001 00000000 00000000 00000000 38001e90up_registerdump: R8: 00000000 00000000 00000000 00000000 00000000 38001e90 08016af5 08016b24up_registerdump: xPSR: 01000000 PRIMASK: 00000000 CONTROL: 00000000up_registerdump: EXC_RETURN: ffffffe9up_dumpstate: sp: 38001cf0
up_dumpstate: stack base: 38001ed0up_dumpstate: stack size: 000007e4
up_stackdump: 38001ce0: 38001ce0 38001ce0 38001cf0 00000400 00000000 00000000 38001d00 0800150bup_stackdump: 38001d00: 38001cf0 380012b0 000007e4 38001ed0 38001d20 080015c1 00000094 38001d40up_stackdump: 38001d20: 00000094 08017b84 38001d40 08002421 40000000 0000000a 00000000 00000000up_stackdump: 38001d40: 38001d48 00000000 38001dbc 00000003 38001d58 000000f0 00000000 00000003up_stackdump: 38001d60: 00000000 4a240000 08016b22 38001dbc 00000001 38001dbc 38001d80 08002c4dup_stackdump: 38001d80: 38001dbc 00000003 38001d90 00000003 00000000 08002341 38001da0 0800231fup_stackdump: 38001da0: 38001dbc 00000003 0000000a 00000000 38001e90 08001a5d 08019a34 38001e90up_stackdump: 38001dc0: 00000000 00000000 00000000 00000000 38001e90 00000000 00000000 00000000
up_stackdump: 38001de0: 00000000 ffffffe9 00000000 00000000 00000000 00000000 00000000 00000000up_stackdump: 38001e00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
up_stackdump: 38001e20: 00000000 00000000 00000016 c0000000 00989680 00000001 00000000 08016af5up_stackdump: 38001e40: 08016b24 01000000 00000000 00000000 00000000 00000000 00000000 00000000
up_stackdump: 38001e60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000up_stackdump: 38001e80: 00000000 00000000 00000000 cc000ccc 38001ed4 00000001 9999999a 3fb99999
up_stackdump: 38001ea0: cccccccd 401ccccc 00000000 00000001 38001eb8 08003259 00000000 00000000up_stackdump: 38001ec0: 380012b0 00000001 00000000 00000000 560868ef 38001edc 00000000 6e6f6e3c
up_hardfault: BASEPRI: 000000f0 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000000up_hardfault: CFAULTS: 00000400 HFAULTS: 40000000 DFAULTS: 0000000a BFAULTADDR: 00000000 AFAULTS: 00000000
The configurable fault register (CFAULTS) is 00000400, which means that you have a bus fault and the bus fault status register (bits 8-15) is 0x04 which, as I suspected is an imprecise error. I gave you a reference before: https://interrupt.memfault.com/blog/cortex-m-fault-debug
Imprecise Bus Error Debug Tips
Imprecise errors are one of the hardest classes of faults to debug. They result asynchronously to instruction execution flow. This means the registers stacked on exception entry will not point to the code that caused the exception.
Instruction fetches and data loads should always generate synchronous faults for Cortex-M devices and be precise. Conversely, store operations can generate asynchronous faults. This is because writes will sometimes be buffered prior to being flushed to prevent pipeline stalls so the program counter will advance before the actual data store completes.
When debugging an imprecise error, you will want to inspect the code around the area reported by the exception for a store that looks suspicious. If the MCU has support for the ARM Embedded Trace Macrocell (ETM), the history of recently executed instructions can be viewed by some debuggers3.
The error is almost certainly caused by the write of the double type to address 0x70000000. As that reference says, the write is buffered and the error gets reported asynchronously some time laster.
I would try to debug the imprecise error. You know that it is an
error in the SDRAM controller setup.. but have not idea what the
error is caused by exactly.
Greg
There is a pretty good memory test at apps/system/ramtest. I performs a lot of tests. I would use that ramtest with SDRAM until you get the SDRAM to pass the test. If the SDRAM passes that test, it is probably configured properly.
Basically I just copied and modified FMC related code from arch/arm/stm32f7 to arch/arm/stm32h7.Make some changes in stm32h7's Kconfig file to be able to select FMC in makemenu. And created stm32_extmem.c file (learn from board/stm32746g-disco) in my costom board's src folder , add it to Makefile.
up_hardfault: IRQ: 3 regs: 0x38001dbc
up_hardfault: BASEPRI: 000000f0 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000000
up_hardfault: CFAULTS: 00008200 HFAULTS: 40000000 DFAULTS: 0000000b BFAULTADDR: c0000000 AFAULTS: 00000000
up_hardfault: PANIC!!! Hard fault: 40000000up_assert: Assertion failed at file:armv7-m/up_hardfault.c line: 148
up_registerdump: R0: 00000016 00000002 00989680 c0000000 00000000 00000000 00000000 38001e90up_registerdump: R8: 00000000 00000000 00000000 00000000 00000000 38001e90 08016545 0801655cup_registerdump: xPSR: 61000000 PRIMASK: 00000000 CONTROL: 00000000up_registerdump: EXC_RETURN: ffffffe9up_dumpstate: sp: 38001cf0
up_dumpstate: stack base: 38001ed0up_dumpstate: stack size: 000007e4
There is arch/arm/src/stm32f7/stm32_fmc.h, and boards/arm/stm32f746g-disco/src/stm32_extmem.c
There is nothing like arch/arm/src/stm32/stm32_fmc.c, but maybe you can get by without that.
You still probably have to enable FMC clocking in the STM32H7 RCC
logic by setting RCC_AHB3ENR_FMCEN
Sorry to disturb again ;)
Sorry to disturb again ;)
nsh> ramtest c0000000 4000
RAMTest: Marching ones: c0000000 4000
RAMTest: Marching zeroes: c0000000 4000
RAMTest: Pattern test: c0000000 4000 55555555 aaaaaaaa
RAMTest: Pattern test: c0000000 4000 66666666 99999999
RAMTest: Pattern test: c0000000 4000 33333333 cccccccc
RAMTest: Address-in-address test: c0000000 4000
nsh> ramtest c0000000 4000
RAMTest: Marching ones: c0000000 4000
RAMTest: Marching zeroes: c0000000 4000
RAMTest: ERROR: Address 0xc00001a6 Found: efff Expected efff
RAMTest: ERROR: Address 0xc00009a6 Found: ffff Expected efff
RAMTest: ERROR: Address 0xc0000da6 up_assert: Assertion failed at file:mm_heap/mm_free.c line: 94
up_registerdump: R0: 00000001 24000270 0000003f 00000000 00000000 00000000 00000000 38001990
up_registerdump: R8: 00000000 00000000 00000000 00000000 00000000 38001970 0800138d 0800164a
nsh> ramtest c0000000 33554430RAMTest: Marching ones: c0000000 33554430RAMTest: ERROR: Address 0xc00001e6 Found: 00e1 Expected 0001RAMTest: ERROR: Address 0xc0000376 Found: 0071 Expected 0001RAMTest: ERROR: Address 0xc00005e6 Found: 00e1 Expected 0001RAMTest: ERROR: Address 0xc0000776 Found: 0071 Expected 0001RAMTest: ERROR: Address 0xc00009e6 Found: 00e1 Expec$RAMTest: ERR����$808�8876 Fx8: 00$8$RA
To unsubscribe from this group and stop receiving emails from it, send an email to nu...@googlegroups.com.
No, I don't think SDRAM is in heap, I removed declaration of SDRAM from scripts/flash.ld and scripts/memory.ld, also CONFIG_ARCH_HAVE_HEAP2=n
By the way, the error address is not completely random:
nsh> ramtest c0000000 33554430RAMTest: Marching ones: c0000000 33554430RAMTest: ERROR: Address 0xc00001e6 Found: 00e1 Expected 0001RAMTest: ERROR: Address 0xc0000376 Found: 0071 Expected 0001RAMTest: ERROR: Address 0xc00005e6 Found: 00e1 Expected 0001RAMTest: ERROR: Address 0xc0000776 Found: 0071 Expected 0001RAMTest: ERROR: Address 0xc00009e6 Found: 00e1 Expec$RAMTest: ERR����$808�8876 Fx8: 00$8$RA
The RAM test is a very good test. It generates some really crazy noise patterns.
It looks like if address bit 8=1, bit6=1, bit5=1,bit4=0, bit3=0,bit2=1,bit1=1, and bit0=0 you generate the error.
Also notice that bits 5-6 from the address also appear int the data read, implying that when the data was sampled, the address (or part of of it) was still on the bus. That would be an SDRAM setup problem. (Actually, you can't tell from this if the error occurred on the read or on the write).
void write_to_memory(uint8_t value) {
uint8_t *ptr = 0x60000000;
for (int i = 0; i < 33554410; i += 1)
{
*ptr++ = value;
}
}
void verify_memory(uint8_t value) {
uint8_t *ptr = 0x60000000;
for (int i = 0; i < 33554410; i += 1)
{
uint8_t v = *ptr;
if (v != value) {
printf("error addr: %08x, data: %ld\n", ptr, *ptr);
}
ptr++;
}
ptr--;
printf("last verified addr: %08x, data: %ld\n", ptr, *ptr);
}
int main(int argc, FAR char *argv[])
{
printf("Hello, World!!\n");
printf("sizeof uint8: %d\n", sizeof(uint8_t));
for (int i = 0; i < 255; i++)
{
write_to_memory(i);
verify_memory(i);
}
return 0;
}NuttShell (NSH) NuttX-8.2
nsh> hello
Hello, World!!
sizeof uint8: 1
last verified addr: 61ffffe9, data: 0
last verified addr: 61ffffe9, data: 1
last verified addr: 61ffffe9, data: 2
............. ( no error )
last verified addr: 61ffffe9, data: 16
last verified addr: 61ffffe9, data: 17
last verified addr: 61ffffe9, data: 18
last verified addr: 61ffffe9, data: 19
error addr: 61248266, data: 4
error addr: 61248267, data: 4
error addr: 61248666, data: 4
error addr: 61248667, data: 4
error addr: 61248a66, data: 4
error addr: 61248a67, data: 4
error addr: 61248e66, data: 4
error addr: 61248e67, data: 4
error addr: 61249666, data: 4
error addr: 61249667, data: 4
last verified addr: 61ffffe9, data: 20
last verified addr: 61ffffe9, data: 21
.............. (some errors)last verified addr: 61ffffe9, data: 135last verified addr: 61ffffe9, data: 136last verified addr: 61ffffe9, data: 137
.............. (some errors)
last verified addr: 61ffffe9, data: 253
last verified addr: 61ffffe9, data: 254
Now I think it's may be a hardware problem and I'm going to by another same board to test it out.
(Or may be it's a cache/buffer problem. I tried to disable/enable DCACHE, but get same corrupted data).
It is necessary for the SDRAM memory region to be strongly
ordered during SDRAM initialization. You can control whether
SDRAM is cacheable or not.
You would think that the effect of data cache, if write buffered
would be that possible SDRAM errors would be missed (since the
data should always be correct in the data cache).
Every time I run ramtest with large size, I got two error:
Assertion failed at file:mm_heap/mm_free.c line: 94
Assertion failed at file:mm_heap/mm_free.c line: 87
This means that something has corrupted the heap. Of course, something related to SDRAM would be suspected in this case. But since you are certain that the SDRAM is not in the heap, then it is not clear how SDRAM accesses could cause this unless they are interfering with the bus in some odd way or if addressing was being aliased.
However, the normal cause an error like this is because the stack size is insufficient or a bad pointer is being used. You might try increasing all of the stack sizes in the .config file to see if this goes away.
write_memory(info, pattern);
write_memory(info, pattern);
verify_memory(info, pattern);NuttShell (NSH) NuttX-8.2nsh> ramtest 60000000 33554420RAMTest: Marching ones: 60000000 33554420RAMTest: Marching zeroes: 60000000 33554420RAMTest: Pattern test: 60000000 33554420 55555555 aaaaaaaaRAMTest: Pattern test: 60000000 33554420 66666666 99999999RAMTest: Pattern test: 60000000 33554420 33333333 ccccccccRAMTest: Address-in-address test: 60000000 33554420