parent
d2a564b9c7
commit
d4d57ed7fe
14 changed files with 301 additions and 0 deletions
Binary file not shown.
@ -0,0 +1,59 @@ |
||||
#include <stdio.h> |
||||
#include <fcntl.h> |
||||
#include <sys/mman.h> |
||||
|
||||
void hexdump(uint32_t *d, int l) { |
||||
for (int i = 0; i < l; i++) { |
||||
if (i%0x10 == 0 && i != 0) printf("\n"); |
||||
printf("%8x ", d[i]); |
||||
} |
||||
printf("\n"); |
||||
} |
||||
|
||||
/* Power cluster primary PLL */ |
||||
#define C0_PLL_MODE 0x0 |
||||
#define C0_PLL_L_VAL 0x4 |
||||
#define C0_PLL_ALPHA 0x8 |
||||
#define C0_PLL_USER_CTL 0x10 |
||||
#define C0_PLL_CONFIG_CTL 0x18 |
||||
#define C0_PLL_CONFIG_CTL_HI 0x1C |
||||
#define C0_PLL_STATUS 0x28 |
||||
#define C0_PLL_TEST_CTL_LO 0x20 |
||||
#define C0_PLL_TEST_CTL_HI 0x24 |
||||
|
||||
/* Power cluster alt PLL */ |
||||
#define C0_PLLA_MODE 0x100 |
||||
#define C0_PLLA_L_VAL 0x104 |
||||
#define C0_PLLA_ALPHA 0x108 |
||||
#define C0_PLLA_USER_CTL 0x110 |
||||
#define C0_PLLA_CONFIG_CTL 0x118 |
||||
#define C0_PLLA_STATUS 0x128 |
||||
#define C0_PLLA_TEST_CTL_LO 0x120 |
||||
|
||||
#define APC_DIAG_OFFSET 0x48 |
||||
#define CLK_CTL_OFFSET 0x44 |
||||
#define MUX_OFFSET 0x40 |
||||
#define MDD_DROOP_CODE 0x7c |
||||
#define SSSCTL_OFFSET 0x160 |
||||
#define PSCTL_OFFSET 0x164 |
||||
|
||||
int main() { |
||||
int fd = open("/dev/mem", O_RDWR); |
||||
volatile uint32_t *mb = (uint32_t*)mmap(0,0x1000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,0x06400000); |
||||
volatile uint32_t *mc = (uint32_t*)mmap(0,0x1000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,0x06480000); |
||||
volatile uint32_t *md = (uint32_t*)mmap(0,0x1000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,0x09A20000); |
||||
while (1) { |
||||
printf("PLL MODE:%x L_VAL:%x ALPHA:%x USER_CTL:%x CONFIG_CTL:%x CONFIG_CTL_HI:%x STATUS:%x TEST_CTL_LO:%x TEST_CTL_HI:%x\n", |
||||
mb[C0_PLL_MODE/4], mb[C0_PLL_L_VAL/4], mb[C0_PLL_ALPHA/4], |
||||
mb[C0_PLL_USER_CTL/4], mb[C0_PLL_CONFIG_CTL/4], mb[C0_PLL_CONFIG_CTL_HI/4], |
||||
mb[C0_PLL_STATUS/4], mb[C0_PLL_TEST_CTL_LO/4], mb[C0_PLL_TEST_CTL_HI/4]); |
||||
printf(" MUX_OFFSET:%x CLK_CTL_OFFSET:%x APC_DIAG_OFFSET:%x MDD_DROOP_CODE:%x\n", |
||||
mb[MUX_OFFSET/4], mb[CLK_CTL_OFFSET/4], mb[APC_DIAG_OFFSET/4], mb[MDD_DROOP_CODE/4]); |
||||
printf(" PLLA MODE:%x L_VAL:%x ALPHA:%x USER_CTL:%x CONFIG_CTL:%x STATUS:%x TEST_CTL_LO:%x SSSCTL_OFFSET:%x PSCTL_OFFSET:%x\n", |
||||
mb[C0_PLLA_MODE/4], mb[C0_PLLA_L_VAL/4], mb[C0_PLLA_ALPHA/4], mb[C0_PLLA_USER_CTL/4], |
||||
mb[C0_PLLA_CONFIG_CTL/4], mb[C0_PLLA_STATUS/4], mb[C0_PLLA_TEST_CTL_LO/4], |
||||
mb[SSSCTL_OFFSET/4], mb[PSCTL_OFFSET/4]); |
||||
usleep(1000*100); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,41 @@ |
||||
#!/usr/bin/env python3.7 |
||||
import os |
||||
from smbus2 import SMBus |
||||
|
||||
def setup_fan(): |
||||
os.system("echo 2 > /sys/module/dwc3_msm/parameters/otg_switch") |
||||
|
||||
bus = SMBus(7, force=True) |
||||
try: |
||||
bus.write_byte_data(0x21, 0x10, 0xf) # mask all interrupts |
||||
bus.write_byte_data(0x21, 0x03, 0x1) # set drive current and global interrupt disable |
||||
bus.write_byte_data(0x21, 0x02, 0x2) # needed? |
||||
bus.write_byte_data(0x21, 0x04, 0x4) # manual override source |
||||
print("OP detected") |
||||
return False |
||||
except IOError: |
||||
print("LEON detected") |
||||
return True |
||||
bus.close() |
||||
|
||||
def get_fan_type(): |
||||
if not setup_fan(): |
||||
return |
||||
|
||||
bus = SMBus(7, force=True) |
||||
try: |
||||
# alternate type |
||||
bus.write_i2c_block_data(0x3d, 0, [0x1]) |
||||
print("Alternate type detected") |
||||
return |
||||
except IOError: |
||||
# tusb320 type |
||||
print("tusb320 type detected") |
||||
bus.close() |
||||
|
||||
|
||||
def main(gctx=None): |
||||
get_fan_type() |
||||
|
||||
if __name__ == "__main__": |
||||
main() |
@ -0,0 +1 @@ |
||||
route add default gw 192.168.5.1 && ndc network create 100 && ndc network interface add 100 eth0 && ndc resolver setnetdns 100 localdomain 8.8.8.8 8.8.4.4 && ndc network default set 100 |
@ -0,0 +1,3 @@ |
||||
build |
||||
out |
||||
src |
@ -0,0 +1,66 @@ |
||||
#!/usr/bin/env bash |
||||
# https://blog.tan-ce.com/gcc-bare-metal/ |
||||
# https://imvoid.wordpress.com/2013/05/01/building-the-gnu-arm-toolchain-for-bare-metal/ |
||||
set -e |
||||
|
||||
BINUTILS=binutils-2.32 |
||||
GCC=gcc-4.7.1 |
||||
|
||||
mkdir -p src |
||||
pushd src |
||||
if [ ! -d $BINUTILS ]; then |
||||
wget ftp://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2 |
||||
tar -xf $BINUTILS.tar.bz2 |
||||
fi |
||||
popd |
||||
|
||||
# TODO: replace with /usr |
||||
mkdir -p out |
||||
PREFIX=$PWD/out |
||||
|
||||
mkdir -p build/$BINUTILS |
||||
pushd build/$BINUTILS |
||||
../../src/$BINUTILS/configure --target=arm-none-eabi \ |
||||
--build=aarch64-unknown-linux-gnu \ |
||||
--prefix=$PREFIX --with-cpu=cortex-m4 \ |
||||
--with-mode=thumb \ |
||||
--disable-nls \ |
||||
--disable-werror |
||||
make -j4 all |
||||
make install |
||||
popd |
||||
|
||||
mkdir -p src |
||||
pushd src |
||||
if [ ! -d $GCC ]; then |
||||
wget ftp://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.bz2 |
||||
tar -xf $GCC.tar.bz2 |
||||
|
||||
cd $GCC |
||||
contrib/download_prerequisites |
||||
fi |
||||
|
||||
popd |
||||
|
||||
export PATH="$PREFIX/bin:$PATH" |
||||
|
||||
mkdir -p build/$GCC |
||||
pushd build/$GCC |
||||
../../src/$GCC/configure --target=arm-none-eabi \ |
||||
--build=aarch64-unknown-linux-gnu \ |
||||
--disable-libssp --disable-gomp --disable-libstcxx-pch --enable-threads \ |
||||
--disable-shared --disable-libmudflap \ |
||||
--prefix=$PREFIX --with-cpu=cortex-m4 \ |
||||
--with-mode=thumb --disable-multilib \ |
||||
--enable-interwork \ |
||||
--enable-languages="c" \ |
||||
--disable-nls \ |
||||
--disable-libgcc |
||||
make -j4 all-gcc |
||||
make install-gcc |
||||
popd |
||||
|
||||
# replace stdint.h with stdint-gcc.h for Android compatibility |
||||
mv $PREFIX/lib/gcc/arm-none-eabi/4.7.1/include/stdint-gcc.h $PREFIX/lib/gcc/arm-none-eabi/4.7.1/include/stdint.h |
||||
|
||||
|
@ -0,0 +1,17 @@ |
||||
#!/bin/sh |
||||
echo 1 > /proc/sys/net/ipv4/ip_forward |
||||
#iptables -t nat --delete-chain |
||||
iptables --flush |
||||
iptables -t nat --flush |
||||
|
||||
# could be either one |
||||
iptables -t nat -A POSTROUTING -o v4-rmnet_data0 -j MASQUERADE |
||||
iptables -t nat -A POSTROUTING -o rmnet_data0 -j MASQUERADE |
||||
|
||||
#iptables --delete-chain |
||||
#iptables -A INPUT -i eth0 -j ACCEPT |
||||
#iptables -A INPUT -i v4-rmnet_data0 -m state --state RELATED,ESTABLISHED -j ACCEPT |
||||
#iptables -A OUTPUT -j ACCEPT |
||||
#iptables -A FORWARD -i rmnet_data0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT |
||||
#iptables -A FORWARD -i eth0 -o v4-rmnet_data0 -j ACCEPT |
||||
|
@ -0,0 +1,7 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
# Stop updater |
||||
pkill -2 -f selfdrive.updated |
||||
|
||||
# Remove pending update |
||||
rm -f /data/safe_staging/finalized/.overlay_consistent |
@ -0,0 +1,16 @@ |
||||
#!/data/data/com.termux/files/usr/bin/bash |
||||
watch -n1 ' |
||||
cat /sys/kernel/debug/clk/pwrcl_clk/measure |
||||
cat /sys/kernel/debug/clk/perfcl_clk/measure |
||||
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq |
||||
cat /sys/class/kgsl/kgsl-3d0/gpuclk |
||||
echo |
||||
echo -n "CPU0 " ; cat /sys/devices/virtual/thermal/thermal_zone5/temp |
||||
echo -n "CPU1 " ; cat /sys/devices/virtual/thermal/thermal_zone7/temp |
||||
echo -n "CPU2 " ; cat /sys/devices/virtual/thermal/thermal_zone10/temp |
||||
echo -n "CPU3 " ; cat /sys/devices/virtual/thermal/thermal_zone12/temp |
||||
echo -n "MEM " ; cat /sys/devices/virtual/thermal/thermal_zone2/temp |
||||
echo -n "GPU " ; cat /sys/devices/virtual/thermal/thermal_zone16/temp |
||||
echo -n "BAT " ; cat /sys/devices/virtual/thermal/thermal_zone29/temp |
||||
' |
||||
|
@ -0,0 +1,4 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
# Send SIGHUP to updater |
||||
pkill -1 -f selfdrive.updated |
Binary file not shown.
@ -0,0 +1,52 @@ |
||||
#define _GNU_SOURCE |
||||
#include <stdio.h> |
||||
#include <sched.h> |
||||
#include <arm_neon.h> |
||||
#include "../selfdrive/common/timing.h" |
||||
|
||||
#define CORES 4 |
||||
double ttime[CORES]; |
||||
double oout[CORES]; |
||||
|
||||
void waste(int pid) { |
||||
cpu_set_t my_set; |
||||
CPU_ZERO(&my_set); |
||||
CPU_SET(pid, &my_set); |
||||
int ret = sched_setaffinity(0, sizeof(cpu_set_t), &my_set); |
||||
printf("set affinity to %d: %d\n", pid, ret); |
||||
|
||||
float32x4_t *tmp = (float32x4_t *)malloc(0x1000008*sizeof(float32x4_t)); |
||||
float32x4_t out; |
||||
|
||||
uint64_t i = 0; |
||||
double sec = seconds_since_boot(); |
||||
while(1) { |
||||
int j; |
||||
for (j = 0; j < 0x1000000; j++) { |
||||
out = vmlaq_f32(out, tmp[j], tmp[j+1]); |
||||
} |
||||
if (i == 0x8) { |
||||
double nsec = seconds_since_boot(); |
||||
ttime[pid] = nsec-sec; |
||||
oout[pid] = out[0] + out[1] + out[2] + out[3]; |
||||
i = 0; |
||||
sec = nsec; |
||||
} |
||||
i++; |
||||
} |
||||
} |
||||
|
||||
int main() { |
||||
pthread_t waster[CORES]; |
||||
for (int i = 0 ; i < CORES; i++) { |
||||
pthread_create(&waster[i], NULL, waste, (void*)i); |
||||
} |
||||
while (1) { |
||||
for (int i = 0 ; i < CORES; i++) { |
||||
printf("%.2f ", ttime[i]); |
||||
} |
||||
printf("\n"); |
||||
sleep(1); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,35 @@ |
||||
#!/usr/bin/env python3 |
||||
from multiprocessing import Process |
||||
from setproctitle import setproctitle |
||||
import os |
||||
import numpy as np |
||||
from common.realtime import sec_since_boot |
||||
|
||||
def waste(pid): |
||||
# set affinity |
||||
os.system("taskset -p %d %d" % (1 << pid, os.getpid())) |
||||
|
||||
m1 = np.zeros((200,200)) + 0.8 |
||||
m2 = np.zeros((200,200)) + 1.2 |
||||
|
||||
i = 1 |
||||
st = sec_since_boot() |
||||
j = 0 |
||||
while 1: |
||||
if (i % 100) == 0: |
||||
setproctitle("%3d: %8d" % (pid, i)) |
||||
lt = sec_since_boot() |
||||
print("%3d: %8d %f %.2f" % (pid, i, lt-st, j)) |
||||
st = lt |
||||
i += 1 |
||||
j = np.sum(np.matmul(m1, m2)) |
||||
|
||||
def main(gctx=None): |
||||
print("1-2 seconds is baseline") |
||||
for i in range(4): |
||||
p = Process(target=waste, args=(i,)) |
||||
p.start() |
||||
|
||||
if __name__ == "__main__": |
||||
main() |
||||
|
Loading…
Reference in new issue