0

I'm trying to get a flashing station up and running on a Raspberry Pi using Raspbian Jessie (latest stable release, Kernel Version 4.4).

However, I want to make use of the four USB ports, and to do so, I'll be using Ethernet over USB (since u-boot uses Ethernet to check the tftp server).

Pre-requisites and configuration

Here is the things I installed on the Raspberry Pi :

  • isc-dhcp-server
  • xinetd

I configured several files :

/etc/dhcp/dhcpd.conf

log-facility local7;
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;

subnet 192.168.2.0 netmask 255.255.255.0
{
  range dynamic-bootp 192.168.2.2 192.168.2.100;
  if substring (option vendor-class-identifier, 0, 10) = "AM335x ROM"
  {
    filename "u-boot-spl-restore.bin";
  }
  elsif substring (option vendor-class-identifier, 0, 17) = "AM335x U-Boot SPL"
  {
    filename "u-boot-restore.img";
  }
  else
  {
    filename "zImage";
  }

  range 192.168.2.101 192.168.2.199;
}

The four first lines being there by default.

/etc/xinetd.d/tftp

service tftp
{
  socket_type = dgram
  protocol = udp
  wait = yes
  user = root
  server = /usr/sbin/in.tftpd
  server_args = -s /tftpboot
  disable = no
}

This file didn't exist, so I had to create it. It's included like other services by /etc/xinetd.conf.

/tftpboot/

Created this folder, executed these commands on it :

  • sudo cp /path/to/boot/files/* /tftpboot/
  • sudo chmod -R 777 /tftpboot/
  • sudo chown -R nobody:nogroup /tftpboot

/etc/default/isc-dhcp-server

Added usb0 to the list of interfaces :

INTERFACES="usb0"

/etc/network/interfaces

Created an interface for usb0 :

allow-hotplug usb0
iface usb0 inet static
    address 192.168.2.1
    network 192.168.2.0
    netmask 255.255.255.0
    broadcast 192.168.2.255
    up /etc/network/if-up.d/usb-interfaces

/etc/network/if-up.d/usb-interfaces

Created the following script, referenced by /etc/network/interfaces :

#!/bin/sh

if [ "$IFACE" = usb0 ]; then
    sudo service isc-dhcp-server restart
fi

Restart all the services!

sudo /etc/init.d/tftp-hpa restart
sudo /etc/init.d/xinetd restart

Tests and results

Let's call the Raspberry Pi the host and the linux I want to flash the target.

So, for this, I had all the logs on the host, and had a serial console on the target (which means that I can access the boot logs from the kernel).

What happens basically :

  • From the target's PoV : nothing in particular displays on the serial log. It just blocks for a bit then boots, normally.
  • From the host's PoV : here is the complete log. It stops after the usb0 interface disappears, when the Linux system starts booting. As you can see, there is a BOOTREQUEST followed immediately by a BOOTREPLY. At this point, the target knows the name of the file it must get from the tftp server (specified in the /etc/dhcp/dhcpd.conf file), so a tftp request should follow... But nothing happens.

I've tested the tftp server running on the Raspberry Pi both from the target and from my computer, and in both cases, I can get the files correctly. I also tried with different files, and was able to confirm that the files used (inside of my /tftpboot/ folder) are correct and functional.

What I thought about and tested :

  • The power supplied by the Raspberry Pi's USB ports isn't enough. Tested through a USB 2.0 independently-powered hub, results were exactly the same.

Any help would be greatly appreciated.

  • Please provide a complete log from the target console as well, thanks! – Tom Rini Feb 13 '17 at 13:38
  • @TomRini, Here is the log. As you can see, it boots from the NAND, doesn't do anything with TFTP. – Nepho Feb 13 '17 at 14:33
  • yes, with the log it's clear that it's not even trying network, and I assume that this means you didn't change anything in the U-Boot environment in order to have it try and use network? I don't see anything in the above post indicating as such and there's lots of general information on how to network boot in U-Boot elsewhere. – Tom Rini Feb 13 '17 at 22:39
  • @TomRini, the U-boot from the target is correctly configured to try a network boot when possible. We actually got it to work by changing exactly the same files and using the same applications on a Ubuntu 12. But this issue is still open since we'd really like to get it to run on the rasp pi. – Nepho Feb 14 '17 at 7:19
  • your U-Boot log is showing that it's not trying to do any sort of network commands at all. You're implying via the dhcp fragment that both SPL and U-Boot self are loading via network and your host log shows that only. In fact, what is confusing here now is that 'usb0' (per your syslog) is not a USB-Ethernet adapter, but the am335x bringing up a USB Gadget interface as ethernet to your RPi. – Tom Rini Feb 14 '17 at 15:05
1

Turns out that the issue was that there were several TFTP servers running on my system, and I wasn't configuring the correct one.

To anyone with this issue, I suggest running a command similar to ps ax | grep tftp. It will often also tell you which directory is used as the root for the TFTP server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.