Hifive Unleashed: Memory gets zeroed out (Bare metal with openocd)


(Hafiz Abid Qadeer) #1

Hi,
I am trying to use Hifive unleashed as bare metal platform. Using the openocd gdb server, I can connect to it, load the executable using gdb and run it. It seems to work fine. But I observed that if my executable exceeds 128K, the load seems to zero out the memory in the start. I was able to produce the same issue on openocd console. Please see the example below. I write a word on 0x80000000 and it goes ok. But when I write something on 0x80020000, it seems to zero out the contents on 0x80000000.

mdw 0x80000000
0x80000000: 00000000
mww 0x80000000 0x10101010
mdw 0x80000000
0x80000000: 10101010
mww 0x80020000 0xff
mdw 0x80020000
0x80020000: 000000ff
mdw 0x80000000
0x80000000: 00000000

I thought that it may be some issue with openocd. Then I wrote a C program which repeats this pattern and observed that memory zeroed out there too. Anybody else observed a similar issue. Am I missing some memory initialization? Any help is greatly appreciated.

Thanks,
Abid


(Paul Walmsley) #2

Hi. You mention you’re running bare-metal. Did you set up the DDR controller first? If not, you’ll probably want to start by trying to load and execute code from the L2 scratchpad (“LIM”).