You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/19 00:27:33 UTC

[GitHub] [incubator-nuttx] abdallah-ali-abdallah commented on issue #7331: Is it possible to enable nsh over composite usb configuration using RP2040?

abdallah-ali-abdallah commented on issue #7331:
URL: https://github.com/apache/incubator-nuttx/issues/7331#issuecomment-1283174034

   Hi @acassis 
   
   Thank you for your help, I did what you explained and after some hacking, tweaking and a lot of jumping between files I was able to operate the NSH over composite mode and used multiple serial instances for extra data transfers
   
   I will state all the steps I did (and I think there might be a way less hacky, please if you have any recommendation for better way mention it) 
   ------------ steps goes as following --------
   
   1- I started with **tools/configure.sh raspberry-pico:composite**
   
   2- Disable the default serial consol over **UART0** 
   **_Device Drivers → Serial Driver Support → No serial console_**
   ![image](https://user-images.githubusercontent.com/8594637/196566879-13230993-c7de-47c9-86e0-e552fe32311a.png)
   
   3- Activate alternative consol **_Application Configuration → NSH Library → Console Configuration_**
   ![image](https://user-images.githubusercontent.com/8594637/196566310-3f299ba1-68fc-4fed-ba3d-61607b6bff8c.png)
   
   4- Now for testing I added 2 serial CDC/ACM by editing **arm/rp2040/common/src/rp2040_composite.c**
   ![image](https://user-images.githubusercontent.com/8594637/196567425-9a66ab3b-6705-479e-b431-a97b0a707acc.png)
   
   
   5- (Here is the tricky part) When I tried to compile the project, no usb detected, after some jumping around files, I missed a simple fact, NSH need access to /dev/ttyACM0 which never initialized because by default we need to call application "conn" from NSH (which not started yet...uuuh).
   
   So the fix is to init the USB composite before starting the NSH, which I did by modifying **nsh_initialize** inside **_apps/nshlib/nsh_init.c_**
   where I added 2 actions applied to USB 
   
   -   ctrl.action   = BOARDIOC_USBDEV_INITIALIZE;
   -   ctrl.action   = BOARDIOC_USBDEV_CONNECT;
   
   ![image](https://user-images.githubusercontent.com/8594637/196567848-f240af8f-b682-4b3f-9215-c7fbdf1f03a5.png)
   
   6- Recompile everything and upload ...
   
   Finally,, dmesg on linux telling me I have 2 serial interfaces attached to my machine
   ![image](https://user-images.githubusercontent.com/8594637/196568130-c678e83b-5cab-4837-964f-1d0c81c18db9.png)
   
   and NSH is working perfectly on /dev/ttyACM0
   
   ... extra problem.
   
   Based on documentation [here](https://nuttx.apache.org/docs/latest/applications/nsh/config.html)
   
   ![image](https://user-images.githubusercontent.com/8594637/196569176-fa9d9569-e964-4a02-852c-ba0194472b3a.png)
   
   NSH will not print '\r\n' to devices except /dev/consol. that causes the consol to read shofted and miss aligned lines
   
   I applied some fix to this by modifying **nuttx/drivers/serial/serial.c** and forced serial to convert every '\n' to '\r\n'
   (based on if TERMIOS is enabled or not)
   
   This
   ![image](https://user-images.githubusercontent.com/8594637/196568509-00963b80-0dee-418a-9cb9-d986bda5c53c.png)
   Or that
   ![image](https://user-images.githubusercontent.com/8594637/196568586-5b1f9627-5cc3-41df-8581-e7b3984ea350.png)
   
   
   Now everything works perfectly and NSH lines printed correctly on minicom.
   
   
   So, Do you have any recommendation for **_cleaner way_** to do it without modifying any core nuttx files for manipulating the nsh_initialize function 
   
   Thank you.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org