From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Serial protocol RS232 / RS485 outside BIOS

Hi all, 

 

I am using a IC-3120 with a Linux RT environment. In its BIOS, one can choose between two different serial communication protocols RS232 and RS485. 

 

Is there any other (programmatic) way of setting this communication protocol at boot-time or at run-time? Ideally I would like this to be part of the firmware image that will get deployed to the IC-3120 controllers during manufacturing of our products. 

 

Thanks a lot in advance! 

0 Kudos
Message 1 of 6
(2,917 Views)

I've got some good news and some bad news.

 

The good news is that there may be a way to do this.

 

The bad news is that it might cause your hair to fall out.

 

Still interested?

0 Kudos
Message 2 of 6
(2,840 Views)

Luckily we have Hay-Soos to deal with the hair problem:

https://dilbert.com/strip/2008-03-10

 

Bring it on!

Message 3 of 6
(2,830 Views)

So here's the deal. RS232 vs RS485 mode control is not exposed in a documentable way. However, it IS exposed through an EFI variable that can be written to — but in a giant blob of configuration shared by a bunch of other BIOS configuration variables. You can't edit the settings in isolation, but you CAN save different values of the entire configuration variable, and one of them will have the port in 232 mode, while another could have it in 485 mode. Any of this could be discovered by a customer by tweaking BIOS settings and looking at what changed in the EFI variable store, so that's why I'm pretty comfortable disclosing all of this.

 

Let me describe the downsides to this approach a little more clearly than "your hair will fall out". Obviously, this is very unsupported, but there's a little more to it than that. If this configuration variable (which includes the port setting) gets screwed up, your controller is probably hosed. This can happen if, for instance, you lose power while updating the configuration. But it could also happen if you restore a different controller's configuration by accident. Or if you restore a config from the SAME controller, but a DIFFERENT firmware version. If you're lucky, you might be able to recovery reset the firmware configuration settings. More likely, you're looking at an RMA. All that said: if this works for you, on your controller, under a controlled execution environment, it is likely to continue working.

 

With that out of the way: see attached for a script I cobbled together to automate most of this. I would describe the testing of this utility as "loose". I wish to repeat that this utility is completely unsupported. You must understand shell script programming in order to effectively deploy this utility. Usage is going to go something like this:

  • At system development time:
    • Install niefinvctl to /usr/local/bin with mode 755.
    • Get the firmware config the way you want it.
    • Run `niefinvctl -b cfg1` to save the current config to a file.
    • Make sure niefinvctl and the config file storage location (currently /var/local/niefinvctl) are included in your system image.
  • At deployed system boot time (you'll need to get this logic into your image too):
    • An init script, of your devising, runs on startup, which in turn runs `niefinvctl -5 -r cfg1`. If the file setting differs from the firmware setting, the firmware is updated; otherwise, no change is made. If the exit code is 5, reboot to make sure the settings take effect.

(EDIT: Utility updated to require opt-in for restore to work, and to abort if config was saved with a different BIOS version or model.)

0 Kudos
Message 4 of 6
(2,821 Views)

Thanks a lot for this suggested solution. 

Given other boundary conditions, this solution will be too risky in production, so we will have to stick to the old fashioned way...

0 Kudos
Message 5 of 6
(2,780 Views)

I think you made the right choice. (I suppose Hay-Soos saves those who save themselves.)

 

I did reach out to the BIOS team and ensured that they are tracking this as a feature request.

0 Kudos
Message 6 of 6
(2,762 Views)