Useful stuff: Difference between revisions

From SoftwareGuy
Jump to navigation Jump to search
Mark (talk | contribs)
Created page with "== Useful commands == cat /sys/devices/virtual/thermal/thermal_zone0/temp cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq == Android shell == editing the build.prop file on the system adb shell su mount -o remount,rw /system cd / echo "persist.service.adb.enable=1" >> default.prop echo "persist.service.debuggable=1" >> default.prop echo "persist.sys.usb.config=mtp,adb" >> default.prop echo..."
 
Mark (talk | contribs)
No edit summary
Line 315: Line 315:
pnmnoraw
pnmnoraw
ppmquant
ppmquant
== extending linux filesystem ==
=== Not LVM ===
Change partition size:
sudo fdisk /dev/sda:
Remove the old partition (d).
Create a new one, starting at the same sector but bigger (n).
You should get a message saying that partition contains a signature. When asked, whether you want to remove it, answer n. If you didn't get the message, then something is wrong, don't continue (don't write the changes) but quit (q).
If all is well, write changes (w).
Expand file system:
sudo e2fsck -f /dev/sda3
sudo resize2fs /dev/sda3
Reboot system, boot as usual.
Check partitions:
df

Revision as of 14:04, 4 February 2025

Useful commands

cat /sys/devices/virtual/thermal/thermal_zone0/temp
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

Android shell

editing the build.prop file on the system

 adb shell
 su
 mount -o remount,rw /system
 cd /
 echo "persist.service.adb.enable=1" >> default.prop 
 echo "persist.service.debuggable=1" >> default.prop
 echo "persist.sys.usb.config=mtp,adb" >> default.prop
 echo "persist.service.adb.enable=1" >> /system/build.prop 
 echo "persist.service.debuggable=1" >> /system/build.prop
 echo "persist.sys.usb.config=mtp,adb" >> /system/build.prop

debugging input devices like the touchscreen

 getevent -il // display all input devices

find the device you care about

 getevent -trl /dev/input/event0 | grep ABS_X  // for example
 getevent -l | grep event0

Development system

adb install -r <filename>.apk

adb push <local filename> <target filename>

adb devices -l

adb -s <system name>

adb screencap -p /sdcard/screen.png

OTA upgrade process

 rm out/target/product/hbi120/boot*
 rm out/target/product/hbi120/kernel
 make -j12 BUILD_TARGET_DEVICE=sd
 adb push out/target/product/hbi120/boot.img /dev/block/mmcblk3p1
 adb reboot
 make -j12 BUILD_TARGET_DEVICE=sd dist
 adb shell 'mkdir -p /cache/recovery'
 adb push out/dist/hbi120-ota-20160824.1441.zip /cache/update.zip
 adb shell 'echo "--update_package=/cache/update.zip" > /cache/recovery/command'
 adb reboot recovery

Write sdcard

./um.sh
pushd out/target/product/hbi120
sudo ../../../../device/fsl/common/tools/fsl-sdcard-partition_1604.sh -f imx6q /dev/sdX
popd

Touchscreen debugging

atmel config

echo 4.8_H_640T_1.2_1WN_001.raw > /sys/bus/i2c/drivers/atmel_mxt_ts/0-004a/update_cfg

mxt-app

adb push ~/projects/Android5.1b/Android_Lolli/kernel_imx/firmware/atmel/4.8_H_640T_1.2_1WN_001.raw /sdcard/Android/data/atmel.raw
adb push projects/mxt-app/libs/armeabi-v7a/mxt-app /data/local/tmp/
adb shell /data/local/tmp/mxt-app --load /sdcard/Android/data/atmel.raw

kernel output when updating the atmel device

adb shell dmesg | grep atmel
[    5.005664] atmel_mxt_ts 0-004a: Family: 164 Variant: 2 Firmware V1.2.AA Objects: 39
[    5.014151] atmel_mxt_ts 0-004a: Enabling RETRIGEN workaround
[    5.104391] atmel_mxt_ts 0-004a: cfg_name atmel/4.8_H_640T_1.2_1WN_001.raw, error 0
[    5.112140] atmel_mxt_ts 0-004a: Direct firmware load failed with error -2
[    5.119072] atmel_mxt_ts 0-004a: Falling back to user helper
[    5.119104] atmel_mxt_ts 0-004a: Touchscreen size2 X0Y0
[    5.148466] atmel_mxt_ts 0-004a: fw_load_from_user_helper fw_priv -734595072
[    5.155552] atmel_mxt_ts 0-004a: fw_load_from_user_helper fw_priv -734595072
[    5.162621] firmware atmel!4.8_H_640T_1.2_1WN_001.raw: _request_firmware_load:
[    7.619973] atmel_mxt_ts 0-004a: fw_load_from_user_helper ret 0
[    7.657693] atmel_mxt_ts 0-004a: Config CRC 0xDC5CE1: does not match file 0x406817
[    8.045181] atmel_mxt_ts 0-004a: Resetting device
[    8.165252] atmel_mxt_ts 0-004a: Config successfully updated
[    8.174276] atmel_mxt_ts 0-004a: multitouch t100
[    8.186835] atmel_mxt_ts 0-004a: Touchscreen size1 X719Y1279

Kernel debugging stuff

/sys/devices/system/cpu/cpu0/cpufreq/
/sys/devices/virtual/thermal/thermal_zone0/temp

Writing kernel modules

power management

manual cpufreq change

cat /sys/fsl_otp/HW_OCOTP_CFG0
cat /sys/fsl_otp/HW_OCOTP_CFG1

Camera stuff

pm enable com.android.gallery3d/com.android.camera.CameraLauncher

https://community.nxp.com/thread/360269

LED control from command line

echo 1 > /sys/class/gpio/gpio171/value
echo 1 > /sys/class/gpio/gpio174/value

I2C debugging

probe bus

i2cdetect -y 0
i2cdetect -y 1
i2cdetect -y 2

pcf8563 rtc

pcf8653 driver

links

http://lxr.free-electrons.com/source/drivers/rtc/rtc-pcf8563.c

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&ved=0ahUKEwjIzt2w9orRAhUp0oMKHUMqAx4QFgg1MAQ&url=https%3A%2F%2Fstuff.mit.edu%2Fafs%2Fsipb%2Fcontrib%2Flinux%2Fdrivers%2Frtc%2Frtc-pcf8563.c&usg=AFQjCNHEqK9c_2d1Qocio_ZumuOL1pvTlg&sig2=E0mpKKNfW2TuydfnxO0TSg

dump rtc

@ 0x51, bus 0

i2cdump -y -f 0 0x51 b
i2cdump -y -f -r 0-0xf 0 0x51 b

clear VL (voltage low)

bit in Reg 0x2

adb shell i2cset -y -f 0 0x51 2 0x80

Setting the time/date

adb shell date -s 20161206.082400

reading/writing rtc

busybox hwclock --show
busybox hwclock --systohc

rtc clockout

See PCF8563.pdf doc [1]

dumping registers:

device address 0x51, register 0x2 (seconds in rtc).

i2cget -f -y 8 0x51 0x2

register CLKOUT_Control, bit 7 is the enable bit for clock output. bits 0,1 select the clock output frequency

i2cget -f -y 8 0x51 0xd
i2cset -f -y 8 0x51 0xd 0

clear all bits in CLKOUT.

Kernel driver for PCF8563 is located at ./kernel_imx/drivers/rtc/rtc-pcf8563.c

JNI tricks

How to reference java object from c++

http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/example-1.1/FieldAccess.c

http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/example-1.1/FieldAccess.java

neon integration example

https://github.com/googlesamples/android-ndk

Android crashes

adb pull /data/anr/traces.txt

adb bugreport > bugreport.txt

USB Permission

Hack #1

Add:

public void onStart() {
   super.onStart();
   mPermissionGranted = true;
   finish();
}

to frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java to bypass the the permission confirmation popup.

Correct way (mostly)

Call getUsbPermission(), it will take care of the getting permission if needed.

   private void getUsbPermission() {
       UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
       HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
       //UsbAccessory[] accessoryList = manager.getAccessoryList();
       //if (manager.hasPermission(accessoryList[0])) {
       if (!manager.hasPermission(deviceList.get("/dev/bus/usb/001/002"))) {
           BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
               @Override
               public void onReceive(Context context, Intent intent) {
                   String action = intent.getAction();
                   if (ACTION_USB_PERMISSION.equals(action)) {
                       synchronized (this) {
                           if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
                               startUsbDevice();
                           }
                       }
                   }
               }
           };
           PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
           IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
           registerReceiver(mUsbReceiver, filter);
           manager.requestPermission(deviceList.get("/dev/bus/usb/001/002"), pi);
       } else {
           startUsbDevice();
       }
   }
   private void startUsbDevice() {
       AsyncTask<Void, Void, Void> fpgaProgressBar = new AsyncTask<Void, Void, Void>() {
           Boolean bFpgaLoads;
           @Override
           protected Void doInBackground(Void... params) {
               bFpgaLoads = loadFpga();
               return null;
           }
           @Override
           protected void onPostExecute(Void result) {
               if (usb.simFtdi) {
                   //textViewTitle.setBackgroundColor(Color.YELLOW);
                   //textViewTitle.setTextColor(Color.BLUE);
                   toolbar.setBackgroundColor(Color.YELLOW);
               }
               if (bFpgaLoads) {
                   // fpga load succeeded
               }  else {
                   // fpga load failed
               }
           }
       };
       fpgaProgressBar.execute();
   }

Switching between openjdk java versions

List all java versions:

update-java-alternatives --list

Set java version as default (needs root permissions):

sudo update-java-alternatives --set /path/to/java/version
sudo update-java-alternatives --set /usr/lib/jvm/java-1.7.0-openjdk-amd64

Wifi debugging with Android studio

Don't get confused between /usr/bin/adb and /opt/android-sdk/platform-tools/adb. If the adb is restarted, then you have to redo the connection process. Only use one version of the tool during this process. For now I'm using the /opt/android-sdk/platform-tools/adb only as it is a higher version than the /usr/bin/adb.

It appears that during the first set of commands you need to have the android target connected via usb until after the tcpip command. This maybe switching communication modes on the android targets adbd as well.

ping 192.168.1.142
./adb kill-server
./adb devices
./adb tcpip 5555
./adb connect 192.168.1.142:5555
./adb devices

Now I appear to be able to debug normally. The connect command may need to be run a couple of times.

git buffer size

git config --global http.postBuffer 1048576000

SQL debugging

/data/data/com.heuresistech.hbi120/databases # sqlite3 Data
.schema
select * from users;

Location of penguin's and splash screen

located in the kernel build

drivers/video/logo/logo_linux_clut224.ppm

located in the android build

device/heuresis/hbi120/overlay/frameworks/base/core/res/assets/images/android-logo-mask.png
device/heuresis/pb200i/overlay/frameworks/base/core/res/assets/images/android-logo-shine.png

Additional tools needed

pnmnoraw ppmquant

extending linux filesystem

Not LVM

Change partition size:

sudo fdisk /dev/sda:

Remove the old partition (d). Create a new one, starting at the same sector but bigger (n). You should get a message saying that partition contains a signature. When asked, whether you want to remove it, answer n. If you didn't get the message, then something is wrong, don't continue (don't write the changes) but quit (q). If all is well, write changes (w). Expand file system:

sudo e2fsck -f /dev/sda3
sudo resize2fs /dev/sda3

Reboot system, boot as usual.

Check partitions:

df