Perfect explanation. I was wondering why I wasn’t finding the hardware partition under the mmcblk0 and now I understand.
Anyway, It is now booting from EMMC. The only thing I am missing now to play with this is a 19.07 or trunk based image. I will wait for you to have time to work on this or maybe @cioby23 can upload his git for me to clone.
One small issue I encountered is that the generated image is double gzipped. I could not find why this is happening yet. So as a workaround you need to run
This is due to the way SD image creation was “hacked” into the existing image creation primitives provided by openwrt buildroot. There were some changes done in the way this primitives work in trunk compared to how they been working in 18.06.x and you’re seeing double gzipping as a side-effect.
P.S. If you really want to decipher what’s going on there you will have to read a lot of “code” written in GNU Make located at the include/*.mk files. Start with image*.mk and package*.mk. Be warned that this experience is not for a fainthearted, the way openwrt’s buildroot system works might be braincracking at times.
Thanks for your effort. I successfully ported your bpir2 changes to the 18.06.4 openwrt distribution. I have some tips for you and for anyone interested.
In gen_mediatek_sdcard_img you assign head=4. That is not a good idea because if you look at ptgen source code, using head=4 will make only the first 1024*4*63*512 bytes of partition table indexable. So the image created, althoungh working, will most likely bring to data corruption and inode indexing errors. I recommend to change its value to 255 (the maximum allowed). So you can create images up to about 7.8GB (no more because of the limitations of ptgen).
I successfully generated and installed an openwrt image for bpi-r2 emmc. Those are the steps to do it:
Create the executable file gen_mediatek_mmc_img.sh in fold/target/linux/mediatek/image
Overwrite the file Config.in in fold/target/linux/mediatek/image
config MEDIATEK_SD_BOOT_PARTSIZE
int "Boot (SD Card) filesystem partition size (in MB)"
depends on TARGET_mediatek
default 32
config MEDIATEK_MMC_ROOT_PARTSIZE
int "Root (MMC Card) filesystem partition size (in MB)"
depends on TARGET_mediatek
default 1024
After the build process you will get also an mmc.tar.gz image. Please note that during the build process you will be asked for your root password. This is needed because the emmc image needs to be mounted to be created. Why so? Because the regular root.ext4 image generated by openwrt build process is created using a tool ported from android that does not need root but will generate “buggy” images with big rootfs sizes (you will get tons of corrupted inodes that cause continuous read only remounts during usage). That’s why I recreate root.ext4 image in Build/mediatek-mmc and I use the parameter MEDIATEK_MMC_ROOT_PARTSIZE and not the builtin CONFIG_TARGET_ROOTFS_PARTSIZE. The MEDIATEK_MMC_ROOT_PARTSIZE can be set to any value that fits the bpi-r2 emmc without any corruption. I recommennd keeping CONFIG_TARGET_ROOTFS_PARTSIZE low.
Verify that the output of last command is Boot configuration bytes [PARTITION_CONFIG: 0x48]
3. Reboot bpi-r2 with openwrt from sdcard.
4. Using scp upload in /tmp the files openwrt-mediatek-mt7623-7623n-bananapi-bpi-r2-ext4-mmc.img.gz (generated by build process) and BPI-R2-EMMC-boot0-DDR1600-20191024-0k.img.gz (download it from here)
5. From ssh console
Reboot without sd card and you should boot from emmc
I am currently trying to make wifi work under openwrt. I successfully built it but it actually reboots the bpi-r2 I think I wil l need frank-w help. I will post on the other thread to ask for help.
I am currently using Kernel 4.14.131. I have the cfg and the firmware both in /etc/firmware and in /system/etc/firmware. That is my debug serial port output (it is really similar to one you posted in the wifi thread: there you said that you solved the problems by patchig your dts. My dts seem very similar to the ones you have i your 4.14 kernel branch)
[ 62.485511] [WMT-DETECT][I]wmt_detect_open:open major 154 minor 0 (pid 860)
[ 62.492461] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191037),arg(0)
[ 62.499604] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (1074034433),arg(302
43)
[ 62.506950] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191036),arg(30
243)
[ 62.514410] [WMT-MOD-INIT][I]do_common_drv_init:start to do common driver ini
t, chipid:0x00007623
[ 62.524762] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6620.defAn
t'.
[ 62.532168] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6628.defAn
t'.
[ 62.539526] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6630.defAn
t'.
[ 62.548146] [WMT-CONSYS-HW][E]mtk_wmt_probe(122):Wmt Cannot find pinctrl defa
ult!
[ 62.555889] [WMT-CONSYS-HW][E]mtk_wmt_probe(170):CanNot get consys reset. ret
=-517
[ 62.564147] [WMT-MOD-INIT][I]do_common_drv_init:finish common driver init
[ 62.570940] [WCN-MOD-INIT][E]do_connectivity_driver_init(57):do common driver
init failed, ret:-1
[ 62.579757] [GPS-MOD-INIT][I]do_gps_drv_init:CONFIG_MTK_COMBO_GPS is not defi
ned
[ 62.587090] [WCN-MOD-INIT][E]do_connectivity_driver_init(62):do common driver
init failed, ret:-1
[ 62.595921] [FM-MOD-INIT][I]do_fm_drv_init:start to do fm module init
[ 62.602321] [FM-MOD-INIT][I]do_fm_drv_init:finish fm module init
[ 62.608275] [WLAN-MOD-INIT][I]do_wlan_drv_init:start to do wlan module init 0
x7623
[ 62.615978] [WLAN-MOD-INIT][I]do_wlan_drv_init:WMT-WIFI char dev init, ret:0
[ 62.624215] [WMT-CONSYS-HW][E]mtk_wmt_probe(122):Wmt Cannot find pinctrl defa
ult!
[ 62.629921] [WLAN-MOD-INIT][I]do_wlan_drv_init:WLAN-GEN2 driver init, ret:0
[ 62.632020] [WMT-CONSYS-HW][E]mtk_wmt_probe(170):CanNot get consys reset. ret
=-517
[ 62.638972] [WLAN-MOD-INIT][I]do_wlan_drv_init:finish wlan module init
[ 62.652828] [WMT-DETECT][I]wmt_detect_close:close major 154 minor 0 (pid 860)
[ 65.666219] [WMT-CORE][E]opfunc_hif_conf(874):WMT-CORE: WMT HIF info added
[ 65.673098] vcn18: mode operation not allowed
[ 65.678641] Unable to handle kernel NULL pointer dereference at virtual addre
ss 00000010
[ 65.686668] pgd = c0004000
[ 65.689347] [00000010] *pgd=00000000
[ 65.692893] Internal error: Oops: 17 [#1] PREEMPT SMP ARM
[ 65.698244] Modules linked in: pppoe ppp_async pppox ppp_generic nf_conntrack
_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE xt_time xt_tcpudp xt_state xt_nat xt
_multiport xt_mark xt_mac xt_limit xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT
xt_LOG xt_FLOWOFFLOAD ums_usbat ums_sddr55 ums_sddr09 ums_karma ums_jumpshot um
s_isd200 ums_freecom ums_datafab ums_cypress ums_alauda slhc nf_reject_ipv4 nf_n
at_redirect nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_i
pv4 nf_flow_table_hw nf_flow_table nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rt
cache nf_conntrack iptable_mangle iptable_filter ip_tables crc_ccitt ip6t_REJECT
nf_reject_ipv6 nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_ta
bles x_tables usb_storage leds_gpio ohci_platform ohci_hcd ehci_platform ehci_hc
d gpio_button_hotplug
[ 65.769284] CPU: 0 PID: 863 Comm: mtk_wmtd Tainted: G W 4.14.131
#0
[ 65.776614] Hardware name: Mediatek Cortex-A7 (Device Tree)
[ 65.782138] task: de3c8a80 task.stack: de330000
[ 65.786632] PC is at clk_core_enable+0x48/0x9c
[ 65.791034] LR is at clk_core_enable+0x3c/0x9c
[ 65.795438] pc : [<c03871d0>] lr : [<c03871c4>] psr: 60000093
[ 65.801648] sp : de331e40 ip : de3c8a80 fp : c0b673dc
[ 65.806825] r10: c0b679a4 r9 : 00000001 r8 : 00000000
[ 65.812003] r7 : 00000000 r6 : c09713b4 r5 : 00000000 r4 : de1a6fc0
[ 65.818473] r3 : 00000000 r2 : 00000001 r1 : 00d200d1 r0 : 00000000
[ 65.824943] Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment non
e
[ 65.832103] Control: 10c5387d Table: 9eb5c06a DAC: 00000051
[ 65.837798] Process mtk_wmtd (pid: 863, stack limit = 0xde330218)
[ 65.843838] Stack: (0xde331e40 to 0xde332000)
[ 65.848159] 1e40: de1a6fc0 a0000013 c09713b4 c038723c c0ba9a9c de1a6a80 c0971
3b4 c03f5f84
[ 65.856269] 1e60: 00000000 00000000 00000000 00000000 df7a8f90 de331f14 de331
f10 c0b66e0c
[ 65.864379] 1e80: 00000000 00000000 00000001 c03f6160 de331f14 c03d9668 de331
ec4 df7a8a80
[ 65.872489] 1ea0: 00001208 00000000 00000000 00000001 00000000 00000000 de331
eec c07041cc
[ 65.880600] 1ec0: df7a8a80 c01373c4 c0b00000 00000000 00000000 df7a8a80 de3c8
a80 de99aa80
[ 65.888710] 1ee0: c0b06e80 00000000 de331f14 c06ffddc c0b673dc 00000002 c0829
538 c0b66e0c
[ 65.896820] 1f00: c08fa358 c0932484 c0b67b64 c03db52c 00000000 00000000 c0b66
e0c 00000009
[ 65.904930] 1f20: c0b67b64 c0ba9a6c 00000000 c03dfb34 c0b679a4 c03db774 df208
8dc c0b66e40
[ 65.913040] 1f40: c0b67b64 c0b67398 c0b673c0 c0ba9a6c 00000000 c03e1ca0 ffffe
000 00000000
[ 65.921150] 1f60: de08e800 df2088c0 de330000 de08e800 00000000 df2088dc c0b67
398 c03e1b44
[ 65.929260] 1f80: de213e5c c0132600 de330000 de08e800 c01324d4 00000000 00000
000 00000000
[ 65.937370] 1fa0: 00000000 00000000 00000000 c01078c8 00000000 00000000 00000
000 00000000
[ 65.945480] 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000
000 00000000
[ 65.953590] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000
000 00000000
[ 65.961708] [<c03871d0>] (clk_core_enable) from [<c038723c>] (clk_core_enable
_lock+0x18/0x2c)
[ 65.970168] [<c038723c>] (clk_core_enable_lock) from [<c03f5f84>] (mtk_wcn_co
nsys_hw_reg_ctrl+0x144/0x2dc)
[ 65.979745] [<c03f5f84>] (mtk_wcn_consys_hw_reg_ctrl) from [<c03f6160>] (mtk_
wcn_consys_hw_pwr_on+0x10/0x20)
[ 65.989494] [<c03f6160>] (mtk_wcn_consys_hw_pwr_on) from [<c03d9668>] (wmt_co
re_ctrl+0x3c/0xb4)
[ 65.998122] [<c03d9668>] (wmt_core_ctrl) from [<c03db52c>] (opfunc_pwr_on+0xa
4/0x1ec)
[ 66.005889] [<c03db52c>] (opfunc_pwr_on) from [<c03db774>] (opfunc_func_on+0x
100/0x32c)
[ 66.013829] [<c03db774>] (opfunc_func_on) from [<c03e1ca0>] (wmtd_thread+0x15
c/0x228)
[ 66.021597] [<c03e1ca0>] (wmtd_thread) from [<c0132600>] (kthread+0x12c/0x138
)
[ 66.028762] [<c0132600>] (kthread) from [<c01078c8>] (ret_from_fork+0x14/0x2c
)
[ 66.035926] Code: ebfffff0 e2505000 1a000013 e5943004 (e5933010)
[ 66.041973] ---[ end trace bc79767b5634c2fd ]---
[ 66.046548] Kernel panic - not syncing: Fatal exception
[ 66.051735] CPU1: stopping
[ 66.054424] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G D W 4.14.131
#0
[ 66.061669] Hardware name: Mediatek Cortex-A7 (Device Tree)
[ 66.067203] [<c010e99c>] (unwind_backtrace) from [<c010aa78>] (show_stack+0x1
0/0x14)
[ 66.074886] [<c010aa78>] (show_stack) from [<c06eb31c>] (dump_stack+0x78/0x8c
)
[ 66.082049] [<c06eb31c>] (dump_stack) from [<c010d998>] (handle_IPI+0xf4/0x1a
c)
[ 66.089299] [<c010d998>] (handle_IPI) from [<c0101470>] (gic_handle_irq+0x8c/
0x90)
[ 66.096806] [<c0101470>] (gic_handle_irq) from [<c010b64c>] (__irq_svc+0x6c/0
xa8)
[ 66.104224] Exception stack(0xdf06df88 to 0xdf06dfd0)
[ 66.109232] df80: 00000001 c08fb314 1ed81000 c0113be0 ffffe
000 c0b03c74
[ 66.117342] dfa0: c0b03c28 c0b32690 8000406a 410fc073 00000000 00000000 00002
54a df06dfd8
[ 66.125450] dfc0: c01081a8 c01081ac 60000013 ffffffff
[ 66.130461] [<c010b64c>] (__irq_svc) from [<c01081ac>] (arch_cpu_idle+0x34/0x
38)
[ 66.137799] [<c01081ac>] (arch_cpu_idle) from [<c014ac80>] (do_idle+0xa8/0x11
c)
[ 66.145049] [<c014ac80>] (do_idle) from [<c014af78>] (cpu_startup_entry+0x18/
0x1c)
[ 66.152557] [<c014af78>] (cpu_startup_entry) from [<8010176c>] (0x8010176c)
[ 66.159460] CPU3: stopping
[ 66.162142] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G D W 4.14.131
#0
[ 66.169387] Hardware name: Mediatek Cortex-A7 (Device Tree)
[ 66.174917] [<c010e99c>] (unwind_backtrace) from [<c010aa78>] (show_stack+0x1
0/0x14)
[ 66.182598] [<c010aa78>] (show_stack) from [<c06eb31c>] (dump_stack+0x78/0x8c
)
[ 66.189760] [<c06eb31c>] (dump_stack) from [<c010d998>] (handle_IPI+0xf4/0x1a
c)
[ 66.197009] [<c010d998>] (handle_IPI) from [<c0101470>] (gic_handle_irq+0x8c/
0x90)
[ 66.204515] [<c0101470>] (gic_handle_irq) from [<c010b64c>] (__irq_svc+0x6c/0
xa8)
[ 66.211932] Exception stack(0xdf071f88 to 0xdf071fd0)
[ 66.216940] 1f80: 00000003 c08fb314 1eda1000 c0113be0 ffffe
000 c0b03c74
[ 66.225050] 1fa0: c0b03c28 c0b32690 8000406a 410fc073 00000000 00000000 00002
54c df071fd8
[ 66.233158] 1fc0: c01081a8 c01081ac 60000013 ffffffff
[ 66.238168] [<c010b64c>] (__irq_svc) from [<c01081ac>] (arch_cpu_idle+0x34/0x
38)
[ 66.245504] [<c01081ac>] (arch_cpu_idle) from [<c014ac80>] (do_idle+0xa8/0x11
c)
[ 66.252754] [<c014ac80>] (do_idle) from [<c014af78>] (cpu_startup_entry+0x18/
0x1c)
[ 66.260261] [<c014af78>] (cpu_startup_entry) from [<8010176c>] (0x8010176c)
[ 66.994343] SMP: failed to stop secondary CPUs
[ 66.998750] Rebooting in 3 seconds..
[ 70.944661] SMP: failed to stop secondary CPUs
This seems a dts problem to me but I don’t see anything wrong in by dts.
This is my mt7623.dtsi.
Basically the only differences from the ones in your 4.14 kernel branch are the hdmi and screen related parts which I removed because in openwrt are not needed.
In the log the driver cannot get consys reset and pinctrl default but both are present i my dts.
I am stcuck. My kernerl .config file seems to me similar to yours in wifi relevant parts.
Thanks in advance for your help
Yes, My bad signal issue was due to missing antenna. I will perform a speed test to see the throughput. I have still a nasty issue with wifi but this is somehow caused by openwrt… After running wifi.sh that starts hostapd putting ap0 in the lan bridge, the bridge starts working fully only after some minutes. In the first minutes I can connect to the wifi but I can only receive packets from the bpi-r2 and not from the rest of the network.
I will try to solve this issue, port my changes to the 18.06.5 (I ported them to the 18.06.4 now) and post my GitHub repository for anyone that needs it. Apart from the wifi, openwrt seems to be really stable and fast.
Why not? If it has to work as access point, shouldn’t it be bidged with the 4 lan ports? Is there some sort of driver limitation?
Thank you and sorry if this is a stupid question.
Using sub-network and routing works. The problem is that if I try to perform a speed test (for example the one found at the url https://fast.com/) the wifi hangs instantly and starts to work again only if I re-invoke the initialization script (wifi.sh). No message shown on dmesg. Have you ever eperienced a similar problem?
I experienced hangs like this sometimes,but no idea how to debug. You can try enabling the tc commands you find in recent versions of wifi.sh on my kernel repo or in official wiki