I'm trying to use piCore 11 on a RaspberryPi 3B+ Rev1.3. I've downloaded the piCore-11.0.img and followed the instructions in
this README to write the image to SD, resize the second partition, and store the ssh-keys generated on first boot.
Now, to get a connection via ethernet, there's two options:
1. Setting a static IP with a script
2. Getting a dynamic IP via DHCP
The problem is that I can make neither of those work automatically. This RPi will be sitting at home, so a static IP is fine, but I will turn it off and on often, so I don't want to type in commands on every boot. Here's what I tried (all code blocks are commands executed directly after boot):
1. Setting a static IP with a scriptOn my main machine, I ran arp-scan --local-network to find a free IP address, ifconfig to determine that the netmask is 255.255.255.0 and route followed by ns-lookup fritz.box to determine that the default gateway's IP is 192.168.178.1.
So, to get a static IP, all I should have to do is:
$ sudo ifconfig eth0 192.168.178.61
$ sudo route add default gw 192.168.178.1
And I did, and the subsequent outputs of ifconfig and route look good, see attached "static_notworking.txt", but ping 8.8.8.8 or a ping to the gateway or my main machine just stays silent and reports 100% packet loss when I Ctrl+C it.
2. Getting a dynamic IP via DHCPFor DHCP to work, the RPi needs to have the correct time. I found that out the hard way. Trying to make udhcpc do its thing without the correct time has no effect:
$ sudo pkill dhcp
$ sudo udhcpc -i eth0 -x hostname:box
udhcpc: started, v1.28.4
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending discover
...
But, this will actually give me a working ethernet connection:
$ export TZ=CEST+2
$ sudo date -s "2020-10-15 19:37:16"
$ sudo ifconfig eth0 down
# Unplug ethernet cable, then plug it back in
$ sudo ifconfig eth0 up
# Wait for a few seconds
Now, everything is working perfectly. /etc/resolv.conf got populated, I can ping URLs, external and internal IPs, ssh into the RPi, everything I want. This also is the nicer solution, because it allows me to easily move the setup and not do any additional setup.
But, this always requires me manually typing in the correct time. I know that this is somewhat due to the RPi not having an RTC, but Raspbian somehow manages to handle this, as my other pi with Raspbian on it can easily be shutdown for days and still connect to the network automatically.
I know that NTP allows to get the time from an external source, but of course DHCP would have to already have obtained a lease for that to work. It seems like
DHCP can actually supply time as well via options 004 and 042, but I guess udhcpc is not querying those or they do something else?
What do?So, I really don't know where to go from here. Should I just get an RTC module for the RPi and be done with it? Or is there some solution to this problem?