Which Khadas SBC do you use?
KVIM3
Which system do you use? Android, Ubuntu, OOWOW or others?
Android
Which version of system do you use? Khadas official images, self built images, or others?
selfbuilt images aosp9 — user build (no super user binaries are there)
Please describe your issue below:
I did a user build for aosp9 so will not have su binaries for build, I want to assign persistent static ip to ehternet eth0 for my khadas vim3 sbc. For that I want to run the shell file below every time when vim3 get booted up to configure static ip to vim3 (note: I am able to do this for RPi-4 (user debug build - su binaries are present) with similar kind of procedure)
device/khadas/kvim3/staticaddr/staticaddr.sh :
#!/system/bin/sh
# Add the IP address to the eth0 interface
ip addr add 192.168.43.0/24 dev eth0
# Check if the command was successful
if [ $? -eq 0 ]; then
echo "IP address added successfully."
else
echo "Failed to add IP address."
fi
I want to run this shell file with help of a service wtih root permissions to make that command work. device/khadas/kvim3/staticaddr/init.staticaddr.rc :
# Set up the ethernet ipv4 addr
service staticaddr /vendor/bin/sh /vendor/etc/staticcommand.sh
class core
user root
group root
oneshot
I wrote staticaddr.te file for this service like this and added in
device/khadas/common/sepolicy/staticaddr.te :
type staticaddr, domain;
type staticaddr_exec, exec_type, vendor_file_type, file_type;
allow staticaddr staticaddr_exec:file rx_file_perms;
init_daemon_domain(staticaddr)
In device/khadas/common/sepolicy/file_contexts file at end I have added this line
# static ip
/vendor/bin/staticaddr u:object_r:staticaddr_exec:s0
In device/khadas/kvim3/kvim3.mk at middle I have added these lines:
PRODUCT_COPY_FILES += \
device/khadas/kvim3/staticaddr/init.staticaddr.rc:/root/init.staticaddr.rc \
device/khadas/kvim3/staticaddr/staticaddr.sh:/vendor/etc/staticaddr.sh
In device/khadas/kvim3/init.amlogic.board.rc I have added these lines:
import init.staticaddr.rc
The build process is completing successfully, but I’m not seeing any output or traces indicating that the shell script is running as expected. Specifically, the static IP assignment to the Ethernet interface is not occurring. When I execute the adb shell service list
command, I don’t see the service name listed, and the Ethernet IP address is not being updated.
can anyone please guide me, where I am doing wrong