Hi,
This is me:
I'm trying to develop for the mbed microcontroller on FreeBSD. The mbed is a microcontroller with a mini USB jack, which when plugged into the host OS, appears as both a mass-storage device and a serial port. See mbed.org for more information.
I have no problem mounting the device and programming it via the cloud IDE (binaries are simply saved to the mass storage device).
My problem applies to monitoring the Serial output of the mbed device on the host serial port. The problem is fundamental: I am unable to see any output from the mbed. This is not a problem on Linux, or Mac, or Windows. I mention the latter, so you can have some confidence that this is not user error: I have used the mbed device on perhaps 15 different non-FreeBSD systems without the problem described here.
This is my first post here. I must admit, I was a little intimidated in this regard, out of fear of appearing stupid. I've attempted to comply to the exacting standards outlined by DutchDaemon, but no doubt I'll have made some egregious mistake in someone's unforgiving eyes. I hope not.
Obseve the following sequence of events (I'm going to plug the mbed device in):
Everything looks OK, both the serial console (umodem0) and the mass storage device (umass0) appear. I'm not sure about the last two lines, but I'm guessing it isn't the problem, any thoughts?
Now that the mbed is plugged in, I'm going to try and monitor it via screen:
Whilst you can't see the output, trust me that screen says:
Hmm, this is strange, what permissions are on this device?
And to which groups do I belong?
Right, so I'm a member of operator, and it looks like operator has rw permissions, so why can I not open this device? Let me guess, there is some weird proviso somehwere that I don't know about concerning these special devices?
That's my first problem: permissions.
However, as I know what I'm connecting to, I don't mind being root to check things out. I'll try and connect as root:
This time the screen session starts, but I cannot see any output from the mbed device. It could be the mbed doing something odd I suppose, but this seems unlikely since it works on Linux and Mac without issue.
You probably don't care, but on the mbed I'm using an exceptionally simple test program:
At least you should be able to ascertain that it would be difficult to get this wrong.
What does stty say about the console device? :
I can't see anything wrong here, but then again, I've only read the stty manual twice.
I've tried setting /dev/cuaU0.init to 115200 baud using stty, just in case, but I can't seem to get it to work. I've also tried the /dev/ttyU0 device, and that didn't work, but from reading the handbook, I can't see why that would be different, unless I've missed something?
Now, here is the clincher: earlier today I fired up screen, and it worked. I have no idea why. I saw the output from the mbed device, and there were no problems. Then it stopped working when I tried something else later on.
And crazily, it just worked now when I tried it, despite not working for the past 1 hour of testing and messing around. I did leave the device unplugged for a while just now, perhaps this has something to do with access to file handles? (a guess based on experience with badly terminated AF_INET sockets)
The next time it breaks, I'll try unplugging it for 15 minutes, and then back in to see if that helps.
In the meantime, any ideas on either of the two problems (permissions and monitoring)?
Thanks
Ashley
This is me:
Code:
[mbd@stdy ~]$ uname -a
FreeBSD stdy.xxx 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 01:47:53 UTC 2012 root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386
I'm trying to develop for the mbed microcontroller on FreeBSD. The mbed is a microcontroller with a mini USB jack, which when plugged into the host OS, appears as both a mass-storage device and a serial port. See mbed.org for more information.
I have no problem mounting the device and programming it via the cloud IDE (binaries are simply saved to the mass storage device).
My problem applies to monitoring the Serial output of the mbed device on the host serial port. The problem is fundamental: I am unable to see any output from the mbed. This is not a problem on Linux, or Mac, or Windows. I mention the latter, so you can have some confidence that this is not user error: I have used the mbed device on perhaps 15 different non-FreeBSD systems without the problem described here.
This is my first post here. I must admit, I was a little intimidated in this regard, out of fear of appearing stupid. I've attempted to comply to the exacting standards outlined by DutchDaemon, but no doubt I'll have made some egregious mistake in someone's unforgiving eyes. I hope not.
Obseve the following sequence of events (I'm going to plug the mbed device in):
Code:
[mbd@stdy ~]# ls -l /dev/cua*
crw-rw---- 1 uucp operator 0, 45 Nov 30 09:35 /dev/cuau0
crw-rw---- 1 uucp operator 0, 46 Nov 30 08:38 /dev/cuau0.init
crw-rw---- 1 uucp operator 0, 47 Nov 30 08:38 /dev/cuau0.lock
[mbd@stdy ~]# # plugging mbed in now
[mbd@stdy ~]# ls -l /dev/cua*
crw-rw---- 1 uucp operator 0, 142 Nov 30 15:36 /dev/cuaU0
crw-rw---- 1 uucp operator 0, 144 Nov 30 15:36 /dev/cuaU0.init
crw-rw---- 1 uucp operator 0, 145 Nov 30 15:36 /dev/cuaU0.lock
crw-rw---- 1 uucp operator 0, 45 Nov 30 09:35 /dev/cuau0
crw-rw---- 1 uucp operator 0, 46 Nov 30 08:38 /dev/cuau0.init
crw-rw---- 1 uucp operator 0, 47 Nov 30 08:38 /dev/cuau0.lock
[mbd@stdy ~]# # examine dmesg
[mbd@stdy ~]# dmesg | tail -n 12
ugen4.3: <mbed> at usbus4
umass0: <mbed Microcontroller, class 2/0, rev 1.10/1.00, addr 3> on usbus4
umass0: SCSI over Bulk-Only; quirks = 0x4100
umass0:2:0:-1: Attached to scbus2
umodem0: <mbed Microcontroller, class 2/0, rev 1.10/1.00, addr 3> on usbus4
umodem0: data interface 2, has CM over data, has break
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <mbed Microcontroller 1.0> Removable Direct Access SCSI-0 device
da0: 1.000MB/s transfers
da0: 2MB (4096 512 byte sectors: 64H 32S/T 2C)
g_vfs_done():ada0p1[READ(offset=262144, length=8192)]error = 5
ext2fs: ada0p1: wrong magic number 0x1f07 (expected 0xef53)
Everything looks OK, both the serial console (umodem0) and the mass storage device (umass0) appear. I'm not sure about the last two lines, but I'm guessing it isn't the problem, any thoughts?
Now that the mbed is plugged in, I'm going to try and monitor it via screen:
Code:
[mbd@stdy ~]$ screen /dev/cuaU0 115200
Whilst you can't see the output, trust me that screen says:
Code:
Cannot open line '/dev/cuaU0' for R/W: Permission denied
Sorry, could not find a PTY.
Hmm, this is strange, what permissions are on this device?
Code:
[mbd@stdy ~]$ ls -l /dev/cuaU*
crw-rw---- 1 uucp operator 0, 142 Nov 30 15:36 /dev/cuaU0
crw-rw---- 1 uucp operator 0, 144 Nov 30 15:36 /dev/cuaU0.init
crw-rw---- 1 uucp operator 0, 145 Nov 30 15:36 /dev/cuaU0.lock
And to which groups do I belong?
Code:
[mbd@stdy ~]$ groups
mbd wheel operator uucp dialer vboxusers
Right, so I'm a member of operator, and it looks like operator has rw permissions, so why can I not open this device? Let me guess, there is some weird proviso somehwere that I don't know about concerning these special devices?
That's my first problem: permissions.
However, as I know what I'm connecting to, I don't mind being root to check things out. I'll try and connect as root:
Code:
[root@stdy ~]# screen /dev/cuaU0 115200
This time the screen session starts, but I cannot see any output from the mbed device. It could be the mbed doing something odd I suppose, but this seems unlikely since it works on Linux and Mac without issue.
You probably don't care, but on the mbed I'm using an exceptionally simple test program:
Code:
#include "mbed.h"
int main() {
Serial pc(USBTX,USBRX);
pc.baud(115200);
while(1) {
pc.printf("Hello\r\n");
wait(1);
}
}
At least you should be able to ascertain that it would be difficult to get this wrong.
What does stty say about the console device? :
Code:
[root@stdy ~]# stty -f /dev/cuaU0
speed 115200 baud;
lflags: -icanon -isig -echo echoe echok echoke echoctl
iflags: -icrnl -ixany -imaxbel ignpar
oflags: -opost -onlcr tab0
cflags: cs8 -parenb -hupcl clocal
eol eol2 erase2 kill min time
^@ ^@ ^@ ^H 100 2
I can't see anything wrong here, but then again, I've only read the stty manual twice.
I've tried setting /dev/cuaU0.init to 115200 baud using stty, just in case, but I can't seem to get it to work. I've also tried the /dev/ttyU0 device, and that didn't work, but from reading the handbook, I can't see why that would be different, unless I've missed something?
Now, here is the clincher: earlier today I fired up screen, and it worked. I have no idea why. I saw the output from the mbed device, and there were no problems. Then it stopped working when I tried something else later on.
And crazily, it just worked now when I tried it, despite not working for the past 1 hour of testing and messing around. I did leave the device unplugged for a while just now, perhaps this has something to do with access to file handles? (a guess based on experience with badly terminated AF_INET sockets)
The next time it breaks, I'll try unplugging it for 15 minutes, and then back in to see if that helps.
In the meantime, any ideas on either of the two problems (permissions and monitoring)?
Thanks
Ashley