Installing Openwrt on Devolo Magic 2 wifi next

You're welcome! Your information helps a lot. My first suggestion would be to try to boot an OpenWRT build using TFTP. It is quite likely this will allow you to get a shell prompt on the device from which you can then flash another image, likely also an ODM image.

Try following the first three steps of this instruction:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=d3c88811942a9dc9bbb01ca0443ae9cd790d1988

Let it know if you manage to get in. Then we should see if there's an ODM image that could be flashed. (As described in step 6, you'd skip step 4 and 5.)

Hello,
How are you? i hope you are doing well, i tried connecting the device through the lan port but it didn't show up, as if nothing is connected, i looked at (arp -a) in CMD and nothing showed up, not sure if im doing it right but i got nowhere, imma a bit of a newby in these things, any ideas what i should try next?
P.S Devolo support told me to try and reset it through the pin button which ofcouse didnt help.
Thanks for your time
Chears

Try using Wireshark and follow the second step of the instruction I linked to to see if you see any traffic. Maybe you'll also need to make sure you have the correct IP address configured on your box (192.168.0.100).

Hello,
i tried using wireshark and got the these info back, any idea what they mean?, also i asked some IT friends about the problem and one of them suggested shorting the device circuit and that will help solve the bootloop as this method is known to work on bootloop in Nanostation devices which are very popular here, any idea about this?

Are you sure that only the Devolo Magic 2 Next was connected? Did set your IP address correctly and hold the reset button while powering on the device?

Hello, do we have clear steps to setup PLC ? The info is a bit fragmented. From above I just managed to extract firmware with binwalk. What is next?

1 Like

Hi @opechunka, I'm afraid there are no clear steps at this time.
I only did some experiments and managed to get things more or less working. I recently obtained an extra Magic 2 device so that I have one free to tinker with.

Once you have extracted the binaries from the Devolo firmware, you should be able to copy them inside OpenWRT and start them similarly as they are started on the Devolo firmware. I can recommend getting shell access on a device with the Devolo firmware running so you can analyze that environment.

Note that you don't need to install OpenWRT on the flash memory of the device. You can do the experiments with a rambooted OpenWRT as well. (That is if you indeed have a Magic 2 Next, which is the ARM version of the Magic 2. There is also a non-Next version which is MIPS based and does not support rambooting.)

If you try something and get stuck, I'll try to respond. We can also communicate outside the forum on this if you want. We should indeed work towards getting a set of instructions and possibly some helper scripts.

Hi @jschwart ,
I have one Magic 2, and another Magic 2 Next.

I managed to load and run Openwrt for Magic 2 (https://openwrt.org/toh/hwdata/devolo/devolo_magic_2_wifi)

But I even couldn't load the OpenWRT for Magic 2 Next from here https://openwrt.org/toh/hwdata/devolo/devolo_magic_2_wifi_next.

With Magic 2 WiFi running OpenWrt 23.05.3, I tried to make configuration similar to Devolo firmware. I made running most of the apps as at Devolo fimware. But the
ghn_console says that gh.nn port is not avalilable.
One important moment, I installed OpenWrt 23.05, but the original Devolo firmware is based on quite old OpenWrt 15.05 So just transfering binaries from original firmware to 23.05 . It makes me doubt, that it will work at all. What was OpenWRT version that you manged to transfer the missing files from Devolo (15.05) and made it work?

Interesting combination :slight_smile:
At least I have both as well now, so let's figure out how to get both up and running with OpenWRT!!

Nice!! Do you also have (the configuration tooling for) the G.hn working?

Great work!! I was also using the newer version instead of that old release. Looking over the GIt commits, I think the issue preventing newer versions to load was resolved.
With regards to the ghn_console tool, I think that I had to specify another device. If I remember correctly, I looked at the dts file to see which one was wired up. But in my commands now I see both ghn and eth0...

Did you see how I am calling the command in the comment above?

LD_LIBRARY_PATH=lib2:lib /lib/ld-musl-armhf.so.1 ./ghn_host -i eth0 -b /tmp/ghn/base/ --name "Magic 2 WiFi next" --serial 1234567890123456 --mac 01:23:45:67:89:AB
 --mt MT3056 --profile 0 --script /tmp/ghn/script  --verbose`

That command gave me working connectivity over G.hn on a then recent OpenWRT version.

This is what the first part of the command I'm using takes care of.

  • LD_LIBRARY_PATH=lib2:lib was pointed to two directories containing libraries I pulled off of the old version
  • /lib/ld-musl-armhf.so.1 specifying the loader avoids the message that the loader from the Devolo version cannot be found (which uses a different name)

Note that the G.hn chip requires that the port speed is set to 100 MBit/s for the initialization to work. The command that the Devolo scripting uses for that won't work on regular OpenWRT, but using ethtool to do this instead will work fine:
ethtool -s ghn speed 100

I've been working on scripts to generate packages out of a vendor OpenWRT tree, this can be found here for now:

First grab the Devolo firmware (delos_magic-2-wifi-next_6.0.1_2023-09-06.bin) and use a tool like binwalk to extract it. Then you can use my scripts to generate packages with a command like this:

./ipkg-build-all-from-installed path/to/extracted/devolo/firmware/_delos_magic-2-wifi-next_6.0.1_2023-09-06.bin.extracted/squashfs-root ${PWD}/packages > package-generation.log

This relies on the ipkg-build* scripts from the OpenWRT scripts directory and the tool patchelf.
The scripts will go through the ODM firmware's usr/lib/opkg content and:

  1. (try to) derive which packages are introduced on top of OpenWRT
  2. generate ipk files only for those
  3. patch ELF binaries to use the new loader and to use the new library names
  4. replace the architecture for the packages
  5. The log file will contain rudimentary information on extra configuration options that should be enabled in make menuconfig for packages that matched with something in .config.

Using this I managed to build and install OpenWRT on my Devolo Magic 2 WiFi next and afterwards copy and install some of the generated ipk packages. ELF binaries like ghn_host seem to execute without issues after having been patched with patchelf.

Next steps

  • There are some Devolo specific files in base-files which is a generic OpenWRT package. Find a way to handle those. Edit: I pushed a hacky script to generate a base-files-downstream package with those.
  • Possibly patching of the Devolo scripts (I haven't patched in ethtool yet to drop to 100 MBit/s instead of the proprietary tool that the scripts refer to. I guess more changes are needed though.) Edit: multiple patches are applied now
  • See if it's possible to get G.hn going through the Devolo scripts It's working with Devolo's scripts just slightly patched, see the post below.
  • Possibly get delos-webui5 working to provide a UI for configuration (it fails to load the login screen on my end, the browser appears to end up in some sort of loop)

If anybody is curious to look along together with me, I hope you can replicate what I managed to reach. I can provide my .config, firmware image and generated packages if that would be helpful.

1 Like

Alright, I have it working!! I'll try to put a complete set of instructions here. I uploaded the needed packages here:

Maybe some packages are missing, just shout then and I'll add them. I still need to figure out exactly which ones are needed. Now I just installed things till it worked.

Step by step instructions

  1. Build and flash OpenWRT according to the instructions in the commit that adds support. You need to make sure you include all upstream packages that are included in Devolo's firmware. You can find my .config through the link above. You can use the latest OpenWRT commit. You can also find my builds at the URL above.
    Include these packages:
    flock, see: Utilities -> flock
    libcap. see: Libraries -> libcap
    ebtables. see: Network -> Firewall -> ebtables-nft
    ethtool, see: Network -> ethtool-full (the non-full version doesn't seem to work)

Now you have two choices, generate your packages:

  1. Find delos_magic-2-wifi-next_6.0.1_2023-09-06.bin on Devolo's website
  2. Unpack it with binwalk
  3. Generate the packages using my scripts

Or download them from the post above.

Use scp to get the packages onto your Devolo Magic2 WiFi next.
Use opkg install to install them, you will need these:

delos-base-files_1.0-7_arm_cortex-a7_neon-vfpv4.ipk
delos-device-name_fdb2dee-1_arm_cortex-a7_neon-vfpv4.ipk
devolo-shared-configlayer_2.34.1_arm_cortex-a7_neon-vfpv4.ipk
dlan2-fw-flashless-2400-ac_001-4_arm_cortex-a7_neon-vfpv4.ipk
dlan2-tools_cdee4af640bdcf3299490ea16f256ad2ebaa06cc-1_arm_cortex-a7_neon-vfpv4.ipk
ghn-flashless_001-4_arm_cortex-a7_neon-vfpv4.ipk
ghn-host_fdb2dee-1_arm_cortex-a7_neon-vfpv4.ipk
libssp_5.2.0-1_arm_cortex-a7_neon-vfpv4.ipk
posix-timezone-db_2021a-2_arm_cortex-a7_neon-vfpv4.ipk

Now you have to reboot your device:

reboot

After rebooting you can use uci to set up your G.hn configuration:

uci set ghn.ghn.disabled=0
uci set ghn.ghn.interface=ghn
uci set ghn.settings.device_name=<devicename, like: devolo-123>
uci set ghn.settings.domain_name=<domain, must match your other device(s)>
uci set ghn.settings.password=<password, must match your other device(s)>
uci set ghn.settings.pairing_secured=1
uci set ghn.settings.pairing_completed=1
uci set ghn.settings.powermask_profile=mimo_full
uci set ghn.settings.dslcoex_enable=0
uci set ghn.settings.force_node=0
uci set ghn.ghn.device_name_initialized=1

uci commit

Enable ghn-host at bootup and start it up:

/etc/init.d/ghn-host enable
/etc/init.d/ghn-host start

Now you have to reboot the device. This is required after the installation of the delos-base-files package. The required uci state in /var/state will become available then. If you have gone through the configuration of G.hn, it should come up. Otherwise use /etc/init.d/ghn-host status to figure out what's going on. The earlier reboot took care of this and is already needed before the ghn configuration is available for uci.

I'm curious if others can get it going as well :slight_smile:

Edit: more fine-tuned instructions now. I also created a wiki page: https://openwrt.org/toh/devolo/magic_2_wifi_next

1 Like

Hi!

I own two Magic 2 WiFi Next adapters and I would like to contribute to OpenWRT on these devices.
I have not used OpenWRT before, but I am familiar with Linux, CLI and basic building. I am currently stuck with the build configuration.
Would it be possible to get a working .config?

Kindest regards,
Pascal

1 Like

Nice work @jschwart! Unfortunately I gave my Devolo Magic 2 wifi next to my sister.

I tried to obtain the same setup for my Devolo Magic 2 next wifi 6 but I was not able to extract the firmware with binwalk. I cannot get the squashfs-root. I'll do some more digging...

I was able though to connect to one of the adapter via SSH and I think the setup would be really similar with the one from Devolo Magic 2 wifi next.

1 Like

Could you provide an error message? The default settings should more or less work, but be sure to enable the G.hn dependencies:

  1. Enable flock, it can be found under: Utilities โ†’ flock
  2. Enable libcap, it can be found under: Libraries โ†’ libcap
  3. Enable ebtables, it can be found under: Network โ†’ Firewall โ†’ ebtables-nft
  4. Enable ethtool, Network โ†’ ethtool-full

See also: https://openwrt.org/toh/devolo/magic_2_wifi_next

Extracting with binwalk should be trivial. Make sure you have all binwalk's dependencies installed.

Yes, I guess the hardware is identical except for the WiFi part. Maybe you could try rambooting the OpenWRT for the non-6 version and see if you can reach the device over SSH.

Hi! Thank you for your reply!
The problem is, that there seems to be no default config, but the propositions made by make menuconfig seem to be wrong (not the architecture stated on the hardware page, etc.)โ€ฆ

Yes, you need to change the architecture and choose the Devolo Magic 2 WiFi next as the model to build for.
Generally I can recommend exploring around in make menuconfig, you'll find many interesting things :slight_smile:

I created a PR for this after cleaning up the script:

No idea if this kind of approach will be accepted though :slight_smile:

1 Like

Sorry for the late answer. I'm traveling until December...

Extracting with binwalk should be trivial. Make sure you have all binwalk's dependencies installed.

I do have all the dependencies(at least the ones state on their github I did not try binwalk3 yet, though...). I am able to extract the binary tor the Devolo Magic 2 wifi next but I am not able (yet) to test it because I still have to get access to my former Devolo Magic 2 wifi next set.

I'm not able to do it for the WIFI6 version. I get an ubifs folder with a kernel directory that is empty.

It seems you're right. That firmware is quite differently structured. In the meantime I learned that the WiFi chip in the WiFi 6 version isn't supported at all by OpenWRT right now. Adding that would be non-trivial. For now I guess the quickest way to get OpenWRT going would indeed be to swap your WiFi 6 for a WiFi next with your sister :slight_smile:

Note that I'm working on a new version of the script which will also support the Magic 2 WiFi v1 (the MIPS device). I already have working package generation for that model as well. I just need to start testing and possibly fix more patches to the binaries/scripts.