I want to hack Robomaster S1 ① Rooting and file configuration check

Overview

What did you do

--Connect Robomasters1 to your PC via USB and use adb to access the root. --I took a peek at the file structure of the contents

What can you do?

――I don't know ... (passionate) --You can run the Python environment on the command line without any restrictions (some libraries cannot be used via the app)

What do you want to do

The ultimate purpose of this article

--I want to send a command from a PC to Robomaster S1 and collect images and sensor data Reference: Mr. Ishikawa's article --I want to use it to process Robomaster images on a PC and send control signals like the volunteer Demo.

The ball tracking demo video is attached below. I want to do something like this.

I want to do this

policy

There is a model called EP, which is the successor to Robomaster S1, and you can do what you just said. SDK is also distributed. (Document is here)

https://github.com/dji-sdk/RoboMaster-SDK/tree/master/sample_code

According to Mr. Bruno who is familiar with this matter, this SDK does not originally support S1, but since the configuration is similar, it can be diverted if done well.

reference:

-Bruno's repository -Bruno's DJI Forum

What I actually did

For the time being, root access seems to be required

-Refer to Discussion here Perform root access. --Look into the contents of the System

Root access from Windows 10 PC using adb

Connect to Robomasters 1 from your Windows 10 Home PC using the microUSB connector.

I will proceed based on PDF here, but note that it cannot be rooted if the firmware is new. There is a report of, so do not update **.

Preparation

Prepare the following items.

--PC, microUSB conversion cable

Unzip Platform Tools and remember the location of the folder. Connect your PC to Robomasters 1. image.png

** Please remove the Android device connected to your PC before going to the next step. ** **

Connection between PC and Robomasters 1

  1. Turn on the power of Robomasters1 and start the software on the PC side to connect. (I have a Wifi connection)

  2. Go to the page to write a Python script from "Lab"-> "DIY Programming".

  3. Copy and paste the following code to create a new one and execute it. (It looks like you're hitting sh to enable adb)

def root_me(module):
 __import__=rm_log.__dict__['__builtins__']['__import__']
 return __import__(module,globals(),locals(),[],0)
builtins=root_me('builtins')
subprocess=root_me('subprocess')
proc=subprocess.Popen('/system/bin/adb_en.sh',shell=True,executable='/system/bin/sh',stdout=subprocess.PIPE,stderr=subprocess.PIPE)

Connection using adb

Next, go to the Platform Tools folder (folder where adb can be executed) that you unzipped earlier, and start Powershell. (Terminal for Linux people)

.\adb.exe devices

After executing

.\adb.exe shell

To execute. If all goes well, you should have it as root as shown below.

image.png

What to do next (maybe)

-~~ Somehow, remove ConnectionRefusedError: [WinError 10061] on the Robomasters1 side and try the SDK sample program ~~ --Apparently the Robomaster s1 doesn't have the socket port that triggers the SDK, so you need to copy the files from the EP ... you don't have the money to buy the EP either ...

Addendum: Looking at Exchanges here, it seems that you need to copy the files from Robomaster EP, which you can do with your own. That's right ...

Description

Looking at the SDK as of August 12, 2020, it seems that the SDK mode is enabled by sending a signal to a specific port of the Robomasters1 address, and various commands are issued.

For example, in a test file that enables the SDK and executes various instructions from a PC, a signal is sent to port 40923 by socket communication.

SDK sample code
# -*- encoding: utf-8 -*-
#Measurement environment: Python 3.6 editions

import socket
import sys

#Under the direct connection model, the robot person's robot IP ground site 192.168.2.1,Control order end mouth number 40923
host = "192.168.100.111"
port = 40923

def main():

        address = (host, int(port))

        #Robot control person restraint order end entrance erection TCP connection
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        print("Connecting...")

        s.connect(address)

        print("Connected!")

        while True:

                #User import restraint order
                msg = input(">>> please input SDK cmd: ")

                #At the time of Q or q, before leaving the program
                if msg.upper() == 'Q':
                        break

                #Addition cohesion
                msg += ';'

                #Transmission restraint order
                s.send(msg.encode('utf-8'))

                try:
                        #The result of the return of the robot
                        buf = s.recv(1024)

                        print(buf.decode('utf-8'))
                except socket.error as e:
                        print("Error receiving :", e)
                        sys.exit(1)
                if not len(buf):
                        break

        #Jacobs bogie connection
        s.shutdown(socket.SHUT_WR)
        s.close()

if __name__ == '__main__':
        main()

However, when connecting from the Client side, the following error is issued.

ConnectionRefusedError: [WinError 10061]The connection could not be made because it was rejected by the target computer.

Do I need to edit hosts or something, or mess with Permission? I'm looking into it for a moment. (I want to learn from someone who is familiar with it.)

Postscript: When I tried it, it seems that the problem is that the Port that is open in EP is not open in S1.

As a basis, I started the following server with Robomaster s1 and confirmed that it can be connected from a PC.

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.bind(("192.168.100.111", 1235))
s.listen(5)

timeout=60## run 60 sec
s.settimeout(timeout)

while True: 
    clientsocket, address = s.accept()
    print(f"Connection from {address} has been established!")
    clientsocket.send(bytes("Welcome to the server!", 'utf-8'))
    clientsocket.close()

print("Exit!")

Supplement: Search the contents

I'm an amateur of Linux and Hack like this, so it was hard to understand by looking inside. I will post it by the record.

System information

It seems to be a Linux system.

$ cat /proc/version
Linux version 3.10.62 (jenkins@APServer01) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Tue Jul 16 04:08:11 CST 2019

Directly below /

I don't know anything, so it feels like I'm looking at this, but I'll make a note of it.

Click to expand
amt
blackbox
cache
data
default.prop
dev
etc
file_contexts
ftp
init
init.environ.rc
init.lc1860.3connective.rc
init.rc
init.trace.rc
init.usb.rc
proc
property_contexts
root
sbin
sdcard
seapp_contexts
sepolicy
sys
system
system.md5
tmp
ueventd.rc
var
vendor

Python environment

There is a Python folder in data / python_flies.

The contents of bin are as follows

2to3
idle
pydoc
python
python-config
python3.6m
pyvenv

You can actually do it. The environment seems to be 3.6.

126|root@xw607_dz_ap0002_v4:/data/python_files/bin # ./python
Python 3.6.6 (default, Jul 16 2018, 17:22:20)
[GCC 4.8.3 20140320 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

The difference from the robomaster app is that you can use certain packages.

For example, in the code created by the application, ** socket etc. is played as an error at the time of import, but it can be executed normally by root command line execution. ** **

It would be nice if there was an editor such as vi, but as far as the output of ls / system / bin is seen, there is no editor, so it seems necessary to transfer files.

If you know where the file created by the application is, it seems that you can operate it to some extent on root.

Contents of dev

Omitted tty. There is video0 and so on.

Click to expand
alarm
android_adb
apple_roleswitch
applecp
ashmem
binder
block
bulk_usb
bus
comip-snd-lowpower
comip-ureg
console
cpu_dma_latency
cuse
full
fuse
graphics
hx170dec
hx280enc
hx280enc_h1
i2c-0
i2c-1
i2c-3
i2c-4
input
ion
kmsg
lcmem
log
loop-control
mem
modem
mtp_usb
network_latency
network_throughput
null
on2map
on2psm
ptmx
pts
random
rtc0
sdpr
sdps
snd
socket
spidev0.0
spidev1.0
spidev2.0
uio0
uio1
uio2
urandom
vcs
vcs1
vcsa
vcsa1
video0
zero

Recommended Posts

I want to hack Robomaster S1 ① Rooting and file configuration check
I want to write an element to a file with numpy and check it.
I want to receive the configuration file and check if the JSON file generated by jinja2 is a valid JSON
I want to format and check Python code to my liking on VS Code
Anyway, I want to check JSON data easily
I want to log file I / O on Linux
I want to write to a file with Python
I want to drop a file on tkinter and get its path [Tkinter DnD2]
I want to get the file name, line number, and function name in Python 3.4
I want to write in Python! (1) Code format check
I want to see the file name from DataLoader
I want to handle optimization with python and cplex
I want to randomly sample a file in Python
I want to replace the variables in the python template file and mass-produce it in another file.
I want to save the photos sent by LINE to S3
I want to know the features of Python and pip
I want to count unique values in arrays and tuples
I want Sphinx to be convenient and used by everyone
I want to use VS Code and Spyder without anaconda! !! !!
I want to solve Sudoku (Sudoku)
How to check and change Linux permissions (permissions) (chmod) (I want to be saved from Permiss on denied)
I want to extract the tag information (title and artist) of a music file (flac, wav).
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
I want to run Rails with rails s even in vagrant environment
LINEbot development, I want to check the operation in the local environment
I want to use both key and value of Python iterator
I want to acquire and list Japanese stock data without scraping
Scraping and tabelog ~ I want to find a good restaurant! ~ (Work)
I want to connect remotely to another computer, and the nautilus command
I want to check the position of my face with OpenCV!
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to separate the processing between test time and production environment
(Python Selenium) I want to check the settings of the download destination of WebDriver
The file name was bad in Python and I was addicted to import
I want to analyze the emotions of people who want to meet and tremble
I made a program to check the size of a file in Python
I want to make a web application using React and Python flask