From 5b07f103d71d27f72ee03d3f8da24617835b42d0 Mon Sep 17 00:00:00 2001 From: Xiangfu Date: Sat, 22 Dec 2012 21:59:40 +0800 Subject: [PATCH] mini-jtag: reset board before load config bits file --- mini-jtag/Makefile | 36 ++++++++++++++++++------------------ mini-jtag/mini-jtag.c | 18 +++++++++++------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/mini-jtag/Makefile b/mini-jtag/Makefile index fe2f608..a465fbb 100644 --- a/mini-jtag/Makefile +++ b/mini-jtag/Makefile @@ -37,14 +37,29 @@ clean: %.bit: @echo "" - @echo "Compile $@ by yourself. copy the bits file here" + @echo "Move the config bits file: <$@> here." @echo "" @exit 1 -test: test-counter test-blinking test-hello_world +test: test-hello_world test-blinking test-counter + +hello_world.bit: + make -C .. hello_world fp2bit + ../hello_world | ../fp2bit - $@ + +test-hello_world: hello_world.bit mini-jtag + ./mini-jtag load $< + sleep 2 + +blinking.bit: + make -C .. blinking_led fp2bit + ../blinking_led | ../fp2bit - $@ + +test-blinking: blinking.bit mini-jtag + ./mini-jtag load $< + sleep 2 test-counter: counter.bit mini-jtag - @./mini-jtag reset @./mini-jtag load $< @echo "Read counter registers (1 ~ 5)" @./mini-jtag read 0 # read version @@ -68,18 +83,3 @@ test-counter: counter.bit mini-jtag @sleep 1 @./mini-jtag read 4 # read counter @./mini-jtag write 1 0 # disable counter - -test-blinking: blinking.bit mini-jtag - ./mini-jtag reset - ./mini-jtag idcode - ./mini-jtag load $< - sleep 2 - ./mini-jtag reset - -hello_world.bit: - make -C ../ - ../hello_world | ../fp2bit - $@ - -test-hello_world: hello_world.bit - ./mini-jtag reset - ./mini-jtag load $< diff --git a/mini-jtag/mini-jtag.c b/mini-jtag/mini-jtag.c index a604abf..267fb21 100644 --- a/mini-jtag/mini-jtag.c +++ b/mini-jtag/mini-jtag.c @@ -61,6 +61,13 @@ static void rev_dump(uint8_t *buf, uint16_t len) printf("%02x ", buf[i]); } +static void brd_reset(struct ftdi_context *ftdi) +{ + tap_reset_rti(ftdi); + tap_shift_ir(ftdi, JPROGRAM); + tap_reset_rti(ftdi); +} + static void usage(char *name) { fprintf(stderr, @@ -138,11 +145,8 @@ int main(int argc, char **argv) printf("\n"); } - if (!strcmp (argv[1], "reset")) { - tap_reset_rti(&ftdi); - tap_shift_ir(&ftdi, JPROGRAM); - tap_reset_rti(&ftdi); - } + if (!strcmp (argv[1], "reset")) + brd_reset(&ftdi); if (!strcmp (argv[1], "load")) { int i; @@ -194,9 +198,9 @@ int main(int argc, char **argv) for (u = 0; u < bs->length; u++) dr_data[u] = rev8(bs->data[u]); - tap_reset_rti(&ftdi); - tap_shift_ir(&ftdi, CFG_IN); + brd_reset(&ftdi); + tap_shift_ir(&ftdi, CFG_IN); tap_shift_dr_bits(&ftdi, dr_data, bs->length * 8, NULL); /* ug380.pdf