Welcome! Log In Create A New Profile

Advanced

Using UART / nectat on Mac (OSX 10)

Posted by Steve1987 
Using UART / nectat on Mac (OSX 10)
February 23, 2016 01:08PM
I though we could share some knowledge among OS X users here, as some tf the tools use different syntax than its linux counterparts.

Netcat

works out of the box, for two-way communication run:

nc -lu 6666

You might have to turn off stealth mode for u-boot to be able to ping your pc (although I think it might be possible to disable this requirement in envs).

UART cable:

Works out of the box, use following command to open connection:

screen /dev/device_name 115200

device name is different for each cable, for me it is cu.SLAB_USBtoUART (CP210X cable)
Re: Using UART / nectat on Mac (OSX 10)
February 26, 2016 03:27PM
Steve,

I saw that you are using the CP210x serial converter. To make it work, you have to install driver. It would be helpful to add to your first post:

- Mac OSX version
- Siliconlabs driver version
- When you install the Siliconlabs driver, how did you make it work. IOW, does this driver have kext (the Prolific PL driver does). And did you need to do anything extra to make it work?


BTW, I've added this to the tutorial and tips thread.

If anybody who has experience using either this converter or the Prolific on OSX, please post in this thread.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Using UART / nectat on Mac (OSX 10)
February 26, 2016 05:27PM
I can confirm Steve1987 that CP2102 works out of the box of OS X 10.10.3.

Here is the log:
Feb 26 18:00:41 are com.apple.kextd[47]: kext file:///System/Library/Extensions/SiLabsUSBDriver64.kext/ is in hash exception list, allowing to load
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver: init
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::attach
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::probe
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::detach
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::attach
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::start - Registered for Power Management
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::start!
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::start - Found device at interface 0
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::setPowerState - Waking up
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::SelectInterfaces - BulkInput Pipe is 0xffffff8025925800 on EP1
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::SelectInterfaces - BulkOutput Pipe is 0xffffff802975d180 on EP1
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo - Part Number Found: 0x02
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo - UsbConfigurationDescriptor -
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo     .bLength = 9
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo     .bDescriptorType = 0x02
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo     .wTotalLength = 32
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo     .bNumInterfaces = 1
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo     .bConfigurationValue = 1
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo     .iConfiguration = 0
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo     .bmAttributes = 0x80
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::GetCP210xInfo     .MaxPower = 50
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::start - Sucessfully loaded the driver
Feb 26 18:00:41 are configd[53]: obj:231c7
        {
            "Bus Power Available" = 250;
            "Device Speed" = 1;
            IOCFPlugInTypes =     {
                "9dc7b780-9ec0-11d4-a54f-000a27052861" = "IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle";
            };
            IOGeneralInterest = "IOCommand is not serializable";
            IOUserClientClass = IOUSBDeviceUserClientV2;
            "Low Power Displayed" = 0;
            PortNum = 1;
            PortNumberOffset = 0;
            "Requested Power" = 50;
            "USB Address" = 14;
            "USB Product Name" = "CP2102 USB to UART Bridge Controller";
            "USB Serial Number" = 0001;
            "USB Vendor Name" = "Silicon Labs";
            bDeviceClass = 0;
            bDeviceProtocol = 0;
            bDeviceSubClass = 0;
            bMaxPacketSize0 = 64;
            bNumConfigurations = 1;
            bcdDevice = 256;
            bcdUSB = 272;
            iManufacturer = 1;
            iProduct = 2;
            iSerialNumber = 3;
            idProduct = 60000;
            idVendor = 4292;
            locationID = 336592896;
            sessionID = 3455930588372791;
        }
Feb 26 18:00:41 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::message
Feb 26 18:00:42: --- last message repeated 1 time ---
Feb 26 18:12:38 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::terminate
Feb 26 18:12:38 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::message
Feb 26 18:12:38 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::finalize
Feb 26 18:12:38 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::stop
Feb 26 18:12:38 are kernel[0]: com_silabs_driver_CP210xVCPDriver64(0xffffff8029b94000)::detach

Very useful information! Thanks!

-syong
Re: Using UART / nectat on Mac (OSX 10)
February 26, 2016 06:08PM
@syong,

Do you have information about the installation the kext for this CP2102?

It seems it is Apple non-approved kext?

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 02/26/2016 06:16PM by bodhi.
Re: Using UART / nectat on Mac (OSX 10)
February 26, 2016 09:29PM
bodhi,

I do not remember I had install anything for CP2102. But checking the kext file shows its kext(Jan 16 2014) does predate those of the others(Sep 19 2014).

I vaguely remember I installed some serial driver to install chirp when I played Baofeng UV-5r.

-syong
Re: Using UART / nectat on Mac (OSX 10)
February 27, 2016 01:53AM
I'm compiling the kwboot for OSX. But it seems to have some problem.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Using UART / nectat on Mac (OSX 10)
February 28, 2016 11:24AM
Yeah, on Mac you need to install the CP2102 kexts from the web (I think I went to the vendor website, it was pretty obvious at the time so didn't think twice about it).
Re: Using UART / nectat on Mac (OSX 10)
February 28, 2016 03:06PM
Thanks guys! I never consider about compiling Linux tools on Mac. Now I think of that, it is obvious!

So the SiliconsLab kext is OK by OSX? or do you make an exception in OSX kext checking?

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Using UART / nectat on Mac (OSX 10)
February 28, 2016 03:15PM
No problem on OS X 10.6 (32-bit) and 10.11 in my case, I got the drivers from https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx#mac

I don't recall any issues with the Kexts.

Re: compiling Linux code on Mac, it's a good starting point, but kwboot won't work without some changes.
I briefly looked into it, it doesn't compile in the first place. Maybe I'll dig into it at some point.

kwboot.c:640:11: warning: implicit declaration of function 'le16_to_cpu' is invalid in C99 [-Wimplicit-function-declaration]
                hdrsz = KWBHEADER_V1_SIZE(hdr);
                        ^
./kwbimage.h:119:33: note: expanded from macro 'KWBHEADER_V1_SIZE'
        (((hdr)->headersz_msb << 16) | le16_to_cpu((hdr)->headersz_lsb))
                                       ^
1 warning generated.
Undefined symbols for architecture x86_64:
  "_le16_to_cpu", referenced from:
      _kwboot_img_patch_hdr in kwboot-03a406.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Re: Using UART / nectat on Mac (OSX 10)
February 28, 2016 03:30PM
Micky Wicky,

> No problem on OS X 10.6 (32-bit) and 10.11 in my
> case, I got the drivers from

I think 10.10+ will reject it (if it is not signed by Apple approved cert). They require this on Yosemite and later. This was a big issue with SSD TRIM when Yosemite was out.

kwboot compiled fine for me now on OSX 10.10.5 and Xcode 7.1. I think you need the latest kwboot source.

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 02/28/2016 03:31PM by bodhi.
Re: Using UART / nectat on Mac (OSX 10)
February 29, 2016 02:53PM
You're right, I just had to git pull and it builds using clang 7.0 on 10.11.1

Running it returns the exact same error as under NetBSD 7.0:

kwboot -B 115200 -t -p -b uboot.2015.10-tld-1.nsa310s.mtd0.kwb /dev/tty.SLAB_USBtoUART
Sending boot message. Please reboot the target...\
Sending boot image...
  0 % [+xmodem: Protocol error

Did you see this as well?
I tried to track it down on NetBSD a few days ago, but I really should run it through a debugger...
Re: Using UART / nectat on Mac (OSX 10)
February 29, 2016 05:17PM
Micky Wicky Wrote:
-------------------------------------------------------
> You're right, I just had to git pull and it builds
> using clang 7.0 on 10.11.1
>
> Running it returns the exact same error as under
> NetBSD 7.0:
>
>
> kwboot -B 115200 -t -p -b
> uboot.2015.10-tld-1.nsa310s.mtd0.kwb
> /dev/tty.SLAB_USBtoUART
> Sending boot message. Please reboot the
> target...\
> Sending boot image...
>   0 % [+xmodem: Protocol error
>
>
> Did you see this as well?
> I tried to track it down on NetBSD a few days ago,
> but I really should run it through a debugger...

I have not tried (I am too lazy to add yet another gadget to my Mac laptop :). I always use a Dockstar or Pogo Moble for serial console.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Using UART / nectat on Mac (OSX 10)
March 01, 2016 06:58AM
I know the feeling - I normally use a RPI-2, but it runs NetBSD!
I'll report if I ever get around to debugging kwboot properly.
Re: Using UART / nectat on Mac (OSX 10)
March 16, 2016 03:01PM
Hi,

pl2302 usb worked fine on the Lions, though the cheap Chinese ripoffs I got died some months after usage.
CH340 seems to be the better.

In any case, you can assign the usb thingy to Linux in VirtualBox if all else fails
or disable the kext sign requirement in MacOSX;

% sudo nvram boot-args="kext-dev-mode=1"

see http://apple.stackexchange.com/questions/163059/how-can-i-disable-kext-signing-in-mac-os-x-10-10-yosemite
Re: Using UART / nectat on Mac (OSX 10)
March 17, 2016 12:37AM
> or disable the kext sign requirement in MacOSX;
>
> % sudo nvram boot-args="kext-dev-mode=1"
>
> see
> http://apple.stackexchange.com/questions/163059/ho
> w-can-i-disable-kext-signing-in-mac-os-x-10-10-yos
> emite

I don't like this blanket approach so I never use it. Wish Apple would enable the option to allow exception per kext.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Using UART / nectat on Mac (OSX 10)
March 18, 2016 03:43PM
No hassle rebooting with SSD :)

Allowing exception per kext cannot be enforced, is never going to happen.
Re: Using UART / nectat on Mac (OSX 10)
March 19, 2016 10:10PM
@bodhi & @Micky Wicky,

I got kwboot working on OS X. Here is the patch:
(%26)(22:56)(are)~/ws/kwboot> diff kwboot.c kwboot.c.orig
152c152,157
<       tv.tv_sec = timeo / 1000, tv.tv_usec = (timeo % 1000) * 1000;
---
>       tv.tv_sec = 0;
>       tv.tv_usec = timeo * 1000;
>       if (tv.tv_usec > 1000000) {
>               tv.tv_sec += tv.tv_usec / 1000000;
>               tv.tv_usec %= 1000000;
>       }
(%26)(22:56)(are)~/ws/kwboot> uname -a
Darwin are 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
(%26)(22:56)(are)~/ws/kwboot>

-syong
Re: Using UART / nectat on Mac (OSX 10)
March 20, 2016 07:23PM
Thanks syong! perhaps I'll try again with my Nokia cable.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Using UART / nectat on Mac (OSX 10)
March 21, 2016 07:12AM
Awesome.
I can confirm this patch makes kwboot work on MacOS 10.11 and on NetBSD (-current)

Compiled both with clang.
Nice work!
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: