Gpio + uart (not the debug-port)

Here you find my compiled kernels:

https://drive.google.com/drive/folders/15Y5Y3NAOwg_IMmN3k6hdb7pAQj9oTVTl?usp=sharing

You’ll find that link also on startpage of my wiki. The archive-file contains folders boot and root,which contents have to be copied to the partitions bpi-root/bpi-boot of sd-card.

Currently i have no emmc-image,i’m building currently a clean debian on my emmc. Install on emmc is a bit more tricky because of the partition-change and burning preloader to boot-device

1 Like

Thanks for your help. I have tried to replace boot and root (lib folder) files but received kernel panic on boot. I will try more but wanted to confirm: Files in lib folder should be replaced or merged?

Files I used:

4.4.112-BPI-R2-Kernel-BPI-BOOT-bpi-r2.tgz

4.4.112-BPI-R2-Kernel.tgz

Image: 2017-09-13-debian-9-stretch-mate-desktop-preview-bpi-r2-sd-emmc.img.zip

Thank you,

I think I’ve made it working (I will try tomorrow with real UART to USB converter when I receive my level shifter). Thanks a lot. Do you think Its possible to write everything from SD to EMMC? Or it will work only from SD?

root@bpi-iot-ros-ai:/home/pi# stty -F /dev/ttyS2 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
root@bpi-iot-ros-ai:/home/pi# stty -F /dev/ttyS1 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl -echoke -flusho -extproc
root@bpi-iot-ros-ai:/home/pi#    

Thank you,

Basicly an OS on sd will also work on emmc. You can copy image also via dd to emmc,but you have do some extra steps.

  • First change partition-config in uboot to “48”
  • enable write-access to boot0
  • flash preloader to boot0

Now you have to modify uEnv.txt (config for uboot) on boot-partition and fstab to mount the right root-partition.

You’ll find the most steps in my wiki

http://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r2/storage

I created my sd/emmc with debootstrap: http://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r2/debian

1 Like

I will try to do like this and share my results. Thanks

copy kernel (p1) and modules (p2, if you not want to copy full rootfs from SD card)
mkdir -p /mnt/emmc/boot/bananapi/bpi-r2/linux
cp /boot/bananapi/bpi-r2/linux/uImage /mnt/emmc/boot/bananapi/bpi-r2/linux
mkdir -p /mnt/emmc/root/lib/modules/
cp -r /lib/modules/$(uname -r) /mnt/emmc/root/lib/modules/
uboot auf die richtige Partition konfigurieren
sed 's/mmcblk0/mmcblk1/' /boot/bananapi/bpi-r2/linux/uEnv.txt > /mnt/emmc/boot/bananapi/bpi-r2/linux/uEnv.txt

I have manually copied uImage and kernel to eemc on my already preinstalled debian9 and its working fine. Now its booting from emmc using your kernel. Thank a lot Frank, you are the best :slight_smile:

Do you happen to know if I can move rootfs to SATA hdd using your kernel? I read somewhere that it should be custom kernel so sata will be available on boot.

Thank you,

you can only copy rootfs to hdd/ssd (boot-partition must be on emmc/SD)

you just need to change uenv.txt (on sd/emmc) to point to you hdd/ssd-partition (root=/dev/sdax) and change /etc/fstab in your rootfs so that the right / is mounted

but now it’s leaving the topic…please make a new topic if you have more questions

You are right. Thanks for your help and wiki you created (it helped a lot), hope this discussion will be valuable for other people as well.

Thank you,

@frank-w May I know how many UARTs are available in BPI-R2. I would like to use 3 UARTs.

TIA.

Uart 0 and 1 are on 40pin-header,uart2 is the debug-uart (maybe can used in another way) and uart3 are only 2 dots on circuitboard near debug-pins

@garywang: i have some 4 solder-pods next to debug-uarts rx-pin…are these connected to the TPxx-pins of uart3?

Thanks for the quick response. Can we use UART 3 on GPIO?. I dont think the 2 dots of near by debug-pins can soldered.

Also like to know if there is any way to disable the debug-UART and can be used for our purpose.

TIA.

imho you can use debug-pins as normal uart, you have to disable the debug-block in dts:

aliases {
	serial2 = &uart2;
};

chosen {
	stdout-path = "serial2:115200n8";
};

@frank-w Till now I am testing with UART0 & UART1 with ttyS1 & ttyS2. I am using RS485/ModbusRTU on these serial ports. However, I am facing some issues while communicating Modbus slave devices over ttyS1 & ttyS2. I can see that these ports also used by login consoles and hence the RS485 modbus failed to communicate devices correctly over modbus prototcol. Is there anyway I can assign some other ports instead of these ttyS1 & ttyS2 for UART0/1?.

TIA.

have you tried to set the serialmode (e.g. raw)? i had also issues because the mode was not set correctly by default

http://wiki.fw-web.de/doku.php?id=en/bpi-r2/gpio#port_preferences