Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Sep 2013 21:59:14 +0200
From:      Torfinn Ingolfsen <torfinn.ingolfsen@getmail.no>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 19 Sep 2013 22:29:00 +0100 (BST)
Richard Tobin <richard@inf.ed.ac.uk> 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 <torfinn.ingolfsen@getmail.no>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130927215914.7e93129302efbfafc678994d>