Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

SSH for communication with the board

Regenerating the SD card image and reflashing the entire SD card every time we want to change our application is not going to be very efficient during the application development/debugging. So instead, we’ll set up networking communication with the board, and use SSH to transfer files. This will also be useful for Qt Creator, as it uses SFTP to deploy files to the target.

Let’s start by enabling a small SSH client/server, called Dropbear. Go in Buildroot menuconfig, and enable the BR2_PACKAGE_DROPBEAR option (in Target packages, Networking applications, dropbear). While Dropbear provides SSH access, it does not support SFTP which will be needed by Qt Creator, so we’ll also enable an SFTP server, gesftpserver. So, we’ll enable BR2_PACKAGE_GESFTPSERVER as well (in Target packages, Networking applications, gesftpserver).

Then, in order to log in through SSH as root, we must have a non-empty root password, so set BR2_TARGET_GENERIC_ROOT_PASSWD (in System configuration, Root password) to a value you like.


You can now exit menuconfig, as we have enabled all features we needed. Before restarting the build, we need to do one last thing: set up a network configuration file so that our STM32MP15 system configures an IP address. To do this, we’ll create a /etc/network/interfaces file, and add it to the root filesystem using the root filesystem overlay mechanism, which was presented in the first post of this series. So, in your Buildroot sources, just create a file board/stmicroelectronics/stm32mp157c-dk/overlay/etc/network/interfaces, with the following contents:


Codeblock
languagetext
titleinterfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp


Caution: Directories etc and network could be missing in overlay directory.

<Under the Hood>

The above interfaces file configures the first ethernet device eth0 for automatic IP configuration (as opposed to a static one), were the client request an IP address
via the DHCP protocol from a DHCP server. In our case the DHCP (and DNS) server for the internal CE network is cluster1.f1.htw-berlin.de. The ISC dhcp server
running on cluster1 is configured to map ethernet addresses of the STMMP1 boards to fixed IP addresses in the internal network and should also provide
a host name (we're running in the STNG name space) which will be resolved by the DNS server also running on cluster1. 

Codeblock
languagetext
  #
  # STM32MP1 Boards
  #

  host picard  { hardware ethernet 00:80:e1:42:69:05; fixed-address 172.16.3.130; option host-name "picard"; }
  host riker   { hardware ethernet 00:80:e1:42:65:26; fixed-address 172.16.3.131; option host-name "riker"; }
  host troi    { hardware ethernet 00:80:e1:42:6c:1f; fixed-address 172.16.3.132; option host-name "troi"; }
  host crusher { hardware ethernet 00:80:e1:42:6c:3f; fixed-address 172.16.3.133; option host-name "crusher"; }
  host laforge { hardware ethernet 00:80:e1:42:6a:c4; fixed-address 172.16.3.134; option host-name "laforge"; }
  host worf    { hardware ethernet 00:80:e1:42:65:25; fixed-address 172.16.3.135; option host-name "worf"; }
  host guinan  { hardware ethernet 00:80:e1:42:6e:94; fixed-address 172.16.3.136; option host-name "guinan"; }
  host yar     { hardware ethernet 00:80:e1:42:65:29; fixed-address 172.16.3.137; option host-name "yar"; }
  host barclay { hardware ethernet 00:80:e1:42:68:7f; fixed-address 172.16.3.138; option host-name "barclay"; }
  host data    { hardware ethernet 00:80:e1:42:6a:cd; fixed-address 172.16.3.139; option host-name "data"; }

</Under the Hood>


Then, run make in Buildroot, reflash your SD card, and boot your system.

...

<Make Troubleshooting>

Starting dropbear sshd: OK

You can also run ip addr show dev eth0 to check the IP address of the eth0interface:

Troubleshooting

If make fails with the following error:

Codeblock
languagetext
***
*** ERROR: package host-mkpasswd installs executables without proper RPATH:
***   /local/gosper/lab4-new/buildroot/output/host/bin/fincore
***   /local/gosper/lab4-new/buildroot/output/host/bin/lsblk
***   /local/gosper/lab4-new/buildroot/output/host/bin/prlimit
***   /local/gosper/lab4-new/buildroot/output/host/bin/umount
***   /local/gosper/lab4-new/buildroot/output/host/bin/uuidparse
***   /local/gosper/lab4-new/buildroot/output/host/bin/genimage
***   /local/gosper/lab4-new/buildroot/output/host/bin/eject
***   /local/gosper/lab4-new/buildroot/output/host/bin/setfacl
***   /local/gosper/lab4-new/buildroot/output/host/bin/getfacl
***   /local/gosper/lab4-new/buildroot/output/host/bin/findmnt
***   /local/gosper/lab4-new/buildroot/output/host/bin/lsmem
***   /local/gosper/lab4-new/buildroot/output/host/bin/column
***   /local/gosper/lab4-new/buildroot/output/host/bin/chacl
***   /local/gosper/lab4-new/buildroot/output/host/bin/lscpu
***   /local/gosper/lab4-new/buildroot/output/host/bin/mount
***   /local/gosper/lab4-new/buildroot/output/host/bin/uuidgen
***   /local/gosper/lab4-new/buildroot/output/host/bin/pkgconf
***   /local/gosper/lab4-new/buildroot/output/host/bin/lsattr
***   /local/gosper/lab4-new/buildroot/output/host/bin/chattr
***   /local/gosper/lab4-new/buildroot/output/host/bin/mountpoint
***   /local/gosper/lab4-new/buildroot/output/host/bin/lsipc
***   /local/gosper/lab4-new/buildroot/output/host/bin/lslocks
***   /local/gosper/lab4-new/buildroot/output/host/bin/lsns
***   /local/gosper/lab4-new/buildroot/output/host/bin/attr
***   /local/gosper/lab4-new/buildroot/output/host/sbin/e4crypt
***   /local/gosper/lab4-new/buildroot/output/host/sbin/fstrim
***   /local/gosper/lab4-new/buildroot/output/host/sbin/sfdisk
***   /local/gosper/lab4-new/buildroot/output/host/sbin/tune2fs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/fsck.cramfs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/e2freefrag
***   /local/gosper/lab4-new/buildroot/output/host/sbin/fsck
***   /local/gosper/lab4-new/buildroot/output/host/sbin/partx
***   /local/gosper/lab4-new/buildroot/output/host/sbin/e2undo
***   /local/gosper/lab4-new/buildroot/output/host/sbin/mke2fs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/e2image
***   /local/gosper/lab4-new/buildroot/output/host/sbin/wipefs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/dumpe2fs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/resize2fs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/e2fsck
***   /local/gosper/lab4-new/buildroot/output/host/sbin/losetup
***   /local/gosper/lab4-new/buildroot/output/host/sbin/mkswap
***   /local/gosper/lab4-new/buildroot/output/host/sbin/debugfs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/swaplabel
***   /local/gosper/lab4-new/buildroot/output/host/sbin/fdisk
***   /local/gosper/lab4-new/buildroot/output/host/sbin/badblocks
***   /local/gosper/lab4-new/buildroot/output/host/sbin/findfs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/mkfs.cramfs
***   /local/gosper/lab4-new/buildroot/output/host/sbin/blkid
***   /local/gosper/lab4-new/buildroot/output/host/sbin/swapon
***   /local/gosper/lab4-new/buildroot/output/host/sbin/swapoff
make: *** [package/pkg-generic.mk:282: /local/gosper/lab4-new/buildroot/output/build/host-mkpasswd/.stamp_host_installed] Error 1

run 

Codeblock
languagetext
make clean world
make

</Make Troubleshooting>

At boot time, you should see:

Codeblock
languagetext
Starting network: [    2.713310] hub 1-1:1.0: USB hub found
[    2.720607] hub 1-1:1.0: 4 ports detected
[    2.752224] stm32-dwmac 5800a000.ethernet eth0: PHY [stmmac-0:00] driver [Generic PHY] (irq=POLL)
[    2.767093] stm32-dwmac 5800a000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
[    2.781368] dwmac4: Master AXI performs any burst length
[    2.788880] stm32-dwmac 5800a000.ethernet eth0: No Safety Features support found
[    2.802204] stm32-dwmac 5800a000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[    2.816753] stm32-dwmac 5800a000.ethernet eth0: registered PTP clock
[    2.829637] stm32-dwmac 5800a000.ethernet eth0: configuring for phy/rgmii-id link mode
udhcpc: started, v1.31.1
udhcpc: sending discover
[    4.953668] stm32-dwmac 5800a000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[    4.968295] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
udhcpc: sending discover
udhcpc: sending select for 172.16.2.100
udhcpc: lease of 172.16.2.100 obtained, lease time 43200
deleting routers
adding dns 141.45.3.100
OK
Starting dropbear sshd: OK
Welcome to Buildroot
buildroot login: 


You can also run ip addr show dev eth0 to check the IP address of the eth0 interface:

Codeblock
languagetext
Welcome to Buildroot
buildroot login: root
Password: 
# ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
    link/ether 00:80:e1:42:69:0c brd ff:ff:ff:ff:ff:ff
    inet 172.16.2.100/16 brd 172.16.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::280:e1ff:fe42:690c/64 scope link 
       valid_lft forever preferred_lft forever
# 


We can now ping our target:

Codeblock
languagebash
gosper@hal9000:~$ ping 172.16.2.100
PING 172.16.2.100 (172.16.2.100) 56(84) bytes of data.
64 bytes from 172.16.2.100: icmp_seq=1 ttl=64 time=0.448 ms
64 bytes from 172.16.2.100: icmp_seq=2 ttl=64 time=0.451 ms
64 bytes from 172.16.2.100: icmp_seq=3 ttl=64 time=0.527 ms
64 bytes from 172.16.2.100: icmp_seq=4 ttl=64 time=0.375 ms
64 bytes from 172.16.2.100: icmp_seq=5 ttl=64 time=0.430 ms
^C
--- 172.16.2.100 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 98ms
rtt min/avg/max/mdev = 0.375/0.446/0.527/0.050 ms
gosper@hal9000:~$ 


Log-in over SSH (be patient - this make take a few seconds):


Codeblock
languagebash
gosper@hal9000:~$ ssh root@172.16.2.100
root@172.16.2.100's password: 
# w
USER		TTY		IDLE	TIME		 HOST
root            console         00:01   Jan  1 00:01:51  
root            pts/0           00:00   Jan  1 00:16:20  172.16.0.1
# 


And verify that SFTP is working:

Codeblock
languagebash
gosper@hal9000:~$ sftp root@172.16.2.100
root@172.16.2.100's password: 
Connected to root@172.16.2.100.
sftp> ls /
/bin         /boot        /dev         /etc         /lib         /lib32       /linuxrc     /lost+found  /media       
/mnt         /opt         /proc        /root        /run         /sbin        /sys         /tmp         /uboot.env   
/usr         /var         
sftp> 


So, now we can make a change to our Qt5 application, for example changing the label of the button, recompile by running make in the application directory, and directly copy the application using scp, and run it over ssh:


Codeblock
languagebash
$ make
[...]
$ scp qt-sensor-demo root@172.16.2.100:/usr/bin/
root@172.16.2.100's password: 
qt-sensor-demo                                    100%   12KB 634.7KB/s   00:00
$ ssh root@172.16.2.100
root@172.16.2.100's password: 
# qt-sensor-demo -platform linuxfb

Much nicer, we don’t have to reflash our SD card every time we want to test a change in our application!

Note that we could create a public/private key pair, with the public key on our target, and this way not have to enter our password every time we want to transfer a file or log-in to the target. Since this blog post is already very long, we’ll live that as an exercise for the reader, there are plenty of resources on the Web about this topic.