diff --git a/brick/Makefile b/brick/Makefile index 857f8dbd..5b53e41d 100644 --- a/brick/Makefile +++ b/brick/Makefile @@ -8,5 +8,5 @@ mod: uf2: $(MAKE) -C uf2daemon @mkdir -p bin - cp uf2daemon/server bin/uf2daemon + cp uf2daemon/server bin/uf2d diff --git a/brick/ins b/brick/ins index c1c3c35d..abeb7604 100755 --- a/brick/ins +++ b/brick/ins @@ -1,22 +1,9 @@ #!/bin/sh set -ex cd /mnt/ramdisk/prjs/ko +echo 3 > /proc/sys/kernel/printk insmod ./nbd.ko sleep 1 -./nbd-serv & +./uf2d > /tmp/uf2d.log 2> /tmp/uf2derr.log sleep 1 insmod ./d_usbdev.ko file=/dev/nbd0 HostStr=EV3 SerialStr=0016535543af -L=/sys/devices/platform/musb_hdrc/gadget/lun0 -echo $L -echo -n "ent: " -read LINE -#echo > $L/file -echo 3 > $L/reset -killall nbd-serv -sleep 1 -./nbd-serv & -sleep 1 -#echo /dev/nbd0 > $L/file -#sleep 1 -echo 4 > $L/reset - diff --git a/brick/mk b/brick/mk index ac3922a3..e6492cc1 100755 --- a/brick/mk +++ b/brick/mk @@ -1,6 +1,6 @@ #!/bin/sh set -xe -scp -qr * vm:linux/pxt/ +scp -qr kernel uf2daemon Makefile vm:linux/pxt/ ssh vm "cd linux/pxt; make $1" mkdir -p bin scp vm:linux/pxt/bin/* bin/ diff --git a/brick/send b/brick/send index ff9e6704..2bdc5f9a 100755 --- a/brick/send +++ b/brick/send @@ -3,6 +3,7 @@ ./mk ev3duder up bin/d_usbdev.ko ../prjs/ko/d_usbdev.ko ev3duder up bin/nbd.ko ../prjs/ko/nbd.ko -ev3duder up bin/nbd-serv ../prjs/ko/nbd-serv ev3duder up ins ../prjs/ko/ins +ev3duder exec 'rm ../prjs/ko/uf2d' +ev3duder up bin/uf2d ../prjs/ko/uf2d diff --git a/brick/uf2daemon/fat.c b/brick/uf2daemon/fat.c index 84f62065..5d794f02 100644 --- a/brick/uf2daemon/fat.c +++ b/brick/uf2daemon/fat.c @@ -666,21 +666,26 @@ void stopLMS() { closedir(dir); if (lmsPid) { - DBG("SIGSTOP to lmsPID=%d", lmsPid); + DBG("SIGSTOP to lmsPID=%d\n", lmsPid); kill(lmsPid, SIGSTOP); + } else { + DBG("LMS not found\n"); } } void waitAndContinue() { + stopLMS(); for (int fd = 3; fd < 9999; ++fd) close(fd); pid_t child = fork(); if (child == 0) { - execl(elfPath, elfPath, "--msd"); + DBG("start %s\n", elfPath); + execl(elfPath, elfPath, "--msd", (char*) NULL); exit(128); } int status; waitpid(child, &status, 0); + DBG("re-start LMS\n"); if (lmsPid) kill(lmsPid, SIGCONT); exit(0); diff --git a/brick/uf2daemon/main.c b/brick/uf2daemon/main.c index aa42d62b..a8aba234 100644 --- a/brick/uf2daemon/main.c +++ b/brick/uf2daemon/main.c @@ -133,6 +133,7 @@ void runNBD() { reply.error = htonl(0); for (;;) { + nbd_ioctl(BLKFLSBUF, 0); // flush buffers - we don't want the kernel to cache the writes int nread = read(sock, &request, sizeof(request)); if (nread < 0) { @@ -199,7 +200,9 @@ int main() { if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != 0) { LOG("abnormal child return, %d", child); - sleep(3); + sleep(5); + } else { + sleep(2); } }