Android9 , how preset UART baud rate?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Android9 , how preset UART baud rate?

755 Views
mariosan
Contributor II

Hi, I'm running Andoid9 over imx8mm and I want to preset the baud rate of my uarts at start up.

I've not found any way to do this in Andoid , any suggestion?

Thank Mario

0 Kudos
1 Reply

675 Views
mariosan
Contributor II

well, I've find a way to setup serials , thanks to other topics .

just launch a script at start up, also if this is not as easy work to do :-)

1) write a script, for example serialcfg.rc like this one and place it under you device

    directory (es; device/fls/imx8m/mydevice)

#!/system/bin/sh

/system/bin/stty 460800 < /dev/ttymxc2
/system/bin/stty 115200 < /dev/ttymxc3

/system/bin/stty 115200 < /dev/ttyUSB0

2) in the device's  policy directory add the serialcfg.te file:

# test domains

type serialcfg, domain;

type serialcfg_exec, exec_type, vendor_file_type, file_type;

init_daemon_domain(serialcfg)

domain_auto_trans(init, vendor_shell_exec, serialcfg)

3) Change  policy/file_contexts

/vendor/bin/serialcfg.rc  u:object_r:serialcfg_exec:s0

4) in the device makefile add the line:

PRODUCT_COPY_FILES += \

$(IMX_DEVICE_PATH)/serialcfg.rc:/vendor/bin/serialcfg.rc

5) in the device's directory change the init.rc

service serialcfg /vendor/bin/serialcfg.rc

class late_start

user root system

group root system

oneshot

After start up I found serials configured as I want , anyway I will appreciate
suggestion for a more simple approach, if any exist

Thanks,

Mario

0 Kudos