I was trying to get some CP code to talk to Processing over a serial port interface. Of course, the CP REPL is normally available on whatever serial port the board mounts by default. This is a little complicated, because although you can use something like print from the REPL (or code.py) to print a value to the console, sys.stdin and sys.stdout are text-based streams, which may not be what you want. And you'll get REPL noise to boot. Not ideal.
This is where usb_cdc comes in. It's a handy library for managing the USB CDC (serial) on most CircuitPython boards. First, usb_cdc can be used to control how many serial ports CP will provide at startup. You can modify boot.py to make this work:
import usb_cdc
usb_cdc.enable(console=True, data=False)
This is equivalent to the standard setup. When you plug in your CP device, you'll get one serial port, which will have the REPL on it, and is mapped to sys.stdin and sys.stdout, all of which goes through the console object, which is a binary stream. This means you can do stuff like this in your code.py:
import usb_cdc
console = usb_cdc.console
console.write(bytes([1]))
This is great, since it means you can send binary data, which is useful if you don't want to muck with the REPL's textstream. However, you're still using the same serial port. We can do better. If you put this in boot.py, you'll get a second serial port when you plug in your board:
import usb_cdc
usb_cdc.enable(console=True, data=True)
Now you can connect to the second serial port and avoid the REPL noise. You can do this with the usb_cdc.data binary stream, in either the REPL or from code.py:
import usb_cdc
console = usb_cdc.data
console.write(bytes([1]))
For reference, take a look at the documentation for the usb_cdc library and this handy guide to configuring the USB ports in CircuitPython.
There is a handy utility library, Adafruit_Board_Toolkit, that provides some utilities for inspecting the serial ports on a system to see if they're avaliable from CP and if so, if they console or data reports.
Once you've installed this library in Python, it's pretty easy to use. For example, to list all of the likely CP serial ports:
from adafruit_board_toolkit import circuitpython_serial as cps
print([port.device for port in cps.comports()])
@bernard01 strictly speaking, you don't need the REPL for CP development, as long as you can mount the CIRCUITPY volume and edit files. But having access to it does make things easier! (And it's one of the selling points versus something like Arduino, where you'll likely have to resort to a debugger for any serious runtime troubleshooting)
I am a bit mystified by why you're not getting both ports on a Pico, TBH. The endpoints are defined in hardware, so CP should be able to use them if they're there. And in that chip, they are.
If I was trying to figure out what was happening, I'd put vanilla CP on your pico, nothing in code.py or main.py, and just try the boot.py dual port setup. And to check if was working, I'd look at the OS and available serial ports before doing anything else with CP. If they don't show up, that might not be CP on the Pico, it could be an issue on the PC side.
If you are exceeding the number of endpoint pairs, that shouldn't kill the console. On the contrary, it should put the board in safe mode and the console/REPL will still be available (see the note at the end of the Customizing USB Devices page).
Anyhow, good luck and let me know if I can try anything out for you.