移植Ubuntu-core 14.04到R16

开个新帖子记录如何移植ubuntu core 14.04到R16吧。此前走Tina启动后chroot到Ubuntu的方案遇到了瓶颈,难以正常启动dbus等,导致很多功能走不下去。

1. 修改从ubuntu启动

./target/allwinner/generic/configs/env-3.4.cfg

将启动参数中的默认启动位置由nandd(rootfs,也就是tinav2)切换到nandg(就是UDISK,也就是我们放了ubuntu的文件系统);将init=/sbin/init改成init=/bin/sh,因为ubuntu与openwrt的启动不同。改完后,重新make、pack,然后烧写。正确的情况是,启动后就不能使用adb连接了,只能uart方式登录(要从这里下载,然后自动找一下usb-serial的驱动,安装完重启下就ok了)。

2. 解决wifi上网的问题

这是非常困难的,此前Tina用到的是全志官方的方法,该方法依赖于openwrt独有的库,因此不能移植到这边。我们只能一步一步来:

首先,制作可用的文件系统:

dd if=/dev/zero of=ubuntu1404v2.img bs=1MB count=1024
mkfs.ext4 ubuntu1404v2.img
sudo mount ubuntu1404v2.img tmp/
sudo apt-get install qemu-user-static 
wget http://cdimage.ubuntu.com/ubuntu-base/releases/14.04.5/release/ubuntu-base-14.04.4-core-armhf.tar.gz
sudo cp /usr/bin/qemu-arm-static tmp/usr/bin/
sudo cp /etc/resolv.conf tmp/etc/resolv.conf
sudo mount chproc tmp/proc/ -t proc
sudo mount chsys tmp/sys/ -t sysfs
sudo mount -t devtmpfs chdev tmp/dev
sudo LC_ALL=C LANGUAGE=C LANG=C chroot tmp/
apt-get update
apt-get install linux-{headers,image}-generic build-essential bluez \
rfkill unzip wget vim wpasupplicant net-tools pkg-config libnl-3-dev \
libssl-dev iputils-ping dnsmasq-base \
libnl-genl-3-dev usbutils dosfstools libdbus-1-dev

然后,要能加载bcmdhd的驱动,也就需要固件的支持,所以需要把固件从Tina文件系统拷贝到Ubuntu对应的目录:

sudo mount -t ext4 ubuntu.img tmp/
cd tmp/lib/
sudo cp ../../Tina-V2-addUbuntu/out/astar-parrot/compile_dir/target/rootfs/lib/firmware/ . -r
sudo cp ../../Tina-V2-addUbuntu/out/astar-parrot/compile_dir/target/rootfs/lib/modules/ . -r
cd ../../
exit 
sudo umount tmp/sys/
sudo umount tmp/proc/
sudo umount tmp/dev/
sudo umount tmp/
cd Tina-V2-addUbuntu/
source build/envsetup.sh
lunch 3
make
pack # 我此前在Tina-V2-addUbuntu/out/下面做了一个软连接,指向ubuntu.img

重新烧录后:

touch /lib/modules/3.4.39/modules.order
touch /lib/modules/3.4.39/modules.builtin
depmod
modprobe bcmdhd

结果是:

# modprobe bcmdhd
[ 211.407618] dhd_module_init: in
[ 211.411249] ======== bcm_wlan_set_plat_data ========
[ 211.416864] GPIO(WL_HOST_WAKE) = 359
[ 211.421122] host_oob_irq: 7 
[ 211.424516] host_oob_irq_flags=1044
[ 211.428481] dhd_wifi_platform_load: Enter
[ 211.433170] Power-up adapter 'DHD generic adapter'
[ 211.438627] wifi_platform_set_power = 1
[ 211.443001] ======== PULL WL_REG_ON HIGH! ========
[ 211.448504] [wifi_pm]: wifi power on
[ 211.760030] wifi_platform_bus_enumerate device present 1
[ 211.766114] ======== Card detection to detect SDIO card! ========
[ 211.773024] [mmc]: sdc1 set ios: clk 0Hz bm PP pm UP vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[ 211.784403] [mmc]: sdc1 power_supply is null
[ 211.810027] [mmc]: sdc1 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[ 211.842346] [mmc]: *** sunxi_mci_dump_errinfo(L824): smc 1 err, cmd 52, RTO !!
[ 211.851576] [mmc]: *** sunxi_mci_dump_errinfo(L824): smc 1 err, cmd 52, RTO !!
[ 211.859910] [mmc]: sdc1 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[ 211.872738] [mmc]: sdc1 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[ 211.884990] [mmc]: *** sunxi_mci_dump_errinfo(L824): smc 1 err, cmd 8, RTO !!
[ 211.893315] *******************Try sdio*******************
[ 211.899812] [mmc]: sdc1 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[ 211.919273] mmc0: queuing unknown CIS tuple 0x80 (2 bytes)
[ 211.926979] mmc0: queuing unknown CIS tuple 0x80 (3 bytes)
[ 211.934756] mmc0: queuing unknown CIS tuple 0x80 (3 bytes)
[ 211.943682] mmc0: queuing unknown CIS tuple 0x80 (7 bytes)
[ 212.035011] [mmc]: sdc1 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing SD-HS(SDR25) dt B
[ 212.045386] [mmc]: sdc1 set ios: clk 50000000Hz bm PP pm ON vdd 3.3V width 1 timing SD-HS(SDR25) dt B
[ 212.055980] [mmc]: sdc1 set ios: clk 50000000Hz bm PP pm ON vdd 3.3V width 4 timing SD-HS(SDR25) dt B
[ 212.067713] mmc0: new high speed SDIO card at address 0001
[ 212.074410] *******************sdio init ok*******************
[ 212.090463] bcmsdh_register: register client driver
[ 212.096133] bcmsdh_sdmmc: bcmsdh_sdmmc_probe Enter
[ 212.101617] bcmsdh_sdmmc: bcmsdh_sdmmc_probe Enter
[ 212.107124] bus num (host idx)=0, slot num (rca)=1
[ 212.112551] found adapter info 'DHD generic adapter'
[ 212.118485] dhdsdio_probe : no mutex held. set lock
[ 212.124090] F1 signature read @0x18000000=0x1530a9a6
[ 212.131398] F1 signature OK, socitype:0x1 chip:0xa9a6 rev:0x0 pkg:0x3
[ 212.139396] DHD: dongle ram size is set to 524288(orig 524288) at 0x0
[ 212.146867] dhd_conf_set_chiprev: chip=0xa9a6, chiprev=0
[ 212.152921] dhd_conf_set_conf_path_by_nv_path: config_path=/lib/firmware/config.txt
[ 212.162271] dhd_conf_read_config: Ignore config file /lib/firmware/config.txt
[ 212.170919] wl_create_event_handler(): thread:wl_event_handler:54 started
[ 212.170930] tsk Enter, tsk = 0xd70e1410
[ 212.183666] p2p0: P2P Interface Registered
[ 212.188470] dhd_attach(): thread:dhd_watchdog_thread:55 started
[ 212.195202] dhd_attach(): thread:dhd_dpc:56 started
[ 212.195214] dhd_dpc_thread: set dpc_cpucore 0 from config.txt
[ 212.207330] dhd_attach(): thread:dhd_rxf:57 started
[ 212.212857] dhd_deferred_work_init: work queue initialized 
[ 212.219380] dhdsdio_probe_init: set use_rxchain 1 from config.txt
[ 212.233344] Dongle Host Driver, version 1.201.59.3 (r506368)
[ 212.233349] Compiled in drivers/net/wireless/bcmdhd on Feb 4 2017 at 12:54:26
[ 212.248355] Register interface [wlan0] MAC: 94:a1:a2:c2:5b:62
[ 212.248361] 
[ 212.256688] dhd_prot_ioctl : bus is down. we have nothing to do
[ 212.263495] bcmsdh_oob_intr_unregister: Enter
[ 212.268429] bcmsdh_oob_intr_unregister: irq is not registered
[ 212.275008] dhd_txglom_enable: enable 0
[ 212.279359] dhd_bus_devreset: WLAN OFF DONE
[ 212.284228] wifi_platform_set_power = 0
[ 212.288670] ======== PULL WL_REG_ON LOW! ========
[ 212.293998] [wifi_pm]: wifi power off
[ 212.298161] dhdsdio_probe : the lock is released.
[ 212.303622] dhd_module_init: Exit err=0

貌似wifi的mac看到了,但由于启动是直接init=/bin/sh,导致没有完成所有的启动流程,从而导致/proc、/dev、/sys等目录并没有完整,所以无法ifconfig。

sudo apt-get install qemu-user-static

vi /etc/init/ttyS0.conf


# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[12345]
stop on runlevel [!12345]

respawn
exec /sbin/getty -L 115200 ttyS0 vt102

3. WIFI AP部分

需要编译bcm的patchram工具:

su root
./s.sh
cd m/

4. 蓝牙部分

1)需要自行编译bluez5,不能用ubuntu 14.04自带的apt-get得到的bluez4(对bcm43xx支持不好)

su root
./s.sh
apt-get install libglib2.0-dev libdbus-1-dev libudev-dev libical-dev \
 libreadline-dev
cd m/
wget http://sources.openelec.tv/mirror/bluez/bluez-5.25.tar.xz
tar xvf bluez-5.25.tar.xz
cd bluez-5.25/
./configure --disable-systemd
make
make install
cp bluez-5.25/src/bluetooth.service /etc/systemd/system/bluetooth.service
cp bluez-5.25/src/bluetoothd /usr/bin/
reboot

2)配置

wget https://launchpad.net/ubuntu/+archive/primary/+files/brcm-patchram-plus_0.1.1.tar.gz tar xvf brcm-patchram-plus_0.1.1.tar.gz 
cd bcm-patchram-plus/ 
gcc -o brcm_patchram_plus brcm_patchram_plus.c
mkdir /etc/firmware/ap6212/
cp /lib/firmware/ap6212/bcm43438a0.hcd /etc/firmware/ap6212/4343A0.hcd
su root
./s.sh

echo "0" > /sys/class/rfkill/rfkill0/state 
echo "1" > /sys/class/rfkill/rfkill0/state 
echo " " > /dev/ttyS1 
hciattach /dev/ttyS1 bcm43xx 115200 
brcm_patchram_plus -d --patchram /lib/firmware/bcm43438a0.hcd --enable_hci --no2bytes --tosleep 1000 /dev/ttyS1 &
rfkill unblock all
hciconfig hci0 class 0x20041C
hciconfig hci0 up 
hciconfig -a 
hcitool scan
bluetoothd &
bluetoothctl


----------------------------
Scanning ...
 XX:XX:XX:XX:XX:XX Samsung Galaxy S7 edge
 XX:XX:XX:XX:XX:XX DESKTOP-672K9Q9

----------------------------

hcitool cc XX:XX:XX:XX:XX:XX
hcitool auth XX:XX:XX:XX:XX:XX


sudo rfcomm connect 20:2D:07:AA:76:BF 2
Advertisements

One thought on “移植Ubuntu-core 14.04到R16

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s