Instantly share code, notes, and snippets.

@probonopd /mxq.md
Last active Nov 11, 2018

Embed
What would you like to do?

Linux on MXQ (PCB: S805Q_V2.0) m8b_m201_v1@23a35625

Seems to be also known as the HD18Q "black box". https://www.ebay.de/itm/153205410117 ("NEU MXQ S805 Smart 1GB+ 8GB Smart TV Box Android 4.4 Quad Core 1.5 G WIFI", seller "SILVESTRAS RUNTA Network Tech Co. Ltd"), EUR 14,99

I can boot with meson8b_m201d.dtb and wired Ethernet works.

U-boot thinks it is a 512 MB device. Linux does, too. The SDK used seems to be named "s805_0701_512M":

root@vegas805:~# strings /mnt/lib/hw/camera.amlogic.so | grep home/
/home/akrd-49/work/4.4/s805_0701_512M/aml-m8-0823_patch_20150113

Power

The board can be powered via USB.

The serial VSS is 3.3V though.

Serial boot

Serial console can easily be soldered to on PCB using

sudo apt install -y screen
sudo screen /dev/ttyUSB0 115200

Although it may not be optimal, the board can be powered from a CP2102 USB serial adaptor's 5V and GND pins. At least for debugging the boot...

m8b_m201_1G#reset
resetting ...
QA5:B;SVN:B72;POC:3FF;STS:0;BOOT:0;INIT:0;READ:0;CHECK:0;PASS:0;
no sdio debug board detected 
TE : 24850
BT : 16:28:24 Nov 11 2016
PMU:NONE
##### VDDEE voltage = 0x044c

CPU clock is 792MHz

DDR mode: 32 bit mode
DDR size: 512MB (auto)
DDR check: Pass!
DDR clock: 636MHz with 2T mode
DDR pll bypass: Disabled
DDR init use : 14969 us

HHH
ucl decompress...pass
0x12345678
Boot from internal device 1st NAND

TE : 213624

System Started


U-boot-00000-g23a3562-dirty(m8b_m201_v1@23a35625) (Nov 11 2016 - 16:28:12)

clr h-ram
DRAM:  512 MiB
relocation Offset is: 0fec8000
show partition table: 
part: 0, name :       logo, size : 2000000
part: 1, name :   recovery, size : 2000000
part: 2, name :       misc, size : 2000000
part: 3, name :       boot, size : 2000000
part: 4, name :     system, size : 40000000
part: 5, name :      cache, size : 20000000
part: 6, name :       data, size : end 
aml_card_type=0x100
MMC:   [mmc_register] add mmc dev_num=0, port=1, if_type=6
[mmc_register] add mmc dev_num=1, port=2, if_type=6
SDIO Port B: 0, SDIO Port C: 1
power init
out reg=c110804c,value=dfffffff
IR init done!
register usb cfg[0][1] = 1ff73884
register usb cfg[2][0] = 1ff76430
NAND:  NAND BOOT: boot_device_flag 1
Nand PHY driver Version: 1.01.001.0004 (c) 2013 Amlogic Inc.
amlnf_phy_init : amlnf init flag 0
NAND device id: ad de 14 a7 42 4a ad de
detect NAND device: E revision 1Ynm NAND 8GiB H27UCG8T2E
nand chip ce mask 1
AML_NAND_NEW_OOB : new oob
bus_cycle=6, bus_timing=8,system=3.9ns,flash->T_REA =16,flash->T_RHOH=15
hynix nand get default reg value at blk:7, page:1792
NAND CKECK  : arg nbbt: arg_valid= 1, valid_blk_addr = 4, valid_page_addr = 0
NAND CKECK  : arg ncnf: arg_valid= 1, valid_blk_addr = 6, valid_page_addr = 0
NAND CKECK  : arg nkey: arg_valid= 1, valid_blk_addr = 5, valid_page_addr = 6
i=0,register --- nand_key
NAND CKECK  : arg nenv: arg_valid= 1, valid_blk_addr = 8, valid_page_addr = 114
nfboot    : offset: 0x000000000000 -0x000001000000 : partitons 0 : single_chip single_plane
nfcache   : offset: 0x00000d000000 -0x000026000000 : partitons 1 : single_chip multi_plane
nfcode    : offset: 0x000033000000 -0x000052000000 : partitons 5 : single_chip multi_plane
nfdata    : offset: 0x000085000000 -0x00017b000000 : partitons 1 : single_chip multi_plane
bad block count = 0

bad block count = 0

bad block count = 1

bad block count = 0

amlnf_logic_init: START
aml_nftl_start:117,size_in_blk=76,tmp_block=65,part->free_block_num=11
aml_nftl_start:117,size_in_blk=164,tmp_block=145,part->free_block_num=19
amlnf_logic_init:  COMPLETE
get_boot_device_flag: init_ret 0
get_boot_device_flag NAND BOOT: 
NAND BOOT,nand_env_relocate_spec : env_relocate_spec 49 
uboot env amlnf_env_read : ####
set_storage_device_flag: store 1
vpu clk_level in dts: 3
set vpu clk: 182150000Hz, readback: 182150000Hz(0x701)
Net:   Meson_Ethernet
init suspend firmware done. (ret:0)
cvbs trimming.1.v5: 0xa0, 0x0
hdmi tx power init
vdac open.1 = 0x1, 0x0
mode is: 4
viu chan = 1
config HPLL
config HPLL done
reboot_mode=charging
efuse version is not selected.
Hit Enter key to stop autoboot -- :  1 tstc enter

exit abortboot: 1
m8b_m201_1G#

---

m8b_m201_1G#bdinfo
arch_number = 0x00000F81
boot_params = 0x80000100
DRAM bank   = 0x00000000
-> start    = 0x00000000
-> size     = 0x20000000
ethaddr     = 00:15:18:xx:xx:xx
ip_addr     = 10.18.9.97
baudrate    = 115200 bps
TLB addr    = 0x1FF6C000
relocaddr   = 0x1FEC8000
reloc off   = 0x0FEC8000
irq_sp      = 0x1F2B7F70
sp start    = 0x1F2B7F68
FB base     = 0x00000000

U-boot commands

m8b_m201_1G#help
?       - alias for 'help'
adc     - M6 ADC test
amlnf   - AMLPHYNAND sub-system
amlnf_test- AMLPHYNAND sub-system
autoping- do auto ping test
autoscr - run script from memory
base    - print or set address offset
bdinfo  - print Board Info structure
bmp     - manipulate BMP image data
boardid_prefetch- boardid sub-system
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
cali    - configure clock phare
calinfo - calinfo print the chip calibration info
cbusreg - cbus register read/write
checkhw - Get the hardware revsion
clear_rebootmode- clear rebootmode
clkmsr  - measure PLL clock
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dcache  - enable or disable data cache
defenv  - default environment
defenv_without- defenv without environment variables
dhcp    - boot image via network using DHCP/TFTP protocol
dtbinit - init some env by reading dtb file
dtbload - load binary dtb file from a dos filesystem
echo    - echo args to console
editenv - edit environment variable
efuse   - efuse version/licence/mac/hdcp/usid read/write or dump raw efuse data commands or info(display chip efuse info)
env     - environment handling commands
ethchk  - check ethernet status
ethdbg  - set ethernet debug level
ethmode - set ethernet mac mode
ethrst  - reset ethernet phy
exit    - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
false   - do nothing, unsuccessfully
fatexist- find the file from a dos filesystem
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fdt     - flattened device tree utility commands
get_img_size- get img size and save the result as a environment variable
get_rebootmode- get reboot mode
go      - start application at address 'addr'
gset    - gpio commands
help    - print command description/usage
icache  - enable or disable instruction cache
imgread - Read the image from internal flash with actual size
imxtract- extract a part of a multi-image
irdetect- Detect IR Key to start recovery system
irkey   - irkey key_value time_value
itest   - return true/false on integer compare
keyunify- key unify sub-system
kgdb    - enter gdb remote debug mode
loadb   - load binary file over serial line (kermit mode)
loadenv - load environment at address 'addr'
loads   - load S-Record file over serial line
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)
logo    - logo sub-system
loop    - infinite loop on address range
macreg  - ethernet mac register read/write/dump
md      - memory display
mdc_clk - do mdc clock
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - mmcinfo <dev num>-- display MMC info
msleep  - delay execution for some time
msr     - Meson msr sub-system
mtest   - simple RAM read/write test
mw      - memory write (fill)
netspd_f- enforce eth speed
nm      - memory modify (constant address)
phyreg  - ethernet phy register read/write/dump
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
put     - put  storage 
pwm     - pwm sub-system
rarpboot- boot image via network using RARP/TFTP protocol
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saradc  - saradc sub-system
saveenv - save environment variables to persistent storage
sdc_burn- Burning with amlogic format package in sdmmc 
sdc_update- Burning a partition with image file in sdmmc card
secukey - security KEY sub-system
setenv  - set environment variables
sf      - SPI flash sub-system
showvar - print local hushshell variables
sleep   - delay execution for some time
source  - run script from memory
ssecukey- NAND KEY sub-system
store   - STORE sub-system
suspend - suspend
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true    - do nothing, successfully
unifykey- unifykey read/write based on the driver keymanage
unpackimg- unpack imgpack to single
update  - Enter v2 usbburning mode
usb     - USB sub-system
usbbc   - test usb bc
usbboot - boot from USB device
usid_prefetch- usid sub-system
uuid_prefetch- uuid sub-system
version - print monitor, compiler and linker version
video   - video sub-system

Environment

m8b_m201_1G#printenv
baudrate=115200
bootargs=init=/init console=ttyS0,115200n8 no_console_suspend storage=1 vdaccfg=0xa000 logo=osd1,loaded,0x7900000,1080p,full hdmimode=1080p cvbsmode=576cvbs androidboot.firstboot=0 hdmitx=
bootcmd=run start_autoscript; run storeboot
bootdelay=1
bootfile=boot.img
bootfromnand=0
bootm_low=0x00000000
bootm_size=0x80000000
bootpath=u-boot.bin
bootsize=100000
bootstart=0
bootup_offset=0x13000240
bootup_size=0x3f4c8
chipname=8726m8
console=ttyS0,115200n8
cvbsmode=576cvbs
digitaudiooutput=PCM
display_bpp=16
display_color_bg=0
display_color_fg=0xffff
display_color_format_index=16
display_height=1080
display_layer=osd2
display_width=1920
ethact=Meson_Ethernet
ethaddr=00:15:18:xx:xx:xx
fb_addr=0x7900000
fb_height=1080
fb_width=1920
firstboot=0
gatewayip=10.18.9.1
get_dt=checkhw
has.accelerometer=false
hdmimode=1080p
hostname=arm_m8
initargs=init=/init console=ttyS0,115200n8 no_console_suspend  storage=1
initrd_high=60000000
ipaddr=10.18.9.97
loadaddr=0x12000000
loadaddr_logo=0x13000000
mmcargs=setenv bootargs console=${console} boardname=m8_board
netmask=255.255.255.0
normalsize=400000
normalstart=1000000
outputmode=1080p
p0path=uImage
p0size=400000
p0start=1000000
p1path=android.rootfs
p1size=8000000
p1start=1400000
partnum=2
preboot=if itest ${upgrade_step} == 3; then run prepare; run storeargs; run update; fi; if itest ${upgrade_step} == 1; then  defenv; setenv upgrade_step 2; saveenv;fi; run prepare;run storeargs;get_rebootmode; clear_rebootmode; echo reboot_mode=${reboot_mode};run update_ir; run update_key; run switch_bootmode
preloaddtb=imgread dtb boot ${loadaddr}
prepare=logo size ${outputmode}; video open; video clear; video dev open ${outputmode};imgread pic logo bootup ${loadaddr_logo}; bmp display ${bootup_offset}; bmp scale;
reboot_mode=charging
recovery=echo enter recovery;if mmcinfo; then if fatload mmc 0 ${loadaddr} recovery.img; then bootm;fi;fi; if usb start 0; then if fatload usb 0 ${loadaddr} recovery.img; then bootm; fi;fi;if imgread kernel recovery ${loadaddr}; then bootm; else echo no recovery in flash; fi;
sdc_burning=sdc_burn ${sdcburncfg}
sdcburncfg=aml_sdc_burn.ini
serverip=10.18.9.113
start_autoscript=if usb start; then run start_usb_autoscript; fi; if mmcinfo; then run start_mmc_autoscript; fi;
start_mmc_autoscript=if fatload mmc 0 11000000 s805_autoscript; then autoscr 11000000; fi;
start_usb_autoscript=if fatload usb 0 11000000 s805_autoscript; then autoscr 11000000; fi; if fatload usb 1 11000000 s805_autoscript; then autoscr 11000000; fi; if fatload usb 2 11000000 s805_autoscript; then autoscr 11000000; fi; if fatload usb 3 11000000 s805_autoscript; then autoscr 11000000; fi;
stderr=serial
stdin=serial
stdout=serial
store=1
storeargs=setenv bootargs ${initargs} vdaccfg=${vdac_config} logo=osd1,loaded,${fb_addr},${outputmode},full hdmimode=${hdmimode} cvbsmode=${cvbsmode} androidboot.firstboot=${firstboot} hdmitx=${cecconfig}
storeboot=echo Booting...; if unifykey get usid; then  setenv bootargs ${bootargs} androidboot.serialno=${usid};fi;imgread kernel boot ${loadaddr};bootm;run recovery
switch_bootmode=if test ${reboot_mode} = factory_reset; then run recovery;else if test ${reboot_mode} = update; then run update;else if test ${reboot_mode} = usb_burning; then run usb_burning;else if test ${wipe_data} = failed; then echo wipe_data=${wipe_data}; run recovery;else   fi;fi;fi;fi
testaddr=0x12400000
update=run usb_burning; if mmcinfo; then if fatexist mmc 0 ${sdcburncfg}; then run sdc_burning; else if fatload mmc 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;run recovery;fi;else run recovery;fi;
update_ir=if irdetect; then run update; fi
update_key=saradc open 0; if saradc get_in_range 0 0x50; then msleep 50; if saradc get_in_range 0 0x50; then echo update by key...; run update; fi;fi
upgrade_step=0
usb_burning=update 1000
vdac_config=0xa000
video_dev=tvout
wipe_data=success

With SD card Armbian_5.44_S812_Ubuntu_xenial_3.10.108_server_20180521.img.xz of which the aml_update.zip has been selected in the update app in Android, getting a stalled boot only when loading the kernel:

reading uInitrd

4301012 bytes read
reading uImage

6006120 bytes read
reading dtb.img

** Unable to read "dtb.img" from mmc 0:1 **
## Booting kernel from Legacy Image at 14000000 ...
   Image Name:   Linux-3.10.108
   Image Type:   ARM Linux Kernel Image (gzip compressed)
   Data Size:    6006056 Bytes = 5.7 MiB
   Load Address: 00208000
   Entry Point:  00208000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 15000000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    4300948 Bytes = 4.1 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 11800000
   Booting using the fdt blob at 0x11800000
board_usb_stop cfg: 0
   Uncompressing Kernel Image ... OK
uboot time: 15893205 us.
EFUSE machid is not set.
Using machid 0xf81 from environment
From device tree /memory/ node aml_reserved_end property, for relocate ramdisk and fdt, relocate_addr: 0x5424001
   Loading Ramdisk to 05009000, end 05423094 ... OK
   Loading Device Tree to 05000000, end 05008541 ... OK

Starting kernel ...

No more output :-(

Copying in https://github.com/150balbes/Amlogic_s905/blob/master/dtb_file/S805/MXQ/dtb.img does not seem to change much:

No more output after Starting kernel ...

EDIT: I can boot (at least other systems, this one is tbc) with meson8b_m201d.dtb and it shows 1G of RAM and wired Ethernet works.

s805_autoscript script starts the system from removable media, taking into account the particularities of each system. So maybe this needs to be fiddled with?

Hardware

  • WLAN: SCI S9083C by Suzhou SmartChip Semiconductor Co., Ltd. = SCI S9083 1T1R 802.11bgn WiFi; seems to need 9083xu.ko

Getting it to run

Armbian_5.44_S805_Ubuntu_xenial_3.10.108_server_20180521.img.xz from https://yadi.sk/d/DnCkh3KBvAFES/Linux/Armbian/5.44

Using the meson8b_m201d.dtb as /boot/dtb.img (from the OS image or from https://github.com/150balbes/Amlogic_s905/blob/master/dtb_file/S805/) I get it to boot the kernel from SD, which I can see on HDMI and on the serial console. (But the HDMI console output is garbled when using the dtb from the GitHub link, works well with the one included with the OS image.) ARMBIAN 5.44 user-built Ubuntu 16.04.4 LTS 3.10.108; login - root, password - 1234

System takes around 30 secs to boot

root@vegas805:/home/user# free
              total        used        free      shared  buff/cache   available
Mem:         364168       39576      175496        5684      149096      301470
Swap:             0           0           0

root@vegas805:/home/user# ls /dev/
amaudio2_ctl       efuse          nand_env            tty2   tty56
amaudio2_in        fb0            net                 tty20  tty57
amaudio2_out       fb1            network_latency     tty21  tty58
amaudio2_utils     fd             network_throughput  tty22  tty59
amaudio_ctl        full           ntd0                tty23  tty6
amaudio_in         fuse           ntd0ro              tty24  tty60
amaudio_out        ge2d           ntd1                tty25  tty61
amaudio_utils      gpio_keyboard  ntd1ro              tty26  tty62
amhdmitx0          i2c-0          ntd2                tty27  tty63
aml_keys           i2c-1          ntd2ro              tty28  tty7
AmlogicCEC         i2c-2          null                tty29  tty8
amremote           i2c-3          ppmgr               tty3   tty9
amstream_abuf      i2c-4          ppp                 tty30  ttyS0
amstream_hevc      initctl        psaux               tty31  ttyS1
amstream_mpps      input          ptmx                tty32  ttyS2
amstream_mpts      ion            pts                 tty33  ttyS4
amstream_rm        irblaster0     random              tty34  uhid
amstream_sub       kmem           recovery            tty35  uinput
amstream_sub_read  kmsg           rfkill              tty36  uio0
amstream_userdata  log            rtc                 tty37  urandom
amstream_vbuf      log_events     rtc0                tty38  vcs
amsubtitle         log_main       shm                 tty39  vcs1
amvideo            logo           snd                 tty4   vcs2
ashmem             log_radio      stderr              tty40  vcs3
audiodsp0          log_system     stdin               tty41  vcs4
audio_spdif        loop0          stdout              tty42  vcs5
autofs             loop1          system              tty43  vcs6
binder             loop2          tty                 tty44  vcsa
block              loop3          tty0                tty45  vcsa1
boot               loop4          tty1                tty46  vcsa2
bootloader         loop5          tty10               tty47  vcsa3
btrfs-control      loop6          tty11               tty48  vcsa4
bus                loop7          tty12               tty49  vcsa5
cache              loop-control   tty13               tty5   vcsa6
char               mapper         tty14               tty50  xt_qtaguid
console            mem            tty15               tty51  zero
cpu_dma_latency    misc           tty16               tty52  zram0
data               mmcblk0        tty17               tty53
di0                mmcblk0p1      tty18               tty54
disk               mmcblk0p2      tty19               tty55

cat /proc/ntd

dev:    block_num   blocksize  name
ntd0: 26000000 00800000 "nfcache"
ntd1: 52000000 00800000 "nfcode"
ntd2: 17b000000 00800000 "nfdata"

root@vegas805:~# cat /sys/kernel/debug/gpio
GPIOs 0-138:
 gpio-3   (gpio_key            ) in  hi
 gpio-49  (amlsd               ) in  lo
 gpio-137 (mute_spk            ) out lo

Ethernet works out of the box.

USB seem to work only on the OTG port. FIXME

Webcam and WLAN drivers seem to be missing. FIXME

Make it announce itself in the network

# Do not automatically update
mv /usr/lib/apt/apt.systemd.daily /usr/lib/apt/apt.systemd.daily.DISABLED
reboot

# Make it announce itself in the network. This should be the default. Incredibly it still isn't.
apt update
apt install -y avahi-daemon
cd /etc/avahi/services/
wget -c https://raw.githubusercontent.com/lathiat/avahi/master/avahi-daemon/sftp-ssh.service
wget -c https://raw.githubusercontent.com/lathiat/avahi/master/avahi-daemon/ssh.service
cd -
sed -i -e 's|use-ipv6=yes|use-ipv6=no|g' /etc/avahi/avahi-daemon.conf # May be necessary to to prevent resolution issues
service avahi-daemon restart

Now it can be accessed, e.g., by Linux desktops under Network as a "file share".

OctoPrint

sudo apt -y install git python-virtualenv python-pip squashfs-tools virtualenv python2.7-dev libyaml-dev libavahi-compat-libdnssd-dev
git clone https://github.com/foosel/OctoPrint
cd OctoPrint
virtualenv -p python2.7 venv
./venv/bin/python setup.py install
./venv/bin/python ./venv/bin/octoprint
./venv/bin/pip install https://goo.gl/SxQZ06 # for Avahi; http://docs.octoprint.org/en/master/bundledplugins/discovery.html
mksquashfs venv/ octoprint.sfs

# nano /etc/rc.local
# add the following before "exit 0":
mount /root/OctoPrint/octoprint.sfs /mnt
runuser -l user -c '/mnt/bin/python /mnt/bin/octoprint' &
# runuser -l user -c '/mnt/bin/python /mnt/bin/octoprint --port=5001 --basedir $HOME/.octoprint2/' & # Second instance

# http://192.168.0.xxx:5000/

# Once everything works, make the system read-only.
sudo su
apt-get -y install overlayroot
echo 'overlayroot="tmpfs"' > /etc/overlayroot.conf
reboot

May want to configure OctoPrint in the GUI (e.g., set it to auto-connect); and/or enable multiple instances.

See https://gist.github.com/probonopd/97f6826cc5aa3c0c0950682b0bc266bc for more information.

Repetier-Server

Might be even better; supports multiple printers out of the box.

wget http://download.repetier.com/files/server/debian-armhf/Repetier-Server-0.90.7-Linux.deb
dpkg -i Repetier-Server-*.deb
# http://192.168.0.34:3344

WLAN

Seems like the source code is not available despite the module claiming to be GPL:

root@vegas805:~# mount /dev/system /mnt

root@vegas805:~#  find /mnt -name *.ko
/mnt/lib/8188eu.ko
/mnt/lib/9083xu.ko
/mnt/lib/audio_data.ko

root@vegas805:~# strings /mnt/lib/9083xu.ko | grep icens
license=GPL
__UNIQUE_ID_license0

root@vegas805:~# strings /mnt/lib/9083xu.ko | grep -i gpl
license=GPL
gpl_future_crcs
gpl_syms
gpl_crcs
num_gpl_syms
gpl_future_syms
num_gpl_future_syms

root@vegas805:~# strings /mnt/lib/9083xu.ko | grep tilk/
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_ieee80211.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_mlme.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_mlme_ext.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_wlan_util.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_xmit.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/efuse/tlw_efuse.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/os_dep/linux/ioctl_cfg80211.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/os_dep/linux/tlw_proc.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/hal/hal_intf.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/hal/tll9083x/tll9083x_hal_init.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/hal/OUTSRC/tdb.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/9083xu.mod.c

root@vegas805:~# strings /mnt/lib/9083xu.ko | grep -i home/
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_ieee80211.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_mlme.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_mlme_ext.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_wlan_util.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/tlw_xmit.c
/home/jolin/sda1/code/Amlogic/s805/common/include/linux/netdevice.h
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/core/efuse/tlw_efuse.c
/home/jolin/sda1/code/Amlogic/s805/common/include/linux/netdevice.h
/home/jolin/sda1/code/Amlogic/s805/common/include/linux/netdevice.h
/home/jolin/sda1/code/Amlogic/s805/common/include/linux/netdevice.h
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/os_dep/linux/ioctl_cfg80211.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/os_dep/linux/tlw_proc.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/hal/hal_intf.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/hal/tll9083x/tll9083x_hal_init.c
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/hal/OUTSRC/tdb.c
/home/jolin/sda1/code/Amlogic/s805/common/include/net/cfg80211.h
/home/jolin/sda1/code/Amlogic/s805/common/include/net/cfg80211.h
/home/jolin/sda1/code/Amlogic/s805/common/include/uapi/asm-generic
/home/jolin/sda1/code/Amlogic/s805/common/include/asm-generic
/home/jolin/sda1/code/Amlogic/s805/common/include/linux
/home/jolin/sda1/code/Amlogic/s805/common/arch/arm/include/asm
/home/jolin/sda1/code/Amlogic/s805/common/include/uapi/linux
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic
/home/jolin/sda1/code/Amlogic/s805/out/target/product/m201/obj/KERNEL_OBJ
/home/jolin/sda1/code/tilk/usb6/tll9083xu-amlogic/9083xu.mod.c

Install on internal memory

Backup NAND using ddbr_backup_nand_full - make sure it works (how?)

root@vegas805:~# ddbr_backup_nand_full

root@vegas805:~# find /ddbr/
/ddbr/
/ddbr/bootloader.img
/ddbr/recovery.img
/ddbr/misc.img
/ddbr/data.img
/ddbr/logo.img
/ddbr/install
/ddbr/install/aboot
/ddbr/install/aboot/zImage
/ddbr/install/aboot/aboot.txt
/ddbr/install/aboot/boot.backup.img
/ddbr/install/aboot/stage2.img
/ddbr/install/aboot/initrd.img
/ddbr/install/aboot/bootimg.cfg
/ddbr/boot.img
/ddbr/system.img

root@vegas805:~# ls -lh /ddbr/
total 6.5G
-rw-r--r-- 1 root root  32M Oct 14 00:34 boot.img
-rw-r--r-- 1 root root    0 Oct 14 00:34 bootloader.img
-rw-r--r-- 1 root root 5.4G Oct 14 00:44 data.img
drwxr-xr-x 3 root root 4.0K Oct 14 01:25 install
-rw-r--r-- 1 root root  32M Oct 14 00:34 logo.img
-rw-r--r-- 1 root root  32M Oct 14 00:34 misc.img
-rw-r--r-- 1 root root  32M Oct 14 00:34 recovery.img
-rw-r--r-- 1 root root 1.0G Oct 14 00:36 system.img

Install Armbian to NAND using ./install.sh

This copies the instance currently running from SD card to the internal memory, but without the /ddbr backup of course.

root@vegas805:~# ./install.sh

(...)

*******************************************
Complete copy OS to eMMC parted DATA
*******************************************

root@vegas805:~# cat /dev/nand_env | tr '\0' '\n' | strings
baudrate=115200
bootcmd=run start_autoscript; run storeboot
bootdelay=1
bootfile=boot.img
bootfromnand=0
bootm_low=0x00000000
bootm_size=0x80000000
bootpath=u-boot.bin
bootsize=100000
bootstart=0
chipname=8726m8
console=ttyS0,115200n8
cvbsmode=576cvbs
digitaudiooutput=PCM
display_bpp=16
display_color_bg=0
display_color_fg=0xffff
display_color_format_index=16
display_height=1080
display_layer=osd2
display_width=1920
ethaddr=00:15:18:xx:xx:xx
fb_addr=0x7900000
fb_height=720
fb_width=1280
firstboot=0
gatewayip=10.18.9.1
get_dt=checkhw
has.accelerometer=false
hdmimode=1080p
hostname=arm_m8
initrd_high=60000000
ipaddr=10.18.9.97
loadaddr=0x12000000
loadaddr_logo=0x13000000
mmcargs=setenv bootargs console=${console} boardname=m8_board
netmask=255.255.255.0
normalsize=400000
normalstart=1000000
outputmode=1080p
p0path=uImage
p0size=400000
p0start=1000000
p1path=android.rootfs
p1size=8000000
p1start=1400000
partnum=2
preboot=if itest ${upgrade_step} == 3; then run prepare; run storeargs; run update; fi; if itest ${upgrade_step} == 1; then  defenv; setenv upgrade_step 2; saveenv;fi; run prepare;run storeargs;get_rebootmode; clear_rebootmode; echo reboot_mode=${reboot_mode};run update_ir; run update_key; run switch_bootmode
preloaddtb=imgread dtb boot ${loadaddr}
prepare=logo size ${outputmode}; video open; video clear; video dev open ${outputmode};imgread pic logo bootup ${loadaddr_logo}; bmp display ${bootup_offset}; bmp scale;
reboot_mode=normal
recovery=echo enter recovery;if mmcinfo; then if fatload mmc 0 ${loadaddr} recovery.img; then bootm;fi;fi; if usb start 0; then if fatload usb 0 ${loadaddr} recovery.img; then bootm; fi;fi;if imgread kernel recovery ${loadaddr}; then bootm; else echo no recovery in flash; fi;
sdc_burning=sdc_burn ${sdcburncfg}
sdcburncfg=aml_sdc_burn.ini
serverip=10.18.9.113
start_autoscript=if usb start; then run start_usb_autoscript; fi; if mmcinfo; then run start_mmc_autoscript; fi;
start_mmc_autoscript=if fatload mmc 0 11000000 s805_autoscript; then autoscr 11000000; fi;
start_usb_autoscript=if fatload usb 0 11000000 s805_autoscript; then autoscr 11000000; fi; if fatload usb 1 11000000 s805_autoscript; then autoscr 11000000; fi; if fatload usb 2 11000000 s805_autoscript; then autoscr 11000000; fi; if fatload usb 3 11000000 s805_autoscript; then autoscr 11000000; fi;
store=1
storeargs=setenv bootargs ${initargs} vdaccfg=${vdac_config} logo=osd1,loaded,${fb_addr},${outputmode},full hdmimode=${hdmimode} cvbsmode=${cvbsmode} androidboot.firstboot=${firstboot} hdmitx=${cecconfig}
storeboot=echo Booting...; if unifykey get usid; then  setenv bootargs ${bootargs} androidboot.serialno=${usid};fi;imgread kernel boot ${loadaddr};bootm;run recovery
switch_bootmode=if test ${reboot_mode} = factory_reset; then run recovery;else if test ${reboot_mode} = update; then run update;else if test ${reboot_mode} = usb_burning; then run usb_burning;else if test ${wipe_data} = failed; then echo wipe_data=${wipe_data}; run recovery;else   fi;fi;fi;fi
testaddr=0x12400000
update=run usb_burning; if mmcinfo; then if fatexist mmc 0 ${sdcburncfg}; then run sdc_burning; else if fatload mmc 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;run recovery;fi;else run recovery;fi;
update_ir=if irdetect; then run update; fi
update_key=saradc open 0; if saradc get_in_range 0 0x50; then msleep 50; if saradc get_in_range 0 0x50; then echo update by key...; run update; fi;fi
upgrade_step=0
usb_burning=update 1000
vdac_config=0x10
video_dev=tvout
wipe_data=success
initargs=root=/dev/data rootflags=data=writeback rw console=ttyS0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.repair=yes net.ifnames=0 mac=${mac}

Booting that stalls at, as we can see on the serial console:

[   17.702125@3] Disconnect cb-Host
[   17.885018@1] usb 1-1: USB disconnect, device number 2
[   17.953476@1] usb 1-1.4: USB disconnect, device number 3
[   18.184609@1] Indeed it is in host mode hprt0 = 00021501
[   18.424699@1] usb 1-1: new high-speed USB device number 4 using dwc_otg
[   18.495188@3] Indeed it is in host mode hprt0 = 00001101
[   18.767626@3] usb 1-1: New USB device found, idVendor=14cd, idProduct=8608
[   18.839143@3] usb 1-1: New USB device strings: Mfr=1, Product=3, SerialNumber=0
[   18.910770@3] usb 1-1: Product: USB 2.0 Hub            
[   18.938248@3] usb 1-1: Manufacturer: USB Device  
[   18.943150@3] hub 1-1:1.0: USB hub found
[   18.947872@3] hub 1-1:1.0: 4 ports detected
[   19.225660@3] usb 1-1.4: new high-speed USB device number 5 using dwc_otg
[   19.404469@3] usb 1-1.4: New USB device found, idVendor=2310, idProduct=9082
[   19.475933@3] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   19.537822@3] usb 1-1.4: Product: 802.11n NIC
[   19.542301@3] usb 1-1.4: Manufacturer: SciInSX

It almost looks like at the point where systemd should take over this does not happen. Does the kernel not find its userland?

Luckily it still boots from SD card. Booted from SD, we do:

root@vegas805:~# mount /dev/data /mnt
root@vegas805:~# cat /mnt/etc/fstab 
#/var/swap none swap sw 0 0
#/dev/root      /               auto            noatime,errors=remount-ro       0 1
#proc           /proc           proc            defaults                                0 0

/dev/root       /               ext4            defaults,noatime,errors=remount-ro      0 1
tmpfs           /tmp            tmpfs           defaults,nosuid                         0 0

root@vegas805:~# ls /dev/root
ls: cannot access '/dev/root': No such file or directory

I wonder whether /dev/root is simply wrong. For test, I change it to /dev/data and reboot without SD card.

Does not seem to boot either, this time stuck at

[   11.839496@1] TV mode 1080p selected.
[   11.843596@1] tvoutc_setmode[505]
[   11.847700@1] tvoutc_setmode[516] mode is 15
[   11.851747@1] vinfo mode is: 1080p
[   11.855767@1] new mode 1080p set ok
[   11.859727@1] hdmitx: video: get current mode: 1080p
[   11.863729@1] is_similar_hdmi_vic[326] vic_old=16,mode_new=15
[   11.868758@1] hdmitx: hpd: HPD deassert!
[   12.864723@1] set_vout_mode[183]

So, trying to flash back the original Android stock ROM:

root@vegas805:~# ddbr_restore_nand 
START ddBR NAND
65536+0 records in
65536+0 records out
33554432 bytes (34 MB, 32 MiB) copied, 5.05754 s, 6.6 MB/s
... (stalled for a very long time)
171+1 records in
171+1 records out
5746196480 bytes (5.7 GB, 5.4 GiB) copied, 547.655 s, 10.5 MB/s
STOP ddBR NAND

Lo and behold, the device now can boot Android again!

Relevant thread

https://forum.armbian.com/topic/1919-armbian-for-amlogic-s805/?page=9 - it also talks about not finding the root partition when booted from NAND here: https://forum.armbian.com/topic/1919-armbian-for-amlogic-s805/?do=findComment&comment=59442

I'm trying to reuse my old OTT S805 box and succeeded in getting the 5.37 build to install to nand, but can't get either of the later ones 5.41 or 5.44 to run after they seem to install.

You do not have root mounted, so the system does not start.

I saw that but i dont understand why it fails to mount /dev/data and i go through the same steps with armbian 5.37 and it works fine.

TODO: Retry with https://yadi.sk/d/DnCkh3KBvAFES/Linux/Armbian/5.37

Best way to install Ubuntu

Install https://yadi.sk/d/DnCkh3KBvAFES/Linux/Armbian/5.37 on SD using Etcher

On the host computer, find the box on the network using

sudo apt-get -y install arp-scan
NIC=$(ifconfig | grep "Bcast:" -C 2 | head -n 1 | awk '{print $1}')
IP=$(sudo arp-scan --interface=$NIC --localnet | grep a8:16:04 | awk '{print $1}')
ssh $IP -l root

From there, continue as above.

The built-in USB hub seems to work here:

[    4.194632] usb 1-1: New USB device found, idVendor=14cd, idProduct=8608
[    4.194641] usb 1-1: New USB device strings: Mfr=1, Product=3, SerialNumber=0
[    4.194648] usb 1-1: Product: USB 2.0 Hub            
[    4.194655] usb 1-1: Manufacturer: USB Device  
[    4.195220] hub 1-1:1.0: USB hub found
[    4.195343] hub 1-1:1.0: 4 ports detected

root@vegas805:~# ddbr_backup_nand_full
START ddBR NAND
dd: failed to open '/dev/dtb': No such file or directory

Do I need to be concerned?

Indeed, it seems like the backup is not complete, since there are fewer files than above where I had used a newer Armbian version:

root@vegas805:~# find /ddbr/
/ddbr/
/ddbr/bootloader.img
/ddbr/data.img
/ddbr/recovery.img
/ddbr/logo.img
/ddbr/boot.img
/ddbr/misc.img
/ddbr/system.img

So we should NOT proceed to flash the OS to NAND if we don't have a known good backup on another running SD card made using a newer Armbian version that has /ddbr/install/aboot/aboot.txt and the likes - or is it just a matter of running https://github.com/ggrandou/abootimg on boot.img to extract those files from there in case we ever need (to inspect or modify) them? Possibly I could just have proceeded here...

UPDATE: Use the build from https://projects.milankragujevic.com/amlogic/s805/2018-10-28/, which also contains the UVC kernel modules for webcams.

Getting WLAN to work

The source code for 9083xu.ko seems not to be available. Apparently this is an internal USB module and could be replaced with a Realtek one...

This is an attempt to force a kernel module to load that was compiled for a slightly different kernel - is the attempt futile?

mount /ddbr/system.img /mnt
cp /mnt/lib/9083xu.ko .
sed -i -e 's|3.10.33|3.10.99|g' 9083xu.ko
insmod /lib/modules/3.10.99/kernel/net/wireless/cfg80211.ko
insmod 9083xu.ko 
dmesg
# How to fix?
# 9083xu: Unknown symbol usb_autopm_get_interface (err 0)

Trying out a newer U-boot from USB

U-Boot needs to be dd'd to USB disk according to https://docs.khadas.com/vim1/CreateBootableSDCard.html

$ sudo dd if=u-boot.bin.sd.bin of=/dev/sdX conv=fsync,notrunc bs=1 count=444
$ sudo dd if=u-boot.bin.sd.bin of=/dev/sdX conv=fsync,notrunc bs=512 skip=1 seek=1

Not tried yet:

gxb_p201_v1#usb storage
  Device 0: Vendor: KINGSTON Rev: 1.01 Prod: DataTraveler 3.0
            Type: Removable Hard Disk
            Capacity: 14832.0 MB = 14.4 GB (30375936 x 512)
gxb_p201_v1#usbboot device 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment