Using Architecture-Independent Drivers Outside NuttX Directory

2024-10-17 Thread Daniel Pereira Carvalho
Hi Team,

I've found it straightforward to develop custom board and application code
outside the NuttX directory tree. However, I'm currently facing a challenge
with utilizing an architecture-independent device driver that is coded
outside the nuttx/drivers directory. Is there a way to achieve this within
the existing NuttX build system?

Thank you for your support.

Best regards,
Daniel Pereira de Carvalho


USB serial communication for RP2040

2024-10-17 Thread Matteo Golin
Hello everyone,

I am attempting to create an embedded device for a school project where I need 
to send some text data over USB on
power-up. It is a constant stream of serial data.

For this, I am setting my own application as the entry point instead of NSH, 
which requires me to instantiate the USB
output myself.

I have copied the USB console setup from NSH into my application, and I can see 
the USB device showing up with `dmesg`
so I know it is successfully started. However, none of my `write()` calls to 
the file descriptor or `fprintf` calls are
working correctly.

The code for the USB setup is:
```c
void board_late_initialize(void) {

/* Initialize the USB serial driver */
struct boardioc_usbdev_ctrl_s ctrl;
FAR void *handle;
int ret;

#if defined(CONFIG_CDCACM)

ctrl.usbdev = BOARDIOC_USBDEV_CDCACM;
ctrl.action = BOARDIOC_USBDEV_CONNECT;
ctrl.instance = 0;
ctrl.handle = &handle;

ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
UNUSED(ret); /* Eliminate warning if not used */
DEBUGASSERT(ret == OK);
#endif
}
```

Then I am writing to the USB device like so:

```c
#define USB_CONSOLE "/dev/ttyACM0"
do {
console = open(USB_CONSOLE, O_RDWR);

/* ENOTCONN means that the USB device is not yet connected, so sleep.
 * Anything else is bad.
 */

DEBUGASSERT(errno == ENOTCONN);
sleep(1);

} while (console < 0);

/* Make USB stdout, stderr, stdin */
dup2(console, 0);
dup2(console, 1);
dup2(console, 2);

printf("A=%lf,B=%lf,G=%lf\n", pos.x, pos.y, pos.z);
```

I have tried using `fprintf` on the file descriptor returned by `open`, and 
also using `write` directly to no avail. The
console just stays blank on my host computer.

Any ideas what else I could try?

Thanks,
Matteo


signature.asc
Description: PGP signature


UnionFS: >2 bindings?

2024-10-17 Thread Tim Hardisty
I am looking at a way to expose 3x on-board MTD NOR flash and an EEPROM device 
(2 formatted with LittleFS and the larger NOR flash probably with FAT) to users 
so they can download log files, upload new firmware for MCUboot to use, or 
customization files etc.

This will probably be via USBMSD (hence FAT being a likely choice for the third 
system, especially as it will have MUCH fewer erases needed over the lifetime 
of the product) and/or via a device-hosted web server over CDC/NCM.

I’m thinking a UnionFS is possibly a way to do this but the relevant fs driver 
is hard-coded to only allow 2 bindings and I would need 3.

Before I look at embarking on expanding that to be a few more:

a) Is my idea sound or is there a better/easier POSIX/NuttX approach to this?
b) If sound, is there a fundamental problem with expanding what we have to 
allow for 3 or 4 - or even a Kconfig-set “n” bindings -  other than the hours 
needed to achieve it!?

Thanks!!