From owner-freebsd-arm@FreeBSD.ORG Fri Sep 27 19:59:34 2013 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F0AC96F1 for ; Fri, 27 Sep 2013 19:59:33 +0000 (UTC) (envelope-from torfinn.ingolfsen@getmail.no) Received: from galore.getmail.no (galore.getmail.no [84.210.184.6]) by mx1.freebsd.org (Postfix) with ESMTP id 8EF3D27E9 for ; Fri, 27 Sep 2013 19:59:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by galore.getmail.no (Postfix) with ESMTP id 59150154113 for ; Fri, 27 Sep 2013 21:59:20 +0200 (CEST) X-Spam-Flag: NO X-Spam-Score: -2.95 X-Spam-Level: X-Spam-Status: No, score=-2.95 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, T_FB_WORD2_END_DOLLAR=0.01, T_KHOP_THREADED=-0.01, T_NICE_REPLY_A=0.01, T_TVD_SUBJ_NUM_OBFU=0.01, T_TVD_SUBJ_NUM_OBFU2=0.01, T_TVD_SUBJ_NUM_OBFU3=0.01, T_UNKNOWN_ORIGIN=0.01] autolearn=ham Authentication-Results: galore.get.c.bitbit.net (amavisd-new); dkim=pass (1024-bit key) header.d=getmail.no Received: from galore.getmail.no ([127.0.0.1]) by localhost (galore.get.c.bitbit.net [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id F2ypilsMnJXH for ; Fri, 27 Sep 2013 21:59:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by galore.getmail.no (Postfix) with ESMTP id 9D5B9154111 for ; Fri, 27 Sep 2013 21:59:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.7.1 galore.getmail.no 9D5B9154111 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getmail.no; s=8A9C8B4C-D727-11E2-8095-B6466E6B3FA2; t=1380311959; bh=v7RWTn7bjcqCS1Zgdss8KmuhCMaDyY1/dKGdSzZfpQQ=; h=Date:From:To:Subject:Message-Id:Mime-Version:Content-Type: Content-Transfer-Encoding; b=sYulNaqw8pT27YYTI5UBHZ/yoWOot0+lHkip4bE/DUo/ltOye6jb2hed7gt9EbSmv N89p2leDgyp6cgmlpsyZkdrSTb/sHtt7L18e7IYMrsywFwCdYqYt+b2zvkHMwh+26W q8b0ynhyi87osorLbqBOmAvz6Z/+QK6RwCiToc1o= X-Virus-Scanned: amavisd-new at Received: from galore.getmail.no ([127.0.0.1]) by localhost (galore.get.c.bitbit.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id i62pllKdZL7J for ; Fri, 27 Sep 2013 21:59:19 +0200 (CEST) Received: from kg-core1.kg4.no (cm-84.215.180.206.getinternet.no [84.215.180.206]) by galore.getmail.no (Postfix) with ESMTPSA id 78FF6154110 for ; Fri, 27 Sep 2013 21:59:19 +0200 (CEST) Date: Fri, 27 Sep 2013 21:59:14 +0200 From: Torfinn Ingolfsen To: freebsd-arm@FreeBSD.org Subject: Re: stm32flash under FreeBSD? Message-Id: <20130927215914.7e93129302efbfafc678994d@getmail.no> In-Reply-To: <20130919212900.5A46A97324E@macavity.inf.ed.ac.uk> References: <20130919212900.5A46A97324E@macavity.inf.ed.ac.uk> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.24.19; amd64-portbld-freebsd8.4) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Sep 2013 19:59:34 -0000 On Thu, 19 Sep 2013 22:29:00 +0100 (BST) Richard Tobin wrote: > > The log shows open, fcntl, tcgettatr, tcgettatr, tcflush, > tcsetattr, tcgettatr. The NLS stuff is inside perror(). > > serial_open() does open, fcntl, tcgettatr, tcgettatr. > > serial_setup() does tcflush, tcsetattr, tcgettatr, and then fails if > the tcgettatr doesn't match the tcsetattr. Presumably that's what's > happening. You were correct. :-) > I would put some debugging printf()s in to see what the settings > returned by the tcgettattr in serial_setup() are. A quick test, printing the flags in hex shows this: tingo@kg-core1$ ./stm32flash /dev/cuaU0 stm32flash - http://stm32flash.googlecode.com/ (read, written) iflag: 1, 1 (read, written) oflag: 0, 0 (read, written) cflag: db00, db10 (read, written) lflag: 0, 0 /dev/cuaU0: No such file or directory So the control flags differ, hmm. The code does this: switch(parity) { case SERIAL_PARITY_NONE: port_parity = 0; break; case SERIAL_PARITY_EVEN: port_parity = INPCK | PARENB; break; case SERIAL_PARITY_ODD : port_parity = INPCK | PARENB | PARODD; break; According to the man page INPCK is an input flag. But then they push that into the control flags here: h->newtio.c_cflag |= port_parity | port_bits | port_stop | CLOCAL | CREAD; which looks wrong to me. Comments? I wonder what happens if I just remove that flag in the code i the switch statement. Ok, it gets a bit further: tingo@kg-core1$ ./stm32flash /dev/cuaU0 stm32flash - http://stm32flash.googlecode.com/ (read, written) iflag: 1, 1 (read, written) oflag: 0, 0 (read, written) cflag: db00, db00 (read, written) lflag: 0, 0 Serial Config: 57600 8E1 read_byte: No such file or directory Assertion failed: (0), function stm32_read_byte, file stm32.c, line 90. Abort trap (core dumped) Truss output (in case it helps): tingo@kg-core1$ LANG=C truss ./stm32flash /dev/cuaU0 __sysctl(0x7fffffffe080,0x2,0x7fffffffe09c,0x7fffffffe090,0x0,0x0) = 0 (0x0) mmap(0x0,688,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 34365198336 (0x800535000) munmap(0x800535000,688) = 0 (0x0) __sysctl(0x7fffffffe0f0,0x2,0x80063f408,0x7fffffffe0e8,0x0,0x0) = 0 (0x0) mmap(0x0,32768,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34365198336 (0x800535000) issetugid(0x800536015,0x800530684,0x80064bb10,0x80064bae0,0x5991,0x0) = 0 (0x0) open("/etc/libmap.conf",O_RDONLY,0666) ERR#2 'No such file or directory' open("/var/run/ld-elf.so.hints",O_RDONLY,057) = 3 (0x3) read(3,"Ehnt\^A\0\0\0\M^@\0\0\0002\^A\0"...,128) = 128 (0x80) lseek(3,0x80,SEEK_SET) = 128 (0x80) read(3,"/lib:/usr/lib:/usr/lib/compat:/u"...,306) = 306 (0x132) close(3) = 0 (0x0) access("/lib/libc.so.7",0) = 0 (0x0) open("/lib/libc.so.7",O_RDONLY,030771340) = 3 (0x3) fstat(3,{ mode=-r--r--r-- ,inode=5537727,size=1298464,blksize=32768 }) = 0 (0x0) pread(0x3,0x80063e2c0,0x1000,0x0,0x101010101010101,0x8080808080808080) = 4096 (0x1000) mmap(0x0,2371584,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 34366341120 (0x80064c000) mmap(0x80064c000,1085440,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE,3,0x0) = 34366341120 (0x80064c000) mmap(0x800855000,126976,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,3,0x109000) = 34368475136 (0x800855000) mmap(0x800874000,110592,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_ANON,-1,0x0) = 34368602112 (0x800874000) close(3) = 0 (0x0) mmap(0x0,656,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 34365231104 (0x80053d000) munmap(0x80053d000,656) = 0 (0x0) mmap(0x0,43904,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 34365231104 (0x80053d000) munmap(0x80053d000,43904) = 0 (0x0) sysarch(0x81,0x7fffffffe170,0x800539088,0x0,0xffffffffffcde450,0x8080808080808080) = 0 (0x0) sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0) = 0 (0x0) sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0) __sysctl(0x7fffffffe100,0x2,0x80087a780,0x7fffffffe0f8,0x0,0x0) = 0 (0x0) sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0) = 0 (0x0) sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0) fstat(1,{ mode=crw--w---- ,inode=147,size=0,blksize=4096 }) = 0 (0x0) __sysctl(0x7fffffffe0c0,0x2,0x800879dc8,0x7fffffffe0b8,0x0,0x0) = 0 (0x0) __sysctl(0x7fffffffdfe0,0x2,0x7fffffffdf70,0x7fffffffdfd8,0x8007478c0,0xc) = 0 (0x0) __sysctl(0x7fffffffdf70,0x2,0x800879fd0,0x7fffffffe038,0x0,0x0) = 0 (0x0) readlink("/etc/malloc.conf",0x7fffffffe0e0,1024) ERR#2 'No such file or directory' issetugid(0x800746581,0x7fffffffe0e0,0xffffffffffffffff,0x0,0x2,0x0) = 0 (0x0) break(0x600000) = 0 (0x0) __sysctl(0x7fffffffe370,0x2,0x7fffffffe38c,0x7fffffffe380,0x0,0x0) = 0 (0x0) mmap(0x0,2097152,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34368712704 (0x80088f000) mmap(0x800a8f000,1511424,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34370809856 (0x800a8f000) munmap(0x80088f000,1511424) = 0 (0x0) ioctl(1,TIOCGETA,0xffffe550) = 0 (0x0) stm32flash - http://stm32flash.googlecode.com/ write(1,"stm32flash - http://stm32flash.g"...,47) = 47 (0x2f) write(1,"\n",1) = 1 (0x1) open("/dev/cuaU0",O_RDWR|O_NONBLOCK|O_NOCTTY,00) = 3 (0x3) fcntl(3,F_SETFL,0x0) = 0 (0x0) ioctl(3,TIOCGETA,0xa07084) = 0 (0x0) ioctl(3,TIOCGETA,0xa070b0) = 0 (0x0) ioctl(3,TIOCFLUSH,0xffffe5d4) = 0 (0x0) ioctl(3,TIOCSETA,0xa070b0) = 0 (0x0) ioctl(3,TIOCGETA,0xffffe630) = 0 (0x0) (read, written) iflag: 1, 1 write(2,"(read, written) iflag: 1, 1\n",28) = 28 (0x1c) (read, written) oflag: 0, 0 write(2,"(read, written) oflag: 0, 0\n",28) = 28 (0x1c) (read, written) cflag: db00, db00 write(2,"(read, written) cflag: db00, db0"...,34) = 34 (0x22) (read, written) lflag: 0, 0 write(2,"(read, written) lflag: 0, 0\n",28) = 28 (0x1c) Serial Config: 57600 8E1 write(1,"Serial Config: 57600 8E1\n",25) = 25 (0x19) write(3,"\^?",1) = 1 (0x1) read(3,0x7fffffffe62b,1) = 0 (0x0) stat("/usr/share/nls/C/libc.cat",0x7fffffffd850) ERR#2 'No such file or directory' stat("/usr/share/nls/libc/C",0x7fffffffd850) ERR#2 'No such file or directory' stat("/usr/local/share/nls/C/libc.cat",0x7fffffffd850) ERR#2 'No such file or directory' stat("/usr/local/share/nls/libc/C",0x7fffffffd850) ERR#2 'No such file or directory' read_byte: No such file or directory writev(0x2,0x7fffffffdd90,0x4,0x19,0x1b6664,0x800a00158) = 37 (0x25) Assertion failed: (0), function stm32_read_byte, file stm32.c, line 90. write(2,"Assertion failed: (0), function "...,72) = 72 (0x48) sigprocmask(SIG_SETMASK,SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGTRAP|SIGEMT|SIGFPE|SIGKILL|SIGBUS|SIGSEGV|SIGSYS|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0) = 0 (0x0) getpid() = 19636 (0x4cb4) kill(19636,SIGABRT) = 0 (0x0) SIGNAL 6 (SIGABRT) process exit, rval = 0 -- Torfinn Ingolfsen