Adding support for SERCOMM NA502S

Would https://openwrt.org/packages/pkgdata_owrt18_6/kmod-mtd-rw help?

1 Like

Yes, probably. In the meantime, I was a bit adventurous: I got hold of a recovery image of a Vera secure. If you keep the reset button pressed while booting, it enters a recovery mode. Using https://github.com/danitool/sercomm-recovery this recovery image can be flashed to a NA502S gateway. However, MiOS is not properly registered and thus doesn't fully work.

Going back didn't work and I bricked the device (killed U-Boot, although I don't know how).

I have used sercomm-recovery with a secomm-device before. It worked but I had to create an image from a flash dump like detailed in here:

Since this post @csharper2005 and @MaxS0niX came up with a more suitable solution to create the file with correct OOB data (I used BBE to just pad 00's since they are discarded by the tool before flashing).

Also when you press the reset button (at least on our devices) you should get a log about what is going to be flashed and what is going to be kept, this means the flash dump has to be complete (at least till the kernel and rootfs that needs to be booted) but the bootloader and config as well as the OOB will be discarded and not changed.

I am not sure I am making sense here but I haven't played with the sercomm device for a few months but I am sure @MaxS0niX and @csharper2005 will be able to help more in regards to the tool

Yeah, I flashed the Vera firmware with sercomm-recovery and tried to go back by flashing my backup using nandwrite from within the Vera firmware. I still don't know what went bad, but since U-Boot is gone, the recovery mode is gone as well.

The Vera recovery image definitely changed the bootloader.

The only solution that I'm aware of to revive my device is to flash the NAND directly. I don't have the necessary tools, so this gateway is dead. Since they sell for as low as €10,- used, it's not a big deal.

Hi,
first post and immediately a question :grimacing:

I got one of the NA502s from my parents, because they had no use for it and was very happy to find your efforts to make it work with OpenWRT.
I managed to get the firmware booting with your informations here (had to do only the sc_nand w 0xa0000 0x01 part).
Also i was able to compile the 21.02.3 tagged source, which i cloned from the official GitHub and patched your changes in there.
The image works and i can control the LED's and the 502 seems to work fine.
The only thing i can't get to work is the ser2net part for ZigBee and ZWave. It seems like the devices aren't even listening / reacting on /dev/ttyS1 or ttyS2.

Do you have any hints, what i maybe have missed?
Do i have to enable the ZigBee or ZWave device on the 502 first somehow?

What i've done so far is:

  • install the ser2net and ser2net-app package via opkg
  • configured one port via the Lucia app
    • Port 5000, Protocol Raw, /dev/ttyS1, 115200 8N1
  • at my OpenHAB instance on another server i used socat to connect to the 502
    • it connects, but then nothing more happens
  • tried cat /dev/ttyS1 and screen /dev/ttyS1 115200 8N1 from a root shell at the 502
    • here i also get nothing, no output, no reactions on keypresses

ZWave is at /dev/ttyS1 115200 baud, ZigBee is at /dev/ttyXRUSB1 57600 baud.

The modules might be in reset state, please check the zwave_reset and zigbee_reset GPIOs.

Thanks for the hint, i don't see a ttyXRUSB1.

root@openwrt87:/# ll /dev/tty*
crw-rw-rw-    1 root     root        5,   0 Jan  1  1970 /dev/tty
crw-rw----    1 root     dialout     4,  64 Apr 21 18:11 /dev/ttyS0
crw-rw----    1 root     dialout     4,  65 Jan  1  1970 /dev/ttyS1
crw-rw----    1 root     dialout     4,  66 Jan  1  1970 /dev/ttyS2

I'm focusing on ZWave now, to try to get one thing working before trying another.
What i can see is that the modules seem to be in reset state.
I'm looking at /sys/class/gpio/zwave_reset:
cat /sys/class/gpio/zwave_reset/active_low is 1
cat /sys/class/gpio/zwave_reset/value is 0
If i understand that right, the pin is in a low state and therefore the module in reset (because active_low == 1).
If i do an echo 1 > /sys/class/gpio/zwave_reset/value it puts a 1 in there, but nothing more happens.
I can do the same things with leds or the buzzer, that works and the buzzer is awfully loud :smiley:

Maybe i'm missing a kernel module in my build config or something similar.
Do you have a diff config for the 502s somewhere or does it make no sense to do that?

So i just checked on my box: the GPIO has active_low=1 and value=0 for the module to function properly. active_low == 1 means that the GPIO is in low state if the value is 1 and it is in a high state if the value is 0. That makes sense, the module is in reset for as long as the GPIO is pulled low.

My /etc/config/ser2net config file looks like this:

config ser2net 'global'
	option enabled '1'

config controlport
	option enabled '0'
	option host 'localhost'
	option port '2000'

config default
	option speed '115200'
	option databits '8'
	option parity 'none'
	option stopbits '1'
	option rtscts 'false'
	option local 'false'
	option remctl 'true'

config proxy
	option port '5000'
	option timeout '0'
	option baudrate '115200'
	option databits '8'
	option parity 'none'
	option stopbits '1'
	option xonxoff 'false'
	option enabled '1'
	option protocol 'raw'
	option device '/dev/ttyS1'

The kernel version is 5.4.105, so if you forward-ported it to the current OpenWrt code, you might have hit some problem with a newer kernel version. For the /dev/ttyXRUSB0 and /dev/ttyXRUSB1 nodes to show up, you need kmod-usb-serial-xr_usb_serial_common installed and loaded.

2 Likes

Oh wow that did it! Thank you so much for your help :partying_face:
I think your ser2net config was the central thing, mine was missing all the rtscts, remctl and xonxoff lines.
Maybe they are default on if nothing is in the config file and so it was somehow waiting for the signals on those lines.
But now i have a happy "Online" badge at my OpenHAB instance. I'm using the Z-Wave Serial Bridge.
I still have to test ZigBee and the devices that were provided with the 502s package (window open sensor, temperature sensor and so on) but now i am a huge step further.
Oh and i never mentioned the exact build i'm on:

. .
Firmware Version OpenWrt 21.02-SNAPSHOT r16577-75cbd8de00 / LuCI openwrt-21.02 branch git-22.099.58713-fe09ab9
Kernel Version 5.4.188

EDIT:
The provided devices where ZWave, both a temperature/luminance sensor and a window open sensor are working great!

I'm glad you got it working. I've got all kinds of ZWave devices running with this gateway and zwavejs/Home Assistant on the other end while providing a nice WiFi AP as an added benefit.

Once some remaining issues are ironed out (most notably the fake sx1509 in the dts), I can create a PR for this device too.

If somebody wants to figure out how a recovery image is built, we might not even need to disassemble the device for the initial installation.

1 Like

Just a short fyi: I've updated my branch and I've created a PR: https://github.com/openwrt/openwrt/pull/9769

2 Likes

I was able to find the version of the Zigbee Firmware of the Zigbee chip:

2022/05/04 19:28:28 Elelabs_EzspFwUtility:   Generic Zigbee EZSP adapter detected:
2022/05/04 19:28:28 Elelabs_EzspFwUtility:   Firmware: 6.4.0-129
2022/05/04 19:28:28 Elelabs_EzspFwUtility:   EZSP v7

The chip is a EM357, i tried upgrading it to a newer version, but did not had success.
I tried it over ser2net with an WSL Ubuntu System as other endpoint. I used this tool: https://github.com/Elelabs/elelabs-zigbee-ezsp-utility

fyi: The PR for the NA502S has just been accepted, so it's now in Snapshot! Official release will follow with the next release cycle.

1 Like

Andreas - Just wanted to thank you for the time and effort spent on this device. Very much appreciated. Thanks again!

I was able to get 3g working. I had nearly every 3g packaged installed bevore.
This document had a lot of information in it, that helped.

This is proof of concept stage.
The 3g Module has different USB modes. It arrived with USB mode 1. So to get a serial console onto the modem I used this command:
echo 1bc7 0026 > /sys/bus/usb-serial/drivers/option1/new_id
With that, some new serial consoles showed up.

I choose USB Mode 3, with the ecm mode.
AT#USBCFG=3

USB Mode 5 did also work.
Then USB device was not able to load, error message

[   10.486126] usb 1-2.4: Not enough host controller resources for new device state.
[   10.501302] usb 1-2.4: can't set config #1, error -12

With this command I removed some / all other USB devices:

 echo 1 > /sys/bus/usb/devices/1-2.1/remove
 echo 1 > /sys/bus/usb/devices/1-2.2/remove
 echo 1 > /sys/bus/usb/devices/1-2.3/remove

then resetted the 3g device over the gpios

echo 0 > /sys/class/gpio/3g_hw_shunt_en/value
echo 1 > /sys/class/gpio/3g_hw_shunt_en/value

Now wwan0 showed up, with the help of an other article, I was able to set the apn and enable the ecm mode:

This document was also useful:

1 Like