Banana Pi BPI-R2 OPENWRT 19.07 Image

Strange,that your makefile points to 4.14

By default 5.4 is used. But if you want to keep 4.14,change trgmii to rgmii in the bpi-r2.dts (i hope i do not get overridden). Normally trgmii on gmac0 and rgmii on gmac1 is right,but driver in 4.14 is buggy and does not setup trgmii right so change to rgmii

If you see dsa-ports like wan and lanX you have switch-driver included.

put my repo in trash and clone new…

May be I have done “git checkout” instead of “git clone” some months ago.

Now I have kernel 5.4 and old problem: generated image not bootable, hangs on

[BLDR] jump to 0x81E00000
[BLDR] <0x81E00000>=0xEA0000B8
[BLDR] <0x81E00004>=0xE59FF014

I used build_dir/target…/tmp/openwrt-…img.gz, unzipped it and wrote to /dev/sdb

I’m not deep in openwrts build process,but afair this comes up if uboot is missing/not bootable

Found it: Bug in ./target/linux/mediatek/image/gen_mtk_mmc_img.sh, line 123/124:

> echo -en "${SDMMC_BOOT}" | dd bs=1 of="${OUTPUT}" seek=0   conv=notrunc`
> echo -en "${BRLYT}"      | dd bs=1 of="${OUTPUT}" seek=512 conv=notrunc`

writes the boot code as ASCII into the image file, including a leading “-en”. As I see, the option -en has no effect, because also the trailing 0x0a is written to $output.

I used okteta to convert it into binary code and voila, the image starts from sd.

BTW: Box is online, including eth0

1 Like

Thank you for the Update

@dwmw2 as author of the script can you please check/fix this? for me it looks right

echo -e should convert \xXX to the byte with hexvalue XX (-n for no newline at the end)

you see only eth0? you should see wan/lanX and need assign ip to these dsa-interfaces (not to eth0)

i tried with this simple script:

 1 #!/bin/bash
 2
 3 OUTPUT=test.img
 4
 5 dd if=/dev/zero of=${OUTPUT} bs=1M count=2;
 6
 7 SDMMC_BOOT="SDMMC_BOOT\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00"
 8 EMMC_BOOT="EMMC_BOOT\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00"
 9 BRLYT="BRLYT\x00\x00\x00\x01\x00\x00\x00\x00\x08\x00\x00\
10 \x00\x08\x00\x00\x42\x42\x42\x42\x08\x00\x01\x00\x00\x08\x00\x00\
11 \x00\x08\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
12
13
14 echo -en "${SDMMC_BOOT}" | dd bs=1 of="${OUTPUT}" seek=0   conv=notrunc
15 echo -en "${BRLYT}"      | dd bs=1 of="${OUTPUT}" seek=512 conv=notrunc
16

which results as it should:

00000000  53 44 4d 4d 43 5f 42 4f  4f 54 00 00 01 00 00 00  |SDMMC_BOOT......|
00000010  00 02 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200  42 52 4c 59 54 00 00 00  01 00 00 00 00 08 00 00  |BRLYT...........|
00000210  00 08 00 00 42 42 42 42  08 00 01 00 00 08 00 00  |....BBBB........|
00000220  00 08 00 00 01 00 00 00  00 00 00 00 00 00 00 00  |................|
00000230  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00200000

Box is fully working including all interfaces (lan, wan and wan6). Openvpn is stopped. No further investigation ATM. Probably thursday.

Because I have altered the script for debugging purposed, I copied the original from github. Same results, the string on 0:0 begins with “-en SDMMC_BOOT\x00\x00\x01” and so on, any null bytes. I´m running ubuntu 20.04.1 on my system, if that matters. I also created test.sh like frank-w and get the correct results on my build system.

I guess script is not executed in local bash…more in own buildchain where echo does not support flags -en

Btw. For everyone seeing retransmitts with kernel 5.4+: i posted patch for adding pause statement in bpi-r2 dts for switchport 6

https://patchwork.kernel.org/patch/11760003/

may it help to set /bin/echo in script?

i don’t know…maybe it runs in chroot or similar…

Thanks for your work. For newbies: how to add this patch in openwrt buildroot? Brute force: patching mt7623n-bananapi-bpi-r2.dts?

If my wife let me hack today, I will report. Tolerance level is low after weekend :slight_smile:

Change the shebang at the top of the script to #!/bin/bash instead of the current #!/bin/sh.

I’ll work out a better way to do this and fix it upstream without requiring bash, if I can…

Will test it and report here.

Short: works

openwrt is a bit tricky with applying patches…you can try to put it in the patches-5.4 folder…if that leads to a build.error you have to include it the normal way:

https://openwrt.org/docs/guide-developer/build-system/use-patches-with-buildsystem

btw. i don’t know if shell (you can show it by adding “type /bin/sh” in script) executing the script is the problem…it is only a thought…maybe changing shebang works, maybe not :wink: if script is running inside chroot it is possible that it also does not work if echo is build without the -e support. on my ubuntu 20.4 system i see this:

$ which echo
/usr/bin/echo
$ LANG=C type echo
echo is a shell builtin

so maybe using /usr/bin/echo helps

wonder why ubuntu uses dash :slight_smile:

 $ which sh
/usr/bin/sh
$ ls -l /usr/bin/sh
lrwxrwxrwx 1 root root 4 Apr 27 13:01 /usr/bin/sh -> dash

i thought it was bash :stuck_out_tongue: but users having bash by default…

$ grep frank /etc/passwd
frank:x:1000:1000:Frank Wunderlich,,,:/home/frank:/bin/bash

Thanks for your work. For newbies: how to add this patch in openwrt buildroot? Brute force: patching mt7623n-bananapi-bpi-r2.dts?

Post an appropriate patch (adding the patch file to openwrt.git) it to [email protected] or bring it to my attention to do so. Does it want to go in to 19.07 too?

https://patchwork.ozlabs.org/project/openwrt/patch/[email protected]/

Thanks for testing.

https://patchwork.ozlabs.org/project/openwrt/patch/[email protected]/

Maybe printf is an option https://unix.stackexchange.com/a/289760