Choose USB Port on Raspberry?

Hello,
I have a fresh installation of version 10.0 and it does not work with megatronics or MKS base 1.6… when flashing, it says " found tty: ttyAMA0 for firmware flash" however the serial port used is ttyUSB0. Anyway to choose the right port for the RAMPS compatible card ?

Thanks

10:41:35.053 [info] usb 1-1.4: new full-speed USB device number 5 using dwc_otg
10:41:35.240 [info] usb 1-1.4: New USB device found, idVendor=0403, idProduct=6001,bcdDevice= 6.00
10:41:35.240 [info] usb 1-1.4: New USB device strings: Mfr=1, Product=2,SerialNumber=3
10:41:35.240 [info] usb 1-1.4: Product: FT232R USB UART
10:41:35.241 [info] usb 1-1.4: Manufacturer: FTDI
10:41:35.255 [info] usb 1-1.4: SerialNumber: AL035T40
10:41:35.303 [info] ftdi_sio 1-1.4:1.0: FTDI USB Serial Device converter detected
10:41:35.303 [info] usb 1-1.4: Detected FT232RL
10:41:35.303 [info] usb 1-1.4: FTDI USB Serial Device converter now attached to ttyUSB0
10:41:35.497 [debug] firmware interface already detected: ttyAMA0

Try using Farmbot OS version 9.2.2, I’ve expected the same log output when using v10.0.0. Connect the raspberry with the webapp under v9.2.2 and make an OTA update then, your arduino will keep the firmware even under v10.0.0. That’s how its working for me at least.

@GillesF I am assuming you are using an off-the-shelf board rather than an official one. If the 3rd party board you are using exposes both *USB0 and *AMA0, it will not work. FBOS was designed to detect exactly one serial port and currently has no means of dealing with setups where two USB serial ports are connected. Unless this problem is affecting official FarmBot boards, it is unlikely that I will add a fix for it, as there are higher priority issues that I need to take care of right now.

Hello,
Thanks to @Ascend. it did the trick. Using version 9.2.2, the pi was able to find correctly the card, then update it.
@RickCarlino : I confirm that the 3rd party board is not exposing the serial port twice according to the log and the tests I did on a raspbian. However the version 9.2.2 works nicely. I believe that the ttyAMA0 is the UART port on the GPIO pins of the Raspberry.
Let me know if there is anything I can do to help confirming this. I am pretty sure I will not be the only one in the case.

@RickCarlino
I’m also running on a 3rd party board (MKS Gen 1.4) which is the arduino mega2560/ramps board in one board. I wasn’t able to find time yet to try flashing the firmware from FBOS10 to a regular mega2560/ramps stack as they were used in Genesis 1.2, but I believe that those devices can also experience this issue if they reflash the OS.
Do you remember if there was any change to FBOS dealing with serial ports / UART ports or anything similar? Its weird that those boards were working nicely until V10.0.0. I think as long as this issue only affects 3rd party boards and not farmbot customers using the 1.2 kit this workaround will help out as there are probably not too many users having a non-kit setup.

@GillesF @Ascend

the 3rd party board is not exposing the serial port twice according to the log and the tests I did on a raspbian.

Raspbian uses a completely different config.txt than FBOS, so this may not be an accurate comparison. As you may have noticed from the volume of support requests on the forum, we are very busy this month and I can’t spend any time investigating this matter unless it is affecting users of official kits.

I believe that those devices [used in Genesis 1.2] can also experience this issue if they reflash the OS.

I do most of my QA testing on a v1.2 RAMPS board and did not experience any issues. I re-flashed from scratch this morning to be sure and saw no issues. I will keep an eye on this, and I welcome feedback from any forum users that are on official 1.2 hardware. We have not seen an uptick in support requests from v1.2 customers related to firmware, though I will need to double check that with Marc when he is in the office.

Do you remember if there was any change to FBOS dealing with serial ports / UART ports or anything similar?

Yes, here is what happened: As we roll out the new FarmBot Express line, some customers want more CPU power than the RPi0 can provide and wish to upgrade their CPU to an RPi3. It is possible in theory to buy a 40 pin connector and replace the RPi0 with a faster RPi3 board. It is not possible in practice, though, due to how FarmBot OS does serial detection. I would like to give customers the ability to upgrade the CPU of their Express kits so in v10.0.0, I made changes to how serial detection works to be more generic. It is still a work in progress and it is not yet possible to do an RPi upgrade on Express bots. Although the work was not complete, it was stable enough to merge and we did not observe any problems during QA for the 10.0.0 release. We performed QA checks on v1.2 devices as part of the release process and did not notice any issues.

I will keep this in mind when I re-visit this feature, which probably won’t be any time soon due to current support requests from customers and reduced staff.

It might be possible to fix the issue by changing the enable_uart value in config.txt of the boot partition, but I can’t spend any time assisting with this process, given the high number of support requests from customers using official hardware.

1 Like

Hello.
Thanks @RickCarlino for the information. I modified the config.txt to remove the enable_uart and tried to push the firmware. It is still asking for a device found as ttyAMA0…
I’ll try to investigate on this although there is a workaround.

Gilles

1 Like

Hi,
I ran through the same issue and I made a fix in my FBOS to handle this.
In fact it was a matter of list order…
ttyAMA0 appears before ttyUSB0 in the list of available port, so farmbot use this one.
In FBOS 9.2.2, this bug was not here because for Rpi3 target, ttyAMA0 was not in the “valid port name list for farmdunio” but in FBOS 10.0.0 they added this port to the valid ones in oder the allow the upgrade from Rpi0 to Rpi3 for Express users (I think).

Anyway, here is my fix in the file farmbot_os/farmbot_core/lib/farmbot_core/firmware_tty_detector.ex

where I modified the function “handle_info” :

  def handle_info(:timeout, state) do
    enumerated = UART.enumerate() |> Map.to_list()
    # now we want to put the ttyAMA0 (if any) at the end of the list
    enumerated =
      if List.keymember?(enumerated,"ttyAMA0",0) do
        ttyserial = List.keyfind(enumerated,"ttyAMA0",0)
        enumerated = List.delete(enumerated, ttyserial)
        enumerated ++ ttyserial
      else
        enumerated
      end
    {:noreply, state, {:continue, enumerated}}
  end

Hope this will help.
PS: I never coded in Elixir before, so there is maybe a better way, but this one works.

2 Likes

Thanks for investigating the @Arti4ever. If it passes QA testing and does not interfere with official FarmBot kits, I can merge this into the next release.

@Arti4ever Some unfortunate news: The fix you’ve applied will not be added to FBOS until the release of 10.1.1. We expect to release 10.1.0 tomorrow but unfortunately we saw problems with Express Farmduino behavior after applying your fix (no root cause identified due to time limitations). Because of this, we had to remove it and schedule it for a different release. Please follow our newsletter or forum announcements for a release notice.

2 Likes

@RickCarlino good communication.

2 Likes

Hello @Ascend, i’ve also plugged in a MKS 1.4 into my rsp3 but updating the firmware from “my.farmbot.io” doesn’t work, i thought I’ve read somewhere the problem has solved with the automatic selection of ttyUSB0 or ttyAMA0. I also tried editing the firmware from the git, but i’m no developer and after a couple of hours trying to make my own firmware i gave up this path.

Is there a different way to change the communication port from ttyAMA0 to ttyUSB0 through ssh and change some files on the sdcard or something?

Hello @Blood_BE, are you running the newest OS version 12.3.3? Looks like the fix that Arti4ever posted was merged into the OS and should work. Unfortunately I didn’t try to upload the firmware in the last months and I’m also not able to try it on my device as its unpowered and partly disassembled.
Is there a log mentioning the ttyAMA0 port when you try to upload the firmware?

log farmbot SSH.txt (8.4 KB)
log farmbot SSH ramps.txt (8.1 KB)
Yes i am on the latest version
I tried ramps 1.2 and farmduino genesis 1.5 as you can see in the log files
see attachments

My bad, everything is working perfectly!

2 Likes

Putting this here for anyone that runs into this error when trying to use the MKS Gen L board

Detecting available UARTs: [“ttyAMA0”, “ttyUSB0”]

It seems ttyAMA0 is some serial interface on the Pi, don’t quote me on this, I disabled mine in the config.txt file on the Pi’s SD card

’ # Enable the UART (/dev/ttyAMA0) on the RPi3.
enable_uart=0

The Farmbot OS then picked up the correct port and flashed firmware correctly to the

@Dope A future update to FBOS might wipe your config.txt file so I don’t recommend that end users modify config.txt directly. This post is over a year old and we have actually updated FBOS to support the original feature requested. Here’s how you can change your serial port from within the web app:

Go to the device settings page and enable “SHOW ADVANCED SETTINGS”:
image

Next, change the FIRMWARE PATH option. You can use whatever value you would like but keep in mind that once you set this value, FarmBot will only use this option. It will not use any sort of fallback.
image

Lastly, be sure to disable ADVANCED SETTINGS when you are done to avoid accidentally changing any of the “dangerous” settings that could negatively affect your device’s motor tuning.

1 Like

Excellent, did not see the advanced settings toggle, thanks for that, will update mine accordingly.

1 Like

Glad to hear @Dope. Since you have already modified the SD card’s boot partition, I ask that you please perform a hard re-flash of the SD card before requesting support from us in the future. The reason I mention this is that we occasionally get support requests from folks (advanced users) who modify the root / user data partition of the card and unwittingly break FBOS features. These support requests are very difficult for us to troubleshoot. Re-flashing the SD card will ensure that there are no leftover modifications to the boot config.