NEO REBOOT

I have covered the FriendlyArm NEO and NEO2 boards here before now and generally been in favour – but for one little item in common with many other boards – little or no IO support – well, that just changed. Read on…

With no apparent way to get to the IO on this cute little board, I promised I would write to FriendlyArm and ask for WIRINGPI and that I did. In the meanwhile if you take a look at the relevant blog entry you’ll see I made a start at using GPIO the hard way and even found a WIRINGOP (OP – Orange Pi) variation that would do basic IO if you could guess the right IO pins, but that was about it.NEo2

Days later I received an email from FriendlyArm asking me to test their new WIRINGNP (as they call it) for both the NEO and NEO2.  I rushed to do the updates they suggested for existing setups but I hit a couple of snags (and reported my problem) – but they’ve also brought out a new ROM with the updates incorporated so I tried that on the H5-based NEO2. They have a WIKI on the subject. There are C examples for setting up soft PWM etc etc   - but here I  mainly use the GPIO utility that runs as user Pi and hence can easily be called from Node-Red or indeed – the command line.

The Ubuntu command line is pretty much what you might expect on any similar “Pi” and certainly it runs my script so I had no trouble testing the new WIRINGNP as they call it.  I was particularly interested in the GPIO program which a non-root user can run from the command line.

NEO2[1]Using their npi-config menu-driven command line tool I told the NEO2 I want to use PWM – you can also set audio, the welcome message, serial, I2c, SPI and PWM enable/disable. At that point the board rebooted with the new settings.

Now-  I’m terribly excited, the serial setup allows for enabling and disabling serial ports 0-3 (yes, FOUR serial ports) with serial port 1 enabled – we’d discussed this by email and this is what I was expecting – I didn’t expect a nice, easy menu setup for this – well done if it works…

After some diversion as they originally chose to refer to physical pins as against wPi or BCM pin designations -  I eventually realised that pin 38 (on a separate 4 pin connector) is the hardware PWM pin

gpio mode 1 pwm
gpio pwm-bal
gpio pwmr 1024
gpio mode 38 pwm
gpio pwm 38 100

The first four lines are setup and I discovered that line 1 was necessary despite being of no relevance to this board (1 on the Raspberry Pi is the PWM pin) – the setup for pin 38 follows as the second last line before setting the PWM value to 100  (out of 0-1024). A handy LED on pin 38 confirmed that the hardware PWM on that pin works.  I've asked FriendlyArm to check. Also if the LED load on this pin is too heavy,  reboot does not work but that I think is more down to the H5 processor.

Note also there is some kind of screen debug output when you run these commands and the C example – again I’ve reported that back to FriendlyArm as you don’t get this on the Rasperry Pi.

You can’t do any other kind of PWM on the other pins using GPIO – but that also applies to the Raspberry Pi.

For simple GPIO – let’s say pin 12

gpio mode 12 out
gpio write 12 1

Works a treat.

FriendlyArm also have conveniently made a user PI – so you don’t even have to create that though they persist on their site in assuming quite often that you are user ROOT – I have suggested they think about that as people are usually encouraged NOT to run as root. Running my script is as simple as dropping it into the PI directory – giving it execute permissions and running it. I ran my script to install Node-Red etc., so I could check out the serial ports.  Serial port 0 is normally used for debug and FriendlyArm suggested making serial port 1 available by default.

NEO SERIAL

As you can see in the image of my Node-Red setup for the serial ports (standard serial node) – I hooked up all 4 serial ports and in the case of serial port 1 – I shorted the input and output pins together. As you would expect – injecting into the ports brought back failures in 3 of them as they’re disabled – but in the second case – the timestamp was sent back. Perfect. I’m out of time but quietly confident the rest would work if I needed them. So in just this one respect – compare this to the Raspberry Pi 3 – it has Bluetooth and that conflicts with the serial port – you don’t actually have a spare serial port – here you have three.

At the end of this – the little NEO2 is going to end up talking to an Arduino Mega running that 433Mhz RFLink board as well as lots of other tasks.

I have yet to test SPI but as it stands – these boards are in very select company in getting support from their own manufacturer! Also - see the blog entry on the NAS - which ends up being about the NEO2 - thanks to the open source Bakebit I now have OLED displays running on these boards.

The following day I received an update: We’d discussed the various naming systems for pins – physical – ie. the actual pin number, wPI (Wiring Pi) and the BCM numbering schemes.  I suggested physical was probably best – but when the update came they’d implemented both for those for programming in C.

//using wiringPi Pin Number
int pin = 18;
wiringPiSetup ();             

  //using Physical Pin Number
int pin = 38;
wiringPiSetupPhys();                                          

  //using BCM Pin Number
int pin = 5;
wiringPiSetupGpio();

Well, I thought that was quite satisfactory!  Here’s a little test I tried – on physical pin 38…

test

such a program needs to be compiled as such:

gcc -Wall -o flashtest flashtest.c -lwiringPi -lpthread

The end program needs to be run as root  - WHY!!!!!!!

Anyway, sudo ./flashtest works – and I tested in the Node-Red EXEC function – it works in there (again using sudo  - no big deal). So it should be possible to make little C programs to do just about anything you want with GPIO and 3d Printed Box for NEO2call them from the EXEC node – which conveniently tells you when they’ve finished running – WITHOUT holding up the show!

More later – I’m hoping they’ll get rid of some debug stuff in there but this according to the WIKI can be setup for both the NEO (cheap) and the NEO2 (more powerful).

MEANWHILE a parcel turned up this morning – up to now I’ve not used the heatsinks on the NEO2 – ok it gets quite warm but not stinking hot – however – as the heatsink and board conveniently fit into the cute 3d printed box… I’ve now fitted it…  all looking very spiffy. Ok, 3d printed cases are not perfect- but for this – good enough!

Facebooktwittergoogle_pluspinterestlinkedin

14 thoughts on “NEO REBOOT

  1. Hi Peter - thanks for Your blog it has been a great source of info in setting up a Nano Pi Neo - have You managed to find out from FriendlyArm if they will enable the other serial ports or how to DIY?
    Regards

    1. I updated the blog - if you look there's a new rom and in that a utility to turn each serial port on and off. Now, by default serial port 1 is on and the rest are off. That is on the NEO2, not tried the NEO yet as for the life of me I can't find mine. Let me know how you get on.

  2. Can the Neo2 img be used on the Neo? I will try it out if so.
    I have been using nanopi-neo_ubuntu-core-xenial_4.11.0_20170417.img and installing WiringNP which seemed to go OK but not sure if the .fex file needs altering to enable the hardware or if it is /dev/ttyS1-3 or /dev/AMA1-3 to access the ports. I am wanting to use Python as opposed to compiling binaries if possible.
    P.S Hope the weathers warmer up there than down here in NZ 😉

    1. I don't have my NEO handy but I am pretty sure they use different processors - in which case that would be no. The NEO uses an H3 and the NEO2 uses an H5. But images are available for both.

      Weather, here in Southern Spain - well it was a bit of a disappointment in April but now it is picking up - I'm guessing it is 26 or 27c out there and the sky is clear blue. Good when you're working on the computer, not so good when you're outside doing a spot of building work.

  3. I'm planning to use a NEO2 as a LAN VPN client->remote VPN server gateway device. I've no real clue if it will work until I get my hands on one but for around £22 delivered it's worth a try. If that doesn't work out I'm sure I'll find some other use for it.

    1. Depending on the VPN software you're using (OpenVPN is still single threaded for example) performance might be pretty low. NEO2 is also not the best choice here since FriendlyELEC didn't implement voltage regulation on this board and NEO2 should not be clocked higher than 912 MHz (otherwise H5 SoC will become instable since fed with just 1.1V).

      Orange Pi PC 2 would be a better choice since here voltage/cpufreq can be increased. If you do a web search for 'openssl speed site:forum.armbian.com' you come accross a lot of performance numbers for VPN/encryption stuff on various ARM boards.

      1. OpenVPN is out for the moment, I'm planning on using IKEv2 with certificate authentication via StrongSwan.

        I'm nowhere near an expert in networking, cryptography and VPNs but I do know that OpenVPN depends on TLS to secure key exchange and it can also use certificates to authenticate - if I can eliminate the dependency on TLS for key exchange then I believe that must help keep things lightweight from a processing perspective.

        I also know that packet fragmentation is always bad and will cause the devices at each end of the VPN to work hard to reassemble packets..so effort should be put into to avoid fragmentation via correct configuration (mss / mtu).

        I have a NEO2 is on order now so I will be giving this a go and if I can get it to go as fast as my internet connection well that's all I need really. If it's worse than that or basically fries itself trying to keep up, well that's a big fat fail 🙂

          1. My 2p: Streisand is easy to setup and get going but so is Algo. Personally I lean towards an Algo self install / self managed VPN because Streisand installs way too much software for my liking and I don't want to have to worry about maintaining a huge footprint of stuff that I'm not going to use but would still have to think about keeping secure if it was there.

  4. My NEO2 arrived and getting StrongSwan installed and talking to an AWS hosted Algo VPN hasn't been completely plain sailing.

    In short the VPN tunnel works but only for only some traffic and the wireshark traces make no sense to me with HTTP traffic going completely missing without a trace (pun not intended..).

    So I've now got issues open with both StrongSwan and FriendlyArm and at the moment this doesn't feel like a StrongSwan issue..so I guess I'm about to find out how the FriendlyArm direct support works with this one 🙂

    And before anyone wades in with a "try it on armbian" suggestion, I already have and it doesn't work there either 😉

    1. It works but it was a indeed a slog getting it going. The problem that I first thought to be with StrongSwan turned out to be caused by a kernel bug in 4.11 which both Armbian and FriendlyArm Debian are based on at the moment.

      Noel Kuntze at StrongSwan made me aware of the kernel bug and pointed me to a core kernel patch that is currently making it's way through but hasn't yet made it into 4.11.y or mainline. I ended up translating this patch into an arm compatible patch and rebuilding Armbian to test that it works.

      The good news is that the performance of the neo2 acting as a VPN gateway looks more than good enough for my needs. There is some ipsec processing overhead but it won't be that noticeable.

      Here are a couple of cli speed test results performed directly on the neo2:

      VPN tunnel up:
      root@nanopineo2:~# ./speedtest-cli
      Retrieving speedtest.net configuration...
      Testing from Amazon (aws.ip.address.ie)...
      Retrieving speedtest.net server list...
      Selecting best server based on ping...
      Hosted by Blacknight (Carlow) [72.18 km]: 43.272 ms
      Testing download speed................................................................................
      Download: 99.73 Mbit/s
      Testing upload speed................................................................................................
      Upload: 5.99 Mbit/s

      VPN tunnel down:
      root@nanopineo2:~# ./speedtest-cli
      Retrieving speedtest.net configuration...
      Testing from Virgin Media (virgin.media.ip.address.uk)...
      Retrieving speedtest.net server list...
      Selecting best server based on ping...
      Hosted by TNP Ltd. (Manchester) [42.99 km]: 26.937 ms
      Testing download speed................................................................................
      Download: 108.12 Mbit/s
      Testing upload speed................................................................................................
      Upload: 6.41 Mbit/s

Leave a Reply

Your email address will not be published. Required fields are marked *