efabless / clear

Apache License 2.0
57 stars 6 forks source link

Chaotic blinking flashing #35

Open Martoni opened 3 months ago

Martoni commented 3 months ago

Hello,

I'm trying to flash the simple blinking example given here.

I've managed to compile blink and configure caravel with flash target :

$ make
generating hex for [blink]
riscv64-unknown-elf-gcc -I../fpga_bitstreams/ -I../common/ -O0 -mabi=ilp32 -march=rv32i -D__vexriscv__ -Wl,-Bstatic,-T,../common/sections.lds,--strip-debug -ffreestanding -nostdlib -o blink.elf ../common/crt0_vex.S ../common/isr.c ../common/gpio_program.c blink.c
riscv64-unknown-elf-objdump -s  blink.elf > blink.lst
riscv64-unknown-elf-objcopy -O verilog blink.elf blink.hex
sed -ie 's/@10/@00/g' blink.hex
$

Flashing work an the first try :

$ make flash
generating hex for [blink]
python3 ../util/ftdi_flash.py blink.hex
Success: Found one matching FTDI device at ftdi://ftdi:232h:1:1c/1

Resetting Flash...
status = 0x00

JEDEC = b'ef4016'
Erasing chip...
done
status = 0x0
setting address to 0x0
addr 0x0: flash page write successful
addr 0x100: flash page write successful
addr 0x200: flash page write successful
addr 0x300: flash page write successful
addr 0x400: flash page write successful
addr 0x500: flash page write successful
addr 0x600: flash page write successful
addr 0x700: flash page write successful
addr 0x800: flash page write successful
addr 0x900: flash page write successful
addr 0xa00: flash page write successful
addr 0xb00: flash page write successful
addr 0xc00: flash page write successful
addr 0xd00: flash page write successful
addr 0xe00: flash page write successful
addr 0xf00: flash page write successful
addr 0x1000: flash page write successful
addr 0x1100: flash page write successful
addr 0x1200: flash page write successful
addr 0x1300: flash page write successful
addr 0x1400: flash page write successful

total_bytes = 5376
status reg_1 = 0x0
status reg_2 = 0x2
************************************
verifying...
************************************
status reg_1 = 0x0
status reg_2 = 0x2
setting address to 0x0
addr 0x0: read compare successful
addr 0x100: read compare successful
addr 0x200: read compare successful
addr 0x300: read compare successful
addr 0x400: read compare successful
addr 0x500: read compare successful
addr 0x600: read compare successful
addr 0x700: read compare successful
addr 0x800: read compare successful
addr 0x900: read compare successful
addr 0xa00: read compare successful
addr 0xb00: read compare successful
addr 0xc00: read compare successful
addr 0xd00: read compare successful
addr 0xe00: read compare successful
addr 0xf00: read compare successful
addr 0x1000: read compare successful
addr 0x1100: read compare successful
addr 0x1200: read compare successful
addr 0x1300: read compare successful
addr 0x1400: read compare successful

total_bytes = 5376

But if I retried the flash command I get errors :

$ make flash
generating hex for [blink]
python3 ../util/ftdi_flash.py blink.hex
Success: Found one matching FTDI device at ftdi://ftdi:232h:1:1d/1

Resetting Flash...
status = 0x00

JEDEC = b'ef4016'
Erasing chip...
done
status = 0x0
setting address to 0x0
addr 0x0: flash page write successful
addr 0x100: flash page write successful
addr 0x200: flash page write successful
addr 0x300: flash page write successful
addr 0x400: flash page write successful
addr 0x500: flash page write successful
addr 0x600: flash page write successful
addr 0x700: flash page write successful
addr 0x800: flash page write successful
addr 0x900: flash page write successful
addr 0xa00: flash page write successful
addr 0xb00: flash page write successful
addr 0xc00: flash page write successful
addr 0xd00: flash page write successful
addr 0xe00: flash page write successful
addr 0xf00: flash page write successful
addr 0x1000: flash page write successful
addr 0x1100: flash page write successful
addr 0x1200: flash page write successful
addr 0x1300: flash page write successful
addr 0x1400: flash page write successful

total_bytes = 5376
status reg_1 = 0x0
status reg_2 = 0x2
************************************
verifying...
************************************
status reg_1 = 0x0
status reg_2 = 0x2
setting address to 0x0
addr 0x0: *** read compare FAILED ***
b'6f00000b13000000130000001300000013000000130000001300000013000000232e11fe232c51fe232a61fe232871fe2326a1fe2324b1fe2322c1fe2320d1fe232ee1fc232cf1fc232a01fd232811fd2326c1fd2324d1fd2322e1fd2320f1fd130101fcef0000118320c1038322810303234103832301030325c1028325810203264102832601020327c101832781010328410183280101032ec100832e8100032f4100832f0100130101047300203013010040170500001305c5f67310553013050000930500001716000013068643630cb500832606002320d50013054500130646006ff0dffe13050000930580006308b50023200500130545006ff05fff'
<----->
b'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
make: *** [../common/common_makefile.mk:38 : flash] Erreur 1

I unplugged the board and changed blink delay to test recompile (l.142) :

//      delay(800000);
        delay(8000000);

And flashing works (have to push reset button first) and LED blinked slower.

It's seem like I need to unplug the board befor reflashing. Is it a normal behavior ?