Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:50 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite Console on MacOS and Linux

     Page 1 of 2    
Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 03:32am 26 Sep 2021
Copy link to clipboard 
Print this post

I'm writing instructions for using the serial over USB console created by the PicoMite firmware on the Raspberry Pi Pico.  

I know all about Windows so that is not a problem.  But, does anyone have instructions for using the PicoMite Console on MacOS or Linux (eg, drivers, how to connect, terminal emulator, etc)?

A short description aimed at non experts would be very gratefully received.

Geoff
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 08:12am 26 Sep 2021
Copy link to clipboard 
Print this post

Geoff, you might want to check out this post because I definitely couldn't get a COM port allocated on my Win7/64 system without following those instructions. Reading through the posts it seems to indicate that that's not the only Microsoft OS that's affected.

Greg
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 08:30am 26 Sep 2021
Copy link to clipboard 
Print this post

For me the answer for Win7 & 8 is Zadig (https://zadig.akeo.ie/) which will install a generic driver for a "usbser" device.  

Geoff
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 09:21am 26 Sep 2021
Copy link to clipboard 
Print this post

Zadig was mentioned as a good alternative on the raspberrypi.org forum threads. A couple of posts down though someone complained that they had trouble with Zadiq with other USB devices (RTL dongles). That made me a bit nervous as I'd never heard of Zadig so I went the modified .inf file route (with the changed 0005 PID) which did work.
I just had a look at the Github thread on using Zadig with the Pico and they seem happy with the driver it loads. It does mention too though that the driver doesn't show up in the Windows Device Manager until it's been plugged in three or four times - bit odd!

Greg
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 10:36am 26 Sep 2021
Copy link to clipboard 
Print this post

Thanks Greg.  Could you email your working driver to me (projects@geoffg.net) and I might just put that in the firmware zip.  I don't have a Win7 box to test it so your experience is valuable.

Geoff
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 11:50am 26 Sep 2021
Copy link to clipboard 
Print this post

OK, on it's way - my .inf file plus raspberrypi.org forum link plus comments re 'what I did'.
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 722
Posted: 01:02pm 26 Sep 2021
Copy link to clipboard 
Print this post

Geoff,

am i Right, that you ask for a terminalemulator for Linux/MacOS?

If this is the case, you can use SCREEN:

screen /dev/<console_port> 115200

Greetings
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 722
Posted: 01:23pm 26 Sep 2021
Copy link to clipboard 
Print this post

https://www.systutorials.com/docs/linux/man/1-screen/

And it is mighty, really might
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 01:41pm 26 Sep 2021
Copy link to clipboard 
Print this post

hi geoff,
   i trust you're aware that the RPi runs linux under the hood, while macOS is built on top of BSD UNIX, and so all three (linux, RPi, macOS) are very much the same and interchangable.

under linux you need to enter the following incantation at the console before you can access any serial ports:

sudo adduser $USER dialout

the same holds for RPi and likely also for macOS. $USER is an alias for the currently logged in user, while dialout is a group that has access to the serial port hardware.

while you're at it, unexpected problems down the track can be avoided by the incantation:

sudo apt-get remove modemmanager

this removes an irritating program called modemmanager that tries to send AT commands to any serial ports that pops up. it is particularly noxious to the arduino IDE.


as for drivers, neither linux, RPi, nor macOS should require drivers for CDC devices, which is what the pico is. same holds for all the usual usb to serial bridge devices. they just work the moment they are plugged in.


alas, finding the serial ports under linux is a bit more hit-and-miss for the beginner. the easiest approach is to run a terminal emulator that has the code to do this built in. GFXterm64 correctly lists live serial ports under linux (32 and 64bit) and RPi (32bit), and should also (in theory) be fine with macOS (for which i have never compiled it, but there is no good reason it should not work).

minicom is a console application that is popular, but quite difficult to drive. i believe that peter has modified the latest beta of pico mmbasic to work with it's function key bindings. others have had some success with the likes of putty.

unfortunately, whereas a myriad of programs are accessible for the win32 platform to do all number of different things, not so much so with macOS and linux; macOS software development has been something that Apple has tried to closely manage (some might say control and stifle), while linux users tend to (individually) roll-their-own rather 'rough' concoctions to solve technical challenges as they arise.


cheers,
rob   :-)
Edited 2021-09-26 23:45 by robert.rozee
 
scruss
Regular Member

Joined: 20/09/2021
Location: Canada
Posts: 86
Posted: 05:53pm 26 Sep 2021
Copy link to clipboard 
Print this post

There are a lot of different Linux distributions and they all have their quirks.

* No driver is required on Linux

* Raspberry Pi OS adds the regular 'pi' user to the 'dialout' group automatically: Debian and Ubuntu may not. You do want to be part of the dialout group, as it gives you access to the serial ports without elevated privileges

* Some distros include/start modemmanager by default, and it is a pain. Raspberry Pi OS doesn't, and I machine I've installed Ubuntu 21.04 on doesn't, but older Ubuntu machines did

* If the Raspberry Pi Pico is the only type of its kind attached to a Linux computer, it will be attached on the port /dev/ttyACM0

* If there are several USB devices like certain Arduinos, MicroPython/CircuitPython boards and alternative input controllers, finding the port can be a little more complicated as it won't always show up on the same port. If you've just plugged the Raspberry Pi Pico in, the command dmesg | tail -20 should include something like this:

[779122.426847] usb 3-13.2: New USB device found, idVendor=2e8a, idProduct=000a,
bcdDevice= 1.00
[779122.426850] usb 3-13.2: New USB device strings: Mfr=1, Product=2, SerialNumb
er=3
[779122.426851] usb 3-13.2: Product: Pico
[779122.426852] usb 3-13.2: Manufacturer: Raspberry Pi
[779122.426853] usb 3-13.2: SerialNumber: 000000000000
[779122.436940] cdc_acm 3-13.2:1.0: ttyACM2: USB ACM device


Your exact numbers will be different, but the string before 'Product: Pico' should match the line following that says ttyACMx: USB ACM device. In this case, the Raspberry Pi Pico is at /dev/ttyACM2. In every case, you'll see the idVendor=2e8a, idProduct=000a listed for the Raspberry Pi Pico.

If you want a serial port address that won't change, this command will show all the Raspberry Pi Picos hanging off the USB serial device:
ls /dev/serial/by-id/usb-Raspberry_Pi_Pico*
/dev/serial/by-id/usb-Raspberry_Pi_Pico_000000000000-if00

For now, all Raspberry Pi Picos running mmbasic will appear at /dev/serial/by-id/usb-Raspberry_Pi_Pico_000000000000-if00 . In the future, that string of zeroes may (should, please: it helps to have a unique board identifier, which you can get from the flash chip)
change to something unique.

For a terminal program, minicom works. Install it (+ xmodem support) on Debian-based systems (incl Raspberry Pi OS and Ubuntu) using:

sudo apt install minicom lrzsz


then run it with

minicom --device /dev/ttyACM0 --color=on


This should connect directly with mmbasic's REPL.Make sure you use the right device name.

(aside: configuring minicom for the first time for a user is annoying, as it tries and fails to overwrite the system configuration. It might be worth issuing this command once before starting minicom for the very first time, as it forces a writeable config file to exist:

echo 'pu port /dev/ttyACM0' > ~/.minirc.dfl


aside ends)

I don't know much about Macs, but CircuitPython's docs suggest the Raspberry Pi Pico will appear as something like /dev/tty.usbmodem*. No driver required.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9129
Posted: 06:27pm 26 Sep 2021
Copy link to clipboard 
Print this post

  Quote  For now, all Raspberry Pi Picos running mmbasic will appear at /dev/serial/by-id/usb-Raspberry_Pi_Pico_000000000000-if00 . In the future, that string of zeroes may (should, please: it helps to have a unique board identifier, which you can get from the flash chip)


You can use mm.info(ID) to get the unique ID. I was intending to put his into the USB descriptor but the descriptor is hard coded in TinyUSB as a constant element and my feeble attempts to make usbd_desc_str variable have all failed completely. Any hints gratefully accepted.

I've also requested a USBD_PID for the PicoMite from the Raspberry Pi Foundation but they haven't replied

*
* This file is based on a file originally part of the
* MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
* Copyright (c) 2019 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#if !defined(TINYUSB_HOST_LINKED) && !defined(TINYUSB_DEVICE_LINKED)

#include "tusb.h"
#include "pico/stdio_usb/reset_interface.h"

#define USBD_VID (0x2E8A) // Raspberry Pi
#define USBD_PID (0x000a) // Raspberry Pi Pico SDK CDC

#define TUD_RPI_RESET_DESC_LEN  9
#if !PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE
#define USBD_DESC_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN)
#else
#define USBD_DESC_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_RPI_RESET_DESC_LEN)
#endif
#define USBD_MAX_POWER_MA (250)

#define USBD_ITF_CDC       (0) // needs 2 interfaces
#if !PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE
#define USBD_ITF_MAX       (2)
#else
#define USBD_ITF_RPI_RESET (2)
#define USBD_ITF_MAX       (3)
#endif

#define USBD_CDC_EP_CMD (0x81)
#define USBD_CDC_EP_OUT (0x02)
#define USBD_CDC_EP_IN (0x82)
#define USBD_CDC_CMD_MAX_SIZE (8)
#define USBD_CDC_IN_OUT_MAX_SIZE (64)

#define USBD_STR_0 (0x00)
#define USBD_STR_MANUF (0x01)
#define USBD_STR_PRODUCT (0x02)
#define USBD_STR_SERIAL (0x03)
#define USBD_STR_CDC (0x04)
#define USBD_STR_RPI_RESET (0x05)

// Note: descriptors returned from callbacks must exist long enough for transfer to complete

static const tusb_desc_device_t usbd_desc_device = {
   .bLength = sizeof(tusb_desc_device_t),
   .bDescriptorType = TUSB_DESC_DEVICE,
   .bcdUSB = 0x0200,
   .bDeviceClass = TUSB_CLASS_MISC,
   .bDeviceSubClass = MISC_SUBCLASS_COMMON,
   .bDeviceProtocol = MISC_PROTOCOL_IAD,
   .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
   .idVendor = USBD_VID,
   .idProduct = USBD_PID,
   .bcdDevice = 0x0100,
   .iManufacturer = USBD_STR_MANUF,
   .iProduct = USBD_STR_PRODUCT,
   .iSerialNumber = USBD_STR_SERIAL,
   .bNumConfigurations = 1,
};

#define TUD_RPI_RESET_DESCRIPTOR(_itfnum, _stridx) \
 /* Interface */\
 9, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_VENDOR_SPECIFIC, RESET_INTERFACE_SUBCLASS, RESET_INTERFACE_PROTOCOL, _stridx,

static const uint8_t usbd_desc_cfg[USBD_DESC_LEN] = {
   TUD_CONFIG_DESCRIPTOR(1, USBD_ITF_MAX, USBD_STR_0, USBD_DESC_LEN,
       0, USBD_MAX_POWER_MA),

   TUD_CDC_DESCRIPTOR(USBD_ITF_CDC, USBD_STR_CDC, USBD_CDC_EP_CMD,
       USBD_CDC_CMD_MAX_SIZE, USBD_CDC_EP_OUT, USBD_CDC_EP_IN, USBD_CDC_IN_OUT_MAX_SIZE),

#if PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE
   TUD_RPI_RESET_DESCRIPTOR(USBD_ITF_RPI_RESET, USBD_STR_RPI_RESET)
#endif
};

static const char *const usbd_desc_str[] = {
   [USBD_STR_MANUF] = "Raspberry Pi",
   [USBD_STR_PRODUCT] = "Pico",
   [USBD_STR_SERIAL] = "000000000000", // TODO
   [USBD_STR_CDC] = "Board CDC",
#if PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE
   [USBD_STR_RPI_RESET] = "Reset",
#endif
};

const uint8_t *tud_descriptor_device_cb(void) {
   return (const uint8_t *)&usbd_desc_device;
}

const uint8_t *tud_descriptor_configuration_cb(uint8_t index) {
   (void)index;
   return usbd_desc_cfg;
}

const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
   #define DESC_STR_MAX (20)
   static uint16_t desc_str[DESC_STR_MAX];

   uint8_t len;
   if (index == 0) {
       desc_str[1] = 0x0409; // supported language is English
       len = 1;
   } else {
       if (index >= sizeof(usbd_desc_str) / sizeof(usbd_desc_str[0])) {
           return NULL;
       }
       const char *str = usbd_desc_str[index];
       for (len = 0; len < DESC_STR_MAX - 1 && str[len]; ++len) {
           desc_str[1 + len] = str[len];
       }
   }

   // first byte is length (including header), second byte is string type
   desc_str[0] = (TUSB_DESC_STRING << 8) | (2 * len + 2);

   return desc_str;
}

#endif

Edited 2021-09-27 04:29 by matherp
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 08:17am 28 Sep 2021
Copy link to clipboard 
Print this post

  matherp said  You can use mm.info(ID) to get the unique ID. I was intending to put his into the USB descriptor but the descriptor is hard coded in TinyUSB as a constant element and my feeble attempts to make usbd_desc_str variable have all failed completely. Any hints gratefully accepted.


hi peter,
   set the serial number to a string of bytes that is completely unique and that appears nowhere else in the firmware.

upon first run of the firmware, have it scan the flash for the above mentioned string of bytes. be creative in the scan algorithm, so that it does not accidentally either (a) encode the same string internally, or (b) the compiler sees a match at compile time and 'optimize' the code with two pointers to the same place! one way is to obfuscate what the search algorithm is to look for, unpacking it into RAM, and then do the searching through flash for a match with the RAM copy.


if a match for the string is found, have the firmware copy the flash block containing it to RAM, modify the block with the flash chip serial number, then write it back to flash. you may also set a flag somewhere elsewhere in flash to indicate that the serial number has been configured and no future search/replace is required.


this is, essentially, a variation of self-modifying code. it is a concept i've employed in the past without problems.


cheers,
rob   :-)
Edited 2021-09-28 18:18 by robert.rozee
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4247
Posted: 08:28am 28 Sep 2021
Copy link to clipboard 
Print this post

Windows builds up a registry, where your serial port enumeration is stored. If you plug the serial device into a different USB port, it gets a new number (i.e COM2, COM3, COM4 etc..)

Linux enumerates "on the fly", and serial devices will show up in the folder /dev/
Depending how the USB device is configured, it will show up as:

/dev/ttyUSB0, /dev/ttyUSB1 ect... for serial ports
-or-
/dev/ttyACM0, /dev/ttyACM1 etc... for serial modems

At every cold or warm boot of the linux system these numbers may change.

However, there is a way to "manually" create something similar to a Windows registry in linux, where you use the manufacurer ID, model ID, or even serial number to link the device to a user defined device name. Every time you unplug and plug, the device is enumerated, and the same device name is attached to it.

This post describes how this is done:
udev rules for serial devices

These new device names can also be used in program like Putty to refer to the device. I have not tried this in minicom though.

Volhout

One additional note: I have 1 machine running a live Ubuntu distribution (from USB stick) with persistent memory. That machine does not obey to the udev rules set. It is not obvious to me why, but maybe it is due to some folders not being mimicked in the persistent storage, or some daemon not running. On Raspbian, and Ubuntu installs the udev rules do work.
Edited 2021-09-28 18:33 by Volhout
PicomiteVGA PETSCII ROBOTS
 
scruss
Regular Member

Joined: 20/09/2021
Location: Canada
Posts: 86
Posted: 05:08pm 28 Sep 2021
Copy link to clipboard 
Print this post

udev rules are complex and need to be set per machine. If the user has only one Raspberry Pi Pico attached to their Linux machine, this will be the port it's on:
/dev/serial/by-id/usb-Raspberry_Pi_Pico_000000000000-if00



Mac OS

I've just had the chance to run a Pico with mmbasic installed on a Mac.

- the port will be of the form /dev/tty.usbmodem*, as in /dev/tty.usbmodem0000000000001

- no driver is required

- Mac OS Terminal is already a full VTxxx emulator, and Mac OS comes with screen installed. You can run it like this:

screen /dev/tty.usbmodem0000000000001


(no serial rate required)

It seems to support the editor:

 
hhtg1968
Senior Member

Joined: 25/05/2023
Location: Germany
Posts: 123
Posted: 10:50am 15 Jul 2023
Copy link to clipboard 
Print this post

perhaps i do not understand the question. but it is easy (read the thread from Volhout above).

1. start the terminal in raspios.

2. install screen (and tftp)

"sudo apt install screen" (or your favourite vt100 program)
"sudo apt install tftp"

3. find the tty-file

"ls /dev/tty*"

you will find something like ttyusb... or ttyACM...

i find "ttyACM0"

4. enter "screen /dev/ttyACM0" (or what tty you will find)

like Volhout said, no baudrate is necessary

hhtg
(most i write from my macbook, sometimes i use my pi4)
 
ice2642

Regular Member

Joined: 27/05/2023
Location: Brazil
Posts: 82
Posted: 05:04pm 16 Jul 2023
Copy link to clipboard 
Print this post

In debian you can use picocom too to connect your pico to PC

sudo apt install picocom

I believe in raspberry pixel repository you can found this program, in amd64 Debian have it.




Best regards,
MMBasic 5.0707 on PicoMite VGA
 
scruss
Regular Member

Joined: 20/09/2021
Location: Canada
Posts: 86
Posted: 02:53pm 17 Jul 2023
Copy link to clipboard 
Print this post

  hhtg1968 said  
...
2. install screen (and tftp)

What do we need tftp for?
 
hhtg1968
Senior Member

Joined: 25/05/2023
Location: Germany
Posts: 123
Posted: 08:59pm 20 Jul 2023
Copy link to clipboard 
Print this post

to transfer files from pc/mac to pico (without sd card)...
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 09:14pm 20 Jul 2023
Copy link to clipboard 
Print this post

tftp is only used on the WEBmite when connecting via network.

It is not available on the picomite or picomiteVGA

Jim
VK7JH
MMedit   MMBasic Help
 
hhtg1968
Senior Member

Joined: 25/05/2023
Location: Germany
Posts: 123
Posted: 09:16pm 20 Jul 2023
Copy link to clipboard 
Print this post

ok. that is right.
 
     Page 1 of 2    
Print this page
© JAQ Software 2024