Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final FMUv5X Netman using the NuttX network monitor and a single rejected App commit. #16330

Merged
merged 5 commits into from Jan 31, 2021

Conversation

davids5
Copy link
Member

@davids5 davids5 commented Dec 3, 2020

Now that the NuttX upgrade and the mtd work are on master, this is the final Netman

The netman system command will display, set and save the network
settings.

netman show - Displays the current settings.

netman update - Will check for a net.cfg file on the SD card.
If present, it will update the paramaters,
delete the file, and reboot. Using the new settings.

netman save - Saves the current settings to net.cfg on the SD card.
This file shoulf be renamed to preserver it across
reboots or editited to chech networkin paramates.

File format is namevalue:

echo DEVICE=eth0 > /fs/microsd/net.cfg
echo BOOTPROTO=fallback >> /fs/microsd/net.cfg
echo IPADDR=192.168.0.4 >> /fs/microsd/net.cfg
echo NETMASK=255.255.255.0 >>/fs/microsd/net.cfg
echo ROUTER=192.168.0.254 >>/fs/microsd/net.cfg
echo DNS=192.168.0.254 >>/fs/microsd/net.cfg

Valid values for proto are dhcp, static, falback
Both will try dhcp for CONFIG_NETINIT_FALLBACK times
and fall back to the static address.

NETMASK - is the network mask.
IPADDR - this nodes ip address for static or fall back.
ROUTER - The default route.
DNS - The address of the dns server.

Background
5 Networking configuration deficits exist in NuttX

NuttX only supported compile time DHCP or STATIC IP addressing.
The static setting are not human readable ip format.
If DHCP was chosen the lease would not be renewed.
If the connected network was powered on after the nuttx node (FMU) booted, the netinit would time out and not bring up the network.
The ability to signal PHY state changes to use the Nuttx Net Monitor was dependent on an IRQ line from the PHY to the CPU.
The nuttx backports fix 4. The Apps rejected backport fixes 1,2,3

The Upstream ipcfg non binary solution is dependent on a writable FS. It has no way to default it's setting. The pathing is rather deep to follow in a Linux like way.

There are some issue with this approach on an FMU.
We can not use this on system without a SD card or EMMC FS.
Networking will not work if the SD card is not inserted.

Greg did a great job in adding a binary solution as well. But we either need to
a) repartition the FRAM
b) Uses a eeprom
c) Write a character driver the to read/write the date in the param system.

All of theses choices have consequences we should discuss.

The network Netman add a way to default the setting, Change the setting and ensure an atomic update.

@davids5
Copy link
Member Author

davids5 commented Dec 3, 2020

fyi @TSC21

@TSC21
Copy link
Member

TSC21 commented Dec 4, 2020

Awesome stuff!

@mrpollo
Copy link
Contributor

mrpollo commented Dec 9, 2020

@hamishwillee we might want to document this!

src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
src/systemcmds/netman/netman.cpp Outdated Show resolved Hide resolved
davids5 and others added 5 commits December 15, 2020 06:47
px4_fmu-v5x:Use Bin Net settigns
   This system command will display, set and save the network
   settings.

   netman show   - Displays the current settings.

   netman update - Will check for a net.cfg file on the SD card.
                   If present, it will update the paramaters,
                   delete the file, and reboot. Using the new settings.

   netman save - Saves the current settings to net.cfg on the SD card.
                 This file shoulf be renamed to preserver it across
                 reboots or editited to chech networkin paramates.

   File format is name<space>value:

   echo DEVICE=eth0           > /fs/microsd/net.cfg
   echo BOOTPROTO=fallback    >> /fs/microsd/net.cfg
   echo IPADDR=192.168.0.4    >> /fs/microsd/net.cfg
   echo NETMASK=255.255.255.0 >>/fs/microsd/net.cfg
   echo ROUTER=192.168.0.254  >>/fs/microsd/net.cfg
   echo DNS=192.168.0.254     >>/fs/microsd/net.cfg

   Valid values for `proto` are `dhcp`, `static`, `falback`
   Both will try dhcp for CONFIG_NETINIT_FALLBACK times
   and fall back to the static address.

   NETMASK - is the network mask.
   IPADDR  - this nodes ip address for static or fall back.
   ROUTER  - The default route.
   DNS     - The address of the dns server.
    Co-authored-by: Beat Küng <beat-kueng@gmx.net>

Apply suggestions from code review use stdout

Co-authored-by: Beat Küng <beat-kueng@gmx.net>
@davids5
Copy link
Member Author

davids5 commented Dec 15, 2020

@bkueng - Thank you for the thorough review! All your suggestions are done and debased on current master.

@davids5 davids5 requested a review from bkueng December 15, 2020 14:59
Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge

@LorenzMeier LorenzMeier reopened this Jan 17, 2021
@LorenzMeier LorenzMeier merged commit f9d4bd5 into master Jan 31, 2021
@LorenzMeier LorenzMeier deleted the pr-dhcp branch January 31, 2021 13:42
@farhangnaderi
Copy link
Contributor

@davids5 on host machine I have to have ROUTES and DNS defined also, right?

@davids5
Copy link
Member Author

davids5 commented Mar 10, 2022

@farhangnaderi - The only params needed by NuttX are set by netman.

I have a router at 192.168.0.254, I set the nuttx node to 192.168.0.4. The DNS and ROUTER of the address of the router. The linux side would have it's own network configuration, dns server and routes but not set by the same way as in nuttx.

echo DEVICE=eth0 > /fs/microsd/net.cfg
echo BOOTPROTO=fallback >> /fs/microsd/net.cfg
echo IPADDR=192.168.0.4 >> /fs/microsd/net.cfg
echo NETMASK=255.255.255.0 >>/fs/microsd/net.cfg
echo ROUTER=192.168.0.254 >>/fs/microsd/net.cfg
echo DNS=192.168.0.254 >>/fs/microsd/net.cfg

@farhangnaderi
Copy link
Contributor

thanks,since am bringing this on docs.

@mrpollo
Copy link
Contributor

mrpollo commented Mar 10, 2022

@farhangnaderi I believe this was covered on our docs wasn't it?

@mrpollo
Copy link
Contributor

mrpollo commented Mar 10, 2022

Alternatively, if you only want to change one setting you can try with only one arrow, this will replace the whole file, I have tried this!

echo IPADDR=192.168.0.4 > /fs/microsd/net.cfg

@farhangnaderi
Copy link
Contributor

Thanks @mrpollo for the reply. I meant on host side. Figured out everything anyway. We better discuss over the PR when I make it.

@mrpollo
Copy link
Contributor

mrpollo commented Mar 10, 2022

Thanks @farhangnaderi

@hamishwillee
Copy link
Contributor

@davids5 Just helping with some doc s on this.

Valid values for proto are dhcp, static, falback

  1. So I presume this setting tells netman that it should use static IP addressing, or it should try dhcp, or it should try dhcp and then fall back to the static address?

What then does "> Both will try dhcp for CONFIG_NETINIT_FALLBACK times" mean - there are three things, so you can't have "both".

What I think it means is that if you set dhcp or fallback it will try DHCP in either case and then fallback. But then what is the point of having the two types?

@davids5
Copy link
Member Author

davids5 commented Mar 17, 2022

@hamishwillee

static is static and nothing changes. System boots with that IP address.

Both refers to DHCP and fallback.

DHCP will just keep trying and will NOT provide an IP until it gets one from the DHCP server. Fallback will time out and use the static IP that is configured.

Fallback works in a way that lets you connect the FMU to a network and get IP from it. Or connect the FMU to a PC (not not running a DHCP server) and connect to it at a known address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants